thread-stats.js: vichan fixes

This commit is contained in:
czaks 2015-04-10 23:11:59 +02:00
parent c4fc827332
commit 0d0b2fcd7e

View File

@ -12,9 +12,9 @@ $(document).ready(function(){
//check if page uses unique ID //check if page uses unique ID
var IDsupport = ($('.poster_id').length > 0); var IDsupport = ($('.poster_id').length > 0);
var thread_id = (document.location.pathname + document.location.search).split('/'); var thread_id = (document.location.pathname + document.location.search).split('/');
thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; thread_id = thread_id[thread_id.length -1].split(/+-/)[0].split('.')[0];
$('form[name="postcontrols"] > .delete') $('.boardlist.bottom, footer')
.first() .first()
.before('<div id="thread_stats"></div>'); .before('<div id="thread_stats"></div>');
var el = $('#thread_stats'); var el = $('#thread_stats');
@ -67,6 +67,7 @@ $(document).ready(function(){
}; };
$('#thread_stats_uids').text(size(ids)); $('#thread_stats_uids').text(size(ids));
} }
var board_name = $('input[name="board"]').val();
$.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){
var found, page = '???'; var found, page = '???';
for (var i=0;data[i];i++){ for (var i=0;data[i];i++){
@ -88,6 +89,7 @@ $(document).ready(function(){
// load the current page the thread is on. // load the current page the thread is on.
// uses ajax call so it gets loaded on a delay (depending on network resources available) // uses ajax call so it gets loaded on a delay (depending on network resources available)
var thread_stats_page_timer = setInterval(function(){ var thread_stats_page_timer = setInterval(function(){
var board_name = $('input[name="board"]').val();
$.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){
var found, page = '???'; var found, page = '???';
for (var i=0;data[i];i++){ for (var i=0;data[i];i++){