Darksergio

Untitled

Sep 22nd, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getData()
  2.     {
  3.        var d = document.getElementsByClassName('inputDateCell');
  4.        var g = document.getElementsByClassName('inputGradeCell');
  5.        var c = document.getElementsByClassName('col_4');
  6.        var n = document.getElementsByClassName('col_0');
  7.        var disp = Object.keys(c).length - Object.keys(g).length;
  8.        var newData = [];
  9.        var newCfu=[];
  10.        var form = d3.time.format("%d/%m/%Y");
  11.  
  12.        for(var i=0; i<Object.keys(d).length-1; i++)
  13.        {
  14.            if(form.parse(d[i].value) !== null && g[i].value.length !== 0 )
  15.            {
  16.                newData.push({"data":d[i].value,"voto":g[i].value,"nome":n[i+disp].innerHTML});
  17.                newCfu[i]=(parseInt(c[i+disp].innerHTML));
  18.            }
  19.        }
  20.        update(newData,newCfu);
  21.     }
  22.  
  23.     function update(d,c)
  24.     {
  25.        var svgCareer = d3.select("#starPath");
  26.        svgCareer.remove();
  27.        var newData = data.concat(d);
  28.        drawStarPath('#careerStarPath',carStarWidth,carStarHeight,newData);
  29.  
  30.        var svgProgress = d3.select("#proDonut");
  31.        svgProgress.remove();
  32.        var newCfuNum = cfuTot+sum(c);
  33.        var newProg = toFixed((newCfuNum/180)*100,2);
  34.        drawDonutChart('#progressDonut',newProg,proWidth,proHeight,"#006699","#a3becc","proDonut");
  35.  
  36.        var g = [];
  37.        for (var i=0; i < Object.keys(d).length; i++)
  38.            g.push(parseInt(d[i].voto));
  39.  
  40.       var newGrade = grade.concat(g);
  41.       var newCfu   = cfu.concat(c);
  42.       var newPond=toFixed(wmean(newGrade,newCfu),2);
  43.       var newTitle=toFixed(tmean(newPond),2);
  44.  
  45.       document.getElementById("proCfuCell").innerHTML = "CFU: "+newCfuNum;
  46.       document.getElementById("proMeanCell").innerHTML = "MEDIA: "+newPond;
  47.       document.getElementById("proTitleCell").innerHTML = "TITOLO: "+newTitle;
  48.  
  49.     }
  50.  
  51.     function reset()
  52.     {
  53.         var svgCareer = d3.select("#starPath");
  54.         svgCareer.remove();
  55.         drawStarPath('#careerStarPath',carStarWidth,carStarHeight,data);
  56.  
  57.        var svgProgress = d3.select("#proDonut");
  58.        svgProgress.remove();
  59.        drawDonutChart('#progressDonut',progress,proWidth,proHeight,"#006699","#a3becc","proDonut");
  60.        document.getElementById("proCfuCell").innerHTML = "";
  61.       document.getElementById("proMeanCell").innerHTML = "";
  62.       document.getElementById("proTitleCell").innerHTML = "";
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment