Custom modifiers as a plugin

This commit is contained in:
patriceac 2022-11-22 19:04:20 -08:00
parent 7cbf62cf12
commit c56a2adbcb
4 changed files with 37 additions and 27 deletions

View File

@ -346,8 +346,8 @@ async function init() {
await getModels() await getModels()
await getDiskPath() await getDiskPath()
await getAppConfig() await getAppConfig()
await loadModifiers()
await loadUIPlugins() await loadUIPlugins()
await loadModifiers()
await getDevices() await getDevices()
setInterval(healthCheck, HEALTH_PING_INTERVAL * 1000) setInterval(healthCheck, HEALTH_PING_INTERVAL * 1000)

View File

@ -310,31 +310,7 @@ function saveCustomModifiers() {
} }
function loadCustomModifiers() { function loadCustomModifiers() {
let customModifiers = localStorage.getItem(CUSTOM_MODIFIERS_KEY, '') PLUGINS['MODIFIERS_LOAD'].forEach(fn=>fn.loader.call())
customModifiersTextBox.value = customModifiers
if (customModifiersGroupElement !== undefined) {
customModifiersGroupElement.remove()
}
if (customModifiers && customModifiers.trim() !== '') {
customModifiers = customModifiers.split('\n')
customModifiers = customModifiers.filter(m => m.trim() !== '')
customModifiers = customModifiers.map(function(m) {
return {
"modifier": m
}
})
let customGroup = {
'category': 'Custom Modifiers',
'modifiers': customModifiers
}
customModifiersGroupElement = createModifierGroup(customGroup, true)
createCollapsibles(customModifiersGroupElement)
}
} }
customModifiersTextBox.addEventListener('change', saveCustomModifiers) customModifiersTextBox.addEventListener('change', saveCustomModifiers)

View File

@ -24,7 +24,8 @@ const PLUGINS = {
* } * }
* }) * })
*/ */
IMAGE_INFO_BUTTONS: [] IMAGE_INFO_BUTTONS: [],
MODIFIERS_LOAD: []
} }
async function loadUIPlugins() { async function loadUIPlugins() {

View File

@ -0,0 +1,33 @@
(function() {
PLUGINS['MODIFIERS_LOAD'] = []
PLUGINS['MODIFIERS_LOAD'].push({
loader: function() {
let customModifiers = localStorage.getItem(CUSTOM_MODIFIERS_KEY, '')
customModifiersTextBox.value = customModifiers
if (customModifiersGroupElement !== undefined) {
customModifiersGroupElement.remove()
}
if (customModifiers && customModifiers.trim() !== '') {
customModifiers = customModifiers.split('\n')
customModifiers = customModifiers.filter(m => m.trim() !== '')
customModifiers = customModifiers.map(function(m) {
return {
"modifier": m
}
})
let customGroup = {
'category': 'Custom Modifiers',
'modifiers': customModifiers
}
customModifiersGroupElement = createModifierGroup(customGroup, true)
createCollapsibles(customModifiersGroupElement)
}
}
})
})()