forked from dsias/blockchain.info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomepage.min.js
1 lines (1 loc) · 2.13 KB
/
homepage.min.js
1
function updateTimes(){var a=new Date().getTime()/1000;$("td[data-time]").each(function(b){var e=parseInt($(this).data("time"));if(e==0){$(this).text("")}var d=a-e;if(d<60){$(this).text("< 1 minute")}else{if(d<3600){var c=(parseInt(d/60)>1)?"s":"";$(this).text(parseInt(d/60)+" minute"+c)}else{var c=(parseInt(d/3600)>1)?"s":"";$(this).text(parseInt(d/3600)+" hour"+c+" "+parseInt((d%3600)/60)+" minutes")}}})}webSocketConnect(function(a){a.onmessage=function(h){var g=$.parseJSON(h.data);if(g.op=="minitx"){var b=g.x;var c;if(b.tag){c='<a href="'+root+"tx/"+b.hash+'" class="tag-address" style="width:85px">'+b.hash+'</a> <span class="tag">('+b.tag;if(b.tag_link){c+=' <a class="external" rel="nofollow" href="'+root+"r?url="+encodeURI(b.tag_link)+'" target="new"></a>'}c+=")</span>"}else{c='<a href="'+root+"tx/"+b.hash+'">'+b.hash.substring(0,25)+"...</a>"}$("<tr><td><div>"+c+'</div></td><td class="hidden-phone" data-time="'+b.time+'"><div>< 1 minute</div></td><td><div><button class="btn btn-success" onclick="toggleSymbol()">'+formatMoney(b.value,true)+"</button></div></td></tr>").insertAfter($("#txs tr:first")).find("div").hide().slideDown("slow");$("#txs tr:last-child").remove()}else{if(g.op=="block"){var i=BlockFromJSON(g.x);if($("#bi:"+i.blockIndex).length>0){return}var f="Unknown";if(i.foundBy!=null){f='<a href="'+i.foundBy.link+'">'+i.foundBy.description+"</a>"}if(i.txIndex){var d=i.txIndex.length}else{var d=0}$('<tr id="bi:'+i.blockIndex+'"><td><div><a href="'+root+"block-index/"+i.blockIndex+"/"+i.hash+'">'+i.height+'</a></div></td><td data-time="'+i.time+'"><div>< 1 minute</div></td><td class="hidden-phone"><div>'+i.txIndex.length+'</div></td><td class="hidden-phone"><div>'+formatMoney(i.totalBTCSent,true)+"</div></td><td><div>"+f+'</div></td><td class="hidden-phone"><div>'+parseInt(i.size/1024)+"</div></td></tr>").insertAfter($("#blocks tr:first")).find("div").hide().slideDown("slow");$("#blocks tr:last-child").remove()}}};a.onopen=function(){a.send('{"op":"set_tx_mini"}{"op":"unconfirmed_sub"}{"op":"blocks_sub"}')}});$(document).ready(function(){if(top.location!=self.location){top.location=self.location.href}setInterval(updateTimes,1000)});