mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 01:55:40 +00:00
frontend linting
This commit is contained in:
@@ -14,13 +14,13 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {LEVELS} from '../levels/index';
|
||||
import updateLevelNumbersOnDOM from './updateDom';
|
||||
import CONST from '../const';
|
||||
import { LEVELS } from "../levels/index";
|
||||
import updateLevelNumbersOnDOM from "./updateDom";
|
||||
import CONST from "../const";
|
||||
|
||||
import log from '../../../../../logger';
|
||||
import log from "../../../../../logger";
|
||||
|
||||
const REMOVE_LEVEL_BUTTON = 'sitekey-form__level-remove-level-button';
|
||||
const REMOVE_LEVEL_BUTTON = "sitekey-form__level-remove-level-button";
|
||||
|
||||
/**
|
||||
* Gets executed when 'Remove' Button is clicked to remove levels
|
||||
@@ -31,12 +31,12 @@ const removeLevel = (e: Event) => {
|
||||
const FIELDSET = <HTMLElement>PARENT.parentElement;
|
||||
|
||||
const levelNum = parseInt(
|
||||
eventTarget.id.slice(CONST.REMOVE_LEVEL_BUTTON_ID_WITHOUT_LEVEL.length),
|
||||
eventTarget.id.slice(CONST.REMOVE_LEVEL_BUTTON_ID_WITHOUT_LEVEL.length)
|
||||
);
|
||||
|
||||
if (Number.isNaN(levelNum)) {
|
||||
const msg =
|
||||
'[removeLevelButton.ts] error in parsing level number from remove button ID';
|
||||
"[removeLevelButton.ts] error in parsing level number from remove button ID";
|
||||
//log.error(msg);
|
||||
throw new Error(msg);
|
||||
}
|
||||
@@ -47,19 +47,19 @@ const removeLevel = (e: Event) => {
|
||||
};
|
||||
|
||||
/** adds onclick event listener */
|
||||
export const addRemoveLevelButtonEventListener = (level: number) => {
|
||||
export const addRemoveLevelButtonEventListener = (level: number): void => {
|
||||
const removeButton = document.getElementById(
|
||||
`${CONST.REMOVE_LEVEL_BUTTON_ID_WITHOUT_LEVEL}${level}`,
|
||||
`${CONST.REMOVE_LEVEL_BUTTON_ID_WITHOUT_LEVEL}${level}`
|
||||
);
|
||||
|
||||
removeButton.addEventListener('click', removeLevel);
|
||||
removeButton.addEventListener("click", removeLevel);
|
||||
};
|
||||
|
||||
/** adds onclick event listener to all remove buttons */
|
||||
export const addRemoveLevelButtonEventListenerAll = () => {
|
||||
export const addRemoveLevelButtonEventListenerAll = (): void => {
|
||||
const removeButtons = document.querySelectorAll(`.${REMOVE_LEVEL_BUTTON}`);
|
||||
removeButtons.forEach(button =>
|
||||
button.addEventListener('click', removeLevel),
|
||||
removeButtons.forEach((button) =>
|
||||
button.addEventListener("click", removeLevel)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -67,20 +67,20 @@ export const addRemoveLevelButtonEventListenerAll = () => {
|
||||
* Generate Remove button HTML. On-click handler should be added
|
||||
* seprately
|
||||
*/
|
||||
export const getRemoveButtonHTML = (level: number) => {
|
||||
export const getRemoveButtonHTML = (level: number): HTMLLabelElement => {
|
||||
log.log(`[generating HTML getHtml]level: ${level}`);
|
||||
|
||||
const btn = document.createElement('input');
|
||||
const btn = document.createElement("input");
|
||||
btn.className = CONST.REMOVE_LEVEL_BUTTON_CLASS;
|
||||
btn.type = 'button';
|
||||
btn.type = "button";
|
||||
const id = `${CONST.REMOVE_LEVEL_BUTTON_ID_WITHOUT_LEVEL}${level}`;
|
||||
btn.name = id;
|
||||
btn.id = id;
|
||||
btn.value = 'x';
|
||||
btn.value = "x";
|
||||
|
||||
const removeLabel = document.createElement('label');
|
||||
const removeLabel = document.createElement("label");
|
||||
removeLabel.className = CONST.REMOVE_LEVEL_LABEL_CLASS;
|
||||
const removeLabelText = document.createTextNode('RemoveLevel');
|
||||
const removeLabelText = document.createTextNode("RemoveLevel");
|
||||
removeLabel.appendChild(removeLabelText);
|
||||
removeLabel.appendChild(btn);
|
||||
removeLabel.htmlFor = id;
|
||||
|
||||
Reference in New Issue
Block a user