From ee54df825a71dab1bfb03fdf91138240f3110a9d Mon Sep 17 00:00:00 2001 From: Michael Save Date: Thu, 15 Mar 2012 14:44:15 +1100 Subject: [PATCH] auto-reload.js: bringing AJAX to tinyboard --- js/auto-reload.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 js/auto-reload.js diff --git a/js/auto-reload.js b/js/auto-reload.js new file mode 100644 index 00000000..3789a136 --- /dev/null +++ b/js/auto-reload.js @@ -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 + * + * 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('
'); + } + }); + } + }); + }, 6000); +}); +