Ticket #8211: bgcolour-visual-indicator.patch

File bgcolour-visual-indicator.patch, 4.7 KB (added by aallai, 8 years ago)
  • proxy/options.html

    From 9779fb982f4d76f27d963581ccfc134ca221b7b2 Mon Sep 17 00:00:00 2001
    From: Alexandre Allaire <alexandre.allaire@mail.mcgill.ca>
    Date: Fri, 1 Mar 2013 21:33:58 -0800
    Subject: [PATCH] visual indicator that fp is active when opting in
    
    implements part A of #8211. If cookie is unset state that the proxy is
    enabled. Remove dynamic text showing cookie setting.
    ---
     proxy/options.html |   69 ++++++++++++++++++++++++++--------------------------
     1 file changed, 35 insertions(+), 34 deletions(-)
    
    diff --git a/proxy/options.html b/proxy/options.html
    index 9caa9e3..51f6e09 100644
    a b p { 
    3232button {
    3333        margin: 0px 7px 7px;
    3434}
     35#badge-state {
     36        font-size: 36px;
     37        text-align: center;
     38        padding: 10px 0;
     39        margin: 0;
     40    color: white;
     41}
     42#badge-state p { display: none; }
    3543</style>
    3644</head>
    3745<body>
    the flash proxy badge. 
    4755<p>
    4856<a href="http://crypto.stanford.edu/flashproxy/">For more information on this system click here</a>.
    4957</p>
     58<p>Do you want your browser to act as a proxy?</p>
    5059</div>
    5160<noscript>
    5261<p>
    While JavaScript is disabled, your computer will not be a proxy. Enable 
    5463JavaScript to change your options.
    5564</p>
    5665</noscript>
    57 <div id="setting">
    58 </div>
    59 <div onclick="update_setting_text()" id="buttons" style="display: none;">
    60 <button onclick="set_cookie_allowed()">Yes</button>
    61 <button onclick="set_cookie_disallowed()">No</button>
     66<button onclick="set_allowed()">Yes</button>
     67<button onclick="set_disallowed()">No</button>
     68<div id="badge-state">
     69  <p id="inactive">Proxy disabled</p>
     70  <p id="active">Proxy enabled</p>
    6271</div>
    6372<div id="cookies_disabled" style="display: none;">
    6473<p>
    function set_cookie_disallowed() { 
    8190    document.cookie = COOKIE_NAME + "=0 ;path=/ ;expires=" + COOKIE_LIFETIME;
    8291}
    8392
     93function set_allowed() {
     94    set_cookie_allowed();
     95    refresh();
     96}
     97
     98function set_disallowed() {
     99    set_cookie_disallowed();
     100    refresh();
     101}
     102
    84103function parse_cookie_string(cookies) {
    85104    var strings;
    86105    var result;
    function read_cookie() { 
    116135}
    117136
    118137/* Updates the text telling the user what his current setting is.*/
    119 function update_setting_text() {
    120     var setting = document.getElementById("setting");
    121     var prefix = "<p>Your current setting is: ";
     138function refresh() {
    122139    var value = read_cookie();
    123140
    124     if (value === undefined) {
    125         setting.innerHTML = prefix + "unspecified. Your browser may or may not " +
    126                                      "run as a proxy, depending on how the website " +
    127                                      "administrator has configured the badge. (See <a href=\"https://lists.torproject.org/pipermail/tor-dev/2012-December/004318.html\">this mailing list post</a> for more information about opt-in versus opt-out.) Click " +
    128                                      "the buttons below to change your setting.";
    129     } else if (value === "1") {
    130         setting.innerHTML = prefix + "use my browser as a proxy. " +
    131                                      "Click no below to change your setting.</p>";
     141    if (value === undefined || value === "1") {
     142        document.getElementById("active").style.display = "block";
     143        document.getElementById("inactive").style.display = "none";
     144        document.getElementById("badge-state").style.backgroundColor = "darkgreen";
    132145    } else {
    133         setting.innerHTML = prefix + "do not use my browser as a proxy. " +
    134                                      "Click yes below to change your setting.</p>";
     146        document.getElementById("inactive").style.display = "block";
     147        document.getElementById("active").style.display = "none";
     148        document.getElementById("badge-state").style.backgroundColor = "red";
    135149    }
    136     setting.innerHTML += "<p>Do you want your browser to act as a proxy?</p>";
    137150}
    138151
    139 window.onload = function () {
    140     if (navigator.cookieEnabled) {
    141         var buttons = document.getElementById("buttons");
    142         buttons.style.display = "block";
    143         update_setting_text();
    144     } else {
    145         document.getElementById("cookies_disabled").style.display = "block";
    146         /* Manually set the text here as otherwise it will refer to
    147            the buttons, which don't show if cookies are disabled. */
    148         document.getElementById("setting").innerHTML = "<p>Your current setting is: " +
    149                                                        "unspecified. Your browser may or may not " +
    150                                                        "run as a proxy, depending on how the website " +
    151                                                        "administrator has configured the badge.</p>";
    152     }
    153 };
     152window.onload = function() {
     153    refresh();
     154}
    154155</script>
    155156</body>
    156157</html>