2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
|
!function(){"use strict";class e{constructor(e){}parseTime(e,t=""){if(0===arguments.length)return null;const s=t||"{y}-{m}-{d} {h}:{i}:{s}.{M}";let i;"object"==typeof e?i=e:(10===(""+e).length&&(e=1e3*parseInt(e)),i=new Date(e));const a={y:i.getFullYear(),m:i.getMonth()+1,d:i.getDate(),h:i.getHours(),i:i.getMinutes(),s:i.getSeconds(),M:i.getMilliseconds(),a:i.getDay()};return s.replace(/{(y|m|d|h|i|s|M|a)+}/g,((e,t)=>{let s=a[t];if("a"===t)return["一","二","三","四","五","六","日"][s-1];if(e.length>0&&s<10&&(s="0"+s),"M"===t){let e="";for(let t=0;t<3-(""+s).length;t++)e+="0";s=e+s}return s||0}))}timeToStamp(e){return new Date(e).getTime()}moveHalf(){let e=this.getDomElement(".timeline-ticMain"),t=this.getDomElement(".timeline-ticLabel");for(let s=0;s<e.length;s++){let i=e[s].offsetLeft-t[s].offsetWidth/2;t[s].style.left=i+"px"}}getDomElement(e,t=null){let s=".ts-zyl "+e,i=document.querySelectorAll(s);return null==t?i:i[t]}}const t={STOP:0,PLAY:1,PAUSE:2},s={EDITING:0,PLAYING:1},i=[".Grid",".Chart"];var a=Object.freeze({__proto__:null,editorMode:s,hideByMode:i,timeStatus:t});class l extends e{constructor(e={}){super(),this.timer1=null,this.timer=null,this._status=t.STOP,this.timestampFunctions={1732783188e3:function(){console.log("在时间戳 1732783188000 执行的函数")},1732783198e3:function(){console.log("在时间戳 1732783588000 执行的函数")},1732784588e3:function(){console.log("在时间戳 1732784588000 执行的函数")}}}makeLabel(e,t=""){return this.parseTime(e,t)}animation(e,t,s=()=>{console.log("滴答")}){let{multiplier:i,startTimestamp:a,endTimestamp:l,currentTimestamp:n}=e;console.log(s);let c=Date.now(),r=0,o=0;s(),this.timer1=setInterval(function e(){return setTimeout((()=>{s()}),1e3/i),e}(),1e3/i),this.timer=setInterval((()=>{let e=Date.now();r=(e-c)*i;let s=n+=r;for(let t=0;t<(e-c)*i;t++)o+=1;c=e,t(s,r,o)}),1)}stopAnimation(){clearInterval(this.timer1),clearInterval(this.timer)}get status(){return this._status}set status(e){this._status=e}}class n extends e{constructor(t={scales:{}}){var i;super(),console.log(t),this._editorMode=t.editorMode||s.EDITING,this._tasks=t.tasks||[],this._startTimestamp=t.startTimestamp||(new Date).getTime(),this._endTimestamp=t.endTimestamp||this.getTotalTime(),this._currentTimestamp=t.currentTimestamp||this._startTimestamp,this._multiplier=t.multiplier||1,this._panelWidth=t.panelWidth||1,this.columns=t.columns||[{name:"name",label:"名称",width:"100%"},{name:"start_time",label:"开始时间",width:"120px",align:"center"},{name:"duration",label:"持续时间",width:"70px",align:"center"}],t.hasOwnProperty("scales")||(t.scales={}),this._scales={cursorLeft:t.scales.cursorLeft||0,scrollLeft:t.scales.scrollLeft||0,scrollTop:t.scales.scrollTop||0,fullWidth:t.scales.fullWidth,fullHeight:t.scales.fullHeight,scaleHeight:t.scales.scaleHeight||30,cellHeight:t.scales.cellHeight||38,preMains:t.scales.preMains||this.getPreMains(),preMainIndex:t.scales.preMainIndex||8,gridWidth:t.scales.gridWidth||400,distanceOfTicTinyRange:[7,8,9,10,11,12,13],distanceOfTicTiny:7,ticTiny:0,originOffset:0,numOfSubRange:[4,5,6,10],numOfSubIndex:2,distanceOfTicSub:42,ticSub:0,numOfSub:6,originSubOffset:0,numOfMain:5,distanceOfTicMain:210,ticMain:0,originMainOffset:0,timeLabels:[],productTinySub:30,preSecondPx:0},this.scales=new Proxy(this._scales,(i=this,{set:(t,s,a,l)=>(t[s]=a,"numOfSubIndex"==s&&(t.numOfSub=t.numOfSubRange[t.numOfSubIndex]),"distanceOfTicTiny"==s&&(t.distanceOfTicSub=t.distanceOfTicTiny*t.numOfSub,t.distanceOfTicMain=t.distanceOfTicSub*t.numOfMain,t.preSecondPx=t.distanceOfTicMain/t.preMains[t.preMainIndex],i.setCurrentStamp(t)),"scrollLeft"==s&&((new e).getDomElement(".Chart",0).scrollLeft=t.scrollLeft,i.setCurrentStamp(t)),"cursorLeft"==s&&i.setCurrentStamp(t),"ticMain"==s&&(t.timeLabels=t.timeLabels.slice(0,t.ticMain)),"fullWidth"==s&&(i.getDomElement(".TimeScale",0).style.width=t.fullWidth+"px"),!0)}))}init(){let e=Math.floor(this.getDomElement(".TimeScale",0).getBoundingClientRect().width);this.panelWidth=e,this.getDomElement(".TimeScale",0).style.width=e+"px",consol
|