Skip to content

Commit

Permalink
added javascript timeout to reload page after 10 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
bantic committed Nov 4, 2008
1 parent 488c756 commit c164b6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/views/reports/review.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
= stylesheet_link_tag 'reviews'
- content_for :javascript do
= javascript_include_tag :defaults
= javascript_tag "var reviewer_timeout;" # used to reset the reviewer's timeclock for the batch of reports

= render :partial => 'reviewer_alert', :collection => current_user.unviewed_alerts

%h1 Review Interface

%p.clear
= link_to_remote content_tag(:span,"Get More Reports"), { :url => assign_reports_path, :method => :post }, :class => "button"
= link_to_remote content_tag(:span,"Get More Reports"), |
{ :url => assign_reports_path, :method => :post, :after => "startReviewerClock();"}, :class => "button" |

%table
%tr
%td{:style => "width: 800px"}
Expand Down
18 changes: 17 additions & 1 deletion public/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Date.prototype.toISO8601String = function (format, offset) {
/* accepted values for the format [1-6]:
1 Year:
Expand Down Expand Up @@ -46,3 +45,20 @@ Date.prototype.toISO8601String = function (format, offset) {
if (format > 3) { str += offset; }
return str;
}

/* reload the reviewer page if the reviewer has been looking at the
reports for > 10 minutes */
function startReviewerClock() {
if (reviewer_timeout) {
clearTimeout(reviewer_timeout);
}
reviewer_timeout = setTimeout('reviewer_time_limit_reached()', 600000);
}

function reviewer_time_limit_reached() {
alert("You have been looking at these reports " +
"for more than 10 minutes. They have been " +
"released. Please reload this page if your " +
"browser doesn't do it automatically.");
window.location.reload();
}

0 comments on commit c164b6a

Please sign in to comment.