From 937cb3492022f9cd313220e2236007e5cc4aaccd Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Fri, 26 Oct 2018 11:31:04 -0400 Subject: [PATCH] Changed how editing sound URLs to be better (aka you don't need to change the URL and save within the 10 second refresh window anymore) --- CookieMonster.js | 14 ++++++++++---- src/Disp.js | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index feed6a6..52fac62 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1569,14 +1569,20 @@ CM.Disp.AddMenuPref = function(title) { input.id = CM.ConfigPrefix + config; input.className = 'option'; input.type = 'text'; - input.value = CM.Config[config]; + input.readOnly = true; + input.setAttribute('value', CM.Config[config]); input.style.width = '300px'; div.appendChild(input); div.appendChild(document.createTextNode(' ')); + var inputPrompt = document.createElement('input'); + inputPrompt.id = CM.ConfigPrefix + config + 'Prompt'; + inputPrompt.className = 'option'; + inputPrompt.type = 'text'; + inputPrompt.setAttribute('value', CM.Config[config]); var a = document.createElement('a'); a.className = 'option'; - a.onclick = function() {CM.Config[config] = l(CM.ConfigPrefix + config).value;CM.SaveConfig(CM.Config);}; - a.textContent = 'Save'; + a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Config[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.SaveConfig(CM.Config); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; + a.textContent = 'Edit'; div.appendChild(a); var label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; @@ -1598,7 +1604,7 @@ CM.Disp.AddMenuPref = function(title) { input.id = CM.ConfigPrefix + 'Color' + CM.Disp.colors[i]; input.className = 'option'; input.style.width = '65px'; - input.value = CM.Config.Colors[CM.Disp.colors[i]]; + input.setAttribute('value', CM.Config.Colors[CM.Disp.colors[i]]); div.appendChild(input); eval('var change = function() {CM.Config.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Config);}'); var jscolorpicker = new jscolor.color(input, {hash: true, caps: false, pickerZIndex: 1000000, pickerPosition: 'right', onImmediateChange: change}); diff --git a/src/Disp.js b/src/Disp.js index ed59071..98d6715 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1015,14 +1015,20 @@ CM.Disp.AddMenuPref = function(title) { input.id = CM.ConfigPrefix + config; input.className = 'option'; input.type = 'text'; - input.value = CM.Config[config]; + input.readOnly = true; + input.setAttribute('value', CM.Config[config]); input.style.width = '300px'; div.appendChild(input); div.appendChild(document.createTextNode(' ')); + var inputPrompt = document.createElement('input'); + inputPrompt.id = CM.ConfigPrefix + config + 'Prompt'; + inputPrompt.className = 'option'; + inputPrompt.type = 'text'; + inputPrompt.setAttribute('value', CM.Config[config]); var a = document.createElement('a'); a.className = 'option'; - a.onclick = function() {CM.Config[config] = l(CM.ConfigPrefix + config).value;CM.SaveConfig(CM.Config);}; - a.textContent = 'Save'; + a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Config[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.SaveConfig(CM.Config); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; + a.textContent = 'Edit'; div.appendChild(a); var label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; @@ -1044,7 +1050,7 @@ CM.Disp.AddMenuPref = function(title) { input.id = CM.ConfigPrefix + 'Color' + CM.Disp.colors[i]; input.className = 'option'; input.style.width = '65px'; - input.value = CM.Config.Colors[CM.Disp.colors[i]]; + input.setAttribute('value', CM.Config.Colors[CM.Disp.colors[i]]); div.appendChild(input); eval('var change = function() {CM.Config.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Config);}'); var jscolorpicker = new jscolor.color(input, {hash: true, caps: false, pickerZIndex: 1000000, pickerPosition: 'right', onImmediateChange: change});