diff --git a/src/js/rulesAssistantOptions.js b/src/js/rulesAssistantOptions.js index caef5a7ec8f548ac6b40ea165c036111f6c3f0ce..d1f19b35858359d1829b953a8c4d3eead0b3366e 100644 --- a/src/js/rulesAssistantOptions.js +++ b/src/js/rulesAssistantOptions.js @@ -7,6 +7,7 @@ window.rulesAssistantOptions = (function() { "use strict"; + const noDefaultSetting = {value: "!NDS!", text: "no default setting"}; let V; /** @type {App.RA.Rule} */ let current_rule; @@ -192,7 +193,7 @@ window.rulesAssistantOptions = (function() { /** @private */ this._capitalizeShortcuts = capitalizeShortcuts; if (allowNullValue) { - this.appendChild(new ListItem("No default setting", null)); + this.appendChild(new ListItem(capFirstChar(noDefaultSetting.text), null)); } data.forEach(item => this.appendChild(this._createListItem(...item))); } @@ -305,15 +306,15 @@ window.rulesAssistantOptions = (function() { // now add options if (allowNullValue) { let nullOpt = document.createElement("option"); - nullOpt.value = null; - nullOpt.text = "No default setting"; + nullOpt.value = noDefaultSetting.value; + nullOpt.text = capFirstChar(noDefaultSetting.text); this.value.appendChild(nullOpt); } for (const dr of data) { - const dv = Array.isArray(dr) && dr.length > 1 ? [dr[1], dr[0]] : [dr, dr]; + const dv = Array.isArray(dr) ? (dr.length > 1 ? [dr[1], dr[0]] : [dr[0], dr[0]]) : [dr, dr]; let opt = document.createElement("option"); opt.value = dv[0]; - opt.text = dv[1]; + opt.text = capFirstChar(dv[1]); this.value.appendChild(opt); } this.value.onchange = () => { @@ -323,11 +324,11 @@ window.rulesAssistantOptions = (function() { } getData() { - return this.value.value; + return this.value.value === noDefaultSetting.value ? null : this.value.value; } setValue(what) { - this.value.value = what; + this.value.value = what === null ? noDefaultSetting.value : what; } inputEdited() { @@ -346,7 +347,7 @@ window.rulesAssistantOptions = (function() { super(prefix, data, allowNullValue, textinput, capitalizeShortcuts); this.values = new Map(); if (allowNullValue) { - this.values.set(null, "no default setting"); + this.values.set(noDefaultSetting.value, noDefaultSetting.text); } data.forEach(d => { if (Array.isArray(d) && d.length > 1) { @@ -714,7 +715,7 @@ window.rulesAssistantOptions = (function() { render(element) { const greeting = document.createElement("p"); - greeting.innerHTML = `<em>${properTitle()}, I will review your slaves and make changes that will have a beneficial effect. Apologies, ${properTitle()}, but this function is... not fully complete. It may have some serious limitations. Please use the 'no default setting' option to identify areas I should not address.</em>`; + greeting.innerHTML = `<em>${properTitle()}, I will review your slaves and make changes that will have a beneficial effect. Apologies, ${properTitle()}, but this function is... not fully complete. It may have some serious limitations. Please use the '${noDefaultSetting.text}' option to identify areas I should not address.</em>`; element.appendChild(greeting); return element; } @@ -1844,7 +1845,7 @@ window.rulesAssistantOptions = (function() { super(); this.sublists = []; const pairs = [ - ["No default setting", () => this.nds()], + [capFirstChar(noDefaultSetting.text), () => this.nds()], ["Girlish figure", () => this.girlish()], ["Stacked figure", () => this.stacked()], ["Huge but functional", () => this.huge()], @@ -2237,7 +2238,7 @@ window.rulesAssistantOptions = (function() { constructor() { // TODO: better data structure? const pairs = [ - ["No default setting", {cum: null, milk: null}], + [capFirstChar(noDefaultSetting.text), {cum: null, milk: null}], ["Normal Diet", {cum: 0, milk: 0}], ["Cum Added", {cum: 1, milk: 0}], ["Milk Added", {cum: 0, milk: 1}], @@ -2509,7 +2510,7 @@ window.rulesAssistantOptions = (function() { class LensesList extends Element { constructor() { super(current_rule.set.eyeColor); - this.appendChild(new OptionsItem("No default setting", () => this.setValue(null))); + this.appendChild(new OptionsItem(capFirstChar(noDefaultSetting.text), () => this.setValue(null))); this.colorlist = new LensesColorList(); this.shapelist = new LensesShapeList(); this.appendChild(this.colorlist);