From d9d05ddbf59ce581fc9fe26791230b1b09b101f8 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Mon, 5 Aug 2024 19:08:28 +0200 Subject: [PATCH] catalog-search.js: format --- js/catalog-search.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/catalog-search.js b/js/catalog-search.js index ff9af785..1887a1cf 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -2,27 +2,27 @@ * catalog-search.js * - Search and filters threads when on catalog view * - Optional shortcuts 's' and 'esc' to open and close the search. - * + * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/comment-toolbar.js'; */ if (active_page == 'catalog') { - onready(function () { + onready(function() { 'use strict'; - // 'true' = enable shortcuts - var useKeybinds = true; + // 'true' = enable shortcuts + let useKeybinds = true; - // trigger the search 400ms after last keystroke - var delay = 400; - var timeoutHandle; + // trigger the search 400ms after last keystroke + let delay = 400; + let timeoutHandle; - //search and hide none matching threads + // search and hide none matching threads function filter(search_term) { $('.replies').each(function () { - var subject = $(this).children('.intro').text().toLowerCase(); - var comment = $(this).clone().children().remove(':lt(2)').end().text().trim().toLowerCase(); + let subject = $(this).children('.intro').text().toLowerCase(); + let comment = $(this).clone().children().remove(':lt(2)').end().text().trim().toLowerCase(); search_term = search_term.toLowerCase(); if (subject.indexOf(search_term) == -1 && comment.indexOf(search_term) == -1) { @@ -34,7 +34,7 @@ if (active_page == 'catalog') { } function searchToggle() { - var button = $('#catalog_search_button'); + let button = $('#catalog_search_button'); if (!button.data('expanded')) { button.data('expanded', '1'); @@ -59,18 +59,18 @@ if (active_page == 'catalog') { }); if (useKeybinds) { - // 's' + // 's' $('body').on('keydown', function (e) { if (e.which === 83 && e.target.tagName === 'BODY' && !(e.ctrlKey || e.altKey || e.shiftKey)) { e.preventDefault(); - if ($('#search_field').length !== 0) { + if ($('#search_field').length !== 0) { $('#search_field').focus(); } else { searchToggle(); } } }); - // 'esc' + // 'esc' $('.catalog_search').on('keydown', 'input#search_field', function (e) { if (e.which === 27 && !(e.ctrlKey || e.altKey || e.shiftKey)) { window.clearTimeout(timeoutHandle);