Sha256: a70025a31098c3f4216e1b5079d3ec1af95d131a51570e403e5b48c4a5ecbaac

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 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));
								$('ul.rally-list > li.rally: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

3 entries across 3 versions & 1 rubygems

Version Path
mountain-goat-0.1.1 lib/mountain-goat/public/mg.js
mountain-goat-0.1.0 lib/mountain-goat/public/mg.js
mountain-goat-0.0.20 lib/mountain-goat/public/mg.js