github.com/alpe/etcd@v0.1.2-0.20130915230056-09f31af88aeb/web/index.html (about) 1 <html> 2 <head> 3 <title>etcd Web Interface</title> 4 <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 5 <script type="text/javascript"> 6 $(function() { 7 8 var conn; 9 var content = $("#content"); 10 11 function update(response) { 12 // if set 13 if (response.action == "SET") { 14 15 if (response.expiration > "1970") { 16 t = response.key + "=" + response.value 17 + " " + response.expiration 18 } else { 19 t = response.key + "=" + response.value 20 } 21 22 id = response.key.replace(new RegExp("/", 'g'), "\\/"); 23 24 if ($("#store_" + id).length == 0) { 25 if (response.expiration > "1970") { 26 t = response.key + "=" + response.value 27 + " " + response.expiration 28 } else { 29 t = response.key + "=" + response.value 30 } 31 32 var e = $('<div id="store_' + response.key + '"/>') 33 .text(t) 34 e.appendTo(content) 35 } 36 else { 37 38 $("#store_" + id) 39 .text(t) 40 } 41 } 42 // if delete 43 else if (response.action == "DELETE") { 44 id = response.key.replace(new RegExp("/", 'g'), "\\/"); 45 46 $("#store_" + id).remove() 47 } 48 } 49 50 51 if (window["WebSocket"]) { 52 conn = new WebSocket("ws://{{.Address}}/ws"); 53 conn.onclose = function(evt) { 54 55 } 56 conn.onmessage = function(evt) { 57 var response = JSON.parse(evt.data) 58 update(response) 59 } 60 } else { 61 appendLog($("<div><b>Your browser does not support WebSockets.</b></div>")) 62 } 63 }); 64 </script> 65 </head> 66 <body> 67 <div id="leader">Leader: {{.Leader}}</div> 68 <div id="content"></div> 69 </body> 70 </html>