From e6f0898b54ce4cb6ccaf287fd5b4da0391b33f15 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 12 Aug 2023 21:55:55 +0300 Subject: [PATCH] dedup if condition --- files/assets/js/core.js | 4 +++- files/assets/js/emoji_modal.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index f2aceb96c..fe71ee244 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -1,5 +1,7 @@ const SITE_FULL_IMAGES = document.getElementById('SITE_FULL_IMAGES').value +const is_chat = (location.pathname == '/chat' || location.pathname == '/old_chat') + function getMessageFromJsonData(success, json) { let message = success ? "Success!" : "Error, please try again later"; let key = success ? "message" : "error"; @@ -506,7 +508,7 @@ function handle_files(input, newfiles) { return } - if (location.pathname != '/chat' && location.pathname != '/old_chat') { + if (!is_chat) { for (const file of newfiles) { insertText(ta, `[${file.name}]`); } diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index 82c9269b8..b5eebb7d3 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -420,7 +420,7 @@ function populate_speed_emoji_modal(results, textbox) close_inline_speed_emoji_modal() textbox.value = textbox.value.replace(new RegExp(current_word+"(?=\\s|$)", "gi"), `:${name}: `) textbox.focus() - if (document.location.pathname != '/chat' && document.location.pathname != '/old_chat'){ + if (!is_chat){ markdown(textbox) } });