[Rt-commit] rt branch, 4.4/background-ticket-timer, updated. rt-4.4.0-86-gc4baf26
Shawn Moore
shawn at bestpractical.com
Mon May 9 17:29:36 EDT 2016
The branch, 4.4/background-ticket-timer has been updated
via c4baf26d75fcc7d01b518a9c53a223e87a4d661d (commit)
from 100b9c755a056b282e88a615d112664bc6f68e24 (commit)
Summary of changes:
share/html/Helpers/TicketTimer | 90 +++++++++++++++++++++---------------------
1 file changed, 45 insertions(+), 45 deletions(-)
- Log -----------------------------------------------------------------
commit c4baf26d75fcc7d01b518a9c53a223e87a4d661d
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Mon May 9 21:28:52 2016 +0000
Use single variable naming convention in timer JS
diff --git a/share/html/Helpers/TicketTimer b/share/html/Helpers/TicketTimer
index 5774cf1..2a8b0d6 100644
--- a/share/html/Helpers/TicketTimer
+++ b/share/html/Helpers/TicketTimer
@@ -52,13 +52,13 @@ $id
my $Ticket = RT::Ticket->new($session{'CurrentUser'});
$Ticket->Load( $id );
-my $unpause_img = RT->Config->Get('WebPath') . '/static/images/unpause.png';
-my $pause_img = RT->Config->Get('WebPath') . '/static/images/pause.png';
+my $UnpauseImg = RT->Config->Get('WebPath') . '/static/images/unpause.png';
+my $PauseImg = RT->Config->Get('WebPath') . '/static/images/pause.png';
-my $now = RT::Date->new($session{'CurrentUser'});
-$now->SetToNow;
+my $Now = RT::Date->new($session{'CurrentUser'});
+$Now->SetToNow;
-my $submit_url = RT->Config->Get('WebPath') . '/Helpers/AddTimeWorked';
+my $SubmitURL = RT->Config->Get('WebPath') . '/Helpers/AddTimeWorked';
</%INIT>
<& /Elements/Header, Title => loc('Timer for #[_1]: [_2]', $Ticket->Id, $Ticket->Subject), RichText => 0, ShowBar => 0, ShowTitle => 0 &>
@@ -86,30 +86,30 @@ jQuery( function() {
// CommittedSeconds.
var CommittedSeconds = 0;
- var readout = jQuery('.readout');
- var playpause = jQuery('.playpause');
- var playpause_img = playpause.find('img');
+ var Readout = jQuery('.readout');
+ var PlayPause = jQuery('.playpause');
+ var PlayPauseImg = PlayPause.find('img');
- var pause_alt = playpause_img.attr('alt');
- var unpause_alt = playpause_img.data('toggle-alt');
+ var PauseAlt = PlayPauseImg.attr('alt');
+ var UnpauseAlt = PlayPauseImg.data('toggle-alt');
- var toHHMMSS = function (total) {
- var hours = Math.floor(total / 3600);
- var minutes = Math.floor((total - (hours * 3600)) / 60);
- var seconds = total - (hours * 3600) - (minutes * 60);
+ var ToHHMMSS = function (Total) {
+ var Hours = Math.floor(Total / 3600);
+ var Minutes = Math.floor((Total - (Hours * 3600)) / 60);
+ var Seconds = Total - (Hours * 3600) - (Minutes * 60);
- if (minutes < 10) { minutes = "0" + minutes; }
- if (seconds < 10) { seconds = "0" + seconds; }
+ if (Minutes < 10) { Minutes = "0" + Minutes; }
+ if (Seconds < 10) { Seconds = "0" + Seconds; }
- return hours + ':' + minutes + ':' + seconds;
+ return Hours + ':' + Minutes + ':' + Seconds;
};
- var renderReadout = function (seconds) {
- readout.text(toHHMMSS(seconds));
+ var RenderReadout = function (seconds) {
+ Readout.text(ToHHMMSS(seconds));
};
- var tick = function () {
- renderReadout(CommittedSeconds + CurrentSeconds());
+ var Tick = function () {
+ RenderReadout(CommittedSeconds + CurrentSeconds());
};
jQuery('.playpause').click(function () {
@@ -119,17 +119,17 @@ jQuery( function() {
Interval = false;
CommittedSeconds += CurrentSeconds();
LastUnpause = false;
- playpause_img.attr('src', <% $unpause_img |n,j %>);
- playpause_img.attr('alt', unpause_alt);
- playpause_img.attr('title', unpause_alt);
+ PlayPauseImg.attr('src', <% $UnpauseImg |n,j %>);
+ PlayPauseImg.attr('alt', UnpauseAlt);
+ PlayPauseImg.attr('title', UnpauseAlt);
}
else {
// unpause
- Interval = setInterval(tick, 1000);
+ Interval = setInterval(Tick, 1000);
LastUnpause = new Date().getTime() / 1000;
- playpause_img.attr('src', <% $pause_img |n,j %>);
- playpause_img.attr('alt', pause_alt);
- playpause_img.attr('title', pause_alt);
+ PlayPauseImg.attr('src', <% $PauseImg |n,j %>);
+ PlayPauseImg.attr('alt', PauseAlt);
+ PlayPauseImg.attr('title', PauseAlt);
}
return false;
});
@@ -139,39 +139,39 @@ jQuery( function() {
jQuery('.control-line a').hide();
CommittedSeconds += CurrentSeconds();
- var payload = {
+ var Payload = {
id: <% $Ticket->id %>,
seconds: CommittedSeconds
};
- readout.text('<% loc("Submitting") %>');
+ Readout.text('<% loc("Submitting") %>');
- var renderSubmitError = function (reason) {
- renderReadout(CommittedSeconds);
+ var RenderSubmitError = function (Reason) {
+ RenderReadout(CommittedSeconds);
jQuery('.ticket-timer').addClass('error');
// give the browser a chance to redraw the readout
setTimeout(function () {
- alert('<% loc("Unable to submit time. Please add it to the ticket manually. Reason:") %>' + ' ' + reason);
+ alert('<% loc("Unable to submit time. Please add it to the ticket manually. Reason:") %>' + ' ' + Reason);
}, 100);
};
jQuery.ajax({
- url: <% $submit_url |n,j %>,
- data: payload,
+ url: <% $SubmitURL |n,j %>,
+ data: Payload,
timeout: 30000, /* 30 seconds */
- success: function (response) {
- if (response.ok) {
- readout.addClass('response');
- readout.text(response.msg);
+ success: function (Response) {
+ if (Response.ok) {
+ Readout.addClass('response');
+ Readout.text(Response.msg);
jQuery('.control-line .close-popup').show().removeClass('hidden');
}
else {
- renderSubmitError(response.msg);
+ RenderSubmitError(Response.msg);
}
},
error: function (xhr, reason) {
- renderSubmitError(reason);
+ RenderSubmitError(reason);
}
});
@@ -183,8 +183,8 @@ jQuery( function() {
return false;
});
- tick();
- Interval = setInterval(tick, 500);
+ Tick();
+ Interval = setInterval(Tick, 500);
});
</script>
@@ -200,13 +200,13 @@ jQuery( function() {
<div class="readout"></div>
<div class="control-line">
- <a href="#" class="playpause"><img src="<% $pause_img %>" alt="<% loc('Pause Timer') %>" data-toggle-alt="<% loc('Resume Timer') %>" title="<% loc('Pause Timer') %>" /></a>
+ <a href="#" class="playpause"><img src="<% $PauseImg %>" alt="<% loc('Pause Timer') %>" data-toggle-alt="<% loc('Resume Timer') %>" title="<% loc('Pause Timer') %>" /></a>
<a href="#" class="submit-time"><img src="<% RT->Config->Get('WebPath') %>/static/images/submit.png" alt="<% loc('Submit Timer') %>" title="<% loc('Submit Timer') %>" /></a>
<a href="#" class="close-popup hidden"><img src="<% RT->Config->Get('WebPath') %>/static/images/close.png" alt="<% loc('Close Window') %>" title="<% loc('Close Window') %>" /></a>
</div>
</div>
- <div class="extra"><&|/l, $now->AsString &>Started at [_1].</&></div>
+ <div class="extra"><&|/l, $Now->AsString &>Started at [_1].</&></div>
% if ($Ticket->TimeEstimated) {
<div class="extra"><&|/l&>Time estimated</&>: <& /Ticket/Elements/ShowTime, minutes => $Ticket->TimeEstimated &></div>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list