*
* ***** 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() { }
},
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;
}
var gCurrentImageData;
function Startup() {
- updateIterMenu();
- updateAlgoMenu();
- updatePaletteMenu();
gMbrotBundle = document.getElementById("mbrotBundle");
document.getElementById("statusLabel").value = gMbrotBundle.getString("statusEmpty");
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 {
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"]) {
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() {
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
<?xml-stylesheet href="chrome://mandelbrot/skin/" type="text/css"?>
<!DOCTYPE page [
- <!ENTITY % mandelOverlayDTD SYSTEM "chrome://mandelbrot/locale/mandelbrot-overlay.dtd">
- %mandelOverlayDTD;
- <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
- %brandDTD;
<!ENTITY % mandelbrotDTD SYSTEM "chrome://mandelbrot/locale/mandelbrot.dtd">
%mandelbrotDTD;
]>
<toolbar class="chromeclass-toolbar"
id="mandelbrotToolbar"
align="center">
- <toolbarbutton id="fileDraw" label="&fileDraw.label;" oncommand="drawImage();"/>
- <toolbarbutton id="fileSave" label="&fileSave.label;" oncommand="saveImage();"/>
+ <toolbarbutton id="fileDraw" label="&toolbarDraw.label;" oncommand="drawImage();"/>
+ <toolbarbutton id="fileSave" label="&toolbarSave.label;" oncommand="saveImage();"/>
<toolbarbutton id="bookmarkMenu"
type="menu"
class="tabbable"
<menuseparator id="bookmarkSeparator"/>
</menupopup>
</toolbarbutton>
- <toolbarbutton id="prefMenu"
- type="menu"
- class="tabbable"
- label="&prefMenu.label;">
- <menupopup id="menu_prefPopup">
- <menu id="iterMenu" label="&iterMenu.label;">
- <menupopup id="menu_iterPopup" onpopupshowing="updateIterMenu();" oncommand="setIter(event.target.value);">
- <menuitem type="radio" name="iter" value="50" label="&iter50.label;"/>
- <menuitem type="radio" name="iter" value="100" label="&iter100.label;"/>
- <menuitem type="radio" name="iter" value="500" label="&iter500.label;"/>
- <menuitem type="radio" name="iter" value="1000" label="&iter1000.label;"/>
- </menupopup>
- </menu>
- <menu id="colorMenu" label="&colorMenu.label;">
- <menupopup id="menu_palettePopup" onpopupshowing="updatePaletteMenu();" oncommand="setPalette(event.target.value);">
- <menuitem type="radio" name="palette" value="bw" label="&colorBW.label;"/>
- <menuitem type="radio" name="palette" value="kairo" label="&colorKairo.label;"/>
- <menuitem type="radio" name="palette" value="rainbow-linear1" label="&colorRBLin1.label;"/>
- <menuitem type="radio" name="palette" value="rainbow-squared1" label="&colorRBSq1.label;"/>
- <menuitem type="radio" name="palette" value="rainbow-linear2" label="&colorRBLin2.label;"/>
- <menuitem type="radio" name="palette" value="rainbow-squared2" label="&colorRBSq2.label;"/>
- </menupopup>
- </menu>
- <menuitem id="imgSettings" label="&imgSettings.label;" oncommand="imgSettings();"/>
- </menupopup>
- </toolbarbutton>
- <toolbarbutton id="debugMenu"
- type="menu"
- class="tabbable"
- label="&debugMenu.label;">
- <menupopup id="menu_debugPopup" onpopupshowing="updateDebugMenu();">
- <menuitem type="checkbox" id="jitEnabled" label="&tracejitEnabled.label;" oncommand="toggleJITState(event.target, '');" hidden="true"/>
- <menuitem type="checkbox" id="tracejitEnabled" label="&tracejitEnabled.label;" oncommand="toggleJITState(event.target, 'trace');"/>
- <menuitem type="checkbox" id="methodjitEnabled" label="&methodjitEnabled.label;" oncommand="toggleJITState(event.target, 'method');"/>
- <menu id="algoMenu" label="&algoMenu.label;">
- <menupopup id="menu_algoPopup" onpopupshowing="updateAlgoMenu();" oncommand="setAlgorithm(event.target.value);">
- <menuitem type="radio" name="algorithm" value="numeric" label="&algoNumeric.label;"/>
- <menuitem type="radio" name="algorithm" value="oo" label="&algoOO.label;"/>
- </menupopup>
- </menu>
- </menupopup>
- </toolbarbutton>
+ <toolbarbutton id="imgSettings" label="&imgSettings.label;" oncommand="imgSettings();"/>
</toolbar>
</toolbox>
<panel id="imgSettingsPanel"
<groupbox>
<caption label="&options.title;"/>
- <hbox align="center">
- <checkbox id="is_syncProp"
- label="&syncProp.label;"
- onclick="checkProportions();"/>
+ <hbox>
+ <vbox>
+ <label value="&colorList.label;" control="colorList"/>
+ <menulist id="colorList">
+ <menupopup oncommand="setPalette(event.target.value);">
+ <menuitem value="bw" label="&colorBW.label;"/>
+ <menuitem value="kairo" label="&colorKairo.label;"/>
+ <menuitem value="rainbow-linear1" label="&colorRBLin1.label;"/>
+ <menuitem value="rainbow-squared1" label="&colorRBSq1.label;"/>
+ <menuitem value="rainbow-linear2" label="&colorRBLin2.label;"/>
+ <menuitem value="rainbow-squared2" label="&colorRBSq2.label;"/>
+ </menupopup>
+ </menulist>
+ <label value="&algoList.label;" control="algoList"/>
+ <menulist id="algoList">
+ <menupopup oncommand="setAlgorithm(event.target.value);">
+ <menuitem value="numeric" label="&algoNumeric.label;"/>
+ <menuitem value="oo" label="&algoOO.label;"/>
+ </menupopup>
+ </menulist>
+ </vbox>
+ <vbox>
+ <label value="&iterList.label;" control="iterList"/>
+ <menulist id="iterList">
+ <menupopup oncommand="setIter(event.target.value);">
+ <menuitem value="50" label="&iter50.label;"/>
+ <menuitem value="100" label="&iter100.label;"/>
+ <menuitem value="500" label="&iter500.label;"/>
+ <menuitem value="1000" label="&iter1000.label;"/>
+ </menupopup>
+ </menulist>
+ <hbox align="center">
+ <checkbox id="is_syncProp"
+ label="&syncProp.label;"
+ onclick="checkProportions();"/>
+ </hbox>
+ </vbox>
</hbox>
</groupbox>
</hbox>
<stack>
<html:canvas id="mbrotImage" width="300" height="300">
</html:canvas>
- <button id="drawButton" label="&fileDraw.label;" oncommand="drawImage();"/>
+ <button id="drawButton" label="&buttonDraw.label;" oncommand="drawImage();"/>
</stack>
</hbox>
<hbox pack="end" align="end">
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
- <em:minVersion>4.0b9</em:minVersion>
+ <em:minVersion>4.0</em:minVersion>
<em:maxVersion>10.0a1</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
- <em:minVersion>2.1b1</em:minVersion>
+ <em:minVersion>2.1</em:minVersion>
<em:maxVersion>2.7a1</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>{a23983c0-fd0e-11dc-95ff-0800200c9a66}</em:id>
- <em:minVersion>4.0b3</em:minVersion>
+ <em:minVersion>4.0</em:minVersion>
<em:maxVersion>10.0a1</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
- <em:minVersion>1.9.0</em:minVersion>
+ <em:minVersion>2.0</em:minVersion>
<em:maxVersion>10.0</em:maxVersion>
</Description>
</em:targetApplication>
-
- ***** END LICENSE BLOCK ***** -->
-<!ENTITY mbBrandFullName "Mandelbrot">
-<!ENTITY mbBrandShortName "Mandelbrot">
-<!ENTITY mbBrandVersion "4.0 Beta 2">
-<!ENTITY mbVendorShortName "KaiRo.at">
-
-<!ENTITY mandelbrotCmd.label "&mbVendorShortName; &mbBrandShortName;">
+<!ENTITY mandelbrotCmd.label "KaiRo.at Mandelbrot">
<!ENTITY mandelbrotCmd.accesskey "K">
-
- ***** END LICENSE BLOCK ***** -->
-<!ENTITY windowTitle "&mbVendorShortName; &mbBrandShortName; &mbBrandVersion;">
+<!ENTITY windowTitle "KaiRo.at Mandelbrot">
-<!ENTITY fileDraw.label "Draw Image">
-<!ENTITY fileSave.label "Save Image…">
+<!ENTITY toolbarDraw.label "Draw">
+<!ENTITY toolbarSave.label "Save…">
-<!ENTITY bookmarkMenu.label "Locations">
+<!ENTITY bookmarkMenu.label "Locations">
<!ENTITY bookmarkOverview.label "Overview">
-<!ENTITY bookmarkSave.label "Save Bookmark…">
+<!ENTITY bookmarkSave.label "Add Bookmark…">
-<!ENTITY prefMenu.label "Settings">
-<!ENTITY iterMenu.label "Iterations">
-<!ENTITY iter50.label "50">
-<!ENTITY iter100.label "100">
-<!ENTITY iter500.label "500">
-<!ENTITY iter1000.label "1000">
-<!ENTITY colorMenu.label "Color Palette">
-<!ENTITY colorBW.label "Black & White">
-<!ENTITY colorKairo.label "KaiRo.at">
-<!ENTITY colorRBLin1.label "Rainbow 1 Linear">
-<!ENTITY colorRBSq1.label "Rainbow 1 Squared">
-<!ENTITY colorRBLin2.label "Rainbow 2 Linear">
-<!ENTITY colorRBSq2.label "Rainbow 2 Squared">
-<!ENTITY imgSettings.label "Image Settings…">
+<!ENTITY imgSettings.label "Settings…">
-<!ENTITY debugMenu.label "Debug">
-<!ENTITY tracejitEnabled.label "Enable Tracing JIT">
-<!ENTITY methodjitEnabled.label "Enable Method JIT">
-<!ENTITY algoMenu.label "Algorithm">
-<!ENTITY algoNumeric.label "Numeric">
-<!ENTITY algoOO.label "Object-Oriented">
+<!ENTITY buttonDraw.label "Draw Image">
<!-- Image Settings panel -->
<!ENTITY imageSettings.title "Image Settings">
<!ENTITY options.title "Options">
<!ENTITY syncProp.label "Proportional">
+
+<!ENTITY iterList.label "Iterations">
+<!ENTITY iter50.label "50">
+<!ENTITY iter100.label "100">
+<!ENTITY iter500.label "500">
+<!ENTITY iter1000.label "1000">
+
+<!ENTITY colorList.label "Color Palette">
+<!ENTITY colorBW.label "Black & White">
+<!ENTITY colorKairo.label "KaiRo.at">
+<!ENTITY colorRBLin1.label "Rainbow 1 Linear">
+<!ENTITY colorRBSq1.label "Rainbow 1 Squared">
+<!ENTITY colorRBLin2.label "Rainbow 2 Linear">
+<!ENTITY colorRBSq2.label "Rainbow 2 Squared">
+
+<!ENTITY algoList.label "Algorithm">
+<!ENTITY algoNumeric.label "Numeric">
+<!ENTITY algoOO.label "Object-Oriented">
+
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// Test some basic functionality of KaiRo-Mandelbrot.
+// Test some basic functionality of KaiRo.at Mandelbrot.
Components.utils.import("resource://gre/modules/Services.jsm");
function test() {
gBrowser.addTab();
- // Open KaiRo-Mandelbrot, testing the menu item.
+ // Open KaiRo.at Mandelbrot, testing the menu item.
let menuitem = document.getElementById("tasksMenuMandelbrot") ||
document.getElementById("menu_openMandelbrot");
menuitem.click();
observe: function(aSubject, aTopic, aData) {
if (aTopic == MBROT_LOADED) {
Services.obs.removeObserver(testObs, MBROT_LOADED);
- ok(true, "KaiRo-Mandelbrot is loaded");
+ ok(true, "KaiRo.at Mandelbrot is loaded");
win = content.wrappedJSObject;
Services.obs.addObserver(testObs, TEST_DONE, false);
var testFuncs = [
function test_open_state(aWin) {
is(aWin.document.documentElement.id, "mandelbrot-page",
- "The active tab is KaiRo-Mandelbrot");
+ "The active tab is KaiRo.at Mandelbrot");
is(aWin.document.getElementById("drawButton").hidden, false,
"The draw button is not hidden");
Services.obs.notifyObservers(window, TEST_DONE, null);
function dmWindowClosedListener() {
aWin.removeEventListener("unload", dmWindowClosedListener, false);
isnot(content.document.documentElement.id, "mandelbrot-page",
- "The active tab is not KaiRo-Mandelbrot");
+ "The active tab is not KaiRo.at Mandelbrot");
Services.obs.notifyObservers(window, TEST_DONE, null);
}
aWin.addEventListener("unload", dmWindowClosedListener, false);