From 5e1cfc41d9c97829d41a74df46d0a6a966bb8052 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Sat, 22 Jan 2022 17:59:14 -0800 Subject: [PATCH] Eliminate jQuery from inline js/css charlimit notice --- www/js/ui.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/www/js/ui.js b/www/js/ui.js index bbb1cc90..68d233d8 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -903,25 +903,28 @@ $("#fullscreenbtn").on('click', function () { function handleCSSJSTooLarge(selector) { if (this.value.length > 20000) { - var warning = $(selector); - if (warning.length > 0) { + let notice = document.querySelector(selector); + if (notice !== null) { return; } - warning = makeAlert("Maximum Size Exceeded", "Inline CSS and JavaScript are " + + notice = makeAlert("Maximum Size Exceeded", "Inline CSS and JavaScript are " + "limited to 20,000 characters or less. If you need more room, you " + "need to use the external CSS or JavaScript option.", "alert-danger") .attr("id", selector.replace(/#/, "")); - warning.insertBefore(this); + + // makeAlert returns jQuery + this.parentNode.insertBefore(notice[0], this); } else { - $(selector).remove(); + let notice = document.querySelector(selector); + notice.remove(); } } -$("#cs-csstext").bind("input", handleCSSJSTooLarge.bind($("#cs-csstext")[0], - "#cs-csstext-too-big")); -$("#cs-jstext").bind("input", handleCSSJSTooLarge.bind($("#cs-jstext")[0], - "#cs-jstext-too-big")); +['#cs-csstext', '#cs-jstext'].forEach((selector)=>{ + elem = document.querySelector(selector); + elem.addEventListener('input', handleCSSJSTooLarge.bind(elem, `${selector}-too-big`)); +}); $("#resize-video-larger").on('click', function () { try {