From 12e371a48170d30eaab6f4c40969d9dfb45df854 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Mon, 26 Dec 2022 22:24:26 -0300 Subject: [PATCH] Unused variable cleanup and new overmask px default Signed-off-by: Victor Seiji Hariki --- js/config.js | 3 +++ js/index.js | 26 -------------------------- js/ui/tool/dream.js | 25 +++++++++++++------------ js/ui/tool/interrogate.js | 3 +-- 4 files changed, 17 insertions(+), 40 deletions(-) diff --git a/js/config.js b/js/config.js index 6120e78..a6f7ba6 100644 --- a/js/config.js +++ b/js/config.js @@ -7,6 +7,9 @@ const config = makeReadOnly( { // Scroll Tick Limit (How much must scroll to reach next tick) wheelTickSize: 50, + + // Endpoint + api: makeReadOnly({path: "/sdapi/v1/"}), }, "config" ); diff --git a/js/index.js b/js/index.js index ace7a55..8c9505d 100644 --- a/js/index.js +++ b/js/index.js @@ -132,35 +132,9 @@ var stableDiffusionData = { }; // stuff things use -let debug = false; -var returnedImages; -var imageIndex = 0; -var tmpImgXYWH = {}; var host = ""; var url = "/sdapi/v1/"; -var endpoint = "txt2img"; -var frameX = 512; -var frameY = 512; -var drawThis = {}; const basePixelCount = 64; //64 px - ALWAYS 64 PX -var snapToGrid = true; -var backupMaskPaintCanvas; //??? -var backupMaskPaintCtx; //...? look i am bad at this -var backupMaskChunk = null; -var backupMaskX = null; -var backupMaskY = null; -var totalImagesReturned; -var overMaskPx = 0; -var drawTargets = []; // is this needed? i only draw the last one anyway... -var dropTargets = []; // uhhh yeah similar to the above but for arbitrary dropped images -var arbitraryImage; -var arbitraryImageData; -var arbitraryImageBitmap; -var arbitraryImageBase64; // seriously js cmon work with me here -var placingArbitraryImage = false; // for when the user has loaded an existing image from their computer -var marchOffset = 0; -var inProgress = false; -var marchCoords = {}; // function startup() { diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index bb3f2dc..4c2ee47 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -13,7 +13,7 @@ let generating = false; const _monitorProgress = (bb, oncheck = null) => { const minDelay = 1000; - const apiURL = `${host}${url}progress?skip_current_image=true`; + const apiURL = `${host}${config.api.path}progress?skip_current_image=true`; const expanded = {...bb}; expanded.x--; @@ -84,7 +84,7 @@ const _monitorProgress = (bb, oncheck = null) => { * @returns {Promise} */ const _dream = async (endpoint, request) => { - const apiURL = `${host}${url}${endpoint}`; + const apiURL = `${host}${config.api.path}${endpoint}`; // Debugging is enabled if (global.debug) { @@ -380,7 +380,7 @@ const _generate = async (endpoint, request, bb, options = {}) => { interruptButton.classList.add("dream-stop-btn"); interruptButton.textContent = "Interrupt"; interruptButton.addEventListener("click", () => { - fetch(`${host}${url}interrupt`, {method: "POST"}); + fetch(`${host}${config.api.path}interrupt`, {method: "POST"}); interruptButton.disabled = true; }); const marchingOptions = {}; @@ -400,13 +400,13 @@ const _generate = async (endpoint, request, bb, options = {}) => { if (lastProgress < nextCP && data.progress >= nextCP) { nextCP += options.drawEvery; - fetch(`${host}${url}progress?skip_current_image=false`).then( - async (response) => { - if (stopDrawingStatus) return; - const imagedata = await response.json(); - redraw(imagedata.current_image); - } - ); + fetch( + `${host}${config.api.path}progress?skip_current_image=false` + ).then(async (response) => { + if (stopDrawingStatus) return; + const imagedata = await response.json(); + redraw(imagedata.current_image); + }); } lastProgress = data.progress; }); @@ -1191,7 +1191,7 @@ const dreamTool = () => state.invertMask = false; state.keepUnmasked = true; state.keepUnmaskedBlur = 8; - state.overMaskPx = 0; + state.overMaskPx = 20; state.preserveMasks = false; state.erasePrevCursor = () => @@ -2022,7 +2022,8 @@ const img2imgTool = () => window.onbeforeunload = async () => { // Stop current generation on page close - if (generating) await fetch(`${host}${url}interrupt`, {method: "POST"}); + if (generating) + await fetch(`${host}${config.api.path}interrupt`, {method: "POST"}); }; const sendSeed = (seed) => { diff --git a/js/ui/tool/interrogate.js b/js/ui/tool/interrogate.js index 4224645..2090c03 100644 --- a/js/ui/tool/interrogate.js +++ b/js/ui/tool/interrogate.js @@ -33,7 +33,6 @@ const interrogateTool = () => state.snapToGrid = true; state.invertMask = false; - state.overMaskPx = 0; state.block_res_change = true; state.erasePrevReticle = () => ovLayer.clear(); @@ -163,7 +162,7 @@ const interrogate_callback = async (evn, state) => { * @returns {Promise} */ const _interrogate = async (request) => { - const apiURL = `${host}${url}` + "interrogate"; + const apiURL = `${host}${config.api.path}interrogate`; /** @type {StableDiffusionResponse} */ let data = null;