Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. function licz(wg){
  2. if( !wg ){ sum_all();return; }
  3. rid=wg.parentNode.parentNode.id;
  4. r=rid.substr(1);
  5. //alert(r);
  6. c="c3_"+r;
  7. p=wg.value.split(":");
  8. text="";
  9. h=m=s=0;
  10. for(i=0;i<3;i++){
  11. if( typeof( p[i] )=="undefined" || !p[i] || p[i]=="." )
  12. p[i]=0;
  13. }
  14. p0=parseFloat(p[0]);
  15. p1=parseFloat(p[1]);
  16. p2=parseFloat(p[2]);
  17. //alert(p0);
  18. if( isNaN(p0) || isNaN(p1) || isNaN(p2) ){
  19. text="Error";
  20. }
  21. else {
  22. t=p0*3600+p1*60+p2;
  23. wg.parentNode.parentNode.seconds=t;
  24. tab=sec2tab(t);
  25. text="&nbsp;"+tab[0]+" godz "+tab[1]+" min "+tab[2]+" sek ";
  26. }
  27. document.getElementById(c).innerHTML=text;
  28. sum_all();
  29. }
  30.  
  31. function sum_all(){
  32. //licz wszystkie
  33. tc=document.getElementById('tcalc');
  34. rows=tc.getElementsByTagName("TR");
  35. sum=0;
  36. for( i=0; i<rows.length; i++ ){
  37. x=rows[i].seconds;
  38. s=rows[i].sign;
  39. // alert(x);
  40. if( !x )x=0;
  41. if( s )
  42. sum-=x;
  43. else
  44. sum+=x;
  45. }
  46. tab2=sec2tab(sum);
  47. text=ftim(tab2[0])+":"+ftim(tab2[1])+":"+ftim(tab2[2]);
  48. document.getElementById('tco').innerText=text;
  49. document.getElementById('tco').textContent=text;
  50. ss=my_round(sum);
  51. mm=my_round(sum/60);
  52. hh=my_round(sum/3600);
  53. text=hh+"<br>"+mm+"<br>"+ss;
  54. document.getElementById('atco').innerHTML=text;
  55. }
  56.  
  57. function ftim(d){
  58. x=new String(d);
  59. if( x.length<2 )
  60. return "0"+x;
  61. return x;
  62. }
  63.  
  64. function sec2tab(t){
  65. ans= new Array();
  66. z="";
  67. if( t<0 )z="-";
  68. t=Math.abs(t);
  69. ans[0]=Math.floor(t/3600);
  70. ans[1]=Math.floor((t-ans[0]*3600)/60);
  71. s=Math.floor(t-ans[0]*3600-ans[1]*60);
  72. ans[0]=z+ans[0];
  73. ms=new String(t);
  74. ix=ms.indexOf(".");
  75. if( ix>-1 )
  76. s+=ms.substr(ix);
  77. ans[2]=s;
  78. return ans;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement