Skip to content

Commit

Permalink
Add countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgaldino committed Dec 20, 2011
1 parent 232d77c commit fa39472
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Karma-Small.bowtie/index.html
Expand Up @@ -31,7 +31,8 @@
</div>

<span id="time">
<span id="time_current">00:00</span><span id="time_total">43:21</span>
<span id="time_current" onClick="toggleCountdown(); return false;">00:00 </span>
<span id="time_total">43:21</span>
</span>

<span id="rating">
Expand All @@ -45,4 +46,4 @@
</div>
</div>
</body>
</html>
</html>
21 changes: 17 additions & 4 deletions Karma-Small.bowtie/script.js
@@ -1,4 +1,5 @@
oldPlayState = 0;
var oldPlayState = 0;
var countdown = false;

function $(el) { return document.getElementById(el); }
function trackUpdate(track)
Expand Down Expand Up @@ -36,7 +37,13 @@ function playerUpdate()

$('progress').style.width = Math.ceil((iTunes.playerPosition() / currentTrack.property('length'))*100) + "%";

$('time_current').innerHTML = secToString(iTunes.playerPosition()) || "00:00";
var time = iTunes.playerPosition();
if (countdown) {
var totalLength = currentTrack.length;
time = totalLength - time;
}

$('time_current').innerHTML = secToString(time) || "00:00";

updateRatingUI(iTunes.rating());
}
Expand Down Expand Up @@ -104,6 +111,12 @@ function secToString(time)

if(min < 10) min = "0" + min;
if(sec < 10) sec = "0" + sec;


if (countdown) min = "-" + min;

return min + ":" + sec;
}
}

function toggleCountdown() {
countdown = !countdown;
}
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -7,7 +7,8 @@ Karma-Small.bowtie
Theme for the [Bowtie](http://bowtieapp.com/) iTunes controller

This is basically the same theme created by [Matt Sephton](http://www.gingerbeardman.com/).
The difference is its size, this one is smaller.
The difference is its size, this one is smaller. In this version you can
also toggle a countdown timer by clicking the timer.

You can find the original theme [here](https://github.com/gingerbeardman/Karma.bowTie).

Expand Down

0 comments on commit fa39472

Please sign in to comment.