Uses 1117K of libraries. Click here for Pure Java version (8567L/45K).
!7 cmodule TimerModule > DynBigNumber { bool active; long setAt, setTill; start { dm_onTopInput(vf<S> setTimer); doEvery(1.0, r updateMe); preloadLibrary(#1400163); } void update { long now = now(); if (setTill == 0 || !active) ret with setValue(""); if (setTill <= now) { setField(active := false); ret with makeAlarm(); } else { long seconds = iround(toSeconds(setTill-now)); setValue(seconds/60 + ":" + formatInt(mod(seconds, 60), 2)); } } void makeAlarm { setValue("ALARM!"); infoBox_noHide("ALARM!"); vmBus_send('timerAlarm, module()); playWAVSnippet(#1400163); } // API void reset enter { setFields(active := false, setAt := 0L, setTill := 0L); update(); } void setTimer(fS s) { final new Matches m; if "* minutes|* minute|set timer to * minutes" { switch to q(); int minutes = parseEnglishNumberOrInt($1); if (minutes <= 0) ret; setFields(active := true, setAt := now(), setTill := now()+fromMinutes(minutes)); dm_showModule(); infoBox("Timer set to " + n2(minutes, "minute")); } } }
download show line numbers debug dex old transpilations
Travelled to 11 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1019774 |
Snippet name: | Timer [Dyn Module] |
Eternal ID of this version: | #1019774/24 |
Text MD5: | 61dcb0d6c22e67340508cd1bfa2938a6 |
Transpilation MD5: | f542f6d84c0dbc313e3a6ccd16d79f95 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-04-23 13:27:34 |
Source code size: | 1212 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 411 / 5357 |
Version history: | 23 change(s) |
Referenced in: | [show references] |