diff --git a/menu.js b/menu.js index 588dad7c..dddce721 100644 --- a/menu.js +++ b/menu.js @@ -149,7 +149,7 @@ const mainMenuTemplate = (win) => [ type: "checkbox", checked: !!config.get("options.proxy"), click: (item) => { - setProxy(item, win); + setProxy(item, win); } }, { @@ -322,10 +322,10 @@ function setProxy(item, win) { }, type: 'input', icon: iconPath, - customStylesheet: path.join(__dirname, "providers", "prompt", "dark-prompt.css"), + customStylesheet: "dark", }; //TODO: custom bar on prompt need testing on macOS - if(!is.macOS()) { + if (!is.macOS()) { Object.assign(options, { frame: false, customScript: path.join(__dirname, "providers", "prompt", "custom-titlebar.js"), diff --git a/providers/prompt/index.js b/providers/prompt/index.js index 009c8c7a..95babc9c 100644 --- a/providers/prompt/index.js +++ b/providers/prompt/index.js @@ -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; diff --git a/providers/prompt/page/prompt.js b/providers/prompt/page/prompt.js index b4759e2d..7f609b52 100644 --- a/providers/prompt/page/prompt.js +++ b/providers/prompt/page/prompt.js @@ -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; } diff --git a/providers/prompt/readme.md b/providers/prompt/readme.md index ec272375..a3775b8d 100644 --- a/providers/prompt/readme.md +++ b/providers/prompt/readme.md @@ -1,6 +1,6 @@ # Prompt Documentation -

Simplest Prompt: