Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. var negativo = 0;
  2. var capienza = 0;
  3. var i = 0;
  4. $(".sbEmpty").each(function(){
  5. if (!($(this).children(".missingCrop").is(':empty'))){
  6. i++;
  7. var pos = $(this).attr('id');
  8. pos = parseInt(pos.replace("supplyRow_","")) + 1;
  9. var prepos = pos - 2;
  10. pos = "supplyRow_" + String(pos);
  11. prepos = "supplyRow_" + String(prepos);
  12. var ti = $(this).children("div.whenEmpty").children("p").children("strong")[0].innerText;
  13. var tf = $("#"+ pos + " div.boxAction")[0].innerText;
  14. ti = ti.replace(". ", "-");
  15. ti = ti.replace(". ", "-");
  16. ti = ti.replace(", ", "-");
  17. tf = tf.replace(". ", "-");
  18. tf = tf.replace(". ", "-");
  19. tf = tf.replace(", ", "-");
  20. function correctDate(data){
  21. var b = data.split('-');
  22. return b[2] + "-" + b[1] + "-" + b[0] + " " + b[3];
  23. }
  24. ti = correctDate(ti);
  25. tf = correctDate(tf);
  26. var d = (new Date(tf) - new Date(ti))/1000;
  27.  
  28. var miss = $(this).children("div").children("a.missing_tooltip")[0].innerHTML;
  29. miss = parseInt(miss.replace(/ /g, ''));
  30.  
  31. var neg = parseInt((miss*3600)/d);
  32.  
  33. var bar1 = $("#"+ prepos + " div.transGraph .boxGraph1").css("width");
  34. var bar2 = $("#"+ prepos + " div.transGraph .boxGraph2").css("width");
  35. bar1 = parseInt(bar1.replace("px",""));
  36. if (bar1 == 0) bar1 = 0.25;
  37. if (typeof bar2 !== 'undefined'){
  38. bar2 = parseInt(bar2.replace("px",""));
  39. }
  40. else{
  41. bar2 = 0;
  42. }
  43. var len = bar1 + bar2;
  44. var rif = $("#"+ prepos + " div.transGraph").css("width");
  45. rif = parseInt(rif.replace("px",""));
  46.  
  47. var tr = $("#"+ prepos + " div.boxAction")[0].innerText;
  48. tr = tr.replace(". ", "-");
  49. tr = tr.replace(". ", "-");
  50. tr = tr.replace(", ", "-");
  51. tr = correctDate(tr);
  52. var tload = (new Date(ti) - new Date(tr))/1000;
  53. var res = parseInt(-1*(neg/3600)*tload);
  54.  
  55. var cap = parseInt((res*rif)/len);
  56.  
  57. negativo += neg;
  58. capienza += cap;
  59. console.log(neg + " " + cap);
  60. }
  61. });
  62. negativo = parseInt(negativo/i);
  63. capienza = parseInt(capienza/i);
  64.  
  65. window.alert("Negativo: " + negativo + "\nCapienza gg: " + capienza + " (non calcolabile)");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement