307 | function createInput(setting, url = ""){ |
308 | const type = inputTypes[typeof setting.defaultValue]; |
309 | let input; |
310 | if (setting.options){ |
311 | input = createSelect(setting); |
312 | } |
313 | else { |
314 | if (type){ |
315 | input = type.input(setting.defaultValue, setting); |
316 | } |
317 | } |
318 | if (type){ |
319 | setting.on(function(){type.updateCallback(input, setting.get(url));}, url); |
320 | input.addEventListener("change", function(){ |
321 | const value = type.getValue(input); |
322 | if (setting.set(value, url)){ |
323 | logging.message("changed setting", setting.name, ":", value); |
324 | } |
325 | else { |
326 | type.updateCallback(input, setting.get(url)); |
327 | logging.message("setting", setting.name, "was not changed"); |
328 | } |
329 | }); |
330 | } |
331 | else if (setting.keys){ |
332 | input = createKeyInput(setting, url); |
333 | } |
334 | |
335 | if (setting.urlSpecific && url === ""){ |
336 | return createUrlSpecificInput(setting, input, type); |
337 | } |
338 | return input || document.createElement("span"); |
339 | } |