From 049773b63c599568dfe9b23beb59878a0ca6e674 Mon Sep 17 00:00:00 2001 From: Patrick Davey Date: Sat, 1 Feb 2014 12:51:00 +1300 Subject: [PATCH 1/6] Allowing user to delete their own carpools --- assets/js/global.js | 40 ++++++++++++++++++++++++++++++++++++---- index.html | 2 +- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/assets/js/global.js b/assets/js/global.js index 85b0ba0..985f695 100644 --- a/assets/js/global.js +++ b/assets/js/global.js @@ -33,6 +33,22 @@ $(document).bind("mobileinit", function(){ /* end of filter code */ + $(document).on("click", "#delete_carpool_button", function(){ + if (confirm('Really Delete Your Carpool?')){ + $.ajax({ + type: "POST", + url: 'http://api.snowpool.org/pools/'+$("#pool_id").val() + '.js', + data: { + "_method" : 'delete', + "token" : users_token() + }, + success: function(data) { + alert("Carpool has been deleted"); + $.mobile.changePage("#country_pool_list"); + } + }); + } + }); $(document).on("click", "#send_message_button", function(){ $.ajax({ @@ -111,6 +127,7 @@ $(document).bind("mobileinit", function(){ window.localStorage.setItem("token" ,data.token); window.localStorage.setItem("telephone" ,data.telephone); window.localStorage.setItem("city" ,data.city); + window.localStorage.setItem("user_id" ,data.user_id); window.localStorage.setItem("valid_login" ,"true"); $.mobile.changePage("#country_pool_list"); }, @@ -150,10 +167,14 @@ $(document).bind("mobileinit", function(){ $("#pool_details").append("Message
"+data.message+"
"); } if (user_is_valid()){ - $("#pool_details").append("

Send "+data.name+" a message
"); - $("#pool_details").append(""); $("#pool_details").append(""); - $("#pool_details").append(''); + if (is_own_carpool(data.user_id)){ + $("#pool_details").append(''); + }else{ + $("#pool_details").append("

Send "+data.name+" a message
"); + $("#pool_details").append(""); + $("#pool_details").append(''); + } }else{ $("#pool_details").append("

If you sign in, then you can send the user a message.

"); } @@ -234,7 +255,12 @@ function empty_and_refresh_carpools(){ //setup all the local variables etc function setup(){ if (user_is_valid()){ - $(".login_button").hide(); + if (user_id_unset()){ + window.localStorage.setItem("valid_login" ,"false"); + $(".add_carpool_button").hide(); + }else{ + $(".login_button").hide(); + } }else{ $(".add_carpool_button").hide(); } @@ -248,6 +274,9 @@ function empty_and_refresh_carpools(){ function user_is_valid(){ return window.localStorage.getItem("valid_login") == "true"; } + function user_id_unset(){ + return window.localStorage.getItem("user_id") === null; + } function users_token(){ return window.localStorage.getItem("token"); } @@ -257,6 +286,9 @@ function empty_and_refresh_carpools(){ function users_city(){ return window.localStorage.getItem("city"); } + function is_own_carpool(user_id){ + return parseInt(window.localStorage.getItem("user_id"), 10) === user_id; + } function users_fields(){ if ( window.localStorage.getItem("has_country_fields") == "true" ){ return JSON.parse(window.localStorage.getItem("country_fields")); diff --git a/index.html b/index.html index 42e5f99..28008e3 100644 --- a/index.html +++ b/index.html @@ -94,7 +94,7 @@

Snowpool (beta)

-
+
Refresh

Snowpool (beta)

From f21a487bbe97bad3dfaa5f7d365c81d6d6a6ffc5 Mon Sep 17 00:00:00 2001 From: Patrick Davey Date: Sat, 1 Feb 2014 13:05:58 +1300 Subject: [PATCH 2/6] Adding the phonegap version --- config.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/config.xml b/config.xml index 9ce2e9d..9fda140 100644 --- a/config.xml +++ b/config.xml @@ -6,11 +6,10 @@ version = "2.0.0"> Snowpool - + A mobile application for snowpool.org - Snowpool @@ -18,9 +17,6 @@ - - - @@ -43,6 +39,4 @@ - - From b7cc056d945b23f42664c578d8f9eff479e7a35e Mon Sep 17 00:00:00 2001 From: Patrick Davey Date: Sat, 1 Feb 2014 13:13:58 +1300 Subject: [PATCH 3/6] Regressing phonegap version --- config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.xml b/config.xml index 9fda140..b70fa15 100644 --- a/config.xml +++ b/config.xml @@ -6,7 +6,7 @@ version = "2.0.0"> Snowpool - + A mobile application for snowpool.org From d0614f1e000153aa7afcb6d6907fbf0fa0128dcd Mon Sep 17 00:00:00 2001 From: Patrick Davey Date: Sat, 1 Feb 2014 13:27:08 +1300 Subject: [PATCH 4/6] Updating the version codes --- config.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.xml b/config.xml index b70fa15..b897ec4 100644 --- a/config.xml +++ b/config.xml @@ -2,8 +2,8 @@ + versionCode="160" + version = "2.1.0"> Snowpool From d096b0541e5cd759cf10294862e620c310ac1c3d Mon Sep 17 00:00:00 2001 From: Patrick Davey Date: Sat, 1 Feb 2014 13:39:59 +1300 Subject: [PATCH 5/6] Removing duplicate phonegap version --- config.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config.xml b/config.xml index 4b87ede..1c6c7dc 100644 --- a/config.xml +++ b/config.xml @@ -6,7 +6,7 @@ version = "2.1.0"> Snowpool - + A mobile application for snowpool.org @@ -42,7 +42,6 @@ - From 65097ac869df54746956c4652846448c9b02cbf9 Mon Sep 17 00:00:00 2001 From: Patrick Davey Date: Sat, 1 Feb 2014 13:45:48 +1300 Subject: [PATCH 6/6] Reverting to 2.5 for android issues --- config.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config.xml b/config.xml index 1c6c7dc..0ab1f57 100644 --- a/config.xml +++ b/config.xml @@ -6,7 +6,7 @@ version = "2.1.0"> Snowpool - + A mobile application for snowpool.org @@ -41,7 +41,6 @@ -