github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/client/www/templates/page_head.html (about) 1 <html><head><title>{PAGE_TITLE} {VERSION}{TESTNET}</title> 2 <script type="text/javascript" src="webui/gocoin.js"></script> 3 <link rel="stylesheet" href="webui/gocoin.css" type="text/css"> 4 <link rel="shortcut icon" href="/webui/favicon.ico" type="image/x-icon"> 5 <script> 6 /*_SESSION_ID_*/ 7 /*_AVERAGE_FEE_SPB_*/ 8 /*_SERVER_MODE_*/ 9 /*_WALLET_ON_*/ 10 /*_CHAIN_IN_SYNC_*/ 11 var doc_title = document.title 12 var testnet = (doc_title.indexOf(" Testnet") != -1) 13 14 var new_block_audio_file = new Audio('webui/new_block.mp3') 15 var back_online_audio_file = new Audio('webui/back_online.mp3') 16 17 var last_blocks_left = -1 18 19 var webuimenu = [ 20 ["/", "Home"], 21 ["/wal", "Wallet"], 22 ["/snd", "MakeTx"], 23 ["/net", "Network"], 24 ["/txs", "Transactions"], 25 ["/blocks", "Blocks"], 26 ["/miners", "Miners"], 27 ["/counts", "Counters"] 28 ] 29 30 const BN_OFFLINE = "XXX" 31 32 function beep_clicked() { 33 beep_new_block.checked = !beep_new_block.checked 34 localStorage.setItem("new_block_beep", beep_new_block.checked?"true":"false") 35 } 36 </script> 37 </head> 38 <body> 39 <table align="center" width="1020" cellpadding="0" cellspacing="0"><tr><td> 40 <table width="100%" border="0" cellspacing="0"><tr> 41 <colgroup> 42 <col> <!-- top menu --> 43 <col width="90"> <!-- block height --> 44 <col width="60"> <!-- beep --> 45 <col width="70"> <!-- status icons --> 46 <col width="80"> <!-- PushTX --> 47 <col> <!-- right menu --> 48 </colgroup> 49 50 <td id="topmenu"></td> 51 <td align="center" class="nw bold" id="blno">...</td> 52 <td align="center" class"min" title="Beep on each new block" class="hand" onclick="beep_clicked()"> 53 <input type="checkbox" id="beep_new_block" class="hand"><img src="webui/music.png"> 54 </td> 55 <td align="center" align="center"> 56 <img id="chainsync_icon" src="webui/chainsync.png" class="hand" style="display:none" onclick="set_tblock_hash()"> 57 </td> 58 <td align="center"> 59 <a href="javascript:pushtx()" class="topmenu" title="Load Raw TX">PushTx</a> 60 <td align="right" id="rightmenu"> 61 <a id="helpmenulink" href="{HELPURL}" class="topmenu">Help</a> 62 </td> 63 </tr></table> 64 <hr style="margin:2px"> 65 <script> 66 67 function set_tblock_hash() { 68 var hash = prompt("To speed up chain sync, enter hash of the highest block you trust") 69 if (hash!=null) { 70 var aj = ajax() 71 aj.onload = function() { 72 location.reload() 73 } 74 aj.open("GET","cfg?sid="+sid+"&trusthash="+hash, true) 75 aj.send(null) 76 } 77 } 78 79 function apply_wallet_on() { 80 if (wallet_on) { 81 topmenu.getElementsByTagName('a')[1].classList.remove('dimenu') 82 topmenu.getElementsByTagName('a')[2].classList.remove('dimenu') 83 } else { 84 topmenu.getElementsByTagName('a')[1].classList.add('dimenu') 85 topmenu.getElementsByTagName('a')[2].classList.add('dimenu') 86 } 87 } 88 89 for (var i=0; i < webuimenu.length; i++) { 90 var a = document.createElement('a') 91 a.href = webuimenu[i][0] 92 a.text = webuimenu[i][1] 93 a.className = 'topmenu' 94 if (document.location.pathname==webuimenu[i][0]) { 95 a.classList.add('menuat') 96 } 97 if (i < webuimenu.length-1) { 98 topmenu.appendChild(a) 99 } else { 100 rightmenu.insertBefore(a, helpmenulink) 101 } 102 103 if (i < webuimenu.length-2) { 104 var sp = document.createElement('span') 105 sp.innerHTML = ' ' 106 topmenu.appendChild(sp) 107 } 108 } 109 apply_wallet_on() 110 if (document.location.pathname=='/help') helpmenulink.classList.add('menuat') 111 112 var time_now /*_TIME_NOW_*/ 113 function refreshblock() { 114 var aj = ajax() 115 aj.onerror=function() { 116 blno.innerText = BN_OFFLINE 117 setTimeout(refreshblock, 10000) 118 } 119 aj.onload=function() { 120 var new_block = false 121 try { 122 var stat = JSON.parse(aj.responseText) 123 124 var blocks_left = stat.LastHeaderHeight - stat.Height 125 if (blocks_left != last_blocks_left) { 126 chainsync_icon.title = blocks_left + " blocks left" 127 } 128 if (chain_in_sync != stat.BlockChainSynchronized) { 129 chain_in_sync = stat.BlockChainSynchronized 130 set_chain_in_sync() 131 } 132 133 if (stat.WalletON != wallet_on) { 134 wallet_on = stat.WalletON 135 apply_wallet_on() 136 } 137 138 blno.title = "Last block received " + ((stat.Time_now-stat.Received)/60).toFixed(1) + " min ago" 139 if (blno.innerText != stat.Height) { 140 if (beep_new_block.checked) { 141 if (blno.innerText==BN_OFFLINE) { 142 back_online_audio_file.play() 143 } else if (blno.innerText.indexOf("...")==-1) { 144 new_block_audio_file.play() 145 } 146 } 147 new_block = true 148 blno.innerText = stat.Height 149 document.title = doc_title + ' @ ' + stat.Height 150 } 151 152 // dispatch event.. 153 var e = document.createEvent("Event") 154 e.initEvent("lastblock", false, false) 155 e.block = stat 156 time_now = stat.Time_now 157 blno.dispatchEvent(e) 158 } catch(e) { 159 blno.title = e 160 blno.innerText = "???" 161 //console.log() 162 } 163 setTimeout(refreshblock, new_block?1000:6000) 164 } 165 aj.open("GET","status.json",true) 166 aj.send(null) 167 } 168 169 function set_chain_in_sync() { 170 //console.log(chain_in_sync) 171 chainsync_icon.style.display = chain_in_sync ? 'none' : 'inline' 172 } 173 set_chain_in_sync() 174 175 if (localStorage.getItem("new_block_beep")==="true") { 176 beep_new_block.checked = true 177 } 178 179 document.addEventListener('DOMContentLoaded', function() { 180 beep_new_block.onclick = function(event) { 181 localStorage.setItem("new_block_beep", beep_new_block.checked?"true":"false") 182 event.stopPropagation() 183 } 184 refreshblock() 185 }) 186 187 </script>