From fd1972b4fb47cf43301906dce6159a4b2de4ffe6 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 29 Dec 2024 16:26:24 +0100 Subject: [PATCH 01/17] name.html: format --- templates/post/name.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/post/name.html b/templates/post/name.html index fda086a5..00490df9 100644 --- a/templates/post/name.html +++ b/templates/post/name.html @@ -12,5 +12,5 @@ {% endif %} {% if capcode %} - {{ capcode.cap }} + {{ capcode.cap }} {% endif %} From 035214c1e1f1f3b8af7a6261eb9f59275bc58a6a Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 17 Aug 2024 18:31:07 +0200 Subject: [PATCH 02/17] post-filter.js: trim --- js/post-filter.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/js/post-filter.js b/js/post-filter.js index c9e903d8..12ae2cd7 100644 --- a/js/post-filter.js +++ b/js/post-filter.js @@ -1,7 +1,13 @@ +/* Depends on post-menu.js + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/post-menu.js'; + * $config['additional_javascript'][] = 'js/post-filter.js'; + */ if (active_page === 'thread' || active_page === 'index' || active_page === 'catalog' || active_page === 'ukko') { $(document).on('menu_ready', function () { 'use strict'; - + // returns blacklist object from storage function getList() { return JSON.parse(localStorage.postFilter); @@ -64,12 +70,12 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata } function nameSpanToString(el) { - var s = ''; + var s = ''; $.each($(el).contents(), function(k,v) { if (v.nodeName === 'IMG') s=s+$(v).attr('alt') - + if (v.nodeName === '#text') s=s+v.nodeValue }); @@ -165,7 +171,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata } }; - /* + /* * hide/show the specified thread/post */ function hide(ele) { @@ -198,7 +204,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata } } - /* + /* * create filter menu when the button is clicked */ function initPostMenu(pageData) { @@ -338,7 +344,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata }); } - /* + /* * hide/unhide thread on index view */ function quickToggle(ele, threadId, pageData) { @@ -352,7 +358,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata var postId = $(ele).find('.post_no').not('[id]').text(); var hidden = $(ele).data('hidden'); var boardId = $(ele).parents('.thread').data('board'); - + if (hidden) { blacklist.remove.post(boardId, threadId, postId, false); $(this).html('[–]'); @@ -744,7 +750,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata } } - /* + /* * clear out pruned threads */ function purge() { @@ -780,7 +786,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata if ((timestamp() - list.lastPurge) < 86400) // less than 1 day return; - + for (boardId in list.nextPurge) { board = list.nextPurge[boardId]; for (threadId in board) { @@ -864,7 +870,7 @@ if (active_page === 'thread' || active_page === 'index' || active_page === 'cata } init(); }); - + if (typeof window.Menu !== "undefined") { $(document).trigger('menu_ready'); } From e9955898033a8ac5b0762e2958f1e176cc0d12bb Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 18 Aug 2024 17:36:16 +0200 Subject: [PATCH 03/17] show-backlinks.js: fix doc --- js/show-backlinks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/show-backlinks.js b/js/show-backlinks.js index d80eebaa..496781b1 100644 --- a/js/show-backlinks.js +++ b/js/show-backlinks.js @@ -8,7 +8,7 @@ * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; - * // $config['additional_javascript'][] = 'js/post-hover'; (optional; must come first) + * // $config['additional_javascript'][] = 'js/post-hover.js'; (optional; must come first) * $config['additional_javascript'][] = 'js/show-backlinks.js'; * */ From 8d56da91083f4c56b9a45a8497c703e42a2d38ad Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 17 Aug 2024 23:36:33 +0200 Subject: [PATCH 04/17] show-backlinks.js: format --- js/show-backlinks.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/js/show-backlinks.js b/js/show-backlinks.js index 496781b1..81cdc7a1 100644 --- a/js/show-backlinks.js +++ b/js/show-backlinks.js @@ -10,7 +10,6 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * // $config['additional_javascript'][] = 'js/post-hover.js'; (optional; must come first) * $config['additional_javascript'][] = 'js/show-backlinks.js'; - * */ onReady(function() { @@ -18,34 +17,33 @@ onReady(function() { let reply_id = $(this).attr('id').replace(/(^reply_)|(^op_)/, ''); $(this).find('div.body a:not([rel="nofollow"])').each(function() { - let id, post, $mentioned; - - if (id = $(this).text().match(/^>>(\d+)$/)) { + let id = $(this).text().match(/^>>(\d+)$/); + if (id) { id = id[1]; } else { return; } - $post = $('#reply_' + id); - if ($post.length == 0){ - $post = $('#op_' + id); - if ($post.length == 0) { + let post = $('#reply_' + id); + if (post.length == 0){ + post = $('#op_' + id); + if (post.length == 0) { return; } } - $mentioned = $post.find('p.intro span.mentioned'); - if($mentioned.length == 0) { - $mentioned = $('').appendTo($post.find('p.intro')); + let mentioned = post.find('p.intro span.mentioned'); + if(mentioned.length == 0) { + mentioned = $('').appendTo(post.find('p.intro')); } - if ($mentioned.find('a.mentioned-' + reply_id).length != 0) { + if (mentioned.find('a.mentioned-' + reply_id).length != 0) { return; } let link = $('>>' + reply_id + ''); - link.appendTo($mentioned) + link.appendTo(mentioned) if (window.init_hover) { link.each(init_hover); @@ -54,13 +52,12 @@ onReady(function() { }; $('div.post.reply').each(showBackLinks); - $('div.post.op').each(showBackLinks); $(document).on('new_post', function(e, post) { - if ($(post).hasClass("op")) { - $(post).find('div.post.reply').each(showBackLinks); + if ($(post).hasClass('reply')) { + showBackLinks.call(post); } else { - $(post).parent().find('div.post.reply').each(showBackLinks); + $(post).find('div.post.reply').each(showBackLinks); } }); }); From 209c334667ab0d15d762ef830eff1c6861a22512 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 4 Jan 2025 21:42:01 +0100 Subject: [PATCH 05/17] auto-reload.js: format --- js/auto-reload.js | 104 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index be381059..db7aac2a 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -17,62 +17,65 @@ * * You must have boardlinks or else this script will not load. * Search for "$config['boards'] = array(" within your inc/config.php and add something similar to your instance-config.php. - * */ - -auto_reload_enabled = true; // for watch.js to interop +auto_reload_enabled = true; // For watch.js to interop. $(document).ready(function(){ - if($('div.banner').length == 0) - return; // not index - - if($(".post.op").size() != 1) - return; //not thread page - + if($('div.banner').length == 0) { + // Not index. + return; + } + + if($(".post.op").size() != 1) { + // Not thread page. + return; + } + var countdown_interval; - // Add an update link + // Add an update link. $('.boardlist.bottom').prev().after("["+_("Update")+"] ( "+_("Auto")+") "); - // Grab the settings + // Grab the settings. var settings = new script_settings('auto-reload'); var poll_interval_mindelay = settings.get('min_delay_bottom', 5000); var poll_interval_maxdelay = settings.get('max_delay', 600000); var poll_interval_errordelay = settings.get('error_delay', 30000); - // number of ms to wait before reloading + // number of ms to wait before reloading. var poll_interval_delay = poll_interval_mindelay; var poll_current_time = poll_interval_delay; var end_of_page = false; - var new_posts = 0; + var new_posts = 0; var first_new_post = null; - + var title = document.title; if (typeof update_title == "undefined") { - var update_title = function() { - if (new_posts) { - document.title = "("+new_posts+") "+title; - } else { - document.title = title; - } - }; + var update_title = function() { + if (new_posts) { + document.title = "("+new_posts+") "+title; + } else { + document.title = title; + } + }; } - if (typeof add_title_collector != "undefined") - add_title_collector(function(){ - return new_posts; - }); + if (typeof add_title_collector != "undefined") { + add_title_collector(function() { + return new_posts; + }); + } var window_active = true; $(window).focus(function() { window_active = true; recheck_activated(); - // Reset the delay if needed + // Reset the delay if needed. if(settings.get('reset_focus', true)) { poll_interval_delay = poll_interval_mindelay; } @@ -80,7 +83,7 @@ $(document).ready(function(){ $(window).blur(function() { window_active = false; }); - + $('#auto_update_status').click(function() { if($("#auto_update_status").is(':checked')) { @@ -89,14 +92,13 @@ $(document).ready(function(){ stop_auto_update(); $('#update_secs').text(""); } - }); - + var decrement_timer = function() { poll_current_time = poll_current_time - 1000; $('#update_secs').text(poll_current_time/1000); - + if (poll_current_time <= 0) { poll(manualUpdate = false); } @@ -112,37 +114,37 @@ $(document).ready(function(){ update_title(); first_new_post = null; }; - + // automatically updates the thread after a specified delay var auto_update = function(delay) { clearInterval(countdown_interval); - poll_current_time = delay; + poll_current_time = delay; countdown_interval = setInterval(decrement_timer, 1000); - $('#update_secs').text(poll_current_time/1000); + $('#update_secs').text(poll_current_time/1000); } - + var stop_auto_update = function() { clearInterval(countdown_interval); } - - var epoch = (new Date).getTime(); - var epochold = epoch; - + + var epoch = (new Date).getTime(); + var epochold = epoch; + var timeDiff = function (delay) { - if((epoch-epochold) > delay) { + if ((epoch-epochold) > delay) { epochold = epoch = (new Date).getTime(); return true; - }else{ + } else { epoch = (new Date).getTime(); return; } } - + var poll = function(manualUpdate) { stop_auto_update(); $('#update_secs').text(_("Updating...")); - + $.ajax({ url: document.location, success: function(data) { @@ -168,15 +170,15 @@ $(document).ready(function(){ $(document).trigger('new_post', ele); }); time_loaded = Date.now(); // interop with watch.js - - + + if ($('#auto_update_status').is(':checked')) { // If there are no new posts, double the delay. Otherwise set it to the min. if(loaded_posts == 0) { // if the update was manual, don't increase the delay if (manualUpdate == false) { poll_interval_delay *= 2; - + // Don't increase the delay beyond the maximum if(poll_interval_delay > poll_interval_maxdelay) { poll_interval_delay = poll_interval_maxdelay; @@ -185,7 +187,7 @@ $(document).ready(function(){ } else { poll_interval_delay = poll_interval_mindelay; } - + auto_update(poll_interval_delay); } else { // Decide the message to show if auto update is disabled @@ -210,7 +212,7 @@ $(document).ready(function(){ } else { $('#update_secs').text(_("Unknown error")); } - + // Keep trying to update if ($('#auto_update_status').is(':checked')) { poll_interval_delay = poll_interval_errordelay; @@ -218,14 +220,14 @@ $(document).ready(function(){ } } }); - + return false; }; - + $(window).scroll(function() { recheck_activated(); - - // if the newest post is not visible + + // If the newest post is not visible. if($(this).scrollTop() + $(this).height() < $('div.post:last').position().top + $('div.post:last').height()) { end_of_page = false; From b6d16c7cd24f5b07d5c11500078e89e31bcc9e3c Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 4 Jan 2025 21:43:16 +0100 Subject: [PATCH 06/17] auto-reload.js: remove variables which are never read --- js/auto-reload.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index db7aac2a..b9cf3e23 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -47,10 +47,7 @@ $(document).ready(function(){ var poll_interval_delay = poll_interval_mindelay; var poll_current_time = poll_interval_delay; - var end_of_page = false; - var new_posts = 0; - var first_new_post = null; var title = document.title; @@ -112,7 +109,6 @@ $(document).ready(function(){ new_posts = 0; } update_title(); - first_new_post = null; }; // automatically updates the thread after a specified delay @@ -154,9 +150,6 @@ $(document).ready(function(){ $(data).find('div.post.reply').each(function() { var id = $(this).attr('id'); if($('#' + id).length == 0) { - if (!new_posts) { - first_new_post = this; - } new_posts++; loaded_posts++; elementsToAppend.push($(this)); @@ -230,13 +223,11 @@ $(document).ready(function(){ // If the newest post is not visible. if($(this).scrollTop() + $(this).height() < $('div.post:last').position().top + $('div.post:last').height()) { - end_of_page = false; return; } else { if($("#auto_update_status").is(':checked') && timeDiff(poll_interval_mindelay)) { poll(manualUpdate = true); } - end_of_page = true; } }); From 8302a121e52ce45089373768a5143c93fcab8d7e Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 24 Aug 2024 00:52:29 +0200 Subject: [PATCH 07/17] quick-post-controls.js: format --- js/quick-post-controls.js | 60 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js index 10d74f98..c625fa85 100644 --- a/js/quick-post-controls.js +++ b/js/quick-post-controls.js @@ -10,33 +10,31 @@ * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/quick-post-controls.js'; - * */ -$(document).ready(function(){ - var open_form = function() { - var thread = $(this).parent().parent().hasClass('op'); - var id = $(this).attr('name').match(/^delete_(\d+)$/)[1]; - var submitButton; - - if(this.checked) { - var post_form = $('
' + +$(document).ready(function() { + let open_form = function() { + let thread = $(this).parent().parent().hasClass('op'); + let id = $(this).attr('name').match(/^delete_(\d+)$/)[1]; + + if (this.checked) { + let post_form = $('' + '
' + (!thread ? '
' : '') + - + '' + - + ': ' + '' + '' + - '' + - ' ' + - + '' + + ' ' + + '
' + - - ': ' + + + ': ' + '' + - ' ' + + ' ' + '
' + '
'); post_form @@ -50,35 +48,36 @@ $(document).ready(function(){ } else if($(this).attr('name') == 'reason') { post_form.find('input[name=report]').click(); } - + return false; } - + return true; }); - + post_form.find('input[type="password"]').val(localStorage.password); - - if(thread) { + + if (thread) { post_form.prependTo($(this).parent().parent().find('div.body')); } else { post_form.appendTo($(this).parent().parent()); - //post_form.insertBefore($(this)); } - + $(window).trigger('quick-post-controls', post_form); } else { - var elm = $(this).parent().parent().find('form'); - - if(elm.attr('class') == 'post-actions') + let elm = $(this).parent().parent().find('form'); + + if (elm.attr('class') == 'post-actions') { elm.remove(); + } } }; - - var init_qpc = function() { + + let init_qpc = function() { $(this).change(open_form); - if(this.checked) + if (this.checked) { $(this).trigger('change'); + } }; $('div.post input[type=checkbox].delete').each(init_qpc); @@ -87,4 +86,3 @@ $(document).ready(function(){ $(post).find('input[type=checkbox].delete').each(init_qpc); }); }); - From 3eba0b87212669c8d776cce627b7c851301830d7 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Thu, 29 Aug 2024 17:40:46 +0200 Subject: [PATCH 08/17] expand.js: format --- js/expand.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/js/expand.js b/js/expand.js index 0fa8de05..b64323d4 100644 --- a/js/expand.js +++ b/js/expand.js @@ -13,37 +13,38 @@ * */ -$(document).ready(function(){ - if($('span.omitted').length == 0) - return; // nothing to expand +$(document).ready(function() { + if ($('span.omitted').length === 0) { + // Nothing to expand. + return; + } - var do_expand = function() { + let doExpand = function() { $(this) .html($(this).text().replace(_("Click reply to view."), ''+_("Click to expand")+'.')) .find('a').click(window.expand_fun = function() { - var thread = $(this).parents('[id^="thread_"]'); - var id = thread.attr('id').replace(/^thread_/, ''); + let thread = $(this).parents('[id^="thread_"]'); $.ajax({ url: thread.find('p.intro a.post_no:first').attr('href'), context: document.body, success: function(data) { - var last_expanded = false; + let lastExpanded = false; $(data).find('div.post.reply').each(function() { thread.find('div.hidden').remove(); - var post_in_doc = thread.find('#' + $(this).attr('id')); - if(post_in_doc.length == 0) { - if(last_expanded) { - $(this).addClass('expanded').insertAfter(last_expanded).before('
'); + let postInDoc = thread.find('#' + $(this).attr('id')); + if (postInDoc.length === 0) { + if (lastExpanded) { + $(this).addClass('expanded').insertAfter(lastExpanded).before('
'); } else { $(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('
'); } - last_expanded = $(this); + lastExpanded = $(this); $(document).trigger('new_post', this); } else { - last_expanded = post_in_doc; + lastExpanded = postInDoc; } }); - + thread.find("span.omitted").css('display', 'none'); @@ -51,19 +52,20 @@ $(document).ready(function(){ .insertAfter(thread.find('.op div.body, .op span.omitted').last()) .click(function() { thread.find('.expanded').remove(); - $(this).parent().find(".omitted:not(.hide-expanded)").css('display', ''); - $(this).parent().find(".hide-expanded").remove(); + let parent = $(this).parent(); + parent.find(".omitted:not(.hide-expanded)").css('display', ''); + parent.find(".hide-expanded").remove(); }); } }); }); } - $('div.post.op span.omitted').each(do_expand); + $('div.post.op span.omitted').each(doExpand); $(document).on("new_post", function(e, post) { if (!$(post).hasClass("reply")) { - $(post).find('div.post.op span.omitted').each(do_expand); + $(post).find('div.post.op span.omitted').each(doExpand); } }); }); From 6a0c1b94b78072dd27f55faf41de8252355aefe6 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Thu, 29 Aug 2024 18:08:00 +0200 Subject: [PATCH 09/17] expand.js: format exposed function --- js/expand.js | 2 +- js/live-index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/expand.js b/js/expand.js index b64323d4..eba21eb9 100644 --- a/js/expand.js +++ b/js/expand.js @@ -22,7 +22,7 @@ $(document).ready(function() { let doExpand = function() { $(this) .html($(this).text().replace(_("Click reply to view."), ''+_("Click to expand")+'.')) - .find('a').click(window.expand_fun = function() { + .find('a').click(window.expandFun = function() { let thread = $(this).parents('[id^="thread_"]'); $.ajax({ url: thread.find('p.intro a.post_no:first').attr('href'), diff --git a/js/live-index.js b/js/live-index.js index 017d0c1f..2cc4698c 100644 --- a/js/live-index.js +++ b/js/live-index.js @@ -85,7 +85,7 @@ if (active_page == 'index' && (""+document.location).match(/\/(index\.html)?(\?| if ($(th).find(".new-posts").html() != msg) { $(th).find(".new-posts").html(msg); - $(th).find(".new-posts a").click(window.expand_fun); + $(th).find(".new-posts a").click(window.expandFun); } }; From 289c137b2d5ce80fac15c8b9f27cbb3be2981590 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Thu, 29 Aug 2024 18:07:20 +0200 Subject: [PATCH 10/17] live-index.js: trim --- js/live-index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/live-index.js b/js/live-index.js index 2cc4698c..3a1611d3 100644 --- a/js/live-index.js +++ b/js/live-index.js @@ -1,16 +1,16 @@ -/* +/* * live-index.js * https://github.com/vichan-devel/Tinyboard/blob/master/js/live-index.js - * + * * Released under the MIT license * Copyright (c) 2014 Marcin Ɓabanowski - * + * * Usage: * $config['api']['enabled'] = true; * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/expand.js'; * $config['additional_javascript'][] = 'js/live-index.js'; - * + * */ if (active_page == 'index' && (""+document.location).match(/\/(index\.html)?(\?|$|#)/)) From 47d2a38b803e0c2d6200010a11741bc42936c1af Mon Sep 17 00:00:00 2001 From: Zankaria Date: Wed, 4 Sep 2024 15:13:06 +0200 Subject: [PATCH 11/17] expand.js: format --- js/expand.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/expand.js b/js/expand.js index eba21eb9..4dde131b 100644 --- a/js/expand.js +++ b/js/expand.js @@ -10,7 +10,6 @@ * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/expand.js'; - * */ $(document).ready(function() { @@ -21,7 +20,7 @@ $(document).ready(function() { let doExpand = function() { $(this) - .html($(this).text().replace(_("Click reply to view."), ''+_("Click to expand")+'.')) + .html($(this).text().replace(_("Click reply to view."), '' + _("Click to expand") + '.')) .find('a').click(window.expandFun = function() { let thread = $(this).parents('[id^="thread_"]'); $.ajax({ @@ -46,15 +45,15 @@ $(document).ready(function() { }); - thread.find("span.omitted").css('display', 'none'); + thread.find('span.omitted').css('display', 'none'); $('' + _('Hide expanded replies') + '.') .insertAfter(thread.find('.op div.body, .op span.omitted').last()) .click(function() { thread.find('.expanded').remove(); let parent = $(this).parent(); - parent.find(".omitted:not(.hide-expanded)").css('display', ''); - parent.find(".hide-expanded").remove(); + parent.find('.omitted:not(.hide-expanded)').css('display', ''); + parent.find('.hide-expanded').remove(); }); } }); @@ -63,8 +62,8 @@ $(document).ready(function() { $('div.post.op span.omitted').each(doExpand); - $(document).on("new_post", function(e, post) { - if (!$(post).hasClass("reply")) { + $(document).on('new_post', function(e, post) { + if (!$(post).hasClass('reply')) { $(post).find('div.post.op span.omitted').each(doExpand); } }); From 2ab6f371f73bc87593db55e2a28d3f3f5d4d18eb Mon Sep 17 00:00:00 2001 From: Zankaria Date: Thu, 5 Sep 2024 15:14:11 +0200 Subject: [PATCH 12/17] inline-expanding.js: format --- js/inline-expanding.js | 117 ++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 54 deletions(-) diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 5db95c09..8eb87f45 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -9,31 +9,31 @@ * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/inline-expanding.js'; - * */ -$(document).ready(function(){ +$(document).ready(function() { 'use strict'; - var DEFAULT_MAX = 5; // default maximum image loads - var inline_expand_post = function() { - var link = this.getElementsByTagName('a'); + // Default maximum image loads. + const DEFAULT_MAX = 5; - var loadingQueue = (function () { - var MAX_IMAGES = localStorage.inline_expand_max || DEFAULT_MAX; // maximum number of images to load concurrently, 0 to disable - var loading = 0; // number of images that is currently loading - var waiting = []; // waiting queue + let inline_expand_post = function() { + let link = this.getElementsByTagName('a'); - var enqueue = function (ele) { + let loadingQueue = (function() { + let MAX_IMAGES = localStorage.inline_expand_max || DEFAULT_MAX; // Maximum number of images to load concurrently, 0 to disable. + let loading = 0; // Number of images that is currently loading. + let waiting = []; // Waiting queue. + + let enqueue = function(ele) { waiting.push(ele); }; - var dequeue = function () { + let dequeue = function() { return waiting.shift(); }; - var update = function() { - var ele; + let update = function() { while (loading < MAX_IMAGES || MAX_IMAGES === 0) { - ele = dequeue(); + let ele = dequeue(); if (ele) { ++loading; ele.deferred.resolve(); @@ -43,8 +43,8 @@ $(document).ready(function(){ } }; return { - remove: function (ele) { - var i = waiting.indexOf(ele); + remove: function(ele) { + let i = waiting.indexOf(ele); if (i > -1) { waiting.splice(i, 1); } @@ -54,14 +54,14 @@ $(document).ready(function(){ --loading; } }, - add: function (ele) { + add: function(ele) { ele.deferred = $.Deferred(); ele.deferred.done(function () { - var $loadstart = $.Deferred(); - var thumb = ele.childNodes[0]; - var img = ele.childNodes[1]; + let $loadstart = $.Deferred(); + let thumb = ele.childNodes[0]; + let img = ele.childNodes[1]; - var onLoadStart = function (img) { + let onLoadStart = function (img) { if (img.naturalWidth) { $loadstart.resolve(img, thumb); } else { @@ -71,7 +71,7 @@ $(document).ready(function(){ $(img).one('load', function () { $.when($loadstart).done(function () { - // once fully loaded, update the waiting queue + // Once fully loaded, update the waiting queue. --loading; $(ele).data('imageLoading', 'false'); update(); @@ -93,35 +93,36 @@ $(document).ready(function(){ } else { enqueue(ele); } - } }; })(); - for (var i = 0; i < link.length; i++) { + for (let i = 0; i < link.length; i++) { if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) { link[i].onclick = function(e) { - var img, post_body, still_open, canvas, scroll; - var thumb = this.childNodes[0]; - var padding = 5; - var boardlist = $('.boardlist')[0]; - + let thumb = this.childNodes[0]; + let padding = 5; + let boardlist = $('.boardlist')[0]; - if (thumb.className == 'hidden') + + if (thumb.className == 'hidden') { return false; - if (e.which == 2 || e.ctrlKey) // open in new tab + } + if (e.which == 2 || e.ctrlKey) { + // Open in new tab. return true; + } if (!$(this).data('expanded')) { - - if (~this.parentNode.className.indexOf('multifile')) + if (~this.parentNode.className.indexOf('multifile')) { $(this).data('width', this.parentNode.style.width); + } this.parentNode.removeAttribute('style'); $(this).data('expanded', 'true'); if (thumb.tagName === 'CANVAS') { - canvas = thumb; + let canvas = thumb; thumb = thumb.nextSibling; this.removeChild(canvas); canvas.style.display = 'block'; @@ -130,7 +131,7 @@ $(document).ready(function(){ thumb.style.opacity = '0.4'; thumb.style.filter = 'alpha(opacity=40)'; - img = document.createElement('img'); + let img = document.createElement('img'); img.className = 'full-image'; img.style.display = 'none'; img.setAttribute('alt', 'Fullsized image'); @@ -140,41 +141,48 @@ $(document).ready(function(){ } else { loadingQueue.remove(this); - scroll = false; + let scroll = false; - // scroll to thumb if not triggered by 'shrink all image' + // Scroll to thumb if not triggered by 'shrink all image'. if (e.target.className == 'full-image') { scroll = true; } - if (~this.parentNode.className.indexOf('multifile')) + if (~this.parentNode.className.indexOf('multifile')) { this.parentNode.style.width = $(this).data('width'); + } thumb.style.opacity = ''; thumb.style.display = ''; - if (thumb.nextSibling) this.removeChild(thumb.nextSibling); //full image loaded or loading + if (thumb.nextSibling) { + // Full image loaded or loading. + this.removeChild(thumb.nextSibling); + } $(this).removeData('expanded'); delete thumb.style.filter; - // do the scrolling after page reflow + // Do the scrolling after page reflow. if (scroll) { - post_body = $(thumb).parentsUntil('form > div').last(); + let post_body = $(thumb).parentsUntil('form > div').last(); - // on multifile posts, determin how many other images are still expanded - still_open = post_body.find('.post-image').filter(function(){ + // On multifile posts, determine how many other images are still expanded. + let still_open = post_body.find('.post-image').filter(function() { return $(this).parent().data('expanded') == 'true'; }).length; - // deal with differnt boards' menu styles - if ($(boardlist).css('position') == 'fixed') + // Deal with different boards menu styles. + if ($(boardlist).css('position') == 'fixed') { padding += boardlist.getBoundingClientRect().height; + } if (still_open > 0) { - if (thumb.getBoundingClientRect().top - padding < 0) + if (thumb.getBoundingClientRect().top - padding < 0) { $(document).scrollTop($(thumb).parent().parent().offset().top - padding); + } } else { - if (post_body[0].getBoundingClientRect().top - padding < 0) + if (post_body[0].getBoundingClientRect().top - padding < 0) { $(document).scrollTop(post_body.offset().top - padding); + } } } @@ -188,17 +196,18 @@ $(document).ready(function(){ } }; - // setting up user option + // Setting up user option. if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''+ _('Number of simultaneous image downloads (0 to disable): ') + - ''); + Options.extend_tab('general', '' + + _('Number of simultaneous image downloads (0 to disable): ') + + ''); $('#inline-expand-max input') .css('width', '50px') .val(localStorage.inline_expand_max || DEFAULT_MAX) .on('change', function (e) { - // validation in case some fucktard tries to enter a negative floating point number - var n = parseInt(e.target.value); - var val = (n<0) ? 0 : n; + // Validation in case some fucktard tries to enter a negative floating point number. + let n = parseInt(e.target.value); + let val = (n < 0) ? 0 : n; localStorage.inline_expand_max = val; }); @@ -207,7 +216,7 @@ $(document).ready(function(){ if (window.jQuery) { $('div[id^="thread_"]').each(inline_expand_post); - // allow to work with auto-reload.js, etc. + // Allow to work with auto-reload.js, etc. $(document).on('new_post', function(e, post) { inline_expand_post.call(post); }); From a3d1fe488419eee672b517aa44c5fe35616df450 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Mon, 30 Sep 2024 22:00:33 +0200 Subject: [PATCH 13/17] thread-watcher.js: format --- js/thread-watcher.js | 107 ++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/js/thread-watcher.js b/js/thread-watcher.js index 09583950..5020eabd 100644 --- a/js/thread-watcher.js +++ b/js/thread-watcher.js @@ -5,9 +5,9 @@ /* jshint globalstrict:true, quotmark:single */ /* jshint browser:true, jquery:true, devel:true, unused:true, undef:true */ /* global active_page:false, board_name:false */ -if(!localStorage.watchlist){ - //If the watchlist is undefined in the localStorage, - //initialize it as an empty array. +if(!localStorage.watchlist) { + // If the watchlist is undefined in the localStorage, + // initialize it as an empty array. localStorage.watchlist = '[]'; } var watchlist = {}; @@ -20,13 +20,17 @@ var watchlist = {}; */ watchlist.render = function(reset) { /* jshint eqnull:true */ - if (reset == null) reset = false; + if (reset == null) { + reset = false; + } /* jshint eqnull:false */ - if (reset && $('#watchlist').length) $('#watchlist').remove(); - var threads = []; - //Read the watchlist and create a new container for each thread. + if (reset && $('#watchlist').length) { + $('#watchlist').remove(); + } + let threads = []; + // Read the watchlist and create a new container for each thread. JSON.parse(localStorage.watchlist).forEach(function(e, i) { - //look at line 69, that's what (e) is here. + // Look at line 69, that's what (e) is here. threads.push('
' + '/'+e[0]+'/ - ' + ''+e[1].replace("thread_", _("Thread #"))+'' + @@ -35,20 +39,21 @@ watchlist.render = function(reset) { '
'); }); if ($('#watchlist').length) { - //If the watchlist is already there, empty it and append the threads. + // If the watchlist is already there, empty it and append the threads. $('#watchlist').children('.watchlist-inner').remove(); $('#watchlist').append(threads.join('')); } else { - //If the watchlist has not yet been rendered, create it. - var menuStyle = getComputedStyle($('.boardlist')[0]); + // If the watchlist has not yet been rendered, create it. + let menuStyle = getComputedStyle($('.boardlist')[0]); $((active_page == 'ukko') ? 'hr:first' : (active_page == 'catalog') ? 'body>span:first' : 'form[name="post"]').before( $('
'+ - ''+ - threads.join('')+ - '
').css("background-color", menuStyle.backgroundColor).css("border", menuStyle.borderBottomWidth+" "+menuStyle.borderBottomStyle+" "+menuStyle.borderBottomColor)); + ''+ + threads.join('')+ + '').css("background-color", menuStyle.backgroundColor).css("border", menuStyle.borderBottomWidth+" "+menuStyle.borderBottomStyle+" "+menuStyle.borderBottomColor) + ); } return this; }; @@ -58,32 +63,31 @@ watchlist.render = function(reset) { * @param {[Obj/Str]} sel [An unwrapped jquery selector.] */ watchlist.add = function(sel) { - var threadName, threadInfo; + let threadName; + let threadInfo; - var board_name = $(sel).parents('.thread').data('board'); + let board_name = $(sel).parents('.thread').data('board'); if (active_page === 'thread') { - if ($('.subject').length){ - //If a subject is given, use the first 20 characters as the thread name. + if ($('.subject').length) { + // If a subject is given, use the first 20 characters as the thread name. threadName = $('.subject').text().substring(0,20); } else { //Otherwise use the thread id. threadName = $('.op').parent().attr('id'); } - //board name, thread name as defined above, current amount of posts, thread url + // Board name, thread name as defined above, current amount of posts, thread url threadInfo = [board_name, threadName, $('.post').length, location.href]; - } else if (active_page === 'index' || active_page === 'ukko') { - - var postCount; - //Figure out the post count. + let postCount; + // Figure out the post count. if ($(sel).parents('.op').children('.omitted').length) { postCount = $(sel).parents('.op').children('.omitted').text().split(' ')[0]; } else { postCount = $(sel).parents('.op').siblings('.post').length+1; } - //Grab the reply link.; - var threadLink = $(sel).siblings('a:not(.watchThread)').last().attr('href'); - //Figure out the thread name. If anon, use the thread id. + // Grab the reply link.; + let threadLink = $(sel).siblings('a:not(.watchThread)').last().attr('href'); + // Figure out the thread name. If anon, use the thread id. if ($(sel).parent().find('.subject').length) { threadName = $(sel).parent().find('.subject').text().substring(0,20); } else { @@ -91,7 +95,6 @@ watchlist.add = function(sel) { } threadInfo = [board_name, threadName, postCount, threadLink]; - } else { alert('Functionality not yet implemented for this type of page.'); return this; @@ -102,7 +105,7 @@ watchlist.add = function(sel) { return this; } - var _watchlist = JSON.parse(localStorage.watchlist); //Read the watchlist + let _watchlist = JSON.parse(localStorage.watchlist); //Read the watchlist _watchlist.push(threadInfo); //Add the new watch item. localStorage.watchlist = JSON.stringify(_watchlist); //Save the watchlist. return this; @@ -113,7 +116,7 @@ watchlist.add = function(sel) { * @param {[Int]} n [The index at which to remove.] */ watchlist.remove = function(n) { - var _watchlist = JSON.parse(localStorage.watchlist); + let _watchlist = JSON.parse(localStorage.watchlist); _watchlist.splice(n, 1); localStorage.watchlist = JSON.stringify(_watchlist); return this; @@ -137,26 +140,26 @@ watchlist.exists = function(sel) { error: function() { watchlist.remove(parseInt($(sel).attr('id').split('-')[1])).render(); }, - success : function(){ + success : function() { return; } }); }; -$(document).ready(function(){ +$(document).ready(function() { if (!(active_page == 'thread' || active_page == 'index' || active_page == 'catalog' || active_page == 'ukko')) { return; } - //Append the watchlist toggle button. - $('.boardlist').append(' [ '+_('watchlist')+' ]'); - //Append a watch thread button after every OP post number. - $('.op>.intro>.post_no:odd').after('['+_('Watch Thread')+']'); + // Append the watchlist toggle button. + $('.boardlist').append(' [ ' + _('watchlist') + ' ]'); + // Append a watch thread button after every OP post number. + $('.op>.intro>.post_no:odd').after('[' + _('Watch Thread') + ']'); - //Draw the watchlist, hidden. + // Draw the watchlist, hidden. watchlist.render(); - //Show or hide the watchlist. + // Show or hide the watchlist. $('.watchlist-toggle').on('click', function(e) { e.preventDefault(); //if ctrl+click, reset the watchlist. @@ -167,35 +170,33 @@ $(document).ready(function(){ $('#watchlist').css('display', 'none'); } else { $('#watchlist').css('display', 'block'); - } //Shit got really weird with hide/show. Went with css manip. Probably faster anyway. + } // Shit got really weird with hide/show. Went with css manip. Probably faster anyway. }); - //Trigger the watchlist add function. - //The selector is passed as an argument in case the page is not a thread. + // Trigger the watchlist add function. + // The selector is passed as an argument in case the page is not a thread. $('.watchThread').on('click', function(e) { e.preventDefault(); watchlist.add(this).render(); }); - //The index is saved in .watchlist-inner so that it can be passed as the argument here. - //$('.watchlist-remove').on('click') won't work in case of re-renders and - //the page will need refreshing. This works around that. + // The index is saved in .watchlist-inner so that it can be passed as the argument here. + // $('.watchlist-remove').on('click') won't work in case of re-renders and + // the page will need refreshing. This works around that. $(document).on('click', '.watchlist-remove', function() { - var item = parseInt($(this).parent().attr('id').split('-')[1]); + let item = parseInt($(this).parent().attr('id').split('-')[1]); watchlist.remove(item).render(); }); - //Empty the watchlist and redraw it. - $('#clearList').on('click', function(){ + // Empty the watchlist and redraw it. + $('#clearList').on('click', function() { watchlist.clear().render(); }); - //Get rid of every watched item that no longer directs to an existing page. + // Get rid of every watched item that no longer directs to an existing page. $('#clearGhosts').on('click', function() { - $('.watchlist-inner').each(function(){ + $('.watchlist-inner').each(function() { watchlist.exists(this); }); }); - }); - From c4b81cffe79c47905f7e70c105268160c30ddd80 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 4 Jan 2025 19:13:23 +0100 Subject: [PATCH 14/17] header.html: fix broken js include --- templates/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/header.html b/templates/header.html index 51a9593c..335f572e 100644 --- a/templates/header.html +++ b/templates/header.html @@ -12,7 +12,7 @@ var modRoot = "{{ config.root }}" + (inMod ? "mod.php?/" : ""); {% if not nojavascript %} - + {% if not config.additional_javascript_compile %} {% for javascript in config.additional_javascript %}{% endfor %} {% endif %} From e31b8abe3547da608db9d58aa9feb0f8faacab8e Mon Sep 17 00:00:00 2001 From: Zankaria Date: Tue, 20 Aug 2024 15:00:00 +0200 Subject: [PATCH 15/17] fileinfo.html: use only tabs --- templates/post/fileinfo.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/post/fileinfo.html b/templates/post/fileinfo.html index 80ddd2a6..6a1841bd 100644 --- a/templates/post/fileinfo.html +++ b/templates/post/fileinfo.html @@ -1,9 +1,9 @@ {% if post.embed %} {{ post.embed }} - {% else %} -
- {% for file in post.files %} -
+ {% else %} +
+ {% for file in post.files %} +
{% if file.file == 'deleted' %} {% else %} From acfd99a4ace0028b6a7ed134a8371af6ec65d868 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 4 Jan 2025 21:57:52 +0100 Subject: [PATCH 16/17] style.css: add missing format spacing --- stylesheets/style.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stylesheets/style.css b/stylesheets/style.css index cd2e931b..131e00f4 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -929,9 +929,11 @@ pre { display: inline-block; user-select: none; } + .poster_id:hover { color: #800000!important; } + .poster_id::before { content: " ID: "; } From d1953752abeb052e9245f8d7a975207466e79504 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sat, 4 Jan 2025 23:15:14 +0100 Subject: [PATCH 17/17] image_identification.html: trim --- templates/post/image_identification.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/post/image_identification.html b/templates/post/image_identification.html index d0609873..4fd45e24 100644 --- a/templates/post/image_identification.html +++ b/templates/post/image_identification.html @@ -1,13 +1,13 @@ {% if file.thumb != 'file' and config.image_identification %} {% if config.image_identification_imgops %} - ImgOps + ImgOps {% endif %} {% if config.image_identification_exif and file.file|extension == 'jpg' %} - Exif + Exif {% endif %} {% if config.image_identification_google %} - Google + Google {% endif %} {% if config.image_identification_iqdb %} iqdb @@ -16,4 +16,4 @@ Yandex {% endif %} -{% endif %} +{% endif %} \ No newline at end of file