From: Robert Kaiser Date: Sat, 15 Oct 2011 22:55:19 +0000 (+0200) Subject: finish things up for 4.0b3 X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=5fb4a082a3ed647f2f00b1050c45cd1ba8020940;p=mandelbrot.git finish things up for 4.0b3 --- diff --git a/aboutMandelbrot.js b/aboutMandelbrot.js index b52f3fc..839d009 100644 --- a/aboutMandelbrot.js +++ b/aboutMandelbrot.js @@ -35,7 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ -//Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); function AboutMandelbrot() { } @@ -50,12 +50,8 @@ AboutMandelbrot.prototype = { }, newChannel: function(aURI) { - //let channel = Services.io.newChannel("chrome://mandelbrot/content/mandelbrot-tab.xul", - // null, null); - let ios = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService); - let channel = ios.newChannel("chrome://mandelbrot/content/mandelbrot-tab.xul", - null, null); + let channel = Services.io.newChannel("chrome://mandelbrot/content/mandelbrot.xul", + null, null); channel.originalURI = aURI; return channel; } diff --git a/content/mandelbrot.js b/content/mandelbrot.js index 7fd6b6e..c1f3e54 100644 --- a/content/mandelbrot.js +++ b/content/mandelbrot.js @@ -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 diff --git a/content/mandelbrot.xul b/content/mandelbrot.xul index b397c8c..109d86e 100644 --- a/content/mandelbrot.xul +++ b/content/mandelbrot.xul @@ -41,10 +41,6 @@ - %mandelOverlayDTD; - - %brandDTD; %mandelbrotDTD; ]> @@ -72,8 +68,8 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + @@ -207,7 +195,7 @@ -