Mercurial > hg > index.fcgi > www > www-1
annotate cs/index.html @ 79:01cf0e93c914
cs: fix cookie paths
author | paulo |
---|---|
date | Thu, 02 Jun 2016 01:51:04 -0600 |
parents | f833a888c548 |
children | 4d3f845c4ef2 |
rev | line source |
---|---|
paulo@78 | 1 <html> |
paulo@78 | 2 <head> |
paulo@78 | 3 <link rel="stylesheet" type="text/css" href="index.css"> |
paulo@78 | 4 <script type="text/javascript" src="cookies.js"></script> |
paulo@78 | 5 </head> |
paulo@78 | 6 |
paulo@78 | 7 <body> |
paulo@78 | 8 <h1>Cookies set</h1> |
paulo@78 | 9 <div id="set_cookies"></div> |
paulo@78 | 10 <div> |
paulo@78 | 11 <input id="set_k"> |
paulo@78 | 12 <input type="password" id="set_v"> |
paulo@78 | 13 <input type="button" value="Set" onclick="set()"> |
paulo@78 | 14 </div> |
paulo@78 | 15 </body> |
paulo@78 | 16 <script type="text/javascript"> |
paulo@78 | 17 var setCookiesDiv = document.getElementById("set_cookies"); |
paulo@78 | 18 var setK = document.getElementById("set_k"); |
paulo@78 | 19 var setV = document.getElementById("set_v"); |
paulo@78 | 20 |
paulo@78 | 21 function addSetCookie(k, v) { |
paulo@78 | 22 var d = document.createElement("div"); |
paulo@78 | 23 |
paulo@78 | 24 var kInput = document.createElement("input"); |
paulo@78 | 25 kInput.disabled = true; |
paulo@78 | 26 kInput.value = k; |
paulo@78 | 27 |
paulo@78 | 28 var vInput = document.createElement("input"); |
paulo@78 | 29 vInput.type = "password"; |
paulo@78 | 30 vInput.disabled = true; |
paulo@78 | 31 vInput.value = v; |
paulo@78 | 32 |
paulo@78 | 33 var unset = document.createElement("input"); |
paulo@78 | 34 unset.type = "button"; |
paulo@78 | 35 unset.value = "Unset"; |
paulo@78 | 36 unset.onclick = function() { |
paulo@79 | 37 docCookies.removeItem(k, "/"); |
paulo@78 | 38 setCookiesDiv.removeChild(d); |
paulo@78 | 39 }; |
paulo@78 | 40 |
paulo@78 | 41 d.appendChild(kInput); |
paulo@78 | 42 d.appendChild(vInput); |
paulo@78 | 43 d.appendChild(unset); |
paulo@78 | 44 |
paulo@78 | 45 setCookiesDiv.appendChild(d); |
paulo@78 | 46 } |
paulo@78 | 47 |
paulo@78 | 48 function clear() { |
paulo@78 | 49 while (setCookiesDiv.firstChild) { |
paulo@78 | 50 setCookiesDiv.removeChild(setCookiesDiv.firstChild); |
paulo@78 | 51 } |
paulo@78 | 52 } |
paulo@78 | 53 |
paulo@78 | 54 function load() { |
paulo@78 | 55 clear(); |
paulo@78 | 56 for (var i=0; i<docCookies.keys().length; i++) { |
paulo@78 | 57 var k = docCookies.keys()[i]; |
paulo@78 | 58 if (docCookies.hasItem(k)) { |
paulo@78 | 59 var v = docCookies.getItem(k); |
paulo@78 | 60 addSetCookie(k, v); |
paulo@78 | 61 } |
paulo@78 | 62 } |
paulo@78 | 63 } |
paulo@78 | 64 |
paulo@78 | 65 function set() { |
paulo@79 | 66 docCookies.setItem(setK.value, setV.value, 600, "/"); |
paulo@78 | 67 setK.value = ""; |
paulo@78 | 68 setV.value = ""; |
paulo@78 | 69 load(); |
paulo@78 | 70 } |
paulo@78 | 71 |
paulo@78 | 72 load(); |
paulo@78 | 73 </script> |
paulo@78 | 74 </html> |