mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
2 lines
50 KiB
JavaScript
2 lines
50 KiB
JavaScript
var JSGantt;JSGantt||(JSGantt={});var vBenchTime=(new Date).getTime();JSGantt.isIE=function(){return"undefined"!=typeof document.all?"pageXOffset"in window?!1:!0:!1},JSGantt.TaskItem=function(t,e,n,a,o,i,s,r,l,d,u,h,c,f,p,m){var v,S,w,D,T,y=parseInt(document.createTextNode(t).data),L=document.createTextNode(e).data,N=new Date(0),G=new Date(0),M=null,J=null,k=document.createTextNode(o).data,C=document.createTextNode(i).data,I=parseInt(document.createTextNode(s).data),F=document.createTextNode(r).data,b=parseFloat(document.createTextNode(l).data),H=parseInt(document.createTextNode(d).data),x=document.createTextNode(u).data,E=2==H?1:parseInt(document.createTextNode(h).data),X=new Array,Y=new Array,O=document.createTextNode(f).data,R="",A=0,V=0,P=1,B=0,U=!1,j=null,W=null,q=m instanceof JSGantt.GanttChart?m:g,_=null,Q=null,z=null,K=null,Z=null;if(T=document.createElement("span"),T.className="gTaskNotes",null!=p&&(T.innerHTML=p,JSGantt.stripUnwanted(T)),null!=n&&""!=n&&(N=n instanceof Date?n:JSGantt.parseDateStr(document.createTextNode(n).data,q.getDateInputFormat()),M=N),null!=a&&""!=a&&(G=a instanceof Date?a:JSGantt.parseDateStr(document.createTextNode(a).data,q.getDateInputFormat()),J=G),null!=c)for(var $=c+"",tt=$.split(","),et=tt.length,nt=0;et>nt;nt++)-1!=tt[nt].toUpperCase().indexOf("SS")?(X[nt]=tt[nt].substring(0,tt[nt].toUpperCase().indexOf("SS")),Y[nt]="SS"):-1!=tt[nt].toUpperCase().indexOf("FF")?(X[nt]=tt[nt].substring(0,tt[nt].toUpperCase().indexOf("FF")),Y[nt]="FF"):-1!=tt[nt].toUpperCase().indexOf("SF")?(X[nt]=tt[nt].substring(0,tt[nt].toUpperCase().indexOf("SF")),Y[nt]="SF"):-1!=tt[nt].toUpperCase().indexOf("FS")?(X[nt]=tt[nt].substring(0,tt[nt].toUpperCase().indexOf("FS")),Y[nt]="FS"):(X[nt]=tt[nt],Y[nt]="FS");this.getID=function(){return y},this.getName=function(){return L},this.getStart=function(){return N},this.getEnd=function(){return G},this.getGroupMinStart=function(){return M},this.getGroupMinEnd=function(){return J},this.getClass=function(){return k},this.getLink=function(){return C},this.getMile=function(){return I},this.getDepend=function(){return X?X:null},this.getDepType=function(){return Y?Y:null},this.getCaption=function(){return O?O:""},this.getResource=function(){return F?F:" "},this.getCompVal=function(){return b?b:0},this.getCompStr=function(){return b?b+"%":""},this.getNotes=function(){return T},this.getSortIdx=function(){return B},this.getToDelete=function(){return U},this.getDuration=function(t,e){if(I)R="-";else{var n=new Date(this.getEnd().getTime()),a=null;switch(t){case"week":a="day";break;case"month":a="week";break;case"quarter":a="month";break;default:a=t}(n.getTime()-6e4*n.getTimezoneOffset())%864e5==0&&(n=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1,n.getHours(),n.getMinutes(),n.getSeconds()));var o=JSGantt.getOffset(this.getStart(),n,999,a)/1e3;switch(Math.floor(o)!=o&&(o=Math.round(10*o)/10),a){case"hour":R=o+" "+(1!=o?e.hrs:e.hr);break;case"day":R=o+" "+(1!=o?e.dys:e.dy);break;case"week":R=o+" "+(1!=o?e.wks:e.wk);break;case"month":R=o+" "+(1!=o?e.mths:e.mth);break;case"quarter":R=o+" "+(1!=o?e.qtrs:e.qtr)}}return R},this.getParent=function(){return x},this.getGroup=function(){return H},this.getOpen=function(){return E},this.getLevel=function(){return A},this.getNumKids=function(){return V},this.getStartX=function(){return v},this.getStartY=function(){return S},this.getEndX=function(){return w},this.getEndY=function(){return D},this.getVisible=function(){return P},this.getParItem=function(){return j},this.getCellDiv=function(){return W},this.getBarDiv=function(){return _},this.getTaskDiv=function(){return Q},this.getChildRow=function(){return K},this.getListChildRow=function(){return z},this.getGroupSpan=function(){return Z},this.setStart=function(t){t instanceof Date&&(N=t)},this.setEnd=function(t){t instanceof Date&&(G=t)},this.setGroupMinStart=function(t){t instanceof Date&&(M=t)},this.setGroupMinEnd=function(t){t instanceof Date&&(J=t)},this.setLevel=function(t){A=parseInt(document.createTextNode(t).data)},this.setNumKid=function(t){V=parseInt(document.createTextNode(t).data)},this.setCompVal=function(t){b=parseFloat(document.createTextNode(t).data)},this.setStartX=function(t){v=parseInt(document.createTextNode(t).data)},this.setStartY=function(t){S=parseInt(document.createTextNode(t).data)},this.setEndX=function(t){w=parseInt(document.createTextNode(t).data)},this.setEndY=function(t){D=parseInt(document.createTextNode(t).data)},this.setOpen=function(t){E=parseInt(document.createTextNode(t).data)},this.setVisible=function(t){P=parseInt(document.createTextNode(t).data)},this.setSortIdx=function(t){B=parseInt(document.createTextNode(t).data)},this.setToDelete=function(t){U=t?!0:!1},this.setParItem=function(t){t instanceof JSGantt.TaskItem&&(j=t)},this.setCellDiv=function(t){("function"!=typeof HTMLDivElement||t instanceof HTMLDivElement)&&(W=t)},this.setGroup=function(t){H=parseInt(document.createTextNode(t).data)},this.setBarDiv=function(t){("function"!=typeof HTMLDivElement||t instanceof HTMLDivElement)&&(_=t)},this.setTaskDiv=function(t){("function"!=typeof HTMLDivElement||t instanceof HTMLDivElement)&&(Q=t)},this.setChildRow=function(t){("function"!=typeof HTMLTableRowElement||t instanceof HTMLTableRowElement)&&(K=t)},this.setListChildRow=function(t){("function"!=typeof HTMLTableRowElement||t instanceof HTMLTableRowElement)&&(z=t)},this.setGroupSpan=function(t){("function"!=typeof HTMLSpanElement||t instanceof HTMLSpanElement)&&(Z=t)}},JSGantt.GanttChart=function(t,e){var n,a=t,o=e,i=null,s=1,r=1,l=1,g=1,d=1,u=25e3,h=1,c=1,f=1,p=1,m=1,v=1,S=1,w=1,D=1,T=1,y=1,L=1,N=1,G=1,M=new Array("top"),J="yyyy-mm-dd",k=JSGantt.parseDateFormatStr("dd/mm/yyyy"),C=JSGantt.parseDateFormatStr("dd month yyyy"),I=JSGantt.parseDateFormatStr("day dd month yyyy"),F=JSGantt.parseDateFormatStr("HH"),b=JSGantt.parseDateFormatStr("dd/mm/yyyy"),H=JSGantt.parseDateFormatStr("dd"),x=JSGantt.parseDateFormatStr("yyyy"),E=JSGantt.parseDateFormatStr("dd/mm"),X=JSGantt.parseDateFormatStr("yyyy"),Y=JSGantt.parseDateFormatStr("mon"),O=JSGantt.parseDateFormatStr("yyyy"),R=JSGantt.parseDateFormatStr("qq"),A=(JSGantt.parseDateFormatStr("dd/mm/yyyy"),1),V=new Array,P=new Array("hour","day","week","month","quarter"),B=(new Array(31,28,31,30,31,30,31,31,30,31,30,31),!0),U=8,j="",W=18,q=18,_=36,Q=36,z=18,K=20,Z=-1,$=null,tt=null,et=null,nt=null,at=null,ot=20;this.setUseFade=function(t){s=t},this.setUseMove=function(t){r=t},this.setUseRowHlt=function(t){l=t},this.setUseToolTip=function(t){g=t},this.setUseSort=function(t){d=t},this.setUseSingleCell=function(t){u=1*t},this.setFormatArr=function(){var t="hour day week month quarter";P=new Array;for(var e=0,n=0;e<arguments.length;e++)if(-1!=t.indexOf(arguments[e].toLowerCase())&&arguments[e].length>1){P[n++]=arguments[e].toLowerCase();var a=new RegExp("(?:^|s)"+arguments[e]+"(?!S)","g");t=t.replace(a,"")}},this.setShowRes=function(t){h=t},this.setShowDur=function(t){c=t},this.setShowComp=function(t){f=t},this.setShowStartDate=function(t){p=t},this.setShowEndDate=function(t){m=t},this.setShowTaskInfoRes=function(t){S=t},this.setShowTaskInfoDur=function(t){w=t},this.setShowTaskInfoComp=function(t){D=t},this.setShowTaskInfoStartDate=function(t){T=t},this.setShowTaskInfoEndDate=function(t){y=t},this.setShowTaskInfoNotes=function(t){L=t},this.setShowTaskInfoLink=function(t){N=t},this.setShowEndWeekDate=function(t){v=t},this.setShowSelector=function(){var t="top bottom";M=new Array;for(var e=0,n=0;e<arguments.length;e++)if(-1!=t.indexOf(arguments[e].toLowerCase())&&arguments[e].length>1){M[n++]=arguments[e].toLowerCase();var a=new RegExp("(?:^|s)"+arguments[e]+"(?!S)","g");t=t.replace(a,"")}},this.setShowDeps=function(t){G=t},this.setDateInputFormat=function(t){J=t},this.setDateTaskTableDisplayFormat=function(t){k=JSGantt.parseDateFormatStr(t)},this.setDateTaskDisplayFormat=function(t){C=JSGantt.parseDateFormatStr(t)},this.setHourMajorDateDisplayFormat=function(t){I=JSGantt.parseDateFormatStr(t)},this.setHourMinorDateDisplayFormat=function(t){F=JSGantt.parseDateFormatStr(t)},this.setDayMajorDateDisplayFormat=function(t){b=JSGantt.parseDateFormatStr(t)},this.setDayMinorDateDisplayFormat=function(t){H=JSGantt.parseDateFormatStr(t)},this.setWeekMajorDateDisplayFormat=function(t){x=JSGantt.parseDateFormatStr(t)},this.setWeekMinorDateDisplayFormat=function(t){E=JSGantt.parseDateFormatStr(t)},this.setMonthMajorDateDisplayFormat=function(t){X=JSGantt.parseDateFormatStr(t)},this.setMonthMinorDateDisplayFormat=function(t){Y=JSGantt.parseDateFormatStr(t)},this.setQuarterMajorDateDisplayFormat=function(t){O=JSGantt.parseDateFormatStr(t)},this.setQuarterMinorDateDisplayFormat=function(t){R=JSGantt.parseDateFormatStr(t)},this.setCaptionType=function(t){n=t},this.setFormat=function(t){o=t,this.Draw()},this.setMinGpLen=function(t){U=t},this.setScrollTo=function(t){j=t},this.setHourColWidth=function(t){W=t},this.setDayColWidth=function(t){q=t},this.setWeekColWidth=function(t){_=t},this.setMonthColWidth=function(t){Q=t},this.setQuarterColWidth=function(t){z=t},this.setRowHeight=function(t){K=t},this.setLang=function(t){vLangs[t]&&(vLang=t)},this.setChartBody=function(t){("function"!=typeof HTMLDivElement||t instanceof HTMLDivElement)&&($=t)},this.setChartHead=function(t){("function"!=typeof HTMLDivElement||t instanceof HTMLDivElement)&&(tt=t)},this.setListBody=function(t){("function"!=typeof HTMLDivElement||t instanceof HTMLDivElement)&&(et=t)},this.setChartTable=function(t){("function"!=typeof HTMLTableElement||t instanceof HTMLTableElement)&&(nt=t)},this.setLines=function(t){("function"!=typeof HTMLDivElement||t instanceof HTMLDivElement)&&(at=t)},this.setTimer=function(t){ot=1*t},this.addLang=function(t,e){if(!vLangs[t]){vLangs[t]=new Object;for(var n in vLangs.en)vLangs[t][n]=e[n]?document.createTextNode(e[n]).data:vLangs.en[n]}},this.getDivId=function(){return i},this.getUseFade=function(){return s},this.getUseMove=function(){return r},this.getUseRowHlt=function(){return l},this.getUseToolTip=function(){return g},this.getUseSort=function(){return d},this.getUseSingleCell=function(){return u},this.getFormatArr=function(){return P},this.getShowRes=function(){return h},this.getShowDur=function(){return c},this.getShowComp=function(){return f},this.getShowStartDate=function(){return p},this.getShowEndDate=function(){return m},this.getShowTaskInfoRes=function(){return S},this.getShowTaskInfoDur=function(){return w},this.getShowTaskInfoComp=function(){return D},this.getShowTaskInfoStartDate=function(){return T},this.getShowTaskInfoEndDate=function(){return y},this.getShowTaskInfoNotes=function(){return L},this.getShowTaskInfoLink=function(){return N},this.getShowEndWeekDate=function(){return v},this.getShowSelector=function(){return M},this.getShowDeps=function(){return G},this.getDateInputFormat=function(){return J},this.getDateTaskTableDisplayFormat=function(){return k},this.getDateTaskDisplayFormat=function(){return C},this.getHourMajorDateDisplayFormat=function(){return I},this.getHourMinorDateDisplayFormat=function(){return F},this.getDayMajorDateDisplayFormat=function(){return b},this.getDayMinorDateDisplayFormat=function(){return H},this.getWeekMajorDateDisplayFormat=function(){return x},this.getWeekMinorDateDisplayFormat=function(){return E},this.getMonthMajorDateDisplayFormat=function(){return X},this.getMonthMinorDateDisplayFormat=function(){return Y},this.getQuarterMajorDateDisplayFormat=function(){return O},this.getQuarterMinorDateDisplayFormat=function(){return R},this.getCaptionType=function(){return n},this.getMinGpLen=function(){return U},this.getScrollTo=function(){return j},this.getHourColWidth=function(){return W},this.getDayColWidth=function(){return q},this.getWeekColWidth=function(){return _},this.getMonthColWidth=function(){return Q},this.getQuarterColWidth=function(){return z},this.getRowHeight=function(){return K},this.getChartBody=function(){return $},this.getChartHead=function(){return tt},this.getListBody=function(){return et},this.getChartTable=function(){return nt},this.getLines=function(){return at},this.getTimer=function(){return ot},this.CalcTaskXY=function(){for(var t,e,n,a,o=this.getList(),i=Math.floor(this.getRowHeight()/2),s=0;s<o.length;s++)t=o[s].getID(),e=o[s].getBarDiv(),n=o[s].getTaskDiv(),a=o[s].getParItem()&&2==o[s].getParItem().getGroup()?o[s].getParItem().getChildRow():o[s].getChildRow(),e&&(o[s].setStartX(e.offsetLeft+1),o[s].setStartY(a.offsetTop+e.offsetTop+i-1),o[s].setEndX(e.offsetLeft+e.offsetWidth+1),o[s].setEndY(a.offsetTop+e.offsetTop+i-1))},this.AddTaskItem=function(t){for(var e=!1,n=0;n<V.length;n++)V[n].getID()==t.getID()&&(n=V.length,e=!0);e||(V.push(t),B=!0)},this.RemoveTaskItem=function(t){for(var e=0;e<V.length;e++)V[e].getID()==t?V[e].setToDelete(!0):V[e].getParent()==t&&this.RemoveTaskItem(V[e].getID());B=!0},this.getList=function(){return V},this.clearDependencies=function(){for(var t=this.getLines();t.hasChildNodes();)t.removeChild(t.firstChild);A=1},this.sLine=function(t,e,n,a,o){var s=Math.min(t,n),r=Math.min(e,a),l=Math.abs(n-t)+1,g=Math.abs(a-e)+1,d=document.createElement("div");return d.id=i+"line"+A++,d.style.position="absolute",d.style.overflow="hidden",d.style.zIndex=0,d.style.left=s+"px",d.style.top=r+"px",d.style.width=l+"px",d.style.height=g+"px",d.style.visibility="visible",1==l?d.className="glinev":d.className="glineh",o&&(d.className+=" "+o),this.getLines().appendChild(d),d},this.drawDependency=function(t,e,n,a,o,i){var s=1,r=!1,l=4,g=Math.floor(this.getRowHeight()/2);switch(e>a&&(g*=-1),o){case"SF":l*=-1,n>=t-10&&e!=a&&(r=!0),s=-1;break;case"SS":n>t?l*=-1:l=n-t-2*l;break;case"FF":n>=t&&(l=n-t+2*l),s=-1;break;default:t+10>=n&&e!=a&&(r=!0)}r?(this.sLine(t,e,t+l,e,i),this.sLine(t+l,e,t+l,a-g,i),this.sLine(t+l,a-g,n-2*l,a-g,i),this.sLine(n-2*l,a-g,n-2*l,a,i),this.sLine(n-2*l,a,n-1*s,a,i)):e!=a?(this.sLine(t,e,t+l,e,i),this.sLine(t+l,e,t+l,a,i),this.sLine(t+l,a,n-1*s,a,i)):this.sLine(t,e,n-1*s,a,i);var d=this.sLine(n,a,n-3-(0>s?1:0),a-3-(0>s?1:0),i+"Arw");d.style.width="0px",d.style.height="0px"},this.DrawDependencies=function(){if(1==this.getShowDeps()){this.CalcTaskXY(),this.clearDependencies();for(var t=this.getList(),e=0;e<t.length;e++){var n=t[e].getDepend(),a=t[e].getDepType(),o=n.length;if(o>0&&1==t[e].getVisible())for(var i=0;o>i;i++){var s=this.getArrayLocationByID(n[i]);s>=0&&2!=t[s].getGroup()&&1==t[s].getVisible()&&("SS"==a[i]?this.drawDependency(t[s].getStartX()-1,t[s].getStartY(),t[e].getStartX()-1,t[e].getStartY(),"SS","gDepSS"):"FF"==a[i]?this.drawDependency(t[s].getEndX(),t[s].getEndY(),t[e].getEndX(),t[e].getEndY(),"FF","gDepFF"):"SF"==a[i]?this.drawDependency(t[s].getStartX()-1,t[s].getStartY(),t[e].getEndX(),t[e].getEndY(),"SF","gDepSF"):"FS"==a[i]&&this.drawDependency(t[s].getEndX(),t[s].getEndY(),t[e].getStartX()-1,t[e].getStartY(),"FS","gDepFS"))}}}Z>=0&&this.sLine(Z,0,Z,this.getChartTable().offsetHeight-1,"gCurDate")},this.getArrayLocationByID=function(t){for(var e=this.getList(),n=0;n<e.length;n++)if(e[n].getID()==t)return n;return-1},this.newNode=function(t,e,n,a,o,i,s,r,l,g){var d=t.appendChild(document.createElement(e));if(g)for(var u=0;u+1<g.length;u+=2)d.setAttribute(g[u],g[u+1]);return n&&(d.id=n),a&&(d.className=a),i&&(d.style.width=isNaN(1*i)?i:i+"px"),s&&(d.style.left=isNaN(1*s)?s:s+"px"),o&&d.appendChild(document.createTextNode(o)),r&&(d.style.display=r),l&&(d.colSpan=l),d},this.Draw=function(){var t=new Date,e=new Date,n=new Date,s=0,r=0,l=1,g=0,d=0,S=!1,w=0,D=null,T=0;if(V.length>0){B&&JSGantt.processRows(V,0,-1,1,1,this.getUseSort()),B=!1,e=JSGantt.getMinDate(V,o),t=JSGantt.getMaxDate(V,o),"day"==o?T=q:"week"==o?T=_:"month"==o?T=Q:"quarter"==o?T=z:"hour"==o&&(T=W);var y=document.createDocumentFragment(),L=this.newNode(y,"div",i+"glisthead","glistlbl gcontainercol"),N=this.newNode(L,"table",null,"gtasktableh"),G=this.newNode(N,"tbody"),M=this.newNode(G,"tr");this.newNode(M,"td",null,"gtasklist"," ");var J=this.newNode(M,"td",null,"gspanning gtaskname");J.appendChild(this.drawSelector("top")),1==h&&this.newNode(M,"td",null,"gspanning gresource"," "),1==c&&this.newNode(M,"td",null,"gspanning gduration"," "),1==f&&this.newNode(M,"td",null,"gspanning gpccomplete"," "),1==p&&this.newNode(M,"td",null,"gspanning gstartdate"," "),1==m&&this.newNode(M,"td",null,"gspanning genddate"," "),M=this.newNode(G,"tr"),this.newNode(M,"td",null,"gtasklist"," "),this.newNode(M,"td",null,"gtaskname"," "),1==h&&this.newNode(M,"td",null,"gtaskheading gresource",vLangs[vLang].resource),1==c&&this.newNode(M,"td",null,"gtaskheading gduration",vLangs[vLang].duration),1==f&&this.newNode(M,"td",null,"gtaskheading gpccomplete",vLangs[vLang].comp),1==p&&this.newNode(M,"td",null,"gtaskheading gstartdate",vLangs[vLang].startdate),1==m&&this.newNode(M,"td",null,"gtaskheading genddate",vLangs[vLang].enddate),L=this.newNode(y,"div",null,"glabelfooter");var C=document.createDocumentFragment(),A=this.newNode(C,"div",i+"glistbody","glistgrid gcontainercol");for(this.setListBody(A),N=this.newNode(A,"table",null,"gtasktable"),G=this.newNode(N,"tbody"),st=0;st<V.length;st++){if(1==V[st].getGroup())var P="ggroupitem";else P="glineitem";if(w=V[st].getID(),!V[st].getParItem()||2!=V[st].getParItem().getGroup()||2==V[st].getGroup()){M=0==V[st].getVisible()?this.newNode(G,"tr",i+"child_"+w,"gname "+P,null,null,null,"none"):this.newNode(G,"tr",i+"child_"+w,"gname "+P),V[st].setListChildRow(M),this.newNode(M,"td",null,"gtasklist"," "),J=this.newNode(M,"td",null,"gtaskname");var K="";for(rt=1;rt<V[st].getLevel();rt++)K+=" ";if(1==V[st].getGroup()){L=this.newNode(J,"div",null,null,K);var $=this.newNode(L,"span",i+"group_"+w,"gfoldercollapse",1==V[st].getOpen()?"-":"+");V[st].setGroupSpan($),JSGantt.addFolderListeners(this,$,w),L.appendChild(document.createTextNode(" "+V[st].getName()))}else K+=" ",L=this.newNode(J,"div",null,null,K+V[st].getName());if(1==h){J=this.newNode(M,"td",null,"gresource");var tt=this.newNode(J,"div",null,"");tt=this.newNode(tt,"a",null,"",vLangs[vLang].moreinfo),tt.setAttribute("href",V[st].getLink())}1==c&&(J=this.newNode(M,"td",null,"gduration"),L=this.newNode(J,"div",null,null,V[st].getDuration(o,vLangs[vLang]))),1==f&&(J=this.newNode(M,"td",null,"gpccomplete"),L=this.newNode(J,"div",null,null,V[st].getCompStr())),1==p&&(J=this.newNode(M,"td",null,"gstartdate"),L=this.newNode(J,"div",null,null,JSGantt.formatDateStr(V[st].getStart(),k,vLangs[vLang]))),1==m&&(J=this.newNode(M,"td",null,"genddate"),L=this.newNode(J,"div",null,null,JSGantt.formatDateStr(V[st].getEnd(),k,vLangs[vLang]))),d++}}M=this.newNode(G,"tr"),this.newNode(M,"td",null,"gtasklist"," "),J=this.newNode(M,"td",null,"gspanning gtaskname"),J.appendChild(this.drawSelector("bottom")),1==h&&this.newNode(M,"td",null,"gspanning gresource"," "),1==c&&this.newNode(M,"td",null,"gspanning gduration"," "),1==f&&this.newNode(M,"td",null,"gspanning gpccomplete"," "),1==p&&this.newNode(M,"td",null,"gspanning gstartdate"," "),1==m&&this.newNode(M,"td",null,"gspanning genddate"," "),this.newNode(A,"br"),this.newNode(A,"br");var et=document.createDocumentFragment();L=this.newNode(et,"div",i+"gcharthead","gchartlbl gcontainercol"),this.setChartHead(L),N=this.newNode(L,"table",i+"chartTableh","gcharttableh"),G=this.newNode(N,"tbody"),M=this.newNode(G,"tr"),n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),"hour"==o?n.setHours(e.getHours()):n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setMilliseconds(0);for(var nt=1;n.getTime()<=t.getTime();){var at="gmajorheading";K="","day"==o?(J=this.newNode(M,"td",null,at,null,null,null,null,7),K+=JSGantt.formatDateStr(n,b,vLangs[vLang]),n.setDate(n.getDate()+6),1==v&&(K+=" - "+JSGantt.formatDateStr(n,b,vLangs[vLang])),this.newNode(J,"div",null,null,K,7*T),n.setDate(n.getDate()+1)):"week"==o?(J=this.newNode(M,"td",null,at,null,T),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,x,vLangs[vLang]),T),n.setDate(n.getDate()+7)):"month"==o?(nt=12-n.getMonth(),n.getFullYear()==t.getFullYear()&&(nt-=11-t.getMonth()),J=this.newNode(M,"td",null,at,null,null,null,null,nt),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,X,vLangs[vLang]),T*nt),n.setFullYear(n.getFullYear()+1,0,1)):"quarter"==o?(nt=4-Math.floor(n.getMonth()/3),n.getFullYear()==t.getFullYear()&&(nt-=3-Math.floor(t.getMonth()/3)),J=this.newNode(M,"td",null,at,null,null,null,null,nt),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,O,vLangs[vLang]),T*nt),n.setFullYear(n.getFullYear()+1,0,1)):"hour"==o&&(nt=24-n.getHours(),n.getFullYear()==t.getFullYear()&&n.getMonth()==t.getMonth()&&n.getDate()==t.getDate()&&(nt-=23-t.getHours()),J=this.newNode(M,"td",null,at,null,null,null,null,nt),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,I,vLangs[vLang]),T*nt),n.setHours(0),n.setDate(n.getDate()+1))}for(M=this.newNode(G,"tr"),n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()),"hour"==o&&n.setHours(e.getHours()),g=0;n.getTime()<=t.getTime();){at="gminorheading";var ot="gtaskcell";if("day"==o)n.getDay()%6==0&&(at+="wkend",ot+="wkend"),t>=n&&(J=this.newNode(M,"td",null,at),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,H,vLangs[vLang]),T),g++),n.setDate(n.getDate()+1);else if("week"==o)t>=n&&(J=this.newNode(M,"td",null,at),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,E,vLangs[vLang]),T),g++),n.setDate(n.getDate()+7);else if("month"==o)for(t>=n&&(J=this.newNode(M,"td",null,at),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,Y,vLangs[vLang]),T),g++),n.setDate(n.getDate()+1);n.getDate()>1;)n.setDate(n.getDate()+1);else if("quarter"==o)for(t>=n&&(J=this.newNode(M,"td",null,at),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,R,vLangs[vLang]),T),g++),n.setDate(n.getDate()+81);n.getDate()>1;)n.setDate(n.getDate()+1);else if("hour"==o){for(st=n.getHours();24>st;st++)n.setHours(st),t>=n&&(J=this.newNode(M,"td",null,at),this.newNode(J,"div",null,null,JSGantt.formatDateStr(n,F,vLangs[vLang]),T),g++);n.setHours(0),n.setDate(n.getDate()+1)}}D=M,s=g*(T+1)+1,0!=u&&g*d>u&&(S=!0),this.newNode(L,"div",null,"rhscrpad",null,null,s+1);var it=document.createDocumentFragment();L=this.newNode(it,"div",i+"gchartbody","gchartgrid gcontainercol"),this.setChartBody(L),N=this.newNode(L,"table",i+"chartTable","gcharttable",null,s),this.setChartTable(N),this.newNode(L,"div",null,"rhscrpad",null,null,s+1),G=this.newNode(N,"tbody");var st=0,rt=0;for(st=0;st<V.length;st++){var lt=V[st].getStart(),gt=V[st].getEnd();(gt.getTime()-6e4*gt.getTimezoneOffset())%864e5==0&&(gt=new Date(gt.getFullYear(),gt.getMonth(),gt.getDate()+1,gt.getHours(),gt.getMinutes(),gt.getSeconds())),s=JSGantt.getOffset(e,lt,T,o),r=JSGantt.getOffset(lt,gt,T,o),w=V[st].getID();var dt=V[st].getParItem()&&2==V[st].getParItem().getGroup(),ut="",ht=V[st],ct="",ft=null;if(V[st].getMile()&&!dt){if(M=this.newNode(G,"tr",i+"childrow_"+w,"gmileitem gmile"+o,null,null,null,0==V[st].getVisible()?"none":null),V[st].setChildRow(M),JSGantt.addThisRowListeners(this,V[st].getListChildRow(),M),J=this.newNode(M,"td",null,"gtaskcell"),L=this.newNode(J,"div",null,"gtaskcelldiv"," "),L=this.newNode(L,"div",i+"bardiv_"+w,"gtaskbarcontainer",null,12,s-6),V[st].setBarDiv(L),A=this.newNode(L,"div",i+"taskbar_"+w,V[st].getClass(),null,12),V[st].setTaskDiv(A),V[st].getCompVal()<100?A.appendChild(document.createTextNode("◊")):(A=this.newNode(A,"div",null,"gmilediamond"),this.newNode(A,"div",null,"gmdtop"),this.newNode(A,"div",null,"gmdbottom")),ft="gmilecaption",!S&&!dt)for(ut="",rt=0;g-1>rt;rt++)ut="day"!=o||rt%7!=4&&rt%7!=5?"gtaskcell":"gtaskcellwkend",this.newNode(M,"td",null,ut," ")}else if(l=r-1,V[st].getGroup()){if(l=l>U&&2*U>l?2*U:l,l=U>l?U:l,M=this.newNode(G,"tr",i+"childrow_"+w,(2==V[st].getGroup()?"glineitem gitem":"ggroupitem ggroup")+o,null,null,null,0==V[st].getVisible()?"none":null),V[st].setChildRow(M),JSGantt.addThisRowListeners(this,V[st].getListChildRow(),M),J=this.newNode(M,"td",null,"gtaskcell"),L=this.newNode(J,"div",null,"gtaskcelldiv"," "),V[st].setCellDiv(L),1==V[st].getGroup()&&(L=this.newNode(L,"div",i+"bardiv_"+w,"gtaskbarcontainer",null,l,s),V[st].setBarDiv(L),A=this.newNode(L,"div",i+"taskbar_"+w,V[st].getClass(),null,l),V[st].setTaskDiv(A),this.newNode(A,"div",i+"complete_"+w,V[st].getClass()+"complete",null,V[st].getCompStr()),this.newNode(L,"div",null,V[st].getClass()+"endpointleft"),l>=2*U&&this.newNode(L,"div",null,V[st].getClass()+"endpointright"),ft="ggroupcaption"),!S&&!dt)for(ut="",rt=0;g-1>rt;rt++)ut="day"!=o||rt%7!=4&&rt%7!=5?"gtaskcell":"gtaskcellwkend",this.newNode(M,"td",null,ut," ")}else if(l=0>=l?1:l,dt?L=V[st].getParItem().getCellDiv():(M=this.newNode(G,"tr",i+"childrow_"+w,"glineitem gitem"+o,null,null,null,0==V[st].getVisible()?"none":null),V[st].setChildRow(M),JSGantt.addThisRowListeners(this,V[st].getListChildRow(),M),J=this.newNode(M,"td",null,"gtaskcell"),L=this.newNode(J,"div",null,"gtaskcelldiv"," ")),L=this.newNode(L,"div",i+"bardiv_"+w,"gtaskbarcontainer",null,l,s),V[st].setBarDiv(L),A=this.newNode(L,"div",i+"taskbar_"+w,V[st].getClass(),null,l),V[st].setTaskDiv(A),this.newNode(A,"div",i+"complete_"+w,V[st].getClass()+"complete",null,V[st].getCompStr()),dt&&(ht=V[st].getParItem()),(!dt||dt&&V[st].getParItem().getEnd()==V[st].getEnd())&&(ft="gcaption"),!S&&!dt)for(ut="",rt=0;g-1>rt;rt++)ut="day"!=o||rt%7!=4&&rt%7!=5?"gtaskcell":"gtaskcellwkend",this.newNode(M,"td",null,ut," ");if(this.getCaptionType()&&null!==ft){switch(this.getCaptionType()){case"Caption":var ct=ht.getCaption();break;case"Resource":ct=ht.getResource();break;case"Duration":ct=ht.getDuration(o,vLangs[vLang]);break;case"Complete":ct=ht.getCompStr()}this.newNode(L,"div",null,ft,ct,120,"gmilecaption"==ft?12:0)}V[st].getTaskDiv()&&L&&(A=this.newNode(L,"div",i+"tt"+w,null,null,null,null,"none"),A.appendChild(this.createTaskInfo(V[st])),JSGantt.addTooltipListeners(this,V[st].getTaskDiv(),A))}for(S||G.appendChild(D.cloneNode(!0));a.hasChildNodes();)a.removeChild(a.firstChild);if(L=this.newNode(a,"div",null,"gchartcontainer"),L.appendChild(et),L.appendChild(y),L.appendChild(it),L.appendChild(C),this.newNode(L,"div",null,"ggridfooter"),A=this.newNode(this.getChartBody(),"div",i+"Lines","glinediv"),A.style.visibility="hidden",this.setLines(A),JSGantt.addScrollListeners(this),""!=j){var pt=new Date(e.getTime()),mt=0;"px"==j.substr(0,2)?mt=parseInt(j.substr(2)):(pt=JSGantt.parseDateStr(j,this.getDateInputFormat()),"hour"==o?pt.setMinutes(0,0,0):pt.setHours(0,0,0,0),mt=JSGantt.getOffset(e,pt,T,o)),this.getChartBody().scrollLeft=mt}Z=e.getTime()<=(new Date).getTime()&&t.getTime()>=(new Date).getTime()?JSGantt.getOffset(e,new Date,T,o):-1,this.DrawDependencies()}},this.mouseOver=function(t,e){this.getUseRowHlt()&&(t.className+=" gitemhighlight",e.className+=" gitemhighlight")},this.mouseOut=function(t,e){this.getUseRowHlt()&&(t.className=t.className.replace(/(?:^|\s)gitemhighlight(?!\S)/g,""),e.className=e.className.replace(/(?:^|\s)gitemhighlight(?!\S)/g,""))},this.drawSelector=function(t){for(var e=document.createDocumentFragment(),n=!1,a=0;a<M.length&&!n;a++)M[a].toLowerCase()==t.toLowerCase()&&(n=!0);if(n){var s=this.newNode(e,"div",null,"gselector",vLangs[vLang].format+":");-1!=P.join().toLowerCase().indexOf("hour")&&JSGantt.addFormatListeners(this,"hour",this.newNode(s,"span",i+"formathour"+t,"gformlabel"+("hour"==o?" gselected":""),vLangs[vLang].hour)),-1!=P.join().toLowerCase().indexOf("day")&&JSGantt.addFormatListeners(this,"day",this.newNode(s,"span",i+"formatday"+t,"gformlabel"+("day"==o?" gselected":""),vLangs[vLang].day)),-1!=P.join().toLowerCase().indexOf("week")&&JSGantt.addFormatListeners(this,"week",this.newNode(s,"span",i+"formatweek"+t,"gformlabel"+("week"==o?" gselected":""),vLangs[vLang].week)),-1!=P.join().toLowerCase().indexOf("month")&&JSGantt.addFormatListeners(this,"month",this.newNode(s,"span",i+"formatmonth"+t,"gformlabel"+("month"==o?" gselected":""),vLangs[vLang].month)),-1!=P.join().toLowerCase().indexOf("quarter")&&JSGantt.addFormatListeners(this,"quarter",this.newNode(s,"span",i+"formatquarter"+t,"gformlabel"+("quarter"==o?" gselected":""),vLangs[vLang].quarter))}else this.newNode(e,"div",null,"gselector");return e},this.createTaskInfo=function(t){var e,n=document.createDocumentFragment(),a=this.newNode(n,"div",null,"gTaskInfo");if(this.newNode(a,"span",null,"gTtTitle",t.getName()),1==T&&(e=this.newNode(a,"div",null,"gTILine gTIsd"),this.newNode(e,"span",null,"gTaskLabel",vLangs[vLang].startdate+": "),this.newNode(e,"span",null,"gTaskText",JSGantt.formatDateStr(t.getStart(),C,vLangs[vLang]))),1==y&&(e=this.newNode(a,"div",null,"gTILine gTIed"),this.newNode(e,"span",null,"gTaskLabel",vLangs[vLang].enddate+": "),this.newNode(e,"span",null,"gTaskText",JSGantt.formatDateStr(t.getEnd(),C,vLangs[vLang]))),1!=w||t.getMile()||(e=this.newNode(a,"div",null,"gTILine gTId"),this.newNode(e,"span",null,"gTaskLabel",vLangs[vLang].duration+": "),this.newNode(e,"span",null,"gTaskText",t.getDuration(o,vLangs[vLang]))),1==D&&(e=this.newNode(a,"div",null,"gTILine gTIc"),this.newNode(e,"span",null,"gTaskLabel",vLangs[vLang].completion+": "),this.newNode(e,"span",null,"gTaskText",t.getCompStr())),1==S&&(e=this.newNode(a,"div",null,"gTILine gTIr"),this.newNode(e,"span",null,"gTaskLabel",vLangs[vLang].resource+": "),this.newNode(e,"span",null,"gTaskText",t.getResource())),1==N&&""!=t.getLink()){e=this.newNode(a,"div",null,"gTILine gTIl");var i=this.newNode(e,"span",null,"gTaskLabel");i=this.newNode(i,"a",null,"gTaskText",vLangs[vLang].moreinfo),i.setAttribute("href",t.getLink())}return 1==L&&(e=this.newNode(a,"div",null,"gTILine gTIn"),this.newNode(e,"span",null,"gTaskLabel",vLangs[vLang].notes+": "),t.getNotes()&&e.appendChild(t.getNotes())),n},this.getXMLProject=function(){for(var t='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',e=0;e<V.length;e++)t+=this.getXMLTask(e,!0);return t+="</project>"},this.getXMLTask=function(t,e){var n=0,a=-1,o="",i=JSGantt.parseDateFormatStr(this.getDateInputFormat()+" HH:MI");if(e===!0)a=t;else for(n=0;n<V.length;n++)if(V[n].getID()==t){a=n;break}if(a>=0&&a<V.length){o="<task>",o+="<pID>"+V[a].getID()+"</pID>",o+="<pName>"+V[a].getName()+"</pName>",o+="<pStart>"+JSGantt.formatDateStr(V[a].getStart(),i,vLangs[vLang])+"</pStart>",o+="<pEnd>"+JSGantt.formatDateStr(V[a].getEnd(),i,vLangs[vLang])+"</pEnd>",o+="<pClass>"+V[a].getClass()+"</pClass>",o+="<pLink>"+V[a].getLink()+"</pLink>",o+="<pMile>"+V[a].getMile()+"</pMile>"," "!=V[a].getResource()&&(o+="<pRes>"+V[a].getResource()+"</pRes>"),o+="<pComp>"+V[a].getCompVal()+"</pComp>",o+="<pGroup>"+V[a].getGroup()+"</pGroup>",o+="<pParent>"+V[a].getParent()+"</pParent>",o+="<pOpen>"+V[a].getOpen()+"</pOpen>",o+="<pDepend>";var s=V[a].getDepend();for(n=0;n<s.length;n++)n>0&&(o+=","),s[n]>0&&(o+=s[n]+V[a].getDepType()[n]);o+="</pDepend>",o+="<pCaption>"+V[a].getCaption()+"</pCaption>";var r=document.createDocumentFragment(),l=this.newNode(r,"div",null,null,V[a].getNotes().innerHTML);o+="<pNotes>"+l.innerHTML+"</pNotes>",o+="</task>"}return o},a&&"div"==a.nodeName.toLowerCase()&&(i=a.id)},JSGantt.updateFlyingObj=function(t,e,n){var a=3,o=5,i=3,s=15,r=t?t.clientX:window.event.clientX,l=t?t.clientY:window.event.clientY,g=document.documentElement.clientWidth||document.getElementsByTagName("body")[0].clientWidth,d=document.documentElement.clientHeight||document.getElementsByTagName("body")[0].clientHeight,u=r,h=l;if("microsoft internet explorer"==navigator.appName.toLowerCase()){r-=document.documentElement.clientLeft,l-=document.documentElement.clientTop;var c=JSGantt.getZoomFactor();1!=c&&(r=Math.round(r/c),l=Math.round(l/c))}var f=JSGantt.getScrollPositions();u=r-o-e.vTool.offsetWidth<0?r+s+e.vTool.offsetWidth>g?f.x:r+f.x+s:r+f.x-o-e.vTool.offsetWidth,h=l+i+e.vTool.offsetHeight>d?l-a-e.vTool.offsetHeight<0?f.y:l+f.y-a-e.vTool.offsetHeight:l+f.y+i,e.getUseMove()?(clearInterval(e.vTool.moveInterval),e.vTool.moveInterval=setInterval(function(){JSGantt.moveToolTip(u,h,e.vTool,n)},n)):(e.vTool.style.left=u+"px",
|
||
e.vTool.style.top=h+"px")},JSGantt.showToolTip=function(t,e,n,a,o){var i=t.getDivId()+"JSGanttToolTip",s=500,r=100,l=n.id;t.getUseToolTip()&&(null==t.vTool&&(t.vTool=document.createElement("div"),t.vTool.id=i,t.vTool.className="JSGanttToolTip",t.vTool.vToolCont=document.createElement("div"),t.vTool.vToolCont.id=i+"cont",t.vTool.vToolCont.className="JSGanttToolTipcont",t.vTool.vToolCont.setAttribute("showing",""),t.vTool.appendChild(t.vTool.vToolCont),document.body.appendChild(t.vTool),t.vTool.style.opacity=0,t.vTool.setAttribute("currentOpacity",0),t.vTool.setAttribute("fadeIncrement",10),t.vTool.setAttribute("moveSpeed",10),t.vTool.style.filter="alpha(opacity=0)",t.vTool.style.visibility="hidden",t.vTool.style.left=Math.floor((e?e.clientX:window.event.clientX)/2)+"px",t.vTool.style.top=Math.floor((e?e.clientY:window.event.clientY)/2)+"px",JSGantt.addListener("mouseover",function(){clearTimeout(t.vTool.delayTimeout)},t.vTool),JSGantt.addListener("mouseout",function(){JSGantt.delayedHide(t,t.vTool,o)},t.vTool)),clearTimeout(t.vTool.delayTimeout),(t.vTool.vToolCont.getAttribute("showing")!=l||"visible"!=t.vTool.style.visibility)&&(t.vTool.vToolCont.getAttribute("showing")!=l&&(t.vTool.vToolCont.setAttribute("showing",l),t.vTool.vToolCont.innerHTML=n.innerHTML,JSGantt.stripIds(t.vTool.vToolCont)),t.vTool.style.visibility="visible",JSGantt.updateFlyingObj(e,t,o),t.vTool.style.width=a?a+"px":"auto",!a&&JSGantt.isIE()&&(t.vTool.style.width=t.vTool.offsetWidth),t.vTool.offsetWidth>s&&(t.vTool.style.width=s+"px")),t.getUseFade()?(clearInterval(t.vTool.fadeInterval),t.vTool.fadeInterval=setInterval(function(){JSGantt.fadeToolTip(1,t.vTool,r)},o)):(t.vTool.style.opacity=.01*r,t.vTool.style.filter="alpha(opacity="+r+")"))},JSGantt.stripIds=function(t){for(var e=0;e<t.childNodes.length;e++)"removeAttribute"in t.childNodes[e]&&t.childNodes[e].removeAttribute("id"),t.childNodes[e].hasChildNodes()&&JSGantt.stripIds(t.childNodes[e])},JSGantt.stripUnwanted=function(t){for(var e=new Array("#text","p","br","ul","ol","li","div","span","img"),n=0;n<t.childNodes.length;n++)-1==(e.join().toLowerCase()+",").indexOf(t.childNodes[n].nodeName.toLowerCase()+",")&&t.replaceChild(document.createTextNode(t.childNodes[n].outerHTML),t.childNodes[n]),t.childNodes[n].hasChildNodes()&&JSGantt.stripUnwanted(t.childNodes[n])},JSGantt.delayedHide=function(t,e,n){var a=1500;e&&(e.delayTimeout=setTimeout(function(){JSGantt.hideToolTip(t,e,n)},a))},JSGantt.hideToolTip=function(t,e,n){t.getUseFade()?(clearInterval(e.fadeInterval),e.fadeInterval=setInterval(function(){JSGantt.fadeToolTip(-1,e,0)},n)):(e.style.opacity=0,e.style.filter="alpha(opacity=0)",e.style.visibility="hidden")},JSGantt.fadeToolTip=function(t,e,n){var a=parseInt(e.getAttribute("fadeIncrement")),o=e.getAttribute("currentOpacity"),i=parseInt(o);if(i!=n&&1==t||0!=i&&-1==t){var s=a;a>n-i&&1==t?s=n-i:a>o&&-1==t&&(s=i),o=i+s*t,e.style.opacity=.01*o,e.style.filter="alpha(opacity="+o+")",e.setAttribute("currentOpacity",o)}else clearInterval(e.fadeInterval),-1==t&&(e.style.opacity=0,e.style.filter="alpha(opacity=0)",e.style.visibility="hidden")},JSGantt.moveToolTip=function(t,e,n){var a=parseInt(n.getAttribute("moveSpeed")),o=parseInt(n.style.left),i=parseInt(n.style.top);"visible"!=n.style.visibility?(n.style.left=t+"px",n.style.top=e+"px",clearInterval(n.moveInterval)):t!=o&&e!=i?(o+=Math.ceil((t-o)/a),i+=Math.ceil((e-i)/a),n.style.left=o+"px",n.style.top=i+"px"):clearInterval(n.moveInterval)},JSGantt.getZoomFactor=function(){var t=1;if(document.body.getBoundingClientRect){var e=document.body.getBoundingClientRect(),n=e.right-e.left,a=document.body.offsetWidth;t=Math.round(n/a*100)/100}return t},JSGantt.getScrollPositions=function(){var t=window.pageXOffset,e=window.pageYOffset;if(!("pageXOffset"in window)){var n=JSGantt.getZoomFactor();t=Math.round(document.documentElement.scrollLeft/n),e=Math.round(document.documentElement.scrollTop/n)}return{x:t,y:e}},JSGantt.getOffset=function(t,e,n,a){var o=new Array(31,28,31,30,31,30,31,31,30,31,30,31),i=new Date(t.getTime()),s=new Date(e.getTime()),r=0,l=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),0,0),g=Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),0,0),d=(g-l)/36e5;if("day"==a)r=Math.ceil(d/24*(n+1));else if("week"==a)r=Math.ceil(d/24*(n+1)/7);else if("month"==a){var u=12*(s.getFullYear()-i.getFullYear())+(s.getMonth()-i.getMonth()),h=new Date(s.getTime());h.setDate(i.getDate());var c=(s.getTime()-h.getTime())/864e5;r=Math.ceil(u*(n+1)+c*(n/o[s.getMonth()]))}else if("quarter"==a)u=12*(s.getFullYear()-i.getFullYear())+(s.getMonth()-i.getMonth()),h=new Date(s.getTime()),h.setDate(i.getDate()),c=(s.getTime()-h.getTime())/864e5,r=Math.ceil(u*((n+1)/3)+c*(n/90));else if("hour"==a){h=new Date(s.getTime()),h.setMinutes(i.getMinutes(),0);var f=(s.getTime()-h.getTime())/36e5;r=Math.ceil(d*(n+1)+f*n)}return r},JSGantt.processRows=function(t,e,n,a,o,i){var s=new Date,r=new Date,l=o,g=null,d=0,u=0,h=0,c=0,f=a,p=t,m=!1,v=0;for(v=0;v<t.length;v++)t[v].getToDelete()&&(t.splice(v,1),v--),v>=0&&t[v].getID()==e&&(g=t[v]);for(v=0;v<t.length;v++)if(t[v].getParent()==e){if(l=o,t[v].setParItem(g),t[v].setVisible(l),1==l&&0==t[v].getOpen()&&(l=0),t[v].getMile()&&t[v].getParItem()&&2==t[v].getParItem().getGroup()){t.splice(v,1),v--;continue}t[v].setLevel(f),c++,t[v].getGroup()&&(t[v].getParItem()&&2==t[v].getParItem().getGroup()&&t[v].setGroup(2),JSGantt.processRows(p,t[v].getID(),v,f+1,l,0)),(0==u||t[v].getStart()<s)&&(s=t[v].getStart(),u=1),(0==h||t[v].getEnd()>r)&&(r=t[v].getEnd(),h=1),d+=t[v].getCompVal(),t[v].setSortIdx(v*t.length)}if(n>=0&&(null!=t[n].getGroupMinStart()&&t[n].getGroupMinStart()<s&&(s=t[n].getGroupMinStart()),null!=t[n].getGroupMinEnd()&&t[n].getGroupMinEnd()>r&&(r=t[n].getGroupMinEnd()),t[n].setStart(s),t[n].setEnd(r),t[n].setNumKid(c),t[n].setCompVal(Math.ceil(d/c))),0==e&&1==i&&(JSGantt.sortTasks(t,0,0),t.sort(function(t,e){return t.getSortIdx()-e.getSortIdx()})),0==e&&1!=i){for(v=0;v<t.length;v++)2==t[v].getGroup()&&(m=!0,JSGantt.sortTasks(t,t[v].getID(),t[v].getSortIdx()+1));1==m&&t.sort(function(t,e){return t.getSortIdx()-e.getSortIdx()})}},JSGantt.sortTasks=function(t,e,n){for(var a=n,o=new Array,i=0;i<t.length;i++)t[i].getParent()==e&&o.push(t[i]);o.length>0&&o.sort(function(t,e){var n=t.getStart().getTime()-e.getStart().getTime();return 0==n&&(n=t.getEnd().getTime()-e.getEnd().getTime()),0==n?t.getID()-e.getID():n});for(var s=0;s<o.length;s++)for(i=0;i<t.length;i++)t[i].getID()==o[s].getID()&&(t[i].setSortIdx(a++),a=JSGantt.sortTasks(t,t[i].getID(),a));return a},JSGantt.getMinDate=function(t,e){var n=new Date;n.setTime(t[0].getStart().getTime());for(var a=0;a<t.length;a++)t[a].getStart().getTime()<n.getTime()&&n.setTime(t[a].getStart().getTime());if("day"==e)for(n.setDate(n.getDate()-1);n.getDay()%7!=1;)n.setDate(n.getDate()-1);else if("week"==e)for(n.setDate(n.getDate()-1);n.getDay()%7!=1;)n.setDate(n.getDate()-1);else if("month"==e)for(n.setDate(n.getDate()-15);n.getDate()>1;)n.setDate(n.getDate()-1);else if("quarter"==e)n.setDate(n.getDate()-31),0==n.getMonth()||1==n.getMonth()||2==n.getMonth()?n.setFullYear(n.getFullYear(),0,1):3==n.getMonth()||4==n.getMonth()||5==n.getMonth()?n.setFullYear(n.getFullYear(),3,1):6==n.getMonth()||7==n.getMonth()||8==n.getMonth()?n.setFullYear(n.getFullYear(),6,1):(9==n.getMonth()||10==n.getMonth()||11==n.getMonth())&&n.setFullYear(n.getFullYear(),9,1);else if("hour"==e)for(n.setHours(n.getHours()-1);n.getHours()%6!=0;)n.setHours(n.getHours()-1);return"hour"==e?n.setMinutes(0,0):n.setHours(0,0,0),n},JSGantt.getMaxDate=function(t,e){var n=new Date;n.setTime(t[0].getEnd().getTime());for(var a=0;a<t.length;a++)t[a].getEnd().getTime()>n.getTime()&&n.setTime(t[a].getEnd().getTime());if("day"==e)for(n.setDate(n.getDate()+1);n.getDay()%7!=0;)n.setDate(n.getDate()+1);else if("week"==e)for(n.setDate(n.getDate()+1);n.getDay()%7!=0;)n.setDate(n.getDate()+1);else if("month"==e){for(;n.getDate()>1;)n.setDate(n.getDate()+1);n.setDate(n.getDate()-1)}else if("quarter"==e)0==n.getMonth()||1==n.getMonth()||2==n.getMonth()?n.setFullYear(n.getFullYear(),2,31):3==n.getMonth()||4==n.getMonth()||5==n.getMonth()?n.setFullYear(n.getFullYear(),5,30):6==n.getMonth()||7==n.getMonth()||8==n.getMonth()?n.setFullYear(n.getFullYear(),8,30):(9==n.getMonth()||10==n.getMonth()||11==n.getMonth())&&n.setFullYear(n.getFullYear(),11,31);else if("hour"==e)for(0==n.getHours()&&n.setDate(n.getDate()+1),n.setHours(n.getHours()+1);n.getHours()%6!=5;)n.setHours(n.getHours()+1);return n},JSGantt.findObj=function(t,e){var n;return e||(e=document),document.getElementById&&(n=document.getElementById(t)),n},JSGantt.changeFormat=function(t,e){e?e.setFormat(t):alert("Chart undefined")},JSGantt.folder=function(t,e){var n=e.getList();e.getDivId();e.clearDependencies();for(var a=0;a<n.length;a++)n[a].getID()==t&&(1==n[a].getOpen()?(n[a].setOpen(0),JSGantt.hide(t,e),JSGantt.isIE()?n[a].getGroupSpan().innerText="+":n[a].getGroupSpan().textContent="+"):(n[a].setOpen(1),JSGantt.show(t,1,e),JSGantt.isIE()?n[a].getGroupSpan().innerText="-":n[a].getGroupSpan().textContent="-"));e.DrawDependencies()},JSGantt.hide=function(t,e){for(var n=e.getList(),a=0,o=(e.getDivId(),0);o<n.length;o++)n[o].getParent()==t&&(a=n[o].getID(),n[o].getListChildRow()&&(n[o].getListChildRow().style.display="none"),n[o].getChildRow()&&(n[o].getChildRow().style.display="none"),n[o].setVisible(0),n[o].getGroup()&&JSGantt.hide(a,e))},JSGantt.show=function(t,e,n){for(var a=n.getList(),o=0,i=(n.getDivId(),""),s=0;s<a.length;s++)a[s].getParent()==t&&(a[s].getParItem().getGroupSpan()&&(i=JSGantt.isIE()?a[s].getParItem().getGroupSpan().innerText:a[s].getParItem().getGroupSpan().textContent),s=a.length);for(s=0;s<a.length;s++)if(a[s].getParent()==t){var r=!1;o=a[s].getID(),1==e&&"+"==i?r=!0:"-"==i?r=!0:a[s].getParItem()&&2==a[s].getParItem().getGroup()&&a[s].setVisible(1),r&&(a[s].getListChildRow()&&(a[s].getListChildRow().style.display=""),a[s].getChildRow()&&(a[s].getChildRow().style.display=""),a[s].setVisible(1)),a[s].getGroup()&&JSGantt.show(o,0,n)}},JSGantt.taskLink=function(t,e,n){if(e)var a=e;else a=400;if(n)var o=n;else o=400;window.open(t,"newwin","height="+o+",width="+a)},JSGantt.parseDateStr=function(t,e){var n=new Date,a=t.split(/[^0-9]/);if(t.length>=10&&a.length>=3){for(;a.length<5;)a.push(0);switch(e){case"mm/dd/yyyy":n=new Date(a[2],a[0]-1,a[1],a[3],a[4]);break;case"dd/mm/yyyy":n=new Date(a[2],a[1]-1,a[0],a[3],a[4]);break;case"yyyy-mm-dd":n=new Date(a[0],a[1]-1,a[2],a[3],a[4])}}return n},JSGantt.formatDateStr=function(t,e,n){for(var a="",o=t.getFullYear().toString().substring(2,4),i=t.getMonth()+1+"",s=new Array(n.january,n.february,n.march,n.april,n.maylong,n.june,n.july,n.august,n.september,n.october,n.november,n.december),r=new Array(n.sunday,n.monday,n.tuesday,n.wednesday,n.thursday,n.friday,n.saturday),l=new Array(n.jan,n.feb,n.mar,n.apr,n.may,n.jun,n.jul,n.aug,n.sep,n.oct,n.nov,n.dec),g=new Array(n.sun,n.mon,n.tue,n.wed,n.thu,n.fri,n.sat),d=0;d<e.length;d++)switch(e[d]){case"dd":t.getDate()<10&&(a+="0");case"d":a+=t.getDate();break;case"day":a+=g[t.getDay()];break;case"DAY":a+=r[t.getDay()];break;case"mm":10>i&&(a+="0");case"m":a+=i;break;case"mon":a+=l[t.getMonth()];break;case"month":a+=s[t.getMonth()];break;case"yyyy":a+=t.getFullYear();break;case"yy":a+=o;break;case"qq":a+="Q";case"q":a+=Math.floor(t.getMonth()/3)+1;break;case"hh":(t.getHours()%12==0?12:t.getHours()%12)<10&&(a+="0");case"h":a+=t.getHours()%12==0?12:t.getHours()%12;break;case"HH":t.getHours()<10&&(a+="0");case"H":a+=t.getHours();break;case"MI":t.getMinutes()<10&&(a+="0");case"mi":a+=t.getMinutes();break;case"pm":a+=t.getHours()<12?"am":"pm";break;case"PM":a+=t.getHours()<12?"AM":"PM";break;case"ww":JSGantt.getIsoWeek(t)<10&&(a+="0");case"w":a+=JSGantt.getIsoWeek(t);break;case"week":var u=JSGantt.getIsoWeek(t),h=t.getFullYear(),c=0==t.getDay()?7:t.getDay();u>=52&&1==i&&h--,1==u&&12==i&&h++,10>u&&(u="0"+u),a+=h+"-W"+u+"-"+c;break;default:a+=n[e[d].toLowerCase()]?n[e[d].toLowerCase()]:e[d]}return a},JSGantt.parseDateFormatStr=function(t){for(var e="",n="",a=new RegExp("[/\\ -.,'\":]"),o=new Array,i=0;i<t.length;i++)n=t.charAt(i),n.match(a)||i+1==t.length?(i+1!=t.length||n.match(a)||(e+=n),o.push(e),n.match(a)&&o.push(n),e=""):e+=n;return o},JSGantt.parseXML=function(t,e){if(window.XMLHttpRequest)var n=new XMLHttpRequest;else n=new ActiveXObject("Microsoft.XMLHTTP");n.open("GET",t,!1),n.send(null);var a=n.responseXML;JSGantt.AddXMLTask(e,a)},JSGantt.parseXMLString=function(t,e){if("undefined"!=typeof window.DOMParser)var n=(new window.DOMParser).parseFromString(t,"text/xml");else"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(n=new window.ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(t));JSGantt.AddXMLTask(e,n)},JSGantt.findXMLNode=function(t,e){var n;try{n=t.getElementsByTagName(e)}catch(a){}return n},JSGantt.getXMLNodeValue=function(t,e,n,a){var o;try{o=t.getElementsByTagName(e)[0].childNodes[0].nodeValue}catch(i){"undefined"!=typeof a&&(o=a)}return"undefined"!=typeof o&&null!=o&&(1==n?o*=1:2==n&&(o=o.toString())),o},JSGantt.AddXMLTask=function(t,e){var n,a="",o=!1,i=0,s=0,r=0,l=0,g=0,d=0,u=new Array,h=new Array,c=new Array,f=new Array,p=JSGantt.findXMLNode(e,"Project");if("undefined"!=typeof p&&p.length>0&&(a=p[0].getAttribute("xmlns")),"http://schemas.microsoft.com/project"==a){o=!0,t.setDateInputFormat("yyyy-mm-dd"),n=JSGantt.findXMLNode(e,"Task"),i="undefined"==typeof n?0:n.length;var m=JSGantt.findXMLNode(e,"Resource");for("undefined"==typeof m?(i=0,s=0):s=m.length,r=0;s>r;r++){var v=JSGantt.getXMLNodeValue(m[r],"Name",2,""),S=JSGantt.getXMLNodeValue(m[r],"UID",1,-1);v.length>0&&S>0&&(c[S]=v)}var w=JSGantt.findXMLNode(e,"Assignment");for(l="undefined"==typeof w?0:w.length,r=0;l>r;r++){var D=JSGantt.getXMLNodeValue(w[r],"ResourceUID",1,-1);S=JSGantt.getXMLNodeValue(w[r],"TaskUID",1,-1),S>0&&(D>0&&(h[S]=c[D]),u[S]=w[r])}for(r=0;i>r;r++){if(S=JSGantt.getXMLNodeValue(n[r],"UID",1,0),0!=S)var T=JSGantt.getXMLNodeValue(n[r],"OutlineNumber",2,"0");S>0&&(f[T]=S),S>d&&(d=S)}for(r=0;i>r;r++){var y=JSGantt.getXMLNodeValue(n[r],"UID",1,0);if(0!=y){var L=JSGantt.getXMLNodeValue(n[r],"Name",2,"No Task Name"),N=JSGantt.getXMLNodeValue(n[r],"Start",2,""),G=JSGantt.getXMLNodeValue(n[r],"Finish",2,""),M=JSGantt.getXMLNodeValue(n[r],"HyperlinkAddress",2,""),J=JSGantt.getXMLNodeValue(n[r],"Milestone",1,0),k=JSGantt.getXMLNodeValue(n[r],"PercentWorkComplete",1,0),C=JSGantt.getXMLNodeValue(n[r],"Summary",1,0),I=0,F=JSGantt.getXMLNodeValue(n[r],"OutlineLevel",1,0);F>1&&(T=JSGantt.getXMLNodeValue(n[r],"OutlineNumber",2,"0"),I=f[T.substr(0,T.lastIndexOf("."))]);try{var b=n[r].getElementsByTagName("Notes")[0].childNodes[1].nodeValue}catch(H){b=""}if("undefined"!=typeof h[y])var x=h[y];else x="";var E=JSGantt.findXMLNode(n[r],"PredecessorLink");l="undefined"==typeof E?0:E.length;var X="";for(g=0;l>g;g++){var Y=JSGantt.getXMLNodeValue(E[g],"PredecessorUID",1,-1),O=JSGantt.getXMLNodeValue(E[g],"Type",1,1);if(Y>0)switch(X.length>0&&(X+=","),O){case 0:X+=Y+"FF";break;case 1:X+=Y+"FS";break;case 2:X+=Y+"SF";break;case 3:X+=Y+"SS";break;default:X+=Y+"FS"}}var R=1,A="";if(C>0)var V="ggroupblack";else V=J>0?"gmilestone":"gtaskblue";var P=JSGantt.findXMLNode(u[y],"TimephasedData");l="undefined"==typeof P?0:P.length;var B=N,U=G,j=!1,W=X.replace(/,*[0-9]+[FS]F/g,"");for(g=0;l>g;g++){var q=JSGantt.getXMLNodeValue(P[g],"Value",2,"0");q="0"+q.replace(/\D/g,""),q*=1,0==q&&!j||g+1==l&&2==C?(C=2,g+1==l&&(W=X.replace(/,*[0-9]+[FS]S/g,"")),d++,U=JSGantt.getXMLNodeValue(P[g],g+1==l?"Finish":"Start",2,""),t.AddTaskItem(new JSGantt.TaskItem(d,L,B,U,"gtaskblue",M,J,x,k,0,y,R,W,A,b,t)),j=!0,W=""):0!=q&&j&&(B=JSGantt.getXMLNodeValue(P[g],"Start",2,""),j=!1)}j&&(X=""),t.AddTaskItem(new JSGantt.TaskItem(y,L,N,G,V,M,J,x,k,C,I,R,X,A,b,t))}}}else for(n=e.getElementsByTagName("task"),i=n.length,r=0;i>r;r++)y=JSGantt.getXMLNodeValue(n[r],"pID",1,0),0!=y&&(L=JSGantt.getXMLNodeValue(n[r],"pName",2,"No Task Name"),N=JSGantt.getXMLNodeValue(n[r],"pStart",2,""),G=JSGantt.getXMLNodeValue(n[r],"pEnd",2,""),M=JSGantt.getXMLNodeValue(n[r],"pLink",2,""),J=JSGantt.getXMLNodeValue(n[r],"pMile",1,0),k=JSGantt.getXMLNodeValue(n[r],"pComp",1,0),C=JSGantt.getXMLNodeValue(n[r],"pGroup",1,0),I=JSGantt.getXMLNodeValue(n[r],"pParent",1,0),x=JSGantt.getXMLNodeValue(n[r],"pRes",2,""),R=JSGantt.getXMLNodeValue(n[r],"pOpen",1,1),X=JSGantt.getXMLNodeValue(n[r],"pDepend",2,""),A=JSGantt.getXMLNodeValue(n[r],"pCaption",2,""),b=JSGantt.getXMLNodeValue(n[r],"pNotes",2,""),V=JSGantt.getXMLNodeValue(n[r],"pClass",2),"undefined"==typeof V&&(V=C>0?"ggroupblack":J>0?"gmilestone":"gtaskblue"),t.AddTaskItem(new JSGantt.TaskItem(y,L,N,G,V,M,J,x,k,C,I,R,X,A,b,t)))},JSGantt.benchMark=function(t){var e=(new Date).getTime();alert(t+": Elapsed time: "+(e-vBenchTime)/1e3+" seconds."),vBenchTime=(new Date).getTime()},JSGantt.getIsoWeek=function(t){var e=864e5,n=new Date(t.getFullYear(),0,4,0,0,0),a=0==n.getDay()?6:n.getDay()-1,o=n.getTime()-a*e,i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0),s=i.getTime(),r=Math.round((s-o)/e),l=99;new Date(o);return l=Math.ceil((r+1)/7),0>=l?l=JSGantt.getIsoWeek(new Date(t.getFullYear()-1,11,31,0,0,0)):53==l&&4!=new Date(t.getFullYear(),0,1,0,0,0).getDay()&&4!=new Date(t.getFullYear(),11,31,0,0,0).getDay()&&(l=1),l},JSGantt.addListener=function(t,e,n){return n===String(n)&&(n=JSGantt.findObj(n)),n.addEventListener?n.addEventListener(t,e,!1):n.attachEvent?n.attachEvent("on"+t,e):!1},JSGantt.addTooltipListeners=function(t,e,n){JSGantt.addListener("mouseover",function(e){JSGantt.showToolTip(t,e,n,null,t.getTimer())},e),JSGantt.addListener("mouseout",function(e){JSGantt.delayedHide(t,t.vTool,t.getTimer())},e)},JSGantt.addThisRowListeners=function(t,e,n){JSGantt.addListener("mouseover",function(){t.mouseOver(e,n)},e),JSGantt.addListener("mouseover",function(){t.mouseOver(e,n)},n),JSGantt.addListener("mouseout",function(){t.mouseOut(e,n)},e),JSGantt.addListener("mouseout",function(){t.mouseOut(e,n)},n)},JSGantt.addFolderListeners=function(t,e,n){JSGantt.addListener("click",function(){JSGantt.folder(n,t)},e)},JSGantt.addFormatListeners=function(t,e,n){JSGantt.addListener("click",function(){JSGantt.changeFormat(e,t)},n)},JSGantt.addScrollListeners=function(t){JSGantt.addListener("scroll",function(){t.getChartBody().scrollTop=t.getListBody().scrollTop},t.getListBody()),JSGantt.addListener("scroll",function(){t.getListBody().scrollTop=t.getChartBody().scrollTop},t.getChartBody()),JSGantt.addListener("scroll",function(){t.getChartHead().scrollLeft=t.getChartBody().scrollLeft},t.getChartBody()),JSGantt.addListener("scroll",function(){t.getChartBody().scrollLeft=t.getChartHead().scrollLeft},t.getChartHead()),JSGantt.addListener("resize",function(){t.getChartHead().scrollLeft=t.getChartBody().scrollLeft},window),JSGantt.addListener("resize",function(){t.getListBody().scrollTop=t.getChartBody().scrollTop},window)}; |