From 981c57056f512128bcd711ebf3f089d035543206 Mon Sep 17 00:00:00 2001 From: lscambo13 Date: Thu, 4 Jan 2024 23:38:44 +0530 Subject: [PATCH] new: Modern notifications for less important messages --- index.html | 1 + js_modules/search.js | 11 +- js_modules/utils/notifyDialog.js | 184 ++++++++----------------------- style.css | 65 ++++++++++- 4 files changed, 115 insertions(+), 146 deletions(-) diff --git a/index.html b/index.html index f8cf0d0..27f2eb4 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,7 @@ +
diff --git a/js_modules/search.js b/js_modules/search.js index 4f579cd..61d2784 100644 --- a/js_modules/search.js +++ b/js_modules/search.js @@ -11,6 +11,7 @@ import { } from './cli.js'; import { isUrlValid } from './validators.js'; import { genericAlert } from './utils/alertDialog.js'; +import { Notify } from './utils/notifyDialog.js'; const MSG = 'You must enter a search query to continue.'; @@ -38,7 +39,7 @@ export function webSearch() { window.open(url, '_self'); } else cliParse(input); } else { - genericAlert('Error', MSG); + Notify.show(MSG); } } @@ -50,7 +51,7 @@ export function movies() { const url = EXT_SEARCH_DOMAIN + input + '/Movies/time/desc/1/'; window.open(url); } else { - genericAlert('Error', MSG); + Notify.show(MSG); } } @@ -61,7 +62,7 @@ export function tv() { const url = EXT_SEARCH_DOMAIN + input + '/TV/size/desc/1/'; window.open(url); } else { - genericAlert('Error', MSG); + Notify.show(MSG); } } @@ -72,7 +73,7 @@ export function games() { const url = EXT_SEARCH_DOMAIN + input + '/Games/time/desc/1/'; window.open(url); } else { - genericAlert('Error', MSG); + Notify.show(MSG); } } export function ebooks() { @@ -82,7 +83,7 @@ export function ebooks() { const url = EXT_SEARCH_DOMAIN + input + '/Other/seeders/desc/1/'; window.open(url); } else { - genericAlert('Error', MSG); + Notify.show(MSG); } }; diff --git a/js_modules/utils/notifyDialog.js b/js_modules/utils/notifyDialog.js index d162125..46b5856 100644 --- a/js_modules/utils/notifyDialog.js +++ b/js_modules/utils/notifyDialog.js @@ -1,152 +1,56 @@ -let modalContainer; -let modalSubmitButton; +const notifyModalContainer = document.getElementById('notifyContainer'); let modalCancelButton; -let tickBoxField; -let inputFields; +let notify; -const showInputDialog = ( - title = null, - description = null, - inputBoxes = ['Input A', 'Input B'], - submitButtonName = 'Submit', - cancelButtonName = 'Cancel', - tickBox = null, - listeners = [onInput = null, onChange = null], - onInit = null, +const showNotifyDialog = ( + description, + ms = '5000', + onClick = null, ) => { - modalContainer = document.getElementById('inputDialogContainer'); - if (modalContainer) modalContainer.remove(); - - document.activeElement.blur(); - - if (title) { - title = `

${title}

`; - } else (title = ''); - if (description) { - description = ` -

${description}

- `; - } else (description = ''); - - document.body - .insertAdjacentHTML('afterbegin', ` -
-