2
// globale Variablen f�r Preferences-Zugriff
3
var aios_pBranch = Components.interfaces.nsIPrefBranch;
4
var aios_gPref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
5
var aios_gPrefBranchN = aios_gPref.getBranch(null);
6
var aios_gPrefBranch = aios_gPref.getBranch("extensions.aios.");
9
// globale Variablen f�r Browser-Zugriff
10
var aios_WW = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].getService(Components.interfaces.nsIWindowWatcher);
11
var aios_WM = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
12
var aios_WIN = aios_WM.getMostRecentWindow('navigator:browser');
13
var aios_APPCONTENT = aios_WIN.document.getElementById('appcontent');
16
var aios_XULAppInfo = Components.classes['@mozilla.org/xre/app-info;1'].getService(Components.interfaces.nsIXULAppInfo);
17
// {ec8030f7-c20a-464f-9b0e-13a3a9e97384} => Firefox; {a463f10c-3994-11da-9945-000d60ca027b} => Flock
18
var aios_appID = aios_XULAppInfo.ID;
20
var aios_appVendor = aios_XULAppInfo.vendor;
21
var aios_appVersion = aios_XULAppInfo.version;
23
var aios_appOS = Components.classes['@mozilla.org/xre/app-info;1'].getService(Components.interfaces.nsIXULRuntime).OS;
25
var aios_appDefTheme = (aios_gPrefBranchN.getCharPref('general.skins.selectedSkin') == "classic/1.0") ? true : false;
28
// globale Variablen und Funktionen zur �berwachung auf Progress-Ver�nderungen
29
// Verwendung in pageInfo.xul und viewSource.xul
30
var aios_ProgListStart = Components.interfaces.nsIWebProgressListener.STATE_START;
31
var aios_ProgListStop = Components.interfaces.nsIWebProgressListener.STATE_STOP;
33
var aiosProgListener = {
34
QueryInterface: function(aIID) {
35
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
36
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
37
aIID.equals(Components.interfaces.nsISupports))
39
throw Components.results.NS_NOINTERFACE;
42
onStateChange: function(aProgress, aRequest, aFlag, aStatus) {
43
//if(aFlag & aios_ProgListStart) { /* This fires when the load event is initiated */ }
44
//if(aFlag & aios_ProgListStop) { /* This fires when the load finishes */ }
45
if(aFlag & aios_ProgListStop) {
46
if(typeof aios_onStateChange == "function") aios_onStateChange();
51
onLocationChange: function(aProgress, aRequest, aURI) {
52
// This fires when the location bar changes i.e load event is confirmed
53
// or when the user switches tabs
54
if(typeof aios_onLocationChange == "function") aios_onLocationChange();
58
// For definitions of the remaining functions see XulPlanet.com
59
onProgressChange: function() { return 0; },
60
onStatusChange: function() { return 0; },
61
onSecurityChange: function() { return 0; },
62
onLinkIconAvailable: function() { return 0; }
67
Variablen zur Verwendung der Erweiterung "DebugLogger" - http://mozmonkey.com/debuglogger/
69
if(Components.classes["@mozmonkey.com/debuglogger/manager;1"]) {
70
var aios_debugLogMngr = Components.classes["@mozmonkey.com/debuglogger/manager;1"].
71
getService(Components.interfaces.nsIDebugLoggerManager);
72
var aios_debugLogger = aios_debugLogMngr.registerLogger("aios");
74
//aios_debugLogger.log(3, "Hello World");
78
Debug-Funktion unter Verwendung der JavaScript-Konsole
80
function aios_debug(aMsg) {
81
var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"].
82
getService(Components.interfaces.nsIConsoleService),
84
msg = 'AIOS: ' + aMsg;
85
aConsoleService.logStringMessage(msg);
87
//aios_debug('Hallo');
91
�ffnet ein neues Tab mit der �bergebenen Adresse im Vordergrund
93
var aiosLastSelTab; // wird f�r Page Info/Page Source/MultiPanel im Tab ben�tigt
94
function aios_addTab(aUrl) {
96
var browser = aios_WIN.getBrowser();
97
aiosLastSelTab = aios_WIN.content;
103
// alle ge�ffneten Tabs durchgehen
104
for(var i = 0; i < browser.tabContainer.childNodes.length; i++) {
105
browserDoc = browser.getBrowserAtIndex(i).contentWindow.document;
106
//alert(browser.getBrowserAtIndex(i).currentURI.spec);
108
var isPermaTab = (browser.tabContainer.childNodes[i].getAttribute('isPermaTab')) ? true : false;
111
/*var attribs = browser.tabContainer.childNodes[i].attributes;
112
//var attribs = browser.mCurrentTab.attributes;
113
for(var a = 0; a < attribs.length; a++) {
114
alert(attribs[a].name + ": " + attribs[a].value);
117
// wenn der Tab leer ist
118
if(browserDoc.location.href == "about:blank" && browser.selectedTab.getAttribute('openBy') != "aios" && !isPermaTab && emptyTab == null)
120
// wenn der Tab schon existiert
121
if(browserDoc.location.href == aUrl && !isPermaTab && existTab == null)
125
// wenn der Tab schon existiert
126
if(existTab != null) {
127
browser.selectedTab = browser.tabContainer.childNodes[existTab];
128
return browser.selectedTab;
131
// wenn der Tab leer ist
132
if(emptyTab != null) {
133
// URL �ffnen und Tab selektieren
134
browser.getBrowserAtIndex(emptyTab).contentWindow.document.location.href = aUrl;
135
browser.selectedTab = browser.tabContainer.childNodes[emptyTab];
136
browser.selectedTab.setAttribute('openBy', 'aios');
137
return browser.selectedTab;
140
// wenn kein leerer Tab vorhanden war, wird ein neuer ge�ffnet
141
browser.selectedTab = browser.addTab(aUrl);
142
browser.selectedTab.setAttribute('openBy', 'aios');
143
return browser.selectedTab;
148
f�gt dem Dokument dynamisch ein Stylesheet hinzu
149
=> Aufruf u.a. durch aios_init() und aios_sidebarLayout() bei den Add-ons, Downloads
151
function aios_addCSS(aURI) {
152
var css = document.createElementNS('http://www.w3.org/1999/xhtml', 'link');
153
css.setAttribute('rel', 'stylesheet');
154
css.setAttribute('href', aURI);
155
css.setAttribute('type', 'text/css');
156
document.documentElement.appendChild(css);
161
errechnet die Breite des Browsers exkl. der AIOS-Toolbar
162
=> Aufruf durch aios_setSidebarDefWidth() in aios.js und aios_setSidebarWidth() in general.js
164
function aios_getBrowserWidth() {
165
var cStyleSidebar = aios_WIN.document.defaultView.getComputedStyle(aios_WIN.document.getElementById('sidebar-box'), '');
166
var cStyleSplitter = aios_WIN.document.defaultView.getComputedStyle(aios_WIN.document.getElementById('sidebar-splitter'), '');
167
var cStyleContent = aios_WIN.document.defaultView.getComputedStyle(aios_WIN.document.getElementById('appcontent'), '');
169
var widthSidebar = parseInt(cStyleSidebar.width) + parseInt(cStyleSidebar.paddingLeft) + parseInt(cStyleSidebar.paddingRight) + parseInt(cStyleSidebar.marginLeft) + parseInt(cStyleSidebar.marginRight);
171
var widthSplitter = parseInt(cStyleSplitter.width) + parseInt(cStyleSplitter.paddingLeft) + parseInt(cStyleSplitter.paddingRight) + parseInt(cStyleSplitter.marginLeft) + parseInt(cStyleSplitter.marginRight);
173
var widthContent = parseInt(cStyleContent.width) + parseInt(cStyleContent.paddingLeft) + parseInt(cStyleContent.paddingRight) + parseInt(cStyleContent.marginLeft) + parseInt(cStyleContent.marginRight);
175
var compWidth = widthSidebar + widthSplitter + widthContent;
177
var ret_arr = new Array(widthSidebar, widthSplitter, widthContent, compWidth);
183
erweitert das Attribut "class" eines Elementes
185
function aios_appendClass(elem, appClass) {
186
if(typeof elem == "string") elem = document.getElementById(elem);
188
var old_class = elem.getAttribute('class');
189
if(old_class.indexOf(appClass) < 0) elem.setAttribute('class', old_class + " " + appClass);
194
l�scht einen Klassennamen im Attribut "class" eines Elementes
196
function aios_stripClass(elem, stripClass) {
197
if(typeof elem == "string") elem = document.getElementById(elem);
199
var old_class = elem.getAttribute('class');
201
if(old_class.indexOf(stripClass) >= 0) {
202
var pos = old_class.indexOf(stripClass);
204
var slice1 = old_class.substring(0, pos);
205
slice1 = slice1.replace(/ /, "");
206
var slice2 = old_class.substring(pos + stripClass.length, old_class.length);
207
slice2 = slice2.replace(/ /, "");
209
elem.setAttribute('class', slice1 + " " + slice2);
215
function aios_gElem(aID) {
216
if(aios_WIN && aios_WIN.document.getElementById(aID)) return aios_WIN.document.getElementById(aID);
222
gibt den boolschen Wert eines Wertes zur�ck
223
=> getAttribute(val) liefert nur "true" oder "false" als String
225
function aios_getBoolean(aElem, aVal) {
228
if(typeof aElem == "object") {
231
else if(typeof aElem == "string" && document.getElementById(aElem)) {
232
elem = document.getElementById(aElem);
236
if(typeof elem.getAttribute == "function") bool = elem.getAttribute(aVal);
239
if(bool == "true") return true;
247
function aios_openDialog(which, args) {
248
var theUrl, theId, theFeatures, theArgs;
253
theUrl = "chrome://aios/content/prefs/prefs.xul";
254
theId = "aiosPrefsDialog";
255
theFeatures = "chrome,titlebar,toolbar,centerscreen,";
256
theFeatures+= (aios_appOS == "Darwin") ? "dialog=no" : "modal";
260
theUrl = "chrome://aios/content/about.xul";
261
theId = "aiosAboutDialog";
262
theFeatures = "chrome,modal";
266
theUrl = "chrome://browser/content/bookmarks/bookmarksPanel.xul";
267
theId = "aiosGlobal:Bookmarks";
268
theFeatures = "width=640,height=480,chrome,resizable,centerscreen";
272
theUrl = "chrome://browser/content/history/history-panel.xul";
273
theId = "aiosGlobal:History";
274
theFeatures = "width=640,height=480,chrome,resizable,centerscreen";
278
theUrl = "chrome://browser/content/web-panels.xul";
279
theId = "aiosGlobal:MultiPanel";
280
theFeatures = "width=640,height=480,chrome,resizable,centerscreen";
284
if(which == "prefs" || which == "about") openDialog(theUrl, theId, theFeatures, theArgs);
285
else toOpenWindowByType(theId, theUrl, theFeatures);
290
pr�ft welche Elemente angezeigt werden sollen
291
=> Aufruf jeweils durch Initialisierung
293
function aios_synchElements(aElems) {
296
for(var i = 0; i < aElems.length; i++) {
297
elem = document.getElementById(aElems[i]);
301
childElems = elem.getAttribute('aiosChilds');
304
childMode = !aios_getBoolean(elem, 'checked');
305
aios_toggleChilds(childElems, childMode);
313
toggelt einen Men�punkt und das/die zugeh�rige/n Element/e
314
=> Aufruf durch die menuitems in der aios.xul
316
function aios_toggleElement(aMenuitem) {
319
if(typeof aMenuitem != "object") aMenuitem = document.getElementById(aMenuitem);
321
if(aMenuitem.getAttribute('observes')) {
322
menuitem = document.getElementById(aMenuitem.getAttribute('observes'));
325
menuitem = document.getElementById(aMenuitem.id);
328
var mode = aios_getBoolean(menuitem, 'checked');
329
var childElems = menuitem.getAttribute('aiosChilds');
331
menuitem.setAttribute('checked', !mode);
332
aios_toggleChilds(childElems, mode);
337
toggelt Kindelemente eines Men�punkts
338
=> Aufruf durch aios_toggleElement()
340
function aios_toggleChilds(childElems, childMode) {
341
var child_str, child;
343
if(childElems != "") {
344
var childElems_arr = childElems.split(",");
346
for(var i = 0; i < childElems_arr.length; i++) {
347
child_str = childElems_arr[i].replace(/ /, "");
349
var idChilds_arr = document.getElementsByAttribute('id', child_str);
351
// wenn es nur ein Element mit der ID gibt...
352
if(idChilds_arr.length == 1) {
353
child = document.getElementById(child_str);
355
// wenn es mehrere Elemente mit der ID gibt...
357
for(var j = 0; j < idChilds_arr.length; j++) {
358
//... nimm das auf der AIOS-Toolbar
359
if(idChilds_arr[j].parentNode.id == "aios-toolbar") child = idChilds_arr[j];
363
if(child) child.setAttribute('hidden', childMode);
b'\\ No newline at end of file'