1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 01:10:51 +01:00

auto-reload.js: bringing AJAX to tinyboard

This commit is contained in:
Michael Save 2012-03-15 14:44:15 +11:00
parent 2bc3c10ee7
commit ee54df825a

33
js/auto-reload.js Normal file
View File

@ -0,0 +1,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);
});