From 990f27e80bf9819cfb4e09092974322c5c4dca34 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 4 Aug 2024 15:07:56 +0200 Subject: [PATCH] main.js: format getCookie --- templates/main.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/templates/main.js b/templates/main.js index e8dae8d1..cbc68d04 100644 --- a/templates/main.js +++ b/templates/main.js @@ -212,12 +212,13 @@ function init_stylechooser() { document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild.nextSibling); } -function get_cookie(cookie_name) { - var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); - if (results) - return (unescape(results[2])); - else +function getCookie(cookie_name) { + let results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); + if (results) { + return unescape(results[2]); + } else { return null; + } } function highlightReply(id) { @@ -323,9 +324,9 @@ function rememberStuff() { if (sessionStorage.body) { var saved = JSON.parse(sessionStorage.body); - if (get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')) { + if (getCookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')) { // Remove successful posts - var successful = JSON.parse(get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')); + var successful = JSON.parse(getCookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')); for (var url in successful) { saved[url] = null; }