home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright 2005-2007 Foxmarks Inc.
-
- foxmarks-overlay.js: implement the foxmarks overlay into the main browser
- window
- */
-
- var foxmarksObserver = {
- observe: function(subject, topic, data) {
- var result = eval(data);
- //ignore component finish messages
- if(result.status == 3)
- return;
- var status = result.status;
- var msg = result.msg || "";
- var complete = status != 1;
-
- window.XULBrowserWindow.setJSStatus("Xmarks: " + msg);
-
- if (complete) {
- setTimeout(foxmarksObserver.clearStatus, status != 0 ? 5000: 1000);
- }
- },
- clearStatus: function() {
- window.XULBrowserWindow.setJSStatus("");
- }
- }
-
- var foxmarksPopupObserver = {
- observe: function(subject, topic, data) {
- var JSON = Cc["@mozilla.org/dom/json;1"].
- createInstance(Ci.nsIJSON);
- FoxmarksNewUserPopup(JSON.decode(data));
- }
- }
- function FoxmarksSetKeyboardShortcut(id, key) {
- var element = document.getElementById(id);
- element.setAttribute("key", key);
- element.setAttribute("disabled", key ? false : true);
- }
-
- function FoxmarksBrowserLoad() {
- var os = Cc["@mozilla.org/observer-service;1"].
- getService(Ci.nsIObserverService);
- os.addObserver(foxmarksObserver, "foxmarks-service", false);
- os.addObserver(foxmarksPopupObserver, "foxmarks-newpopup", false);
-
- FoxmarksSetKeyboardShortcut("SyncNow", gSettings.syncShortcutKey);
- FoxmarksSetKeyboardShortcut("OpenFoxmarksDialog",
- gSettings.openSettingsDialogShortcutKey);
- FoxmarksSetKeyboardShortcut("FoxmarksSimSiteKey",
- gSettings.siteinfoDialogShortcutKey);
-
- // Load SERP
- FoxmarksSERP.init();
-
- // Load similiar sites
- FoxmarksSimSites.init();
- }
-
- function FoxmarksOnPopupShowing() {
- if (gSettings.hideStatusIcon) {
- document.getElementById("foxmarks-showstatusicon").
- removeAttribute("checked");
- } else {
- document.getElementById("foxmarks-showstatusicon").
- setAttribute("checked", "true");
- }
- return true;
- }
-
- function FoxmarksToggleIcon(event) {
- gSettings.hideStatusIcon = !gSettings.hideStatusIcon;
- }
-
- function FoxmarksBrowserUnload() {
- var os = Cc["@mozilla.org/observer-service;1"].
- getService(Ci.nsIObserverService);
-
- try {
- os.removeObserver(foxmarksObserver, "foxmarks-service");
- } catch (e) {
- LogWrite("Warning: removeObserver failed.");
- }
- }
-
- window.addEventListener("load", FoxmarksBrowserLoad, false);
- window.addEventListener("unload", FoxmarksBrowserUnload, false);
-
-