Sha256: f1ecf946841fae15bc7944611355e087eeea1c44986cc652698b5534de419449

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

/**
 * @author Geoff
 */

(function() {
	$(document).ready(function () {
		$('input.slider[type="checkbox"]').change(function() {
			if ($(this).is(':checked')) {
				$($(this).data('slider')).slideDown();
			} else {
				$($(this).data('slider')).slideUp();
			}
		}).change();
		
		if ($('.recent-rally[data-reload="true"]').size() > 0) {
			setTimeout(function() { reloadRallies(); }, 4000);
		}
		
		$('.reload').click(function() { reloadRallies(); });
		
		var reloadRallies = function() {
			var rally_id = parseInt($('.recent-rally').data('rally-id'));
			var convert_id = $('.recent-rally').data('convert-id');
			if (rally_id) {
				$.ajax({
						url: '/mg/rallies/new',
						data: { 'recent_rally': rally_id, 'convert_id': convert_id },
						success: function(json) {
							if (!json.success) {
								console.log('No new events');
							} else {
								$('.recent-rally').data('rally-id', json.recent_rally_id);
								$('.rally-list').prepend($(json.result));
								$('.rally-list li:gt(100)').remove(); //only show 100 elements
								
								if ($('.rally-list abbr.time-ago').size() > 0) {
									$('.rally-list abbr.time-ago').timeago();	
								}
							}
							
							if ($('.recent-rally[data-reload="true"]').size() > 0) {
								setTimeout(function() { reloadRallies(); }, 4000);
							}
						}
				});	
			}
		};
		
		if ($('abbr.time-ago').size() > 0) {
			$('abbr.time-ago').timeago();	
		}
	});	
})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mountain-goat-0.0.19 lib/mountain-goat/public/mg.js