2012-03-04 15:58:16 -05:00
|
|
|
//= require vendor/jquery
|
2012-03-29 16:57:32 -04:00
|
|
|
//= require vendor/jquery.timeago
|
2012-03-04 15:58:16 -05:00
|
|
|
//= require bootstrap
|
|
|
|
//= require_tree .
|
2012-03-29 16:57:32 -04:00
|
|
|
|
2012-05-11 19:48:03 -04:00
|
|
|
$(function() {
|
|
|
|
$.timeago.settings.allowFuture = true
|
|
|
|
$("time").timeago();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(function() {
|
|
|
|
$('.check_all').live('click', function() {
|
|
|
|
var checked = $(this).attr('checked');
|
|
|
|
if (checked == 'checked') {
|
|
|
|
$('input[type=checkbox]', $(this).closest('table')).attr('checked', checked);
|
|
|
|
} else {
|
|
|
|
$('input[type=checkbox]', $(this).closest('table')).removeAttr('checked');
|
|
|
|
}
|
|
|
|
});
|
2012-03-29 16:57:32 -04:00
|
|
|
});
|
2012-07-26 19:08:15 -04:00
|
|
|
|
|
|
|
$(function() {
|
2012-08-18 21:14:38 -04:00
|
|
|
function pad(n) { return ('0' + n).slice(-2); }
|
|
|
|
|
2012-07-26 19:08:15 -04:00
|
|
|
$('a[name=poll]').data('polling', false);
|
|
|
|
|
|
|
|
$('a[name=poll]').on('click', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var pollLink = $(this);
|
|
|
|
if (pollLink.data('polling')) {
|
|
|
|
clearInterval(pollLink.data('interval'));
|
|
|
|
pollLink.text('Live Poll');
|
|
|
|
$('.poll-status').text('');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var href = pollLink.attr('href');
|
|
|
|
pollLink.data('interval', setInterval(function() {
|
|
|
|
$.get(href, function(data) {
|
|
|
|
var responseHtml = $(data);
|
|
|
|
$('.hero-unit').replaceWith(responseHtml.find('.hero-unit'));
|
|
|
|
$('.workers').replaceWith(responseHtml.find('.workers'));
|
|
|
|
});
|
|
|
|
var currentTime = new Date();
|
2012-08-18 21:14:38 -04:00
|
|
|
$('.poll-status').text('Last polled at: ' + currentTime.getHours() + ':' + pad(currentTime.getMinutes()) + ':' + pad(currentTime.getSeconds()));
|
2012-07-26 19:08:15 -04:00
|
|
|
}, 2000));
|
|
|
|
$('.poll-status').text('Starting to poll...');
|
|
|
|
pollLink.text('Stop Polling');
|
|
|
|
}
|
|
|
|
pollLink.data('polling', !pollLink.data('polling'));
|
|
|
|
})
|
|
|
|
});
|