diff --git a/index.js b/index.js index 6f7a046..80b18ad 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,7 @@ import { saveDropdownPositions } from './js_modules/save_preferences.js'; import { getLastUpdated } from './js_modules/utils/getLastUpdated.js'; import { blurLevel } from './js_modules/utils/blurLevel.js'; import { isItChristmas } from './js_modules/utils/letItSnow.js'; -import { Dialog } from './js_modules/utils/dialog.js'; +import { InputDialog } from './js_modules/utils/inputDialog.js'; import { isTouchDevice } from './js_modules/utils/isTouchDevice.js'; import { enableSubmitButton } from './js_modules/utils/enableSubmitButton.js'; @@ -109,26 +109,26 @@ const wallpapersPanel = (str) => { }; window.createNewBookmark = () => { - const dialogTitle = 'Add new bookmark'; - const dialogDescription = ` + const inputDialogTitle = 'Add new bookmark'; + const inputDialogDescription = ` You may only use upto four letters as the bookmark name.`; const bookmarkLabel = 'Bookmark name'; const bookmarkAddress = 'Link to website'; - Dialog.show( - dialogTitle, - dialogDescription, + InputDialog.show( + inputDialogTitle, + inputDialogDescription, [bookmarkLabel, bookmarkAddress], 'Save', undefined, null, [() => enableSubmitButton(event, true), null], () => { - const label = Dialog.getInputFields()[0]; + const label = InputDialog.getInputFields()[0]; label.setAttribute('maxlength', 4); label.setAttribute('placeholder', 'e.g. YT'); - const address = Dialog.getInputFields()[1]; + const address = InputDialog.getInputFields()[1]; address.setAttribute('placeholder', 'e.g. youtube.com'); address.value = 'https://'; diff --git a/js_modules/custom_bookmarks.js b/js_modules/custom_bookmarks.js index 8d93f20..188ef4e 100644 --- a/js_modules/custom_bookmarks.js +++ b/js_modules/custom_bookmarks.js @@ -1,4 +1,4 @@ -import { Dialog } from './utils/dialog.js'; +import { InputDialog } from './utils/inputDialog.js'; import { enableSubmitButton } from './utils/enableSubmitButton.js'; import { crossDisplay } from './utils/toggleDisplay.js'; @@ -112,9 +112,9 @@ export function editBookmark(event) { const targetElement = event.target.parentNode; const onChange = () => { - const checkbox = Dialog.getCheckboxField(); - const modalSubmitButton = Dialog.getSubmitButton(); - const inputFields = Dialog.getInputFields(); + const checkbox = InputDialog.getCheckboxField(); + const modalSubmitButton = InputDialog.getSubmitButton(); + const inputFields = InputDialog.getInputFields(); if (checkbox.checked) { modalSubmitButton.textContent = 'Delete'; @@ -134,7 +134,7 @@ export function editBookmark(event) { const details = getBookmarkDetailsFromLocalStorage(targetElement.id); - Dialog.show('Edit bookmark', + InputDialog.show('Edit bookmark', null, ['Name', 'Address'], 'Save', @@ -142,9 +142,9 @@ export function editBookmark(event) { 'Delete this bookmark', [() => enableSubmitButton(event, true), onChange], () => { - Dialog.getInputFields()[0].setAttribute('maxlength', '4'); - Dialog.getInputFields()[0].value = details[1]; - Dialog.getInputFields()[1].value = details[2]; + InputDialog.getInputFields()[0].setAttribute('maxlength', '4'); + InputDialog.getInputFields()[0].value = details[1]; + InputDialog.getInputFields()[1].value = details[2]; }, ).then((res) => { if (res.checkboxChecked) { diff --git a/js_modules/load_preferences.js b/js_modules/load_preferences.js index ca1a76b..b7c14e2 100644 --- a/js_modules/load_preferences.js +++ b/js_modules/load_preferences.js @@ -6,7 +6,7 @@ import { } from './constants.js'; import { displayClock, refreshGreeting } from './preferences.js'; import { fixBackgroundBlurOnResize } from './utils.js'; -import { Dialog } from './utils/dialog.js'; +import { InputDialog } from './utils/inputDialog.js'; import { enableSubmitButton } from './utils/enableSubmitButton.js'; import { intersectionObserver } from './utils/intersectionObserver.js'; @@ -239,7 +239,7 @@ function defaultWidget(value) { export function askCustomText() { const savedText = localStorage.getItem('customWidgetText'); - Dialog.show( + InputDialog.show( 'Custom widget text', 'Enter text you want to set as the main widget.', ['Custom text'], @@ -248,7 +248,7 @@ export function askCustomText() { null, [enableSubmitButton, null], () => { - Dialog.getInputFields()[0].value = savedText; + InputDialog.getInputFields()[0].value = savedText; }, ).then((res) => { localStorage.setItem('customWidgetText', res.inputValues[0]); @@ -261,7 +261,7 @@ export function askCustomText() { export function askCustomDomain() { const savedDomain = localStorage.getItem('customDomain'); - Dialog.show( + InputDialog.show( 'Custom widget text', 'Enter text you want to set as the main widget.', ['Custom text'], @@ -270,7 +270,7 @@ export function askCustomDomain() { null, [enableSubmitButton, null], () => { - Dialog.getInputFields()[0].value = savedDomain; + InputDialog.getInputFields()[0].value = savedDomain; }, ).then((res) => { localStorage.setItem('customDomain', res.inputValues[0]); diff --git a/js_modules/onboarding.js b/js_modules/onboarding.js index 8c3e600..5e807d6 100644 --- a/js_modules/onboarding.js +++ b/js_modules/onboarding.js @@ -2,7 +2,7 @@ import { DEF_PREF, DEF_WALLPAPER } from './constants.js'; import { updateUserNamePreview } from './load_preferences.js'; import { refreshGreeting } from './preferences.js'; import { updateUserNameText } from './strings.js'; -import { Dialog } from './utils/dialog.js'; +import { InputDialog } from './utils/inputDialog.js'; import { enableSubmitButton } from './utils/enableSubmitButton.js'; export function askUserName() { @@ -22,7 +22,7 @@ export function askUserName() { // }; if (userName) { - Dialog.show( + InputDialog.show( 'Update your name', updateUserNameText, ['Change name to'], @@ -31,8 +31,8 @@ export function askUserName() { null, [enableSubmitButton, null], () => { - Dialog.getInputFields()[0].setAttribute('maxlength', 17); - Dialog.getInputFields()[0].value = userName; + InputDialog.getInputFields()[0].setAttribute('maxlength', 17); + InputDialog.getInputFields()[0].value = userName; }, ).then((res) => { userName = res.inputValues[0]; @@ -48,7 +48,7 @@ export function askUserName() { }; if (!userName) { - const onBoardingInProgress = Dialog.show( + const onBoardingInProgress = InputDialog.show( 'Welcome to Casa Mia', `Hi! We are so excited to see you here. Please fill out the following details before moving forward. `, @@ -58,7 +58,7 @@ export function askUserName() { null, [enableSubmitButton, null], () => { - Dialog.getInputFields()[0].setAttribute('maxlength', 17); + InputDialog.getInputFields()[0].setAttribute('maxlength', 17); }, ); onBoardingInProgress.then((res) => { diff --git a/js_modules/utils/enableSubmitButton.js b/js_modules/utils/enableSubmitButton.js index 0ba3526..03305ab 100644 --- a/js_modules/utils/enableSubmitButton.js +++ b/js_modules/utils/enableSubmitButton.js @@ -1,9 +1,9 @@ import { isUrlValid } from '../validators.js'; -import { Dialog } from './dialog.js'; +import { InputDialog } from './inputDialog.js'; export const enableSubmitButton = (event, alt = false) => { - const modalSubmitButton = Dialog.getSubmitButton(); - const inputFields = Dialog.getInputFields(); + const modalSubmitButton = InputDialog.getSubmitButton(); + const inputFields = InputDialog.getInputFields(); for (const e of inputFields) { if (e.value.length) modalSubmitButton.disabled = false; else { diff --git a/js_modules/utils/dialog.js b/js_modules/utils/inputDialog.js similarity index 97% rename from js_modules/utils/dialog.js rename to js_modules/utils/inputDialog.js index f3e76b3..6494ba1 100644 --- a/js_modules/utils/dialog.js +++ b/js_modules/utils/inputDialog.js @@ -4,7 +4,7 @@ let modalCancelButton; let tickBoxField; let inputFields; -const showInputDialog = ( +const showInputInputDialog = ( title = null, description = null, inputBoxes = ['Input A', 'Input B'], @@ -135,8 +135,8 @@ const showInputDialog = ( return promise; }; -export const Dialog = { - show: showInputDialog, +export const InputDialog = { + show: showInputInputDialog, getSubmitButton: () => { return modalSubmitButton; },