summaryrefslogtreecommitdiff
path: root/js/auto-reload.js
blob: 3789a1367c884a2118123c1aae1f7c106ecf81d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * auto-reload.js
 * https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/auto-reload.js
 *
 * Brings AJAX to Tinyboard.
 *
 * Released under the MIT license
 * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
 *
 * Usage:
 *   $config['additional_javascript'][] = $config['root'] . 'auto-reload.js';
 *
 */

$(document).ready(function(){
	if($('div.banner').length == 0)
		return; // not index
	
	setInterval(function() {
		$.ajax({
			url: document.location,
			success: function(data) {
				$(data).find('div.post.reply').each(function() {
					var id = $(this).attr('id');
					if($('#' + id).length == 0) {
						$(this).insertAfter($('div.reply:last').next()).after('<br class="clear">');
					}
				});
			}
		});
	}, 6000);
});