github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/client/www/templates/blocks.html (about) 1 <script type="text/javascript" src="webui/jquery.min.js"></script> 2 <script type="text/javascript" src="webui/jquery.flot.min.js"></script> 3 <script type="text/javascript" src="webui/jquery.flot.crosshair.js"></script> 4 <style> 5 .stat0 { 6 } 7 .stat1 { 8 } 9 .time0 { 10 } 11 .time1 { 12 } 13 td.bordr { 14 border-right: 1px solid; 15 } 16 </style> 17 18 <!-- include fees_chart.html --> 19 20 <div style="text-align:right;margin-bottom:8px;"> 21 <span class="hand" onclick="stats_type_min.click()"> 22 <input type="radio" name="stats_type" id="stats_type_min" onchange="switch_stats_type()" onclick="event.stopPropagation()"> Mining Information 23 </span> 24 • 25 <span class="hand" onclick="stats_type_pro.click()"> 26 <input type="radio" name="stats_type" id="stats_type_pro" onchange="switch_stats_type()" onclick="event.stopPropagation()"> Block Processing 27 </span> 28 </div> 29 <table class="blocks bord" id="blkstab"> 30 <tr> 31 <th colspan="7">Block info 32 <th class="stat0 hand" colspan="4" onclick="stats_type_pro.click()">Mining Information 33 <th class="stat1 hand" colspan="7" onclick="stats_type_min.click()">Block Processing <i>(ms)</i> 34 <tr> 35 <th width="52">Height 36 <th class="time0" width="70" onclick="swap_time_mode()" style="cursor:pointer">Received 37 <th class="time1" width="70" onclick="swap_time_mode()" style="cursor:pointer;font-size:85%">Timestamp 38 <th width="480">Hash 39 <th width="35" align="right">TXs 40 <th width="40" align="right">SiOps 41 <th width="45" align="right">kByte 42 <th> 43 <th class="stat0" width="30">BTC 44 <th class="stat0" width="30" align="right">SPB 45 <th class="stat0" width="20">Ver 46 <th class="stat0 bordr" align="left">Miner 47 <th class="stat1" width="10" title="Received from ConnID">Fro 48 <th class="stat1" width="10" title="Missing TXs in cmpctblk">Mis 49 <th class="stat1" width="20" title="Preprocessing time ms" align="right">Pre 50 <th class="stat1" width="20" title="Full download time ms" align="right">D/L 51 <th class="stat1" width="20" title="Queueing time ms" align="right">Que 52 <th class="stat1" width="20" title="Block committed after ms" align="right">Ver 53 <th class="stat1" width="10" title="Extra times received">X 54 </tr> 55 </table> 56 <script> 57 function switch_stats_type() { 58 if (stats_type_pro.checked) { 59 css('.stat1', 'display', 'table-cell') 60 css('.stat0', 'display', 'none') 61 localStorage.setItem("blocks_info", "pro") 62 } else { 63 css('.stat0', 'display', 'table-cell') 64 css('.stat1', 'display', 'none') 65 localStorage.setItem("blocks_info", "min") 66 } 67 } 68 function remember_info_setting() { 69 var mod = localStorage.getItem("blocks_info") 70 if ((mod+'').length!=3) mod = "min" 71 document.getElementById('stats_type_'+mod).checked = true 72 } 73 remember_info_setting() 74 switch_stats_type() 75 76 const MINER_ID_COLUMN = 11 77 const VERSION_COLUMN = 10 78 79 var show_timestamp = false 80 81 function swap_time_mode() { 82 show_timestamp = !show_timestamp 83 if (show_timestamp) { 84 css('.time1', 'display', 'table-cell') 85 css('.time0', 'display', 'none') 86 } else { 87 css('.time0', 'display', 'table-cell') 88 css('.time1', 'display', 'none') 89 } 90 localStorage.setItem("blocks_show_timestmp", show_timestamp) 91 } 92 93 var mid = null 94 95 function hl_rows(column, i) { 96 var row = blkstab.rows[2+i] 97 mid = row.cells[column].innerHTML 98 if (row.className.indexOf("own")!=-1) { 99 mid = null 100 } 101 for (var i=2; i<blkstab.rows.length; i++) { 102 if (blkstab.rows[i].cells[column].innerHTML==mid) { 103 blkstab.rows[i].classList.add("own") 104 } else { 105 blkstab.rows[i].classList.remove("own") 106 } 107 } 108 } 109 110 111 function do_rcvd_time(td) { 112 td.innerText = ((time_now-parseInt(td.name))/60.0).toFixed(1) + 'min' 113 } 114 115 116 function ms2str(v) { 117 if (v>=10e3) { 118 if (v>=180e3) { 119 if (v>=3600e3) { 120 v = (v/3600e3).toFixed(1) + 'hrs' 121 } else { 122 v = (v/60e3).toFixed(1) + 'min' 123 } 124 } else { 125 v = (v/1000).toFixed(1) + 's' 126 } 127 } 128 return v 129 } 130 131 132 function refreshblocks() { 133 function onc_mid(c,id) { 134 c.onclick = function() {hl_rows(MINER_ID_COLUMN, id)} 135 } 136 137 function onc_ver(c,id) { 138 c.onclick = function() {hl_rows(VERSION_COLUMN, id)} 139 } 140 141 function onc_stat(c,height,size,minedby) { 142 c.onclick = function() { 143 show_block_fees(height,size,minedby) 144 return false 145 } 146 } 147 148 var aj = ajax() 149 aj.onerror=function() { 150 setTimeout(refreshblocks, 1000) 151 } 152 aj.onload=function() { 153 try { 154 var cs = JSON.parse(aj.responseText) 155 156 while (blkstab.rows.length>2) blkstab.deleteRow(2) 157 158 for (var i=0; i<cs.length; i++) { 159 var td, row = blkstab.insertRow(-1) 160 161 row.className = 'hov' 162 row.title = "Rcvd at " + tim2str(cs[i].Received) + " with TS " + tim2str(cs[i].Timestamp) 163 164 td = row.insertCell(-1) 165 td.className = 'bold' 166 td.style.textAlign = 'center' 167 td.innerText = cs[i].Height 168 169 td = row.insertCell(-1) 170 td.style.textAlign = 'right' 171 td.className = 'i time0' 172 td.name = cs[i].Received 173 do_rcvd_time(td) 174 175 td = row.insertCell(-1) 176 td.style.textAlign = 'right' 177 td.className = 'i time1' 178 td.name = cs[i].Received 179 td.innerText = tim2str(cs[i].Timestamp, true) 180 181 td = row.insertCell(-1) 182 td.className = 'mono block_hash nw' 183 td.innerText = cs[i].Hash 184 //var h = cs[i].Hash 185 if (cs[i].HaveFeeStats) { 186 var img = document.createElement('img') 187 img.src = 'webui/stats.png' 188 img.className = 'hand' 189 img.style.margin = '0px 0px 0px 10px' 190 td.appendChild(img) 191 onc_stat(img, cs[i].Height, cs[i].Size, cs[i].Miner.substr(0,12)) 192 //h += '<img src="webui/stats.png" style="float:right" onclick="feestats(\'' + h + '\')">' 193 } 194 195 td = row.insertCell(-1) 196 td.style.textAlign = 'right' 197 if (cs[i].TxCnt>1) td.innerText = cs[i].TxCnt 198 199 td = row.insertCell(-1) 200 td.style.textAlign = 'right' 201 td.className = 'blsigops' 202 if (cs[i].Sigops>0) td.innerText = cs[i].Sigops 203 204 td = row.insertCell(-1) 205 td.style.textAlign = 'right' 206 td.className = 'bold' 207 td.innerText = (cs[i].Size/1000.0).toFixed(1) 208 if (cs[i].NonWitnessSize>0 && cs[i].NonWitnessSize!=cs[i].Size) { 209 td.style.color = 'blue' 210 td.title = cs[i].Size + ' -> ' + cs[i].NonWitnessSize 211 //(cs[i].NonWitnessSize/1000.0).toFixed(1) 212 } 213 td = row.insertCell(-1) 214 td.innerText = '' 215 216 td = row.insertCell(-1) 217 td.className = 'blreward stat0' 218 td.innerText = (cs[i].Reward/1e8).toFixed(2) 219 220 td = row.insertCell(-1) 221 td.className = 'blspb stat0' 222 td.innerText = cs[i].FeeSPB.toFixed(1) 223 224 td = row.insertCell(-1) 225 td.style.textAlign = 'center' 226 td.className = 'stat0 hand' 227 td.innerText = (cs[i].Version&15).toString(16) 228 td.title = '0x' + cs[i].Version.toString(16) 229 onc_ver(td, i) 230 231 var miner = cs[i].Miner.substr(0,11) 232 td = row.insertCell(-1) 233 td.className = "i stat0 hand bordr" 234 td.innerText = miner 235 onc_mid(td, i) 236 237 td = row.insertCell(-1) 238 td.style.textAlign = 'right' 239 td.className = 'nodeid stat1' 240 if (cs[i].FromConID>0) td.innerText = cs[i].FromConID 241 242 td = row.insertCell(-1) 243 td.style.textAlign = 'right' 244 td.className = 'blstatmissedtxs stat1' 245 if (cs[i].MissedCnt>0) td.innerText = cs[i].MissedCnt 246 247 td = row.insertCell(-1) 248 td.style.textAlign = 'right' 249 td.className = 'blstat stat1' 250 var time_base = cs[i].TimePre 251 if (cs[i].TimePre>0) td.innerText = ms2str(cs[i].TimePre) 252 253 td = row.insertCell(-1) 254 td.style.textAlign = 'right' 255 td.className = 'blstat stat1' 256 if (cs[i].TimeDl>0) { 257 td.innerText = ms2str(cs[i].TimeDl - time_base) 258 time_base = cs[i].TimeDl 259 } 260 261 td = row.insertCell(-1) 262 td.style.textAlign = 'right' 263 td.className = 'blstat stat1' 264 if (cs[i].TimeQue>0) { 265 td.innerText = ms2str(cs[i].TimeQue - time_base) 266 time_base = cs[i].TimeQue 267 } 268 269 td = row.insertCell(-1) 270 td.style.textAlign = 'right' 271 td.className = 'blstat stat1' 272 if (cs[i].TimeVer>0) { 273 td.innerText = ms2str(cs[i].TimeVer - time_base) 274 } 275 276 td = row.insertCell(-1) 277 td.style.textAlign = 'right' 278 td.className = 'blstatwaste stat1' 279 if (cs[i].WasteCnt>0) td.innerText = cs[i].WasteCnt 280 281 if (cs[i].TimeVer>=0) { // block received during this uptime 282 if (cs[i].MissedCnt>=0) { 283 row.classList.add("bip152") 284 } else { 285 if (cs[i].MissedCnt==-2) { 286 row.classList.add("CFN") // Cornell-Falcon-Network 287 } 288 } 289 } 290 } 291 292 if (mid!=null) { 293 for (var i=2; i<blkstab.rows.length; i++) { 294 if (blkstab.rows[i].cells[7].innerHTML==mid) { 295 blkstab.rows[i].classList.add("own") 296 } 297 } 298 } 299 } catch(e) { 300 console.log(e) 301 } 302 } 303 aj.open("GET","blocks.json",true) 304 aj.send(null) 305 } 306 307 308 309 var _lblo = 0 310 311 blno.addEventListener("lastblock", function(e) { 312 if (e.block.Height!=_lblo) { 313 _lblo = e.block.Height 314 refreshblocks() // refersh the table for each new block notifiaction 315 } else { 316 for (var i=2; i<blkstab.rows.length; i++) { 317 do_rcvd_time(blkstab.rows[i].cells[1]) 318 } 319 } 320 }) 321 322 document.addEventListener('DOMContentLoaded', function() { 323 window.onkeyup = function (event) { 324 if(event.keyCode == 27) closepopup() 325 } 326 }) 327 328 show_timestamp = localStorage.getItem("blocks_show_timestmp")!=="true" 329 swap_time_mode() 330 331 </script>