[Rt-commit] rt branch, 4.4/ticket-timer, updated. rt-4.2.11-6-g97a5b74
Shawn Moore
shawn at bestpractical.com
Fri May 15 14:10:37 EDT 2015
The branch, 4.4/ticket-timer has been updated
via 97a5b7404e1a4f7cca64468b2b1d20836df7ea50 (commit)
via 0101c7b09fa9cf72d55e5809290ee7b5fa844dac (commit)
from ecf1ee083fd440640b66863794849a3696fc7a12 (commit)
Summary of changes:
share/html/Elements/TicketTimer | 13 +++++++
share/static/css/base/misc.css | 24 +++++++++++-
share/static/images/pause.png | Bin 0 -> 1189 bytes
share/static/images/stopwatch.png | Bin 0 -> 1813 bytes
share/static/images/unpause.png | Bin 0 -> 1310 bytes
share/static/js/util.js | 79 ++++++++++++++++++++++++++++++++++++--
6 files changed, 112 insertions(+), 4 deletions(-)
create mode 100644 share/static/images/pause.png
create mode 100644 share/static/images/stopwatch.png
create mode 100644 share/static/images/unpause.png
- Log -----------------------------------------------------------------
commit 0101c7b09fa9cf72d55e5809290ee7b5fa844dac
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu May 14 19:24:32 2015 +0000
Hide seconds from ticket timer so we can run less frequently
I don't want to write a new cookie every second
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 7852d78..6a4a579 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -334,23 +334,19 @@ function AddTicketTimer() {
var seconds = 0;
setInterval(function () {
- seconds++;
+ seconds += 10;
var s = seconds;
var h = Math.floor(s / 3600);
s -= h * 3600;
var m = Math.floor(s / 60);
- s -= m * 60;
if (m < 10) {
m = "0" + m;
}
- if (s < 10) {
- s = "0" + s;
- }
- readout.text(h + ':' + m + ':' + s);
- }, 1000);
+ readout.text(h + ':' + m);
+ }, 10000);
}
jQuery(function() {
commit 97a5b7404e1a4f7cca64468b2b1d20836df7ea50
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri May 15 17:34:18 2015 +0000
WIP
diff --git a/share/html/Elements/TicketTimer b/share/html/Elements/TicketTimer
index c479980..ddec3a3 100644
--- a/share/html/Elements/TicketTimer
+++ b/share/html/Elements/TicketTimer
@@ -46,5 +46,18 @@
%#
%# END BPS TAGGED BLOCK }}}
<div id="ticket_timer">
+ <span class="start">
+ <img src="<% RT->Config->Get('WebPath') %>/static/images/stopwatch.png" alt="<% loc('Start Timer') %>" />
+ </span>
+
+ <span class="playpause">
+ <span class="pause"><img src="<% RT->Config->Get('WebPath') %>/static/images/pause.png" alt="<% loc('Pause Timer') %>" /></span>
+ <span class="unpause"><img src="<% RT->Config->Get('WebPath') %>/static/images/unpause.png" alt="<% loc('Unpause Timer') %>" /></span>
+ </span>
+
<span class="readout">0:00:00</span>
+
+ <span class="ticket">
+ <a href="<% RT->Config->Get('WebPath') %>/Ticket/Display.html?id=1">#1</a>
+ </span>
</div>
diff --git a/share/static/css/base/misc.css b/share/static/css/base/misc.css
index a6706cf..8da8565 100644
--- a/share/static/css/base/misc.css
+++ b/share/static/css/base/misc.css
@@ -82,7 +82,7 @@ textarea.messagebox, #cke_Content, #cke_UpdateContent {
#ticket_timer {
position: fixed;
- bottom: 25px;
+ bottom: 50px;
right: 0px;
background-color: rgba(255, 255, 255, 0.85);
z-index: 9999;
@@ -92,6 +92,28 @@ textarea.messagebox, #cke_Content, #cke_UpdateContent {
border-bottom: 1px solid #600;
}
+#ticket_timer .start img {
+ cursor: pointer;
+ height: 1.5em;
+ width: auto;
+}
+
+#ticket_timer .playpause img {
+ cursor: pointer;
+ height: 1em;
+ width: auto;
+}
+
#ticket_timer .readout {
+ display: none;
font-size: 1.5em;
}
+
+#ticket_timer .playpause {
+ display: none;
+}
+
+#ticket_timer .ticket {
+ display: none;
+ color: #999;
+}
diff --git a/share/static/images/pause.png b/share/static/images/pause.png
new file mode 100644
index 0000000..af54e1f
Binary files /dev/null and b/share/static/images/pause.png differ
diff --git a/share/static/images/stopwatch.png b/share/static/images/stopwatch.png
new file mode 100644
index 0000000..4c0c8a6
Binary files /dev/null and b/share/static/images/stopwatch.png differ
diff --git a/share/static/images/unpause.png b/share/static/images/unpause.png
new file mode 100644
index 0000000..48f04ad
Binary files /dev/null and b/share/static/images/unpause.png differ
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 6a4a579..01ff275 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -331,22 +331,99 @@ function escapeCssSelector(str) {
function AddTicketTimer() {
var container = jQuery('#ticket_timer');
var readout = container.find('.readout');
+ var start = container.find('.start');
+ var playpause = container.find('.playpause');
+ var pause = playpause.find('.pause');
+ var unpause = playpause.find('.unpause');
+ var ticket = container.find('.ticket');
+
+ var isRunning = false;
+ var isTicketPage = window.location.href.match(new RegExp('/Ticket/'));
var seconds = 0;
- setInterval(function () {
- seconds += 10;
+ if (sessionStorage && sessionStorage.seconds) {
+ seconds = parseInt(sessionStorage.seconds);
+ isRunning = true;
+ }
+
+ var isPaused = false;
+ if (sessionStorage && sessionStorage.isPaused) {
+ isPaused = parseInt(sessionStorage.isPaused) ? true : false;
+ }
+ var renderReadout = function (seconds) {
var s = seconds;
var h = Math.floor(s / 3600);
s -= h * 3600;
var m = Math.floor(s / 60);
+ s -= m * 60;
if (m < 10) {
m = "0" + m;
}
+ if (s < 10) {
+ s = "0" + s;
+ }
+
+ readout.text(h + ':' + m + ':' + s);
+ };
+
+ var renderPlaypause = function (isPaused) {
+ if (isPaused) {
+ pause.hide();
+ unpause.show();
+ }
+ else {
+ unpause.hide();
+ pause.show();
+ }
+ };
+
+ var intervalCallback = function () {
+ if (isPaused) {
+ return;
+ }
- readout.text(h + ':' + m);
- }, 10000);
+ seconds += 1;
+ sessionStorage.seconds = seconds;
+
+ renderReadout(seconds);
+ };
+
+ var startTimer = function () {
+ renderReadout(seconds);
+ renderPlaypause(isPaused);
+ start.hide();
+ readout.show();
+ playpause.show();
+ ticket.show();
+ setInterval(intervalCallback, 1000);
+ };
+
+ playpause.on('click', function () {
+ isPaused = !isPaused;
+ sessionStorage.isPaused = isPaused ? 1 : 0;
+
+ renderPlaypause(isPaused);
+ });
+
+ // if the timer is already running on load, hide the start button and
+ // show the readout
+ if (isRunning) {
+ startTimer();
+ }
+ // the timer isn't running, but we're on a ticket page, so show the
+ // start button
+ else if (isTicketPage) {
+ start.on('click', function () {
+ startTimer();
+ });
+ }
+ // otherwise, the timer is not running, and we're not on a ticket page,
+ // so don't offer to start the timer
+ else {
+ container.hide();
+ }
}
jQuery(function() {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list