mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
lint
This commit is contained in:
@ -19,7 +19,7 @@ function electronPrompt(options, parentWindow) {
|
||||
const options_ = Object.assign(
|
||||
{
|
||||
width: options?.type === "counter" ? DEFAULT_COUNTER_WIDTH : DEFAULT_WIDTH,
|
||||
height:options?.type === "counter" ? DEFAULT_COUNTER_HEIGHT: DEFAULT_HEIGHT,
|
||||
height: options?.type === "counter" ? DEFAULT_COUNTER_HEIGHT : DEFAULT_HEIGHT,
|
||||
resizable: false,
|
||||
title: "Prompt",
|
||||
label: "Please input a value:",
|
||||
@ -28,7 +28,7 @@ function electronPrompt(options, parentWindow) {
|
||||
value: null,
|
||||
type: "input",
|
||||
selectOptions: null,
|
||||
counterOptions: {minimum: null, maximum: null, multiFire: false},
|
||||
counterOptions: { minimum: null, maximum: null, multiFire: false },
|
||||
icon: null,
|
||||
useHtmlLabel: false,
|
||||
customStylesheet: null,
|
||||
@ -44,6 +44,10 @@ function electronPrompt(options, parentWindow) {
|
||||
options_.minWidth = options?.minWidth || options?.width || options_.width;
|
||||
options_.minHeight = options?.minHeight || options?.height || options_.height;
|
||||
|
||||
if (options_.customStylesheet === "dark") {
|
||||
options_.customStylesheet = require("path").join(__dirname, "dark-prompt.css");
|
||||
}
|
||||
|
||||
if (options_.type === "counter" && (options_.counterOptions !== null && typeof options_.selectOptions !== "object")) {
|
||||
reject(new Error('"counterOptions" must be an object if specified'));
|
||||
return;
|
||||
|
||||
@ -229,17 +229,18 @@ let nextTimeoutID = null;
|
||||
function multiFire(callback, timer = { time: 500, scaleSpeed: 140, limit: 100 }, stepsArg = 1, counter = 0) {
|
||||
callback(stepsArg);
|
||||
|
||||
const nextTimeout = timer.time
|
||||
const nextTimeout = timer.time;
|
||||
|
||||
if (counter > 20) {
|
||||
counter = 0 - stepsArg;
|
||||
if (timer.limit > 1) {
|
||||
timer.limit = timer.limit / 2;
|
||||
timer.limit /= 2;
|
||||
} else {
|
||||
stepsArg *= 2;
|
||||
}
|
||||
}
|
||||
if (timer.time != timer.limit) {
|
||||
|
||||
if (timer.time !== timer.limit) {
|
||||
timer.time = timer.time > timer.limit ?
|
||||
timer.time - timer.scaleSpeed :
|
||||
timer.limit;
|
||||
@ -253,26 +254,28 @@ function multiFire(callback, timer = { time: 500, scaleSpeed: 140, limit: 100 },
|
||||
timer,
|
||||
stepsArg,
|
||||
counter + 1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function createMinusButton(dataElement) {
|
||||
function doMinus(steps) {
|
||||
dataElement.value = validateCounterInput(parseInt(dataElement.value) - steps);
|
||||
}
|
||||
|
||||
const minusBtn = document.createElement("span");
|
||||
minusBtn.textContent = "-";
|
||||
minusBtn.classList.add("minus");
|
||||
|
||||
if (promptOptions.counterOptions?.multiFire) {
|
||||
minusBtn.onmousedown = () => {
|
||||
multiFire(doMinus);
|
||||
};
|
||||
|
||||
} else {
|
||||
minusBtn.onmousedown = () => {
|
||||
doMinus();
|
||||
};
|
||||
}
|
||||
|
||||
return minusBtn;
|
||||
}
|
||||
|
||||
@ -280,9 +283,11 @@ function createPlusButton(dataElement) {
|
||||
function doPlus(steps) {
|
||||
dataElement.value = validateCounterInput(parseInt(dataElement.value) + steps);
|
||||
}
|
||||
|
||||
const plusBtn = document.createElement("span");
|
||||
plusBtn.textContent = "+";
|
||||
plusBtn.classList.add("plus");
|
||||
|
||||
if (promptOptions.counterOptions?.multiFire) {
|
||||
plusBtn.onmousedown = () => {
|
||||
multiFire(doPlus);
|
||||
@ -292,13 +297,14 @@ function createPlusButton(dataElement) {
|
||||
doPlus();
|
||||
};
|
||||
}
|
||||
|
||||
return plusBtn;
|
||||
}
|
||||
|
||||
function promptCreateCounter() {
|
||||
if (promptOptions.counterOptions?.multiFire) {
|
||||
document.onmouseup = () => {
|
||||
if (!!nextTimeoutID) {
|
||||
if (nextTimeoutID) {
|
||||
clearTimeout(nextTimeoutID)
|
||||
nextTimeoutID = null;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Prompt Documentation
|
||||
|
||||
<p align="center"><img width="482" alt="prompt-preview" src="https://user-images.githubusercontent.com/17620180/111753337-09c0c680-8897-11eb-8ce8-43de29c143bd.png"></p>
|
||||
<p align="center">Simplest Prompt:<br><img width="482" alt="prompt-preview" src="https://user-images.githubusercontent.com/17620180/111753337-09c0c680-8897-11eb-8ce8-43de29c143bd.png"></p>
|
||||
|
||||
## Usage
|
||||
```js
|
||||
@ -49,13 +49,13 @@ prompt({
|
||||
| selectOptions | (optional, object) The items for the select dropdown if using the 'select' type in the format 'value': 'display text', where the value is what will be given to the then block and the display text is what the user will see. |
|
||||
| useHtmlLabel | (optional, boolean) Whether the label should be interpreted as HTML or not. Defaults to false. |
|
||||
| width | (optional, integer) The width of the prompt window. Defaults to 370. |
|
||||
| minWidth | (optional, integer) The minimum allowed width for the prompt window. Same default value as width. |
|
||||
| minWidth | (optional, integer) The minimum allowed width for the prompt window. Default to width if specified or default_width(370). | |
|
||||
| height | (optional, integer) The height of the prompt window. Defaults to 130. |
|
||||
| minHeight | (optional, integer) The minimum allowed height for the prompt window. Same default value as height. |
|
||||
| resizable | (optional, boolean) Whether the prompt window can be resized or not (also sets useContentSize). Defaults to false. |
|
||||
| alwaysOnTop | (optional, boolean) Whether the window should always stay on top of other windows. Defaults to false |
|
||||
| icon | (optional, string) The path to an icon image to use in the title bar. Defaults to null and uses electron's icon. |
|
||||
| customStylesheet | (optional, string) The local path of a CSS file to stylize the prompt window. Defaults to null. |
|
||||
| customStylesheet | (optional, string) The local path of a CSS file to customize the style of the prompt window, you can use just "dark" to use the premade dark skin. Defaults to null. |
|
||||
| menuBarVisible | (optional, boolean) Whether to show the menubar or not. Defaults to false. |
|
||||
| skipTaskbar | (optional, boolean) Whether to show the prompt window icon in taskbar. Defaults to true. |
|
||||
| frame | (optional, boolean) Wether to create prompt with frame. Defaults to true. |
|
||||
|
||||
Reference in New Issue
Block a user