mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
xo --fix
This commit is contained in:
@ -34,7 +34,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
fileExists(songInfoProviderPath, require(songInfoProviderPath));
|
fileExists(songInfoProviderPath, require(songInfoProviderPath));
|
||||||
|
|
||||||
// inject front logger
|
// inject front logger
|
||||||
const loggerPath = path.join(__dirname, "providers", "frontLogger.js")
|
const loggerPath = path.join(__dirname, "providers", "front-logger.js")
|
||||||
fileExists(loggerPath, require(loggerPath));
|
fileExists(loggerPath, require(loggerPath));
|
||||||
|
|
||||||
// Add action for reloading
|
// Add action for reloading
|
||||||
|
|||||||
@ -8,7 +8,7 @@ const path = require("path");
|
|||||||
const DEFAULT_WIDTH = 370;
|
const DEFAULT_WIDTH = 370;
|
||||||
const DEFAULT_COUNTER_WIDTH = 300;
|
const DEFAULT_COUNTER_WIDTH = 300;
|
||||||
const DEFAULT_HEIGHT = 160;
|
const DEFAULT_HEIGHT = 160;
|
||||||
const DEFAULT_COUNTER_HEIGHT= 150;
|
const DEFAULT_COUNTER_HEIGHT = 150;
|
||||||
|
|
||||||
function electronPrompt(options, parentWindow) {
|
function electronPrompt(options, parentWindow) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -130,21 +130,21 @@ function electronPrompt(options, parentWindow) {
|
|||||||
event,
|
event,
|
||||||
errorCode,
|
errorCode,
|
||||||
errorDescription,
|
errorDescription,
|
||||||
validatedURL,
|
validatedURL
|
||||||
) => {
|
) => {
|
||||||
const log = {
|
const log = {
|
||||||
error: "did-fail-load",
|
error: "did-fail-load",
|
||||||
errorCode,
|
errorCode,
|
||||||
errorDescription,
|
errorDescription,
|
||||||
validatedURL,
|
validatedURL
|
||||||
};
|
};
|
||||||
reject(new Error("prompt.html did-fail-load, log:\n", + log.toString()));
|
reject(new Error("prompt.html did-fail-load, log:\n" + log.toString()));
|
||||||
});
|
});
|
||||||
|
|
||||||
const promptUrl = url.format({
|
const promptUrl = url.format({
|
||||||
protocol: 'file',
|
protocol: "file",
|
||||||
slashes: true,
|
slashes: true,
|
||||||
pathname: path.join(__dirname, 'page', 'prompt.html'),
|
pathname: path.join(__dirname, "page", "prompt.html"),
|
||||||
hash: id
|
hash: id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,9 +4,11 @@ const { ipcRenderer } = require("electron");
|
|||||||
let promptId = null;
|
let promptId = null;
|
||||||
let promptOptions = null;
|
let promptOptions = null;
|
||||||
|
|
||||||
function $(selector) { return document.querySelector(selector) }
|
function $(selector) {
|
||||||
|
return document.querySelector(selector);
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', promptRegister);
|
document.addEventListener("DOMContentLoaded", promptRegister);
|
||||||
|
|
||||||
function promptRegister() {
|
function promptRegister() {
|
||||||
//get custom session id
|
//get custom session id
|
||||||
@ -54,7 +56,6 @@ function promptRegister() {
|
|||||||
$("#form").addEventListener("submit", promptSubmit);
|
$("#form").addEventListener("submit", promptSubmit);
|
||||||
$("#cancel").addEventListener("click", promptCancel);
|
$("#cancel").addEventListener("click", promptCancel);
|
||||||
|
|
||||||
|
|
||||||
//create input/select
|
//create input/select
|
||||||
const dataContainerElement = $("#data-container");
|
const dataContainerElement = $("#data-container");
|
||||||
let dataElement;
|
let dataElement;
|
||||||
@ -70,19 +71,20 @@ function promptRegister() {
|
|||||||
default:
|
default:
|
||||||
return promptError(`Unhandled input type '${promptOptions.type}'`);
|
return promptError(`Unhandled input type '${promptOptions.type}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (promptOptions.type === "counter") {
|
if (promptOptions.type === "counter") {
|
||||||
dataElement.style.width = "unset";
|
dataElement.style.width = "unset";
|
||||||
dataElement.style["text-align"] = "center";
|
dataElement.style["text-align"] = "center";
|
||||||
//dataElement.style["min-height"] = "1.5em";
|
dataContainerElement.append(createMinusButton(dataElement));
|
||||||
dataContainerElement.append(createMinus(dataElement));
|
|
||||||
dataContainerElement.append(dataElement);
|
dataContainerElement.append(dataElement);
|
||||||
dataContainerElement.append(createPlus(dataElement));
|
dataContainerElement.append(createPlusButton(dataElement));
|
||||||
} else {
|
} else {
|
||||||
dataContainerElement.append(dataElement);
|
dataContainerElement.append(dataElement);
|
||||||
}
|
}
|
||||||
dataElement.setAttribute("id", "data");
|
|
||||||
|
|
||||||
|
dataElement.setAttribute("id", "data");
|
||||||
dataElement.focus();
|
dataElement.focus();
|
||||||
|
|
||||||
if (promptOptions.type === "input" || promptOptions.type === "counter") {
|
if (promptOptions.type === "input" || promptOptions.type === "counter") {
|
||||||
dataElement.select();
|
dataElement.select();
|
||||||
}
|
}
|
||||||
@ -100,7 +102,8 @@ function promptRegister() {
|
|||||||
|
|
||||||
window.addEventListener("error", error => {
|
window.addEventListener("error", error => {
|
||||||
if (promptId) {
|
if (promptId) {
|
||||||
promptError("An error has occured on the prompt window: \n" + JSON.stringify(error, ["message", "arguments", "type", "name"])
|
promptError("An error has occured on the prompt window: \n" +
|
||||||
|
JSON.stringify(error, ["message", "arguments", "type", "name"])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -209,35 +212,39 @@ function promptCreateSelect() {
|
|||||||
return dataElement;
|
return dataElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMinus(dataElement) {
|
function createMinusButton(dataElement) {
|
||||||
const minus = document.createElement("span");
|
const minusBtn = document.createElement("span");
|
||||||
minus.textContent = "-";
|
minusBtn.textContent = "-";
|
||||||
minus.classList.add("minus");
|
minusBtn.classList.add("minus");
|
||||||
minus.onmousedown = () => {
|
minusBtn.onmousedown = () => {
|
||||||
dataElement.value = validateCounterInput(parseInt(dataElement.value) - 1);
|
dataElement.value = validateCounterInput(parseInt(dataElement.value) - 1);
|
||||||
};
|
};
|
||||||
return minus;
|
return minusBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPlus(dataElement) {
|
function createPlusButton(dataElement) {
|
||||||
const plus = document.createElement("span");
|
const plusBtn = document.createElement("span");
|
||||||
plus.textContent = "+";
|
plusBtn.textContent = "+";
|
||||||
plus.classList.add("plus");
|
plusBtn.classList.add("plus");
|
||||||
plus.onmousedown = () => {
|
plusBtn.onmousedown = () => {
|
||||||
dataElement.value = validateCounterInput(parseInt(dataElement.value) + 1);
|
dataElement.value = validateCounterInput(parseInt(dataElement.value) + 1);
|
||||||
};
|
};
|
||||||
return plus;
|
|
||||||
|
return plusBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
//validate counter
|
//validate counter
|
||||||
function validateCounterInput(input) {
|
function validateCounterInput(input) {
|
||||||
const min = promptOptions.counterOptions?.minimum,
|
const min = promptOptions.counterOptions?.minimum;
|
||||||
max = promptOptions.counterOptions?.maximum;
|
const max = promptOptions.counterOptions?.maximum;
|
||||||
|
|
||||||
if (min !== undefined && input < min) {
|
if (min !== undefined && input < min) {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max !== undefined && input > max) {
|
if (max !== undefined && input > max) {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user