From 745f1cbb230530a0bb7a58a4c4a5b695bc833040 Mon Sep 17 00:00:00 2001 From: discomrade Date: Fri, 25 Feb 2022 06:04:06 -0100 Subject: [PATCH] Fix obsoleted getJSON(...).error function --- js/watch.js | 156 ++++++++++++++++++++++++++-------------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/js/watch.js b/js/watch.js index d7049ad8..fae74880 100644 --- a/js/watch.js +++ b/js/watch.js @@ -14,7 +14,7 @@ * //$config['additional_javascript'][] = 'js/hide-threads.js'; * //$config['additional_javascript'][] = 'js/compact-boardlist.js'; * $config['additional_javascript'][] = 'js/watch.js'; - * + * */ $(function(){ @@ -125,7 +125,7 @@ $(function(){ var tag; if (variant == 'desktop') { tag = $("#"+tid+""+newposts+""); - tag.find(".watch-remove").mouseenter(function() { + tag.find(".watch-remove").mouseenter(function() { this.oldval = $(this).html(); $(this).css("min-width", $(this).width()); $(this).html(""); @@ -136,7 +136,7 @@ $(function(){ } else if (variant == 'mobile') { tag = $("#"+tid+""+newposts+"" - +""); + +""); } tag.attr('data-thread', tid) @@ -148,7 +148,7 @@ $(function(){ var t = $(this).parent().attr("data-thread"); toggle_threadwatched(b, t); $(this).parent().parent().parent().mouseleave(); - $(this).parent().remove(); + $(this).parent().remove(); return false; }); } @@ -174,48 +174,48 @@ $(function(){ var st = storage(); for (var i in st) { if (is_pinned(st[i])) { - var link; + var link; if (bl.find('[href*="'+modRoot+i+'/index.html"]:not(.cb-menuitem)').length) link = bl.find('[href*="'+modRoot+i+'/"]').first(); else link = $('/'+i+'/').appendTo(pinned); - if (link[0].origtitle === undefined) { - link[0].origtitle = link.html(); - } - else { - link.html(link[0].origtitle); - } + if (link[0].origtitle === undefined) { + link[0].origtitle = link.html(); + } + else { + link.html(link[0].origtitle); + } - if (st[i].watched) { - link.css("font-weight", "bold"); - if (status && status[i] && status[i].new_threads) { - link.html(link.html() + " (" + status[i].new_threads + ")"); - } - } - else if (st[i].threads && osize(st[i].threads)) { - link.css("font-style", "italic"); + if (st[i].watched) { + link.css("font-weight", "bold"); + if (status && status[i] && status[i].new_threads) { + link.html(link.html() + " (" + status[i].new_threads + ")"); + } + } + else if (st[i].threads && osize(st[i].threads)) { + link.css("font-style", "italic"); - link.attr("data-board", i); + link.attr("data-board", i); if (status && status[i] && status[i].threads) { - var new_posts = 0; + var new_posts = 0; for (var tid in status[i].threads) { if (status[i].threads[tid] > 0) { - new_posts += status[i].threads[tid]; - } - } - if (new_posts > 0) { + new_posts += status[i].threads[tid]; + } + } + if (new_posts > 0) { link.html(link.html() + " (" + new_posts + ")"); - } + } } - if (device_type == "desktop") - link.off().mouseenter(function() { - $('.cb-menu').remove(); + if (device_type == "desktop") + link.off().mouseenter(function() { + $('.cb-menu').remove(); - var board = $(this).attr("data-board"); + var board = $(this).attr("data-board"); - var wl = construct_watchlist_for(board, "desktop").appendTo($(this)) + var wl = construct_watchlist_for(board, "desktop").appendTo($(this)) .css("top", $(this).position().top + ($(this).css('padding-top').replace('px', '')|0) + ($(this).css('padding-bottom').replace('px', '')|0) @@ -225,12 +225,12 @@ $(function(){ .css("font-style", "normal"); if (typeof init_hover != "undefined") - wl.find("a.cb-menuitem").each(init_hover); + wl.find("a.cb-menuitem").each(init_hover); - }).mouseleave(function() { - $('.boardlist .cb-menu').remove(); - }); - } + }).mouseleave(function() { + $('.boardlist .cb-menu').remove(); + }); + } } } @@ -252,7 +252,7 @@ $(function(){ for (var i in st) { if (st[i].watched) { - (function(i) { + (function(i) { setTimeout(function() { var r = $.getJSON(configRoot+i+"/threads.json", function(j, x, r) { handle_board_json(r.board, j); @@ -260,24 +260,24 @@ $(function(){ r.board = i; }, sched); sched += sched_diff; - })(i); + })(i); } else if (st[i].threads) { for (var j in st[i].threads) { (function(i,j) { setTimeout(function() { var r = $.getJSON(configRoot+i+"/res/"+j+".json", function(k, x, r) { - handle_thread_json(r.board, r.thread, k); - }).error(function(r) { - if(r.status == 404) handle_thread_404(r.board, r.thread); - }); - - r.board = i; - r.thread = j; + handle_thread_json(r.board, r.thread, k); + }).fail(function(r) { + if(r.status == 404) handle_thread_404(r.board, r.thread); + }); + + r.board = i; + r.thread = j; }, sched); })(i,j); sched += sched_diff; - } + } } } @@ -298,22 +298,22 @@ $(function(){ for (var j in json[i].threads) { var thread = json[i].threads[j]; - if (hidden_data[board]) { // hide threads integration - var cont = false; - for (var k in hidden_data[board]) { - if (parseInt(k) == thread.no) { - cont = true; - break; - } - } - if (cont) continue; - } - - if (thread.last_modified > storage()[board].watched / 1000) { - last_thread = thread.no; - - new_threads++; - } + if (hidden_data[board]) { // hide threads integration + var cont = false; + for (var k in hidden_data[board]) { + if (parseInt(k) == thread.no) { + cont = true; + break; + } + } + if (cont) continue; + } + + if (thread.last_modified > storage()[board].watched / 1000) { + last_thread = thread.no; + + new_threads++; + } } } @@ -331,7 +331,7 @@ $(function(){ var post = json.posts[i]; if (post.time > storage()[board].threads[threadid] / 1000) { - new_posts++; + new_posts++; } } @@ -398,20 +398,20 @@ $(function(){ for(var bid in status) { if (((status[bid].new_threads && (active_page == "ukko" || active_page == "index")) || status[bid].new_threads == 1) && check_post(this, $('[data-board="'+bid+'"]#thread_'+status[bid].last_thread))) { - var st = storage() - st[bid].watched = time_loaded; - storage_save(st); - refresh = true; + var st = storage() + st[bid].watched = time_loaded; + storage_save(st); + refresh = true; } if (!status[bid].threads) continue; for (var tid in status[bid].threads) { - if(status[bid].threads[tid] && check_post(this, $('[data-board="'+bid+'"]#thread_'+tid))) { - var st = storage(); - st[bid].threads[tid] = time_loaded; - storage_save(st); - refresh = true; - } + if(status[bid].threads[tid] && check_post(this, $('[data-board="'+bid+'"]#thread_'+tid))) { + var st = storage(); + st[bid].threads[tid] = time_loaded; + storage_save(st); + refresh = true; + } } } return refresh; @@ -431,19 +431,19 @@ $(function(){ var sum = 0; for (var bid in status) { if (status[bid].new_threads) { - sum += status[bid].new_threads; + sum += status[bid].new_threads; if (!status[bid].threads) continue; for (var tid in status[bid].threads) { - if (status[bid].threads[tid] > 0) { + if (status[bid].threads[tid] > 0) { if (auto_reload_enabled && active_page == "thread") { var board = $('form[name="post"] input[name="board"]').val(); var thread = $('form[name="post"] input[name="thread"]').val(); if (board == bid && thread == tid) continue; } - sum += status[bid].threads[tid]; - } - } + sum += status[bid].threads[tid]; + } + } } } return sum;