Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function licz(wg){
- if( !wg ){ sum_all();return; }
- rid=wg.parentNode.parentNode.id;
- r=rid.substr(1);
- //alert(r);
- c="c3_"+r;
- p=wg.value.split(":");
- text="";
- h=m=s=0;
- for(i=0;i<3;i++){
- if( typeof( p[i] )=="undefined" || !p[i] || p[i]=="." )
- p[i]=0;
- }
- p0=parseFloat(p[0]);
- p1=parseFloat(p[1]);
- p2=parseFloat(p[2]);
- //alert(p0);
- if( isNaN(p0) || isNaN(p1) || isNaN(p2) ){
- text="Error";
- }
- else {
- t=p0*3600+p1*60+p2;
- wg.parentNode.parentNode.seconds=t;
- tab=sec2tab(t);
- text=" "+tab[0]+" godz "+tab[1]+" min "+tab[2]+" sek ";
- }
- document.getElementById(c).innerHTML=text;
- sum_all();
- }
- function sum_all(){
- //licz wszystkie
- tc=document.getElementById('tcalc');
- rows=tc.getElementsByTagName("TR");
- sum=0;
- for( i=0; i<rows.length; i++ ){
- x=rows[i].seconds;
- s=rows[i].sign;
- // alert(x);
- if( !x )x=0;
- if( s )
- sum-=x;
- else
- sum+=x;
- }
- tab2=sec2tab(sum);
- text=ftim(tab2[0])+":"+ftim(tab2[1])+":"+ftim(tab2[2]);
- document.getElementById('tco').innerText=text;
- document.getElementById('tco').textContent=text;
- ss=my_round(sum);
- mm=my_round(sum/60);
- hh=my_round(sum/3600);
- text=hh+"<br>"+mm+"<br>"+ss;
- document.getElementById('atco').innerHTML=text;
- }
- function ftim(d){
- x=new String(d);
- if( x.length<2 )
- return "0"+x;
- return x;
- }
- function sec2tab(t){
- ans= new Array();
- z="";
- if( t<0 )z="-";
- t=Math.abs(t);
- ans[0]=Math.floor(t/3600);
- ans[1]=Math.floor((t-ans[0]*3600)/60);
- s=Math.floor(t-ans[0]*3600-ans[1]*60);
- ans[0]=z+ans[0];
- ms=new String(t);
- ix=ms.indexOf(".");
- if( ix>-1 )
- s+=ms.substr(ix);
- ans[2]=s;
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement