X-Git-Url: https://git-public.kairo.at/?a=blobdiff_plain;f=xulapp%2Fchrome%2Fmandelbrot%2Fcontent%2Fmandelbrot.js;h=c0a8c1ca64331968c71a9c74056e34340952e966;hb=cd60527f1b69372c6b9bd2e50b6df285cb644fee;hp=34761cac22fe4f9779508aaf59e45715d79811b3;hpb=86e67c44355487a4cb23dc5f2700a064440e77bc;p=mandelbrot.git diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index 34761ca..c0a8c1c 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -511,10 +511,40 @@ function updateBookmarkMenu(aParent) { function callBookmark(evtarget) { if (evtarget.id == "bookmarkSave" || evtarget.id == "bookmarkSeparator") - return + return; + if (evtarget.id == "bookmarkOverview") { + adjustCoordsAndDraw(new complex(0,0), new complex(0,0)); + return; + } + + if (evtarget.getAttribute('bmRowID')) { + let iterMax = 0; + let C_min = null; + let C_max = null; + + let file = Components.classes["@mozilla.org/file/directory_service;1"] + .getService(Components.interfaces.nsIProperties) + .get("ProfD", Components.interfaces.nsIFile); + file.append("mandelbookmarks.sqlite"); + let connection = Components.classes["@mozilla.org/storage/service;1"] + .getService(Components.interfaces.mozIStorageService) + .openDatabase(file); + let statement = connection.createStatement( + "SELECT iteration_max,Cr_min,Cr_max,Ci_min,Ci_max FROM bookmarks WHERE ROWID=?1"); + statement.bindStringParameter(0, evtarget.getAttribute('bmRowID')); + while (statement.executeStep()) { + iterMax = statement.getInt32(0); + C_min = new complex(statement.getDouble(1), statement.getDouble(3)); + C_max = new complex(statement.getDouble(2), statement.getDouble(4)); + } + statement.finalize(); + connection.close(); - alert(evtarget.getAttribute('label') + ', ' + evtarget.getAttribute('bmRowID')); - //gPref.setIntPref("mandelbrot.iteration_max", iterMax); + if (iterMax && C_min && C_max) { + gPref.setIntPref("mandelbrot.iteration_max", iterMax); + adjustCoordsAndDraw(C_min, C_max); + } + } } function saveBookmark() {