Forum

[en] Simulation progress bookmarklet
RiDDi
27.12.09 - 19:47
I was a little bored yesterday, so I wrote a bookmarklet that computes simulation progress.
Just create a new bookmark with the following URL and visit it on the simulations page:

javascript:function f(s){h=Math.floor(s/3600);m=Math.floor((s%25 3600)/60);s=Math.round(s%25 60);return(h<10?'0':'')+h+':'+(m<10?'0':'')+m+':'+(s<10?'0':'')+s;}tables=document.getElementsByTagName("table");lastString=tables[0].firstChild.lastChild.childNodes[4].firstChild.data;currentString=tables[1].firstChild.childNodes[4].childNodes[4].firstChild.data;percentageString=tables[1].firstChild.childNodes[4].childNodes[6].firstChild.data;arr=lastString.match(/[0-9]{2,4}/g);lastDate=new Date(arr[0],arr[1]-1,arr[2],arr[3],arr[4],arr[5],0);arr=currentString.match(/[0-9]{2,4}/g);currentDate=new Date(arr[0],arr[1]-1,arr[2],arr[3],arr[4],arr[5],0);elapsed=(currentDate.getTime()-lastDate.getTime())/1000;percentage=eval(percentageString.match(/[0-9]{2}.[0-9]/))/100;estimated=elapsed/percentage;remaining=estimated-elapsed;alert("elapsed: "+f(elapsed)+" remaining: "+f(remaining)+" total: "+f(estimated)+" finished: "+new Date(currentDate.getTime()+remaining*1000).toString());

Anyways, I hope you had a very merry christmas and will have a happy new year.
RiDDi
29.12.09 - 10:25
Bummer. Apparently, numbers smaller than ten have only one digit before the point ;)
Here's a fixed version:

javascript:function f(s){h=Math.floor(s/3600);m=Math.floor((s%25 3600)/60);s=Math.round(s%25 60);return(h<10?'0':'')+h+':'+(m<10?'0':'')+m+':'+(s<10?'0':'')+s;}tables=document.getElementsByTagName("table");lastString=tables[0].firstChild.lastChild.childNodes[4].firstChild.data;currentString=tables[1].firstChild.childNodes[4].childNodes[4].firstChild.data;percentageString=tables[1].firstChild.childNodes[4].childNodes[6].firstChild.data;arr=lastString.match(/[0-9]{2,4}/g);lastDate=new Date(arr[0],arr[1]-1,arr[2],arr[3],arr[4],arr[5],0);arr=currentString.match(/[0-9]{2,4}/g);currentDate=new Date(arr[0],arr[1]-1,arr[2],arr[3],arr[4],arr[5],0);elapsed=(currentDate.getTime()-lastDate.getTime())/1000;percentage=eval(percentageString.match(/[0-9]{1,2}.[0-9]/))/100;estimated=elapsed/percentage;remaining=estimated-elapsed;alert("elapsed: "+f(elapsed)+" remaining: "+f(remaining)+" total: "+f(estimated)+" finished: "+new Date(currentDate.getTime()+remaining*1000).toString());
Back to Topic Overview

Back to Main Page