2014-04-18 21:57:32 +02:00
|
|
|
var Timeline={};Timeline.ns="http://www.w3.org/2000/svg";Timeline.xlinkns="http://www.w3.org/1999/xlink";Timeline.marginBottom=10;Timeline.marginTop=15;Timeline.marginLeft=10;Timeline.marginRight=10;Timeline.rounded=false;Timeline.x_axis=false;Timeline.fill=true;Timeline.line="line";Timeline.dashed_style="5, 5";Timeline.parent_holder=false;Timeline.holder=false;Timeline.g=false;Timeline.axis=false;Timeline.graphs=[];Timeline.raw_points=[];Timeline.x_callback=false;Timeline.createElement=function(b,a){var c=document.createElementNS(Timeline.ns,b);for(attr in a){c.setAttribute(attr,a[attr])}return c};Timeline.hasClass=function(b,a){return(" "+b.getAttribute("class")+" ").indexOf(" "+a+" ")>-1};Timeline.addGraph=function(b,a){Timeline.graphs[b]=a};Timeline.hasGraph=function(a){if(typeof(Timeline.graphs[a])==="undefined"){return false}else{return true}};Timeline.clearGraph=function(b){if(typeof(b)==="undefined"){Timeline.raw_points=[];Timeline.graphs=[]}else{for(var a=0;a<Timeline.raw_points.length;a++){if(Timeline.raw_points[a].graph===b){Timeline.raw_points[a]=undefined}}}};Timeline.addPoints=function(d,c){for(var a=0;a<c.length;a++){var b={graph:d,x:c[a].x,y:c[a].y};if(typeof(c[a].label)!=="undefined"){b.label=c[a].label}else{b.label=""}if(typeof(c[a].click)!=="undefined"){b.click=c[a].click}else{b.click=false}Timeline.raw_points.push(b)}Timeline.raw_points.sort(function(f,e){if(f.x<e.x){return -1}else{if(f.x==e.x){return 0}else{return 1}}})};Timeline.newCoordinate=function(f,d,b,e,g){var c=(g-e)/(b-d);return c*(f-d)+e};Timeline.getNewXY=function(a,c,d,b){return function(e,f){return{x:Timeline.newCoordinate(e,a,c,Timeline.marginLeft,Timeline.parent_holder.offsetWidth-Timeline.marginRight),y:Timeline.newCoordinate(f,d,b,2*Timeline.marginBottom,Timeline.parent_holder.offsetHeight-Timeline.marginTop)}}};Timeline.getControlPoints=function(h){var p=new Array();var o=new Array();var e=h.length-1;var l=new Array();var k=new Array();var j=new Array();var d=new Array();l[0]=0;k[0]=2;j[0]=1;d[0]=h[0]+2*h[1];for(var g=1;g<e-1;g++){l[g]=1;k[g]=4;j[g]=1;d[g]=4*h[g]+2*h[g+1]}l[e-1]=2;k[e-1]=7;j[e-1]=0;d[e-1]=8*h[e-1]+h[e];var f;for(var g=1;g<e;g++){f=l[g]/k[g-1];k[g]=k[g]-f*j[g-1];d[g]=d[g]-f*d[g-1]}p[e-1]=d[e-1]/k[e-1];for(var g=e-2;g>=0;--g){p[g]=(d[g]-j[g]*p[g+1])/k[g]}for(var g=0;g<e-1;g++){o[g]=2*h[g+1]-p[g+1]}o[e-1]=0.5*(h[e]+p[e-1]);return{p1:p,p2:o}};Timeline.init=function(j){if(!document.implementation.hasFeature("http://www.w3.org/TR/Timeline11/feature#Image","1.1")){alert("ERROR : Your browser does not support embedded Timeline.")}Timeline.parent_holder=document.getElementById(j.id);var h=Timeline.createElement("svg:svg",{width:j.width,height:j.height});h.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink",Timeline.xlinkns);Timeline.parent_holder.appendChild(h);Timeline.holder=Timeline.parent_holder.querySelector("svg");defs=Timeline.createElement("defs",{});Timeline.holder.appendChild(defs);if(j.grid==="small"||j.grid==="both"){var i=Timeline.createElement("pattern",{id:"smallGrid",width:8,height:8,patternUnits:"userSpaceOnUse"});var e=Timeline.createElement("path",{d:"M 8 0 L 0 0 0 8",fill:"none",stroke:"gray","stroke-width":"0.5"});i.appendChild(e);defs.appendChild(i)}if(j.grid==="big"||j.grid==="both"){var d=Timeline.createElement("pattern",{id:"grid",width:80,height:80,patternUnits:"userSpaceOnUse"});if(j.grid==="both"){var c=Timeline.createElement("rect",{width:80,height:80,fill:"url(#smallGrid)"});d.appendChild(c)}var f=Timeline.createElement("path",{d:"M 80 0 L 0 0 0 80",fill:"none",stroke:"gray","stroke-width":"1"});d.appendChild(f);defs.appendChild(d)}Timeline.grid=j.grid;var g=Timeline.createElement("marker",{id:"markerArrow",markerWidth:13,markerHeight:13,refX:2,refY:6,orient:"auto"});var b=Timeline.createElement("path",{d:"M2,2 L2,11 L10,6 L2,2",fill:"gray"});g.appendChild(b);defs.appendChild(g);Timeline.g=Timeline.createElement("g",{transform:"translate(0, "+Timeline.parent_holder.offsetHeight+") scale(1, -1)"});Timeline.holder.appendChild(Timeline.g);if(j.x_axis===true){Timeline.axis=Timeline.createE
|