update loopback script to include interrogator "telephone" option, "remove" user script saving because i don't think JS can even silently write to one of its own files.... prove me wrong? please?
This commit is contained in:
parent
0e54435f4c
commit
eb8946266f
4 changed files with 80 additions and 52 deletions
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"defaultScripts": {
|
"defaultScripts": {
|
||||||
"Loopback": {
|
"Loopback": {
|
||||||
"titleText": "IMG2IMG ONLY\n\nParams:\nloops (int) //def: 8\ndenoising_strength_change_factor (decimal, 0.90-1.10) //def: 0.99",
|
"titleText": "IMG2IMG ONLY\n\nParams:\nloops (int) //def: 8\ndenoising_strength_change_factor (decimal, 0.90-1.10) //def: 0.99\nappend_interrogation (enum, str: [\"None\",\"CLIP\",\"DeepBooru\"]) //def: None",
|
||||||
"scriptValues": "[8, 0.99]"
|
"scriptValues": "[8, 0.99, \"None\"]"
|
||||||
},
|
},
|
||||||
"Prompt matrix": {
|
"Prompt matrix": {
|
||||||
"titleText": "Params:\nput_at_start (bool): expect pipe (|) delimited options at start of prompt //def: false\ndifferent_seeds (bool): use different seeds for each picture //def: false\nprompt_type (enum, str: [\"positive\",\"negative\"]) //def: \"positive\"\nvariations_delimiter (enum, str [\"comma\", \"space\"] //def: \"comma\"\nmargin_size (int): px margin value //def: 2",
|
"titleText": "Params:\nput_at_start (bool): expect pipe (|) delimited options at start of prompt //def: false\ndifferent_seeds (bool): use different seeds for each picture //def: false\nprompt_type (enum, str: [\"positive\",\"negative\"]) //def: \"positive\"\nvariations_delimiter (enum, str [\"comma\", \"space\"] //def: \"comma\"\nmargin_size (int): px margin value //def: 2",
|
||||||
|
|
15
index.html
15
index.html
|
@ -374,24 +374,29 @@
|
||||||
<!-- <option id="no_selected_script" value="">Select a script...</option>
|
<!-- <option id="no_selected_script" value="">Select a script...</option>
|
||||||
<option id="custom" value="custom">Custom</option> -->
|
<option id="custom" value="custom">Custom</option> -->
|
||||||
</select>
|
</select>
|
||||||
<button
|
<!-- <button
|
||||||
id="save-custom-script"
|
id="save-custom-script"
|
||||||
disabled="disabled"
|
disabled="disabled"
|
||||||
title="Save custom script"
|
title="Save custom script"
|
||||||
onclick="saveCustomScript()">
|
onclick="saveCustomScript()">
|
||||||
<image src="./res/icons/save.svg" width="60%"></image>
|
<image src="./res/icons/save.svg" width="60%"></image>
|
||||||
</button>
|
</button> -->
|
||||||
</div>
|
</div>
|
||||||
<div id="script-name" class="script-name">
|
<div id="script-name" class="script-name">
|
||||||
<label for="script-name-input">Script Name:</label>
|
<label for="scrip-name-input">Script Name:</label>
|
||||||
<br />
|
<br />
|
||||||
<input id="script-name-input" disabled="disabled" />
|
<input
|
||||||
|
id="script-name-input"
|
||||||
|
disabled="disabled"
|
||||||
|
onfocusout="storeUserscriptVal(event, 'name')" />
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
<div id="script-args" class="script-args">
|
<div id="script-args" class="script-args">
|
||||||
<label for="script-args-input">Script Args List:</label>
|
<label for="script-args-input">Script Args List:</label>
|
||||||
<br />
|
<br />
|
||||||
<textarea id="script-args-input"></textarea>
|
<textarea
|
||||||
|
id="script-args-input"
|
||||||
|
onfocusout="storeUserscriptVal(event, 'args')"></textarea>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
111
js/index.js
111
js/index.js
|
@ -1406,7 +1406,7 @@ function refreshScripts() {
|
||||||
selector.innerHTML = "";
|
selector.innerHTML = "";
|
||||||
createBaseScriptOptions();
|
createBaseScriptOptions();
|
||||||
loadDefaultScripts();
|
loadDefaultScripts();
|
||||||
loadUserScripts();
|
// loadUserScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBaseScriptOptions() {
|
function createBaseScriptOptions() {
|
||||||
|
@ -1433,41 +1433,48 @@ async function loadDefaultScripts() {
|
||||||
selector.appendChild(opt);
|
selector.appendChild(opt);
|
||||||
}
|
}
|
||||||
defaultScripts = json;
|
defaultScripts = json;
|
||||||
//return json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadUserScripts() {
|
// async function loadUserScripts() {
|
||||||
selector = document.getElementById("script-selector");
|
// selector = document.getElementById("script-selector");
|
||||||
const response = await fetch("./userdefinedscripts.json");
|
// const response = await fetch("./userdefinedscripts.json");
|
||||||
const json = await response.json();
|
// const json = await response.json();
|
||||||
for (const key in json.userScripts) {
|
// for (const key in json.userScripts) {
|
||||||
var opt = document.createElement("option");
|
// var opt = document.createElement("option");
|
||||||
opt.value = opt.innerHTML = key;
|
// opt.value = opt.innerHTML = key;
|
||||||
selector.appendChild(opt);
|
// selector.appendChild(opt);
|
||||||
}
|
// }
|
||||||
userScripts = json;
|
// userScripts = json;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function changeScript(event) {
|
function changeScript(event) {
|
||||||
let enable = () => {
|
let enable = () => {
|
||||||
scriptName.disabled = false;
|
scriptName.disabled = false;
|
||||||
saveScriptButton.disabled = false;
|
// saveScriptButton.disabled = false;
|
||||||
};
|
};
|
||||||
let disable = () => {
|
let disable = () => {
|
||||||
scriptName.disabled = true;
|
scriptName.disabled = true;
|
||||||
saveScriptButton.disabled = true;
|
// saveScriptButton.disabled = true;
|
||||||
};
|
};
|
||||||
let selected = event.target.value;
|
let selected = event.target.value;
|
||||||
let scriptName = document.getElementById("script-name-input");
|
let scriptName = document.getElementById("script-name-input");
|
||||||
let scriptArgs = document.getElementById("script-args-input");
|
let scriptArgs = document.getElementById("script-args-input");
|
||||||
let saveScriptButton = document.getElementById("save-custom-script");
|
// let saveScriptButton = document.getElementById("save-custom-script");
|
||||||
scriptName.value = selected;
|
scriptName.value = selected;
|
||||||
scriptArgs.title = "";
|
scriptArgs.title = "";
|
||||||
disable();
|
disable();
|
||||||
switch (selected) {
|
switch (selected) {
|
||||||
case "custom": {
|
case "custom": {
|
||||||
scriptName.value = "";
|
let _script_name_input =
|
||||||
scriptArgs.value = "[]";
|
localStorage.getItem("openoutpaint/script_name_input") === null
|
||||||
|
? ""
|
||||||
|
: localStorage.getItem("openoutpaint/script_name_input");
|
||||||
|
let _script_args_input =
|
||||||
|
localStorage.getItem("openoutpaint/script_args_input") === null
|
||||||
|
? "[]"
|
||||||
|
: localStorage.getItem("openoutpaint/script_args_input");
|
||||||
|
scriptName.value = _script_name_input;
|
||||||
|
scriptArgs.value = _script_args_input;
|
||||||
scriptArgs.title = "";
|
scriptArgs.title = "";
|
||||||
enable();
|
enable();
|
||||||
break;
|
break;
|
||||||
|
@ -1484,44 +1491,58 @@ function changeScript(event) {
|
||||||
scriptArgs.value = defaultScripts.defaultScripts[selected].scriptValues;
|
scriptArgs.value = defaultScripts.defaultScripts[selected].scriptValues;
|
||||||
scriptArgs.title = defaultScripts.defaultScripts[selected].titleText;
|
scriptArgs.title = defaultScripts.defaultScripts[selected].titleText;
|
||||||
}
|
}
|
||||||
|
// FURTHER TODO see if this is even plausible as i don't think JS can arbitrarily save data to files without downloading
|
||||||
|
|
||||||
// if not found, check user scripts
|
// if not found, check user scripts
|
||||||
// TODO yknow what check userscripts first; if customizations have been made load those instead of defaults, i'm too stupid to do that right now
|
// TODO yknow what check userscripts first; if customizations have been made load those instead of defaults, i'm too stupid to do that right now
|
||||||
else if (selected in userScripts.userScripts) {
|
// else if (selected in userScripts.userScripts) {
|
||||||
scriptArgs.value = userScripts.userScripts[selected].scriptValues;
|
// scriptArgs.value = userScripts.userScripts[selected].scriptValues;
|
||||||
enable();
|
// enable();
|
||||||
}
|
// }
|
||||||
// if not found, wtf
|
// if not found, wtf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveCustomScript() {
|
// async function saveCustomScript() {
|
||||||
let selector = document.getElementById("script-name-input");
|
// let selector = document.getElementById("script-name-input");
|
||||||
let selected = selector.value;
|
// let selected = selector.value;
|
||||||
let args = document.getElementById("script-args-input").value;
|
// let args = document.getElementById("script-args-input").value;
|
||||||
if (selected.trim() != "") {
|
// if (selected.trim() != "") {
|
||||||
if (selected in userScripts.userScripts) {
|
// if (selected in userScripts.userScripts) {
|
||||||
userScripts.userScripts[selected].scriptValues = args;
|
// userScripts.userScripts[selected].scriptValues = args;
|
||||||
} else {
|
// } else {
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
function togglePix2PixImgCfg(value) {
|
function togglePix2PixImgCfg(value) {
|
||||||
// super hacky
|
// super hacky
|
||||||
// actually doesn't work at all yet so i'm leaving it here to taunt and remind me of my failures
|
// actually doesn't work at all yet so i'm leaving it here to taunt and remind me of my failures
|
||||||
|
// try {
|
||||||
|
// if (value.toLowerCase().includes("pix2pix")) {
|
||||||
|
// document
|
||||||
|
// .querySelector(".instruct-pix2pix-img-cfg")
|
||||||
|
// .classList.remove("invisible");
|
||||||
|
// } else {
|
||||||
|
// document
|
||||||
|
// .querySelector(".instruct-pix2pix-img-cfg")
|
||||||
|
// .classList.add("invisible");
|
||||||
|
// }
|
||||||
|
// } catch (e) {
|
||||||
|
// // highly likely not currently using img2img tool, do nothing
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
function storeUserscriptVal(evt, type) {
|
||||||
if (value.toLowerCase().includes("pix2pix")) {
|
let currentScript = document.getElementById("script-selector").value;
|
||||||
document
|
if (currentScript === "custom") {
|
||||||
.querySelector(".instruct-pix2pix-img-cfg")
|
console.log(type);
|
||||||
.classList.remove("invisible");
|
console.log(evt);
|
||||||
} else {
|
let val = (currentScript = document.getElementById(
|
||||||
document
|
"script-" + type + "-input"
|
||||||
.querySelector(".instruct-pix2pix-img-cfg")
|
).value);
|
||||||
.classList.add("invisible");
|
|
||||||
}
|
localStorage.setItem("openoutpaint/script_" + type + "_input", val);
|
||||||
} catch (e) {
|
|
||||||
// highly likely not currently using img2img tool, do nothing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,6 +519,7 @@ const stampTool = () =>
|
||||||
const {checkbox: flipCheckbox, setValue: flipSetValue} =
|
const {checkbox: flipCheckbox, setValue: flipSetValue} =
|
||||||
_toolbar_input.checkbox(
|
_toolbar_input.checkbox(
|
||||||
state,
|
state,
|
||||||
|
"openoutpaint/stamp-flip",
|
||||||
"flipStamp",
|
"flipStamp",
|
||||||
"Flip Stamp",
|
"Flip Stamp",
|
||||||
"icon-flip-vertical"
|
"icon-flip-vertical"
|
||||||
|
@ -530,6 +531,7 @@ const stampTool = () =>
|
||||||
const {checkbox: mirrorCheckbox, setValue: mirrorSetValue} =
|
const {checkbox: mirrorCheckbox, setValue: mirrorSetValue} =
|
||||||
_toolbar_input.checkbox(
|
_toolbar_input.checkbox(
|
||||||
state,
|
state,
|
||||||
|
"openoutpaint/stamp-mirror",
|
||||||
"mirrorStamp",
|
"mirrorStamp",
|
||||||
"Mirror Stamp",
|
"Mirror Stamp",
|
||||||
"icon-flip-horizontal"
|
"icon-flip-horizontal"
|
||||||
|
|
Loading…
Reference in a new issue