finish things up for 4.0b3
[mandelbrot.git] / content / mandelbrot.js
index 7fd6b6e6f554f4f33b7dfa0e590ca55440fa8b78..c1f3e5461d33a834be720e733ca6fca82032dd25 100644 (file)
@@ -45,9 +45,6 @@ var gMbrotBundle;
 var gCurrentImageData;
 
 function Startup() {
-  updateIterMenu();
-  updateAlgoMenu();
-  updatePaletteMenu();
   gMbrotBundle = document.getElementById("mbrotBundle");
   document.getElementById("statusLabel").value = gMbrotBundle.getString("statusEmpty");
 
@@ -670,53 +667,10 @@ function saveBookmark() {
   connection.close();
 }
 
-function updateIterMenu() {
-  let currentIter = getAdjustPref("iteration_max");
-
-  let popup = document.getElementById("menu_iterPopup");
-  let item = popup.firstChild;
-  while (item) {
-    if (item.getAttribute("name") == "iter") {
-      if (item.getAttribute("value") == currentIter)
-        item.setAttribute("checked","true");
-      else
-        item.removeAttribute("checked");
-    }
-    item = item.nextSibling;
-  }
-}
-
-function setIter(aIter) {
-  Services.prefs.setIntPref("mandelbrot.iteration_max", aIter);
-}
-
-function updatePaletteMenu() {
-  let currentPalette = getAdjustPref("color_palette");
-  if (!gColorPalette || !gColorPalette.length)
-    gColorPalette = getColorPalette(currentPalette);
-
-  let popup = document.getElementById("menu_palettePopup");
-  let item = popup.firstChild;
-  while (item) {
-    if (item.getAttribute("name") == "palette") {
-      if (item.getAttribute("value") == currentPalette)
-        item.setAttribute("checked", "true");
-      else
-        item.removeAttribute("checked");
-    }
-    item = item.nextSibling;
-  }
-}
-
-function setPalette(aPaletteID) {
-  Services.prefs.setCharPref("mandelbrot.color_palette", aPaletteID);
-  gColorPalette = getColorPalette(aPaletteID);
-}
-
 function imgSettings() {
   let anchor = null;
   let position = "before_start";
-  if (document.getElementById("mandelbrotWindow").nodeName == "page") {
+  if (document.getElementById("mandelbrot-page").nodeName == "page") {
     anchor = document.getElementById("mandelbrotToolbar");
   }
   else {
@@ -726,56 +680,6 @@ function imgSettings() {
   document.getElementById("imgSettingsPanel").showPopup(anchor, position);
 }
 
-function updateDebugMenu() {
-  let scope = (document.getElementById("mandelbrotWindow").nodeName == "page") ? "content" : "chrome";
-  try {
-    // This throws in versions that don't have JaegerMonkey yet --> catch block
-    Services.prefs.getBoolPref("javascript.options.methodjit." + scope);
-
-    // We have JaegerMonkey, i.e. two prefs for trace/method JIT
-    for each (let type in ["tracejit", "methodjit"]) {
-      let jitMenuItem = document.getElementById(type + "Enabled");
-      jitMenuItem.setAttribute("checked", Services.prefs.getBoolPref("javascript.options." + type + "." + scope));
-    }
-  }
-  catch (e) {
-    // We have TraceMonkey only, i.e. one JIT pref, care only that is displayed
-    for each (let type in ["tracejit", "methodjit"])
-      document.getElementById(type + "Enabled").hidden = true;
-    let jitMenuItem = document.getElementById("jitEnabled");
-    jitMenuItem.hidden = false;
-    jitMenuItem.setAttribute("checked", Services.prefs.getBoolPref("javascript.options.jit." + scope));
-  }
-}
-
-function toggleJITState(jitMenuItem, jittype) {
-  let scope = (document.getElementById("mandelbrotWindow").nodeName == "page") ? "content" : "chrome";
-  let jitpref = "javascript.options." + jittype + "jit." + scope;
-  let jitEnabled = !Services.prefs.getBoolPref(jitpref);
-  Services.prefs.setBoolPref(jitpref, jitEnabled)
-  jitMenuItem.setAttribute("checked", jitEnabled ? "true" : "false");
-}
-
-function updateAlgoMenu() {
-  let currentAlgo = getAdjustPref("use_algorithm");
-
-  let popup = document.getElementById("menu_algoPopup");
-  let item = popup.firstChild;
-  while (item) {
-    if (item.getAttribute("name") == "algorithm") {
-      if (item.getAttribute("value") == currentAlgo)
-        item.setAttribute("checked", "true");
-      else
-        item.removeAttribute("checked");
-    }
-    item = item.nextSibling;
-  }
-}
-
-function setAlgorithm(algoID) {
-  Services.prefs.setCharPref("mandelbrot.use_algorithm", algoID);
-}
-
 function initImgSettings() {
   // Get values from prefs.
   for each (let coord in ["Cr", "Ci"]) {
@@ -797,6 +701,11 @@ function initImgSettings() {
   let context = canvas.getContext("2d");
   context.fillStyle = "rgba(255, 255, 255, 127)";
   context.fillRect(0, 0, canvas.width, canvas.height);
+
+  // Set lists to correct values.
+  updateIterList();
+  updatePaletteList();
+  updateAlgoList();
 }
 
 function closeImgSettings() {
@@ -914,6 +823,37 @@ function roundCoord(floatval) {
   return parseFloat(floatval.toFixed(10));
 }
 
+function updateIterList() {
+  let currentIter = getAdjustPref("iteration_max");
+  document.getElementById("iterList").value = currentIter;
+}
+
+function updatePaletteList() {
+  let currentPalette = getAdjustPref("color_palette");
+  if (!gColorPalette || !gColorPalette.length)
+    gColorPalette = getColorPalette(currentPalette);
+  document.getElementById("colorList").value = currentPalette;
+}
+
+function updateAlgoList() {
+  let currentAlgo = getAdjustPref("use_algorithm");
+  document.getElementById("algoList").value = currentAlgo;
+}
+
+function setIter(aIter) {
+  Services.prefs.setIntPref("mandelbrot.iteration_max", aIter);
+}
+
+function setPalette(aPaletteID) {
+  Services.prefs.setCharPref("mandelbrot.color_palette", aPaletteID);
+  gColorPalette = getColorPalette(aPaletteID);
+}
+
+function setAlgorithm(algoID) {
+  Services.prefs.setCharPref("mandelbrot.use_algorithm", algoID);
+}
+
+
 /***** helper functions from external sources *****/
 
 // function below is based on http://developer.mozilla.org/en/docs/Code_snippets:Canvas