From 59478a7f4b781f36b9ea74691ea5185d024e6e2f Mon Sep 17 00:00:00 2001 From: Aaron Tan Date: Tue, 13 Feb 2018 19:39:01 -0500 Subject: [PATCH] Initial commit --- LICENSE | 21 +++++ README.md | 2 + app/index.js | 101 ++++++++++++++++++++++++ manifest.json | 1 + package.json | 33 ++++++++ resources/icon.png | Bin 0 -> 1644 bytes resources/icon.svg | 144 +++++++++++++++++++++++++++++++++++ resources/index.gui | 72 ++++++++++++++++++ resources/play.png.txi | Bin 0 -> 566 bytes resources/play_press.png.txi | Bin 0 -> 338 bytes resources/styles.css | 27 +++++++ resources/widgets.gui | 7 ++ 12 files changed, 408 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 app/index.js create mode 100644 manifest.json create mode 100644 package.json create mode 100644 resources/icon.png create mode 100644 resources/icon.svg create mode 100644 resources/index.gui create mode 100644 resources/play.png.txi create mode 100644 resources/play_press.png.txi create mode 100644 resources/styles.css create mode 100644 resources/widgets.gui diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1af2cc7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Aaron Tan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a024837 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Fitbit Pomodoro +A Pomodoro app for the Fitbit Ionic. diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..655e69f --- /dev/null +++ b/app/index.js @@ -0,0 +1,101 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var document = _interopDefault(require('document')); +var haptics = require('haptics'); + +var backgroundRect = document.getElementById("backgroundRect"); +var backgroundRectResting = document.getElementById("backgroundRectResting"); +var backgroundRectLongResting = document.getElementById("backgroundRectLongResting"); + +var btnBR = document.getElementById("btn-br"); +var stateText = document.getElementById("stateText"); +var minuteText = document.getElementById("minuteText"); +var unitText = document.getElementById("unitText"); +var times = 0; + +btnBR.onactivate = function (evt) { + btnBR.style.display = "none"; + haptics.vibration.start("confirmation"); + minuteText.text = "24:59"; + unitText.style.display = "none"; + backgroundRect.animate("disable"); + setTimeout(function() { + startWorkTimer(times); + }, 300); +}; + +function startWorkTimer(times) { + stateText.text = "Get to work!"; + backgroundRect.animate("enable"); + var end = new Date(new Date().getTime() + 25 * 60000); + minuteText.text = "24:59"; + var timer = setInterval(function () { + var now = new Date().getTime(); + var distance = end - now; + var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); + var seconds = Math.floor((distance % (1000 * 60)) / 1000); + minutes = (minutes < 10) ? ("0" + minutes) : minutes; + seconds = (seconds < 10) ? ("0" + seconds) : seconds; + minuteText.text = minutes + ":" + seconds; + if (distance < 1) { + clearInterval(timer); + haptics.vibration.start("ping"); + backgroundRect.animate("disable"); + times++; + if (times < 2) { + backgroundRectResting.animate("enable"); + startShortBreakTimer(times); + } else { + times = 0; + backgroundRectLongResting.animate("enable"); + startLongBreakTimer(times); + } + } + }, 1000); +}; + +function startShortBreakTimer(times) { + stateText.text = "Take a short break"; + var end = new Date(new Date().getTime() + 5 * 60000); + minuteText.text = "04:59"; + var timer = setInterval(function () { + var now = new Date().getTime(); + var distance = end - now; + var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); + var seconds = Math.floor((distance % (1000 * 60)) / 1000); + minutes = (minutes < 10) ? ("0" + minutes) : minutes; + seconds = (seconds < 10) ? ("0" + seconds) : seconds; + minuteText.text = minutes + ":" + seconds; + if (distance < 1) { + clearInterval(timer); + haptics.vibration.start("ping"); + backgroundRectResting.animate("disable"); + backgroundRect.animate("enable"); + startWorkTimer(times); + } + }, 1000); +} + +function startLongBreakTimer(times) { + stateText.text = "Take a long break"; + var end = new Date(new Date().getTime() + 15 * 60000); + minuteText.text = "14:59"; + var timer = setInterval(function () { + var now = new Date().getTime(); + var distance = end - now; + var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); + var seconds = Math.floor((distance % (1000 * 60)) / 1000); + minutes = (minutes < 10) ? ("0" + minutes) : minutes; + seconds = (seconds < 10) ? ("0" + seconds) : seconds; + minuteText.text = minutes + ":" + seconds; + if (distance < 1) { + clearInterval(timer); + haptics.vibration.start("ping"); + backgroundRectLongResting.animate("disable"); + backgroundRect.animate("enable"); + startWorkTimer(times); + } + }, 1000); +} \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..364ce85 --- /dev/null +++ b/manifest.json @@ -0,0 +1 @@ +{"appManifestVersion":1,"main":"app/index.js","svgMain":"resources/index.gui","svgWidgets":"resources/widgets.gui","appType":"app","i18n":{"en":{"name":"Tomatina"}},"buildId":"0x0730781e263c063b","uuid":"4c0f5346-6d11-4494-a04f-731b152e6c1e","name":"Tomatina","bundleDate":"2018-01-09T22:46:27.359Z","requestedPermissions":[],"wipeColor":"#f44336"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..cc7dda3 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "fitbit": { + "appUUID": "55d5be9a-1571-4987-b5e7-cda00dc7d56b", + "appType": "app", + "appDisplayName": "Tomatina", + "iconFile": "resources/icon.png", + "wipeColor": "#f44336", + "requestedPermissions": [], + "i18n": { + "en": { + "name": "Tomatina" + }, + "zh-cn": { + "name": "番茄工作计时器" + }, + "zh-tw": { + "name": "番茄工作計時器" + }, + "fr": { + "name": "Tomatina" + }, + "es": { + "name": "Tomatina" + }, + "ja": { + "name": "トマティーナ" + }, + "ko": { + "name": "토마티나" + } + } + } +} \ No newline at end of file diff --git a/resources/icon.png b/resources/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..2f221472c9c79c23b416d2f886a6fff3c04303fc GIT binary patch literal 1644 zcmV-y29x=TP)WFU8GbZ8()Nlj2>E@cM*00q!VL_t(|+U=Zsh*VV^ z$3MS2HT52{BiEWPy^ITP_y05)=qy&;!h@Pzf`)ptfvL zH_gZhH4(+gd{tDwR!#AVJFEMidw%`l15syp=FaRkGxvV~oVna{&gXv5@BGf=Uhw3} zlP6D}97>Y4Vq0~qzmZTWm}!E{9VbP5Jb+QET+0WFnlfPMwV%SME~&BV78Xl!vj;GO zf*SO9C%+VB5zz4tm;B-romDKwe|Z3J(VP1IK%dIZu8UOV283WU)r*4?G_D62)S&;0 z=}-z0U3X_GJ8hpeYpJ|`*tGzk*M$RZ+b$E4q0v&iMRmX%pIUE!gxvmT+5#M{LH|9b zrc^PDG#1xIZpCJw$a594^i!)3s*sH0mPQaGzneA2)E+tdcAQ++w%ng!8} zuo^3(DE<|sLj3;XkZih?asUI3BL*0e+gvA3Dy8bU@&d;(GP|ME_ARLaP_Z7Wd2BxD zyFf-<;O+oXoHa~=PkarXUpteN%Stmyv76+ET*VuH?@T7XZdr8a@^8u_@gs@(zV3zK>i zwzhy4q_~MrV(A!JS$U-00P4&MJ@ET>0r#gxKU7X2I$Tz7INjy|b@s$;Y_@|Irdc@K zOI^lDsi=r)aPh}nOtUFVLwEp>l2NxBnAT1blRupM6R0(bzOFsuN^C(MCbH0DW!N|)ux6J*`iO>qO%AQt;Z z{RRwn8Nh=S{#+xZ%a zcJW$)qS8+`?>g+vfnjEVaWOvxm=3(<44`cnCGi2S_R{2*07j&vV~5?1X+8&7E(d5( z>t5Nm=R#}_Y;GLo!2`fT%m`q8Yygct1Qib-fXHA60CiAnn>a4gpx6hIu-)6^c0&)u z4p2=Vo&m3CgLw`dXmUJqH=2!Lt_gNR=A0LBB* z=yBjdj~xJ2PSTivfX6*{fa)P90QY%Qxf|N+qzmu#xLuP^BC?3QoCOwr@=ihIEZiLn z37qE0nVu5iV79*nvPM-m0CQa)|0<=0Q|+y6D(PB`+X2eDmJQnC92$#W-3|iNJkK3#HXw2lE?TsQmZU>8VLb+xm(@O8pRFNHL( z>xT$Imkqy5T7wsr0|7KYKNC~`CoQbZrkPHnf&Oy#Y;8gS0%*6KDTq|K1mI*jSG_*E zG%=Qt+C8TnWk#CAtB~`dsE_%^1~4}_7r)sL^h(b`mnw{}P%d2xwF$th5VH!gtR1A^ zY1MixYouHV{Tka$&&h+z%`QT;0`R2?JR6lMQhhn*Q@GCGRLaeoiBd-DAOBF$xe}^d zgv9aE8R{= zT{;K)qt;rWe~REc1ZIlVHXVq2zLKy9+Jzh%GFE^-o#fX0g8HTsftrL&_!3^d%)lfJ z%YYt9M(z}b5@~8m=%-MmZNdv#1Ol&tE=YpdSPQzCrto_LwTZrYn{K-)bSL0{1=V@L zUF{4mgvfH5!XF5nZ>vJuW#3XE8=r3mFb8yK+mzr q2M}t}sRb0000 + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/resources/index.gui b/resources/index.gui new file mode 100644 index 0000000..416e639 --- /dev/null +++ b/resources/index.gui @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Start a Pomodoro + 25 + min + + + + + + + + + \ No newline at end of file diff --git a/resources/play.png.txi b/resources/play.png.txi new file mode 100644 index 0000000000000000000000000000000000000000..58dc78e02cc5b895cc25155abb3e8e3fa5bb5581 GIT binary patch literal 566 zcmY+BJuE{}7>2)lPTDji4MPW;uypCfBx%&53nr;WOd1ij8N|lGWK;WC3W25`>tEoKsw3F znGe4quHCD^00~DH(sa!-Xo95XeT2B+6AADn3EL)4a}9COGzr%Q4oeYh3>YG59xI|! z-V+7RlBhd`_NYD#nj_)4gSI$oo(Im8v_?wMUbyCfVG<2FXj8UXP=uuL6(D}{Y9Vlp zL`@o}S;sUePNMZ1f4;h>Knao-|GREzmu1p_iIrEsO0KelDkrK6_ZWEL9(}4ud4er9 z0gt!v$>X)~co@D@4L`1i|9>;S_Q)Hw`7XXTOldx6Q=-Zgb}Wgmr;Y3w``N4f98`Xm q-QHDha}=S!D9SknR8HDHsvILgjyW1`Yub11JW@Ao2J6*4}GlU}p8PUCO{XrRhJ@1*^pjjL)0@ zGyj_*xR9akKhvw21q>bknf7VSW9ab)Taa01GO&(Y6ltS z*atSd7HBrqDv-tDlfmwo40H$3S!Yb9fnAvkbS2QyD}j!NdI9947NC!S9^4P~AjrFM W3!wg=1@u4TRA`Vev-;Z3X8-{8!--P> literal 0 HcmV?d00001 diff --git a/resources/styles.css b/resources/styles.css new file mode 100644 index 0000000..e318867 --- /dev/null +++ b/resources/styles.css @@ -0,0 +1,27 @@ +#backgroundRectResting { + display: inline; +} + +#backgroundRect { + display: inline; +} + +.minutesBigText { + fill: #FFFFFF; + font-family: Seville-Book; + font-size: 105; +} + +.stateText { + display: inline; + fill: #D3D3D3; + font-family: Seville-Book; + font-size: 35; +} + +.unitText { + display: inline; + fill: #C0C0C0; + font-family: Seville-Book; + font-size: 40; +} \ No newline at end of file diff --git a/resources/widgets.gui b/resources/widgets.gui new file mode 100644 index 0000000..ee90e99 --- /dev/null +++ b/resources/widgets.gui @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file