diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/cntdwn/shrtcnt.def |
Initial commit
Diffstat (limited to 'macros/latex/contrib/cntdwn/shrtcnt.def')
-rw-r--r-- | macros/latex/contrib/cntdwn/shrtcnt.def | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/macros/latex/contrib/cntdwn/shrtcnt.def b/macros/latex/contrib/cntdwn/shrtcnt.def new file mode 100644 index 0000000000..00e3c8a20a --- /dev/null +++ b/macros/latex/contrib/cntdwn/shrtcnt.def @@ -0,0 +1,271 @@ +%% +%% This is file `shrtcnt.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% cntdwn.dtx (with options: `copyright,shortcnt') +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% cntdwn package, 2010-8-2 %% +%% Copyright (C) 2010 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\cntdwnopts}[1]{\TU{#1}\H{N}\S{S}\BG{}} +\newcommand{\cntdwnDisplay}[4][]{% + \expandafter\ifnum\csname#2@autorun\endcsname=1\relax + \def\autorun@presets{% + \AA{\AAPageOpen{if (!\CDO#2.isCounting&&!\CDO#2.bNotify4) + sStartTimer(\CDO#2);}}}\else + \let\autorun@presets\@empty\fi + \textField[\Ff\FfReadOnly\Q{1}#1\presets{\autorun@presets} + ]{\CDO#2.cntdwn.TimeRemaining}{#3}{#4}} +\newcommand{\cntdwnStartT}[4][]{% + \pushButton[\presets{\cntdwnopts{Start}} + \A{\JS{sStartTimer(\CDO#2);}}#1]{\CDO#2.cntdwn.Notify1}{#3}{#4}} +\newcommand{\cntdwnStart}[4][]{% + \pushButton[\TU{Start}\A{\JS{sStartTimer(\CDO#2);}}#1 + ]{\CDO#2.cntdwn.Start}{#3}{#4}} +\newcommand{\cntdwnPauseT}[4][]{% + \pushButton[\presets{\cntdwnopts{Pause}} + \A{\JS{sPauseTimer(\CDO#2);}}#1 + ]{\CDO#2.cntdwn.Notify2}{#3}{#4}} +\newcommand{\cntdwnPause}[4][]{% + \pushButton[\TU{Pause}\A{\JS{sPauseTimer(\CDO#2);}}#1 + ]{\CDO#2.cntdwn.Pause}{#3}{#4}} +\newcommand{\cntdwnStopT}[4][]{% + \pushButton[\presets{\cntdwnopts{Stop}} + \A{\JS{sStopTimer(\CDO#2);}}#1 + ]{\CDO#2.cntdwn.Notify3}{#3}{#4}} +\newcommand{\cntdwnStop}[4][]{% + \pushButton[\TU{Stop}\A{\JS{sStopTimer(\CDO#2);}}#1 + ]{\CDO#2.cntdwn.Stop}{#3}{#4}} +\newcommand{\cntdwnEndTarget}[4][]{% + \textField[\Ff\FfReadOnly\Ff\FfMultiline#1 + ]{\CDO#2.cntdwn.End}{#3}{#4}} +\newcommand{\setShortCntDwn}[2]{\begingroup + \@ifundefined{#1@timername}{\cntdwn@namegdef{#1@timername}{#1}}% + {\PackageError{cntdwn}{The name `#1' is already defined as a timer + variable.}{Choose a unique timer variable name, + one different from `#1'.}}% + \def\seconds{_oTime.second}\def\minutes{_oTime.minute}% + \def\hours{_oTime.hour}% + \setkeys{cntdwn}{endmsg,#2}% + \cntdwn@namexdef{#1@autorun}{\ctndwn@autorun}% + \def\r{^^J}\def\t{\space\space\space\space}% + \cntdwn@namexdef{#1TimerObject}{% + var _o#1 = {\r\t + name: "_o#1",\r\t + length: \cntdwn@length,\r\t + timeleft: \cntdwn@length,\r\t + notify1: \cntdwn@notifyi,\r\t + notify2: \cntdwn@notifyii,\r\t + notify3: \cntdwn@notifyiii,\r\t + refreshrate: \cntdwn@refreshrate,\r\t + event1: "\cntdwn@eventi",\r\t + event2: "\cntdwn@eventii",\r\t + event3: "\cntdwn@eventiii",\r\t + endEvent: "\cntdwn@eventiv",\r\t + weStopOnEnd: \cntdwn@ifstop,\r\t + isStopwatch: \isStopwatch,\r\t + startcolor: \cntdwn@startcolor,\r\t + pausecolor: \cntdwn@pausecolor,\r\t + stopcolor: \cntdwn@stopcolor,\r\t + endMsg: "\cntdwn@endmsg",\r\t + bNotify1:false,\r\t + bNotify2:false,\r\t + bNotify3:false,\r\t + bNotify4:false,\r\t + isCounting:false,\r\t + bBlinkOn:false,\r\t + startTime:0,\r\t + pauseTime:0,\r\t + EndOfTime:0,\r\t + blinkTimeOut:null,\r\t + timeout:null\r + }; + }% + \ifx\cntdwnlTimers\@empty + \else\g@addto@macro\cntdwnlTimers{^^J}\fi + \expandafter\g@addto@macro\expandafter\cntdwnlTimers + \expandafter{\csname#1TimerObject\endcsname}% + \ifx\cntdwnaTimers\@empty\else\g@addto@macro\cntdwnaTimers{^^J}\fi + \g@addto@macro\cntdwnaTimers{aTimers["_o#1"]=_o#1;}% + \endgroup} +\def\thetimername#1{\csname#1@timername\endcsname} +\@onlypreamble\setShortCntDwn +\define@boolkey{cntdwn}{stopwatch}[true]{% + \edef\isStopwatch{\ifKV@cntdwn@stopwatch true\else false\fi}} +\define@boolkey{cntdwn}{autorun}[true]{% + \edef\ctndwn@autorun{\ifKV@cntdwn@autorun1\else0\fi}} +\define@key{cntdwn}{length}[20*\minutes]{\def\cntdwn@length{#1}} +\define@key{cntdwn}{notify1}[5*\minutes]{\def\cntdwn@notifyi{#1}} +\define@key{cntdwn}{notify2}[3*\minutes]{\def\cntdwn@notifyii{#1}} +\define@key{cntdwn}{notify3}[1*\minutes]{\def\cntdwn@notifyiii{#1}} +\define@key{cntdwn}{refreshrate}[1000]{\def\cntdwn@refreshrate{#1}} +\define@key{cntdwn}{event1}[sDefNotify1]{\def\cntdwn@eventi{#1}} +\define@key{cntdwn}{event2}[sDefNotify2]{\def\cntdwn@eventii{#1}} +\define@key{cntdwn}{event3}[sDefNotify3]{\def\cntdwn@eventiii{#1}} +\define@key{cntdwn}{endEvent}[sDefEndEvent]{\def\cntdwn@eventiv{#1}} +\define@choicekey{cntdwn}{onfinish}[\val\nr]{stop,continue}[stop]{% + \ifcase\nr\relax\def\cntdwn@ifstop{true}\or + \def\cntdwn@ifstop{false}\fi} +\define@key{cntdwn}{startcolor}[color.green]{% + \def\cntdwn@startcolor{#1}} +\define@key{cntdwn}{pausecolor}[color.yellow]{% + \def\cntdwn@pausecolor{#1}} +\define@key{cntdwn}{stopcolor}[color.red]{\def\cntdwn@stopcolor{#1}} +\newcommand{\cnddwnDefaultEndMsg}{This ends the + Presentation, any questions?} +\define@key{cntdwn}{endmsg}[\cnddwnDefaultEndMsg]{% + \def\cntdwn@endmsg{#1}} +\setkeys{cntdwn}{stopwatch=false,onfinish,length,% + notify1,notify2,notify3,refreshrate,startcolor,pausecolor,% + stopcolor,event1,event2,event3,endEvent,autorun=false,endmsg} +\begin{insDLJS*}[shrtcntdwn]{shrtcntdwn} +\begin{newsegment}{CntDwn: Countdown JavaScript} +function shrtcntdwn(cTimer){ + var oTimer=aTimers[cTimer]; + var _delta,nDays,pDays,nHours,pHours,nMinutes, + pMinutes,nSeconds,pSeconds,timeValue,isEndReached; + _delta=(oTimer.isStopwatch)?new Date()% +-new Date(oTimer.startTime):new Date(oTimer.EndOfTime)-new Date(); + oTimer.timeleft=_delta; + _delta=(_delta<0)?-_delta:_delta; + this.delay=true; + nDays = Math.floor(_delta/_oTime.day); + pDays = _delta\%_oTime.day; + nHours = Math.floor(pDays/_oTime.hour); + pHours = pDays\%_oTime.hour; + nMinutes = Math.floor(pHours/_oTime.minute ); + pMinutes = pHours\%_oTime.minute; + nSeconds = Math.floor(pMinutes/_oTime.second); + pSeconds = pMinutes\%_oTime.second; + timeValue=((nHours>=1)?((nHours<10)?"0":"")+nHours+":":"") + +((nMinutes<10)?"0":"")+nMinutes + +":"+((nSeconds<10)?"0":"")+nSeconds; + try { this.getField(oTimer.name% ++".cntdwn.TimeRemaining").value= timeValue; } + catch(e) {}; + isEndReached=(oTimer.isStopwatch)?oTimer.timeleft>oTimer.length% +:oTimer.timeleft< 0; + if ( isEndReached && !oTimer.bNotify4) { + oTimer.bNotify4=true; + eval(oTimer.endEvent)(this,cTimer); + if (oTimer.weStopOnEnd) { + oTimer.isCounting=false; + try { app.clearInterval(oTimer.timeout); + oTimer.timeout=null; } catch(e){}; + } + try { app.clearInterval(oTimer.blinkTimeOut); + oTimer.blinkTimeOut=null; } catch(e){}; + this.delay=false;this.dirty=false; + if (oTimer.weStopOnEnd) return; + } + if (oTimer.isStopwatch) { + if (!oTimer.bNotify1&&(_delta>oTimer.notify1)) + {oTimer.bNotify1=true;eval(oTimer.event1)(this,cTimer);} + if (!oTimer.bNotify2&&(_delta>oTimer.notify2)) + {oTimer.bNotify2=true;eval(oTimer.event2)(this,cTimer);} + if (!oTimer.bNotify3&&(_delta>oTimer.notify3)) + {oTimer.bNotify3=true;eval(oTimer.event3)(this,cTimer);} + } else { + if (!oTimer.bNotify1&&(_delta<oTimer.notify1)) + {oTimer.bNotify1=true;eval(oTimer.event1)(this,cTimer);} + if (!oTimer.bNotify2&&(_delta<oTimer.notify2)) + {oTimer.bNotify2=true;eval(oTimer.event2)(this,cTimer);} + if (!oTimer.bNotify3&&(_delta<oTimer.notify3)) + {oTimer.bNotify3=true;eval(oTimer.event3)(this,cTimer);} + } + this.delay=false;this.dirty=false; +} +function sDefNotify1(doc,cTimer) { + var oTimer=aTimers[cTimer]; + var f = doc.getField(cTimer+".cntdwn.Notify1"); + if (f!=null) f.fillColor = oTimer.startcolor; + app.beep(); +} +function sDefNotify2(doc,cTimer) { + var oTimer=aTimers[cTimer]; + var f = doc.getField(cTimer+".cntdwn.Notify2"); + if (f!=null) f.fillColor = oTimer.pausecolor; + app.beep(); +} +function sDefNotify3(doc,cTimer) { + var oTimer=aTimers[cTimer]; + app.beep(); + var f = doc.getField(cTimer+".cntdwn.Notify3"); + if ( f!=null) + oTimer.blinkTimeOut=app.setInterval(% +"_sBlinkRed(\""+cTimer+"\")",500); +} +function _sBlinkRed(cTimer) { + var oTimer=aTimers[cTimer]; + var f=this.getField(cTimer+".cntdwn.Notify3"); + f.fillColor = ( oTimer.bBlinkOn )?color.white:oTimer.stopcolor; + oTimer.bBlinkOn=!oTimer.bBlinkOn; + this.dirty=false; +} +function sDefEndEvent(doc,cTimer) { + var oTimer=aTimers[cTimer]; + var f=doc.getField(cTimer+".cntdwn.Notify3"); + if (f!=null) f.fillColor = oTimer.stopcolor; + f=doc.getField(cTimer+".cntdwn.End"); + if (f!=null) f.value = oTimer.endMsg; +} +function sPauseTimer(oTimer) { + oTimer.isCounting=false; + oTimer.pauseTime=new Date().valueOf(); + try { app.clearInterval(oTimer.timeout); + oTimer.timeout=null; } catch(e){}; +} +function sStopTimer(oTimer) { + oTimer.isCounting=false; + oTimer.startTime=oTimer.pauseTime=0; + oTimer.timeleft=oTimer.length; + try { app.clearInterval(oTimer.timeout); + oTimer.timeout=null; } catch(e){}; + try { app.clearInterval(oTimer.blinkTimeOut); + oTimer.blinkTimeOut=null; } catch(e){}; + try { this.getField(oTimer.name% ++".cntdwn.Notify1").fillColor = color.white; } catch(e) {} + try { this.getField(oTimer.name% ++".cntdwn.Notify2").fillColor = color.white; } catch(e) {} + try { this.getField(oTimer.name% ++".cntdwn.Notify3").fillColor = color.white; } catch(e) {} + oTimer.bNotify1=oTimer.bNotify2=oTimer.bNotify3% +=oTimer.bNotify4=false; + this.resetForm([oTimer.name]); + this.dirty=false; +} +function sStartTimer(oTimer) { + if (oTimer.isCounting) return; + oTimer.isCounting=true; + if (oTimer.startTime == 0 || (event.shift) % +|| (oTimer.weStopOnEnd&&oTimer.bNotify4) ){ + sStopTimer(oTimer); + oTimer.startTime=new Date().valueOf(); + } + oTimer.pauseTime=(oTimer.pauseTime==0)?0:new Date()% +-new Date(oTimer.pauseTime)+oTimer.refreshrate; + oTimer.startTime+=oTimer.pauseTime; + if (oTimer.isStopwatch) + oTimer.EndOfTime=oTimer.startTime+((event.shift)?oTimer.length% +:oTimer.timeleft); + else + oTimer.EndOfTime=new Date().valueOf()% ++((event.shift)?oTimer.length:oTimer.timeleft); + oTimer.timeout=app.setInterval(% +"shrtcntdwn(\""+oTimer.name+"\")",oTimer.refreshrate); +} +\end{newsegment} +\end{insDLJS*} +\endinput +%% +%% End of file `shrtcnt.def'. |