[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Simplify setting and deletion of cookie.



commit 103f936ccf49d1a5e7ebb9e789429b781899b749
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Wed Dec 19 17:18:53 2012 -0800

    Simplify setting and deletion of cookie.
    
    Use onclick handlers so it's more obvious from the HTML what clicking
    the buttons will do. Use "allowed" and "disallowed" to make it clear
    what the presence of the cookie means.
---
 proxy/options.html |    3 ++-
 proxy/options.js   |   18 ++++++++----------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/proxy/options.html b/proxy/options.html
index efe57bc..d9f70a3 100644
--- a/proxy/options.html
+++ b/proxy/options.html
@@ -66,7 +66,8 @@ JavaScript to change your options.
 <div id="setting">
 </div>
 <div id="buttons" style="display: none;">
-<button id="yes">Yes</button><button id="no">No</button>
+<button onclick="set_cookie_allowed()">Yes</button>
+<button onclick="set_cookie_disallowed()">No</button>
 </div>
 <div id="cookies_disabled" style="display: none;">
 <p>
diff --git a/proxy/options.js b/proxy/options.js
index f39f358..8382240 100644
--- a/proxy/options.js
+++ b/proxy/options.js
@@ -15,6 +15,14 @@ function add_event(elem, evt, handler) {
         elem.addEventListener(evt, handler);
 }
 
+function set_cookie_allowed() {
+    document.cookie = COOKIE_NAME + "= ;path=/ ;expires=" + COOKIE_LIFETIME;
+}
+
+function set_cookie_disallowed() {
+    document.cookie = COOKIE_NAME + "= ;path=/ ;expires=Thu, 01 Jan 1970 00:00:00 GMT";
+}
+
 add_event(window, "load", function () {
 
     function cookie_present() {
@@ -45,19 +53,9 @@ add_event(window, "load", function () {
         }
     }
 
-    function set_cookie() {
-        document.cookie = COOKIE_NAME + "= ;path=/ ;expires=" + COOKIE_LIFETIME;
-    }
-
-    function del_cookie() {
-        document.cookie = COOKIE_NAME + "= ;path=/ ;expires=Thu, 01 Jan 1970 00:00:00 GMT";
-    }
-
     if (navigator.cookieEnabled) {
         var buttons = document.getElementById("buttons");
         add_event(buttons, "click", update_setting_text);
-        add_event(document.getElementById("yes"), "click", set_cookie);
-        add_event(document.getElementById("no"), "click", del_cookie);
         buttons.style.display = "block";
         update_setting_text();
     } else {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits