This is just some static backup of the original site, don't expect every link to work!

source: content/vI_statusmenu.js

ng_0.9 0.10.3
Last change on this file was 1fb53b, checked in by rene <rene@…>, 4 years ago

removed fcc settings, only available via identity now

  • Property mode set to 100644
File size: 8.1 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2    This program is free software; you can redistribute it and/or modify
3    it under the terms of the GNU General Public License as published by
4    the Free Software Foundation; either version 2 of the License, or
5    (at your option) any later version.
6
7    This program is distributed in the hope that it will be useful,
8    but WITHOUT ANY WARRANTY; without even the implied warranty of
9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10    GNU General Public License for more details.
11
12    You should have received a copy of the GNU General Public License
13    along with this program; if not, write to the Free Software
14    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
15
16    The Original Code is the Virtual Identity Extension.
17
18    The Initial Developer of the Original Code is Rene Ejury.
19    Portions created by the Initial Developer are Copyright (C) 2007
20    the Initial Developer. All Rights Reserved.
21
22    Contributor(s):
23 * ***** END LICENSE BLOCK ***** */
24
25Components.utils.import("resource://v_identity/vI_nameSpaceWrapper.js");
26virtualIdentityExtension.ns(function () {
27  with(virtualIdentityExtension.LIB) {
28
29    let Log = vI.setupLogging("virtualIdentity.statusmenu");
30
31    Components.utils.import("resource://v_identity/vI_prefs.js", virtualIdentityExtension);
32
33    var statusmenu = {
34      stringBundle: Components.classes["@mozilla.org/intl/stringbundle;1"]
35        .getService(Components.interfaces.nsIStringBundleService)
36        .createBundle("chrome://v_identity/locale/v_identity.properties"),
37
38      objStatusMenu: null,
39      objSaveBaseIDMenuItem: null,
40      objStorageSaveMenuItem: null,
41      objStatusMenuSeparator: null,
42      objStatusText: null,
43      objStatusLogo: null,
44
45      observe: function (self, subject, topic, data) {
46        //         Log.debug("statusmenu observe " + data);
47        switch (data) {
48        case "show_status":
49          statusmenu.objStatusMenu.setAttribute("hidden", !vI.vIprefs.get(data));
50          statusmenu.objStatusLogo.setAttribute("hidden", !vI.vIprefs.get(data));
51          break;
52        case "storage_store":
53          statusmenu.objStorageSaveMenuItem.setAttribute("checked", vI.vIprefs.get(data));
54          break;
55        case "storage_store_base_id":
56          statusmenu.objSaveBaseIDMenuItem.setAttribute("checked", vI.vIprefs.get(data));
57          break;
58        case "storage_colorIndication":
59          document.getElementById("identityHbox").setAttribute("colorize", vI.vIprefs.get(data))
60          document.getElementById("baseIDHbox").setAttribute("colorize", vI.vIprefs.get(data))
61          break;
62        case "storage":
63          if (vI.vIprefs.get(data)) {
64            statusmenu.objStorageSaveMenuItem.removeAttribute("hidden");
65            statusmenu.objSaveBaseIDMenuItem.removeAttribute("hidden");
66            statusmenu.objStatusMenuSeparator.removeAttribute("hidden");
67          } else {
68            statusmenu.objStorageSaveMenuItem.setAttribute("hidden", "true");
69            statusmenu.objSaveBaseIDMenuItem.setAttribute("hidden", "true");
70            statusmenu.objStatusMenuSeparator.setAttribute("hidden", "true");
71          }
72          break;
73        }
74        statusmenu.menuConstraint(statusmenu.objStorageSaveMenuItem);
75      },
76
77      addObserver: function () {
78        vI.vIprefs.addObserver("show_status", this.observe, this);
79        vI.vIprefs.addObserver("storage", this.observe, this);
80        vI.vIprefs.addObserver("storage_colorIndication", this.observe, this);
81        vI.vIprefs.addObserver("storage_store", this.observe, this);
82        vI.vIprefs.addObserver("storage_store_base_id", this.observe, this);
83      },
84
85      removeObserver: function () {
86        vI.vIprefs.removeObserver("show_status", this.observe);
87        vI.vIprefs.removeObserver("storage", this.observe);
88        vI.vIprefs.removeObserver("storage_colorIndication", this.observe);
89        vI.vIprefs.removeObserver("storage_store", this.observe);
90        vI.vIprefs.removeObserver("storage_store_base_id", this.observe);
91      },
92
93      init: function () {
94        statusmenu.objStatusMenu = document.getElementById("virtualIdentityExtension_vIStatusMenu");
95        statusmenu.objStatusLogo = document.getElementById("virtualIdentityExtension_Logo");
96        statusmenu.objSaveBaseIDMenuItem = document.getElementById("virtualIdentityExtension_statusMenu_storage_saveBaseID");
97        statusmenu.objStorageSaveMenuItem = document.getElementById("virtualIdentityExtension_statusMenu_storage_save");
98        statusmenu.objStatusMenuSeparator = document.getElementById("virtualIdentityExtension_statusMenu_separator");
99        statusmenu.objStatusText = document.getElementById("statusText");
100        statusmenu.objStatusTooltipLine1 = document.getElementById("virtualIdentityExtension_statusMenuTooltip_StatusValueLine1");
101        statusmenu.objStatusTooltipLine2 = document.getElementById("virtualIdentityExtension_statusMenuTooltip_StatusValueLine2");
102
103        statusmenu.addObserver();
104        statusmenu.observe(this, null, null, "show_status");
105        statusmenu.observe(this, null, null, "storage_colorIndication");
106        statusmenu.observe(this, null, null, "storage_store_base_id");
107        statusmenu.observe(this, null, null, "storage_store");
108        statusmenu.observe(this, null, null, "storage");
109      },
110
111      __timeout: 5, // timeout for status messages in seconds
112      __addStatusMessage: function (save) {
113        if (vI.vIprefs.get("show_status")) {
114          var sourceString = "vident.statusText.save." + save;
115          var messageLine1 = statusmenu.stringBundle.GetStringFromName(sourceString + ".line1");
116          var messageLine2 = statusmenu.stringBundle.GetStringFromName(sourceString + ".line2");
117          if (!messageLine2) {
118            statusmenu.objStatusText.setAttribute("label", messageLine1);
119            statusmenu.objStatusTooltipLine1.setAttribute("value", messageLine1);
120            statusmenu.objStatusTooltipLine2.setAttribute("hidden", "true");
121          } else {
122            statusmenu.objStatusText.setAttribute("label", messageLine1 + " " + messageLine2);
123            statusmenu.objStatusTooltipLine1.setAttribute("value", messageLine1);
124            statusmenu.objStatusTooltipLine2.setAttribute("value", messageLine2);
125            statusmenu.objStatusTooltipLine2.removeAttribute("hidden");
126          }
127          window.setTimeout(virtualIdentityExtension.statusmenu.__clearStatusMessage, statusmenu.__timeout * 1000);
128        }
129      },
130
131      __clearStatusMessage: function () {
132        statusmenu.objStatusText.setAttribute("label", "");
133      },
134
135      changeBaseIDStatus: function (elem) {
136        statusmenu.objSaveBaseIDMenuItem.setAttribute("checked", elem.getAttribute("checked"));
137        statusmenu.menuConstraint();
138      },
139
140      changeSaveStatus: function (elem) {
141        statusmenu.objStorageSaveMenuItem.setAttribute("checked", elem.getAttribute("checked"));
142        statusmenu.menuConstraint();
143      },
144
145      menuConstraint: function () {
146        var save = "off";
147        if (statusmenu.objStorageSaveMenuItem.getAttribute("checked") == "true") {
148          statusmenu.objSaveBaseIDMenuItem.removeAttribute("disabled");
149          if (vI.vIprefs.get("storage")) {
150            if (statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true") save = "base";
151            else save = "ok";
152          }
153        } else {
154          statusmenu.objSaveBaseIDMenuItem.setAttribute("disabled", "true");
155        }
156        statusmenu.objStatusMenu.setAttribute("save", save);
157        statusmenu.__addStatusMessage(save);
158      },
159
160      clicked: function (button) {
161        if (button != 0) return; // only react on left mouse button
162        if (!vI.vIprefs.get("storage")) return;
163
164        var curSaveStatus = vI.vIprefs.get("storage_store")
165        var curSaveBaseIDStatus = vI.vIprefs.get("storage_store_base_id")
166        var newSaveStatus = ((!curSaveStatus) || (curSaveStatus && !curSaveBaseIDStatus))
167        var newSaveBaseIDStatus = (curSaveStatus && !curSaveBaseIDStatus)
168
169        vI.vIprefs.set("storage_store", newSaveStatus)
170        vI.vIprefs.set("storage_store_base_id", newSaveBaseIDStatus)
171
172        statusmenu.menuConstraint();
173      }
174    }
175    vI.statusmenu = statusmenu;
176  }
177});
Note: See TracBrowser for help on using the repository browser.