From a743cc9897c6517d624fc3e8ea416af14fcb6745 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 28 Dec 2020 23:22:47 +0100 Subject: [PATCH] #48 Added types for settings scripts --- src/javascript/settings.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/javascript/settings.ts b/src/javascript/settings.ts index db82c4e..8d67105 100644 --- a/src/javascript/settings.ts +++ b/src/javascript/settings.ts @@ -5,25 +5,28 @@ const OPTION_SELECTOR = 'input[type="checkbox"'; function storeOptions() { document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => { - getGlobalStorageProvider().setDataAsBoolean(optionElement.id, optionElement.checked); + let optionInputElement = optionElement as HTMLInputElement; + getGlobalStorageProvider().setDataAsBoolean(optionInputElement.id, optionInputElement.checked); }); } function restoreOptions() { - document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => { - let defaultValue = optionElement.dataset.defaultValue === 'true' ? true : false; + document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => { + let optionInputElement = optionElement as HTMLInputElement; + let defaultValue = optionInputElement.dataset.defaultValue === 'true' ? true : false; - getGlobalStorageProvider().getDataAsBoolean(optionElement.id, defaultValue, value => { - optionElement.checked = value; + getGlobalStorageProvider().getDataAsBoolean(optionInputElement.id, defaultValue, value => { + optionInputElement.checked = value; }); }); } function resetOptions() { document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => { - let defaultValue = optionElement.dataset.defaultValue === 'true' ? true : false; + let optionInputElement = optionElement as HTMLInputElement; + let defaultValue = optionInputElement.dataset.defaultValue === 'true' ? true : false; - optionElement.checked = defaultValue; + optionInputElement.checked = defaultValue; }); }