Tidy whitespace and bracing (r=slamm@netscape.com).

This commit is contained in:
brendan%mozilla.org 1999-12-07 00:52:42 +00:00
parent c0d84a657c
commit e26b151b43
2 changed files with 150 additions and 158 deletions

View File

@ -3,7 +3,7 @@
* The contents of this file are subject to the Mozilla Public License * The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in * Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at * compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/ * http://www.mozilla.org/MPL/
* *
* Software distributed under the License is distributed on an "AS IS" * Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
@ -30,8 +30,7 @@ var PANELS_RDF_FILE = 66626;
// the default sidebar: // the default sidebar:
var sidebar = new Object; var sidebar = new Object;
function debug(msg) function debug(msg) {
{
// uncomment for noise // uncomment for noise
// dump(msg+"\n"); // dump(msg+"\n");
} }
@ -40,12 +39,12 @@ var panel_observer = new Object;
panel_observer = { panel_observer = {
OnAssert : function(src,prop,target) OnAssert : function(src,prop,target)
{ {
debug("Setting timeout to open default"); debug("Setting timeout to open default");
//xxxslamm This timeout does not work. JS bug #???? (bugzilla is down). //xxxslamm This timeout does not work. JS bug #???? (bugzilla is down).
// Brendan said that norris is working on this. // Brendan said that norris is working on this.
//setTimeout("sidebarOpenDefaultPanel(100, 0)",100); //setTimeout("sidebarOpenDefaultPanel(100, 0)",100);
}, },
OnUnassert : function(src,prop,target) OnUnassert : function(src,prop,target)
{ debug("panel_observer: onUnassert"); }, { debug("panel_observer: onUnassert"); },
OnChange : function(src,prop,old_target,new_target) OnChange : function(src,prop,old_target,new_target)
@ -57,35 +56,34 @@ panel_observer = {
function getSidebarDatasourceURI(panels_file_id) { function getSidebarDatasourceURI(panels_file_id) {
try { try {
var fileLocatorInterface = Components.interfaces.nsIFileLocator; var fileLocatorInterface = Components.interfaces.nsIFileLocator;
var fileLocatorProgID = 'component://netscape/filelocator'; var fileLocatorProgID = 'component://netscape/filelocator';
var fileLocatorService = Components.classes[fileLocatorProgID].getService(); var fileLocatorService = Components.classes[fileLocatorProgID].getService();
// use the fileLocator to look in the profile directory // use the fileLocator to look in the profile directory
// to find 'panels.rdf', which is the // to find 'panels.rdf', which is the
// database of the user's currently selected panels. // database of the user's currently selected panels.
fileLocatorService = fileLocatorService.QueryInterface(fileLocatorInterface); fileLocatorService = fileLocatorService.QueryInterface(fileLocatorInterface);
// if <profile>/panels.rdf doesn't exist, GetFileLocation() will copy // if <profile>/panels.rdf doesn't exist, GetFileLocation() will copy
// bin/defaults/profile/panels.rdf to <profile>/panels.rdf // bin/defaults/profile/panels.rdf to <profile>/panels.rdf
var sidebar_file = fileLocatorService.GetFileLocation(panels_file_id); var sidebar_file = fileLocatorService.GetFileLocation(panels_file_id);
if (!sidebar_file.exists()) { if (!sidebar_file.exists()) {
// this should not happen, as GetFileLocation() should copy // this should not happen, as GetFileLocation() should copy
// defaults/panels.rdf to the users profile directory // defaults/panels.rdf to the users profile directory
return null; return null;
} }
debug("sidebar uri is " + sidebar_file.URLString); debug("sidebar uri is " + sidebar_file.URLString);
return sidebar_file.URLString; return sidebar_file.URLString;
} }
catch (ex) { catch (ex) {
// this should not happen // this should not happen
return null; return null;
} }
} }
function sidebarOverlayInit() function sidebarOverlayInit() {
{
sidebar.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE); sidebar.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE);
sidebar.resource = 'urn:sidebar:current-panel-list'; sidebar.resource = 'urn:sidebar:current-panel-list';
@ -95,31 +93,29 @@ function sidebarOverlayInit()
if (sidebar_element.getAttribute('hidden') == 'true') { if (sidebar_element.getAttribute('hidden') == 'true') {
sidebar_element.setAttribute('style', 'display:none') sidebar_element.setAttribute('style', 'display:none')
if (sidebar_menuitem) if (sidebar_menuitem)
sidebar_menuitem.setAttribute('checked', 'false') sidebar_menuitem.setAttribute('checked', 'false')
} else { } else {
if (sidebar_menuitem) if (sidebar_menuitem)
sidebar_menuitem.setAttribute('checked', 'true'); sidebar_menuitem.setAttribute('checked', 'true');
debug("sidebar = " + sidebar); debug("sidebar = " + sidebar);
debug("sidebar.resource = " + sidebar.resource); debug("sidebar.resource = " + sidebar.resource);
debug("sidebar.datasource_uri = " + sidebar.datasource_uri); debug("sidebar.datasource_uri = " + sidebar.datasource_uri);
// Add the user's current panel choices to the template builder, // Add the user's current panel choices to the template builder,
// which will aggregate it with the other datasources that describe // which will aggregate it with the other datasources that describe
// the individual panel's title, customize URL, and content URL. // the individual panel's title, customize URL, and content URL.
var panels = document.getElementById('sidebar-panels'); var panels = document.getElementById('sidebar-panels');
panels.database.AddDataSource(RDF.GetDataSource(sidebar.datasource_uri)); panels.database.AddDataSource(RDF.GetDataSource(sidebar.datasource_uri));
debug("Adding observer to database."); debug("Adding observer to database.");
panels.database.AddObserver(panel_observer); panels.database.AddObserver(panel_observer);
// XXX This is a hack to force re-display // XXX This is a hack to force re-display
panels.setAttribute('ref', 'urn:sidebar:current-panel-list'); panels.setAttribute('ref', 'urn:sidebar:current-panel-list');
sidebarOpenDefaultPanel(100, 0); sidebarOpenDefaultPanel(100, 0);
} }
} }
@ -132,19 +128,19 @@ function sidebarOpenDefaultPanel(wait, tries) {
debug(" target="+target); debug(" target="+target);
if (children.length < 3) { if (children.length < 3) {
if (tries < 5) { if (tries < 5) {
// No children yet, try again later // No children yet, try again later
setTimeout('sidebarOpenDefaultPanel('+(wait*2)+','+(tries+1)+')',wait); setTimeout('sidebarOpenDefaultPanel('+(wait*2)+','+(tries+1)+')',wait);
} }
return; return;
} }
if (target && target != '') { if (target && target != '') {
for (var ii=0; ii < children.length; ii++) { for (var ii=0; ii < children.length; ii++) {
if (children.item(ii).getAttribute('src') == target) { if (children.item(ii).getAttribute('src') == target) {
children.item(ii).removeAttribute('collapsed'); children.item(ii).removeAttribute('collapsed');
return; return;
} }
} }
} }
// Pick the first one // Pick the first one
var first_iframe = children.item(2); var first_iframe = children.item(2);
@ -160,27 +156,27 @@ function sidebarOpenClosePanel(titledbutton) {
var children = titledbutton.parentNode.childNodes; var children = titledbutton.parentNode.childNodes;
if (target == last_src) { if (target == last_src) {
return; return;
} }
for (var ii=0; ii < children.length; ii++) { for (var ii=0; ii < children.length; ii++) {
var src = children.item(ii).getAttribute('src') var src = children.item(ii).getAttribute('src')
if (src == target) { if (src == target) {
children.item(ii).removeAttribute('collapsed'); children.item(ii).removeAttribute('collapsed');
titledbutton.parentNode.setAttribute('open-panel-src',target); titledbutton.parentNode.setAttribute('open-panel-src',target);
} }
if (src == last_src) { if (src == last_src) {
children.item(ii).setAttribute('collapsed','true'); children.item(ii).setAttribute('collapsed','true');
} }
} }
} }
function sidebarReload() { function sidebarReload() {
sidebarOverlayInit(sidebar) sidebarOverlayInit(sidebar);
} }
// Set up a lame hack to avoid opening two customize // Set up a lame hack to avoid opening two customize
// windows on a double click. // windows on a double click.
var gDisableCustomize = false; var gDisableCustomize = false;
function enableCustomize() { function enableCustomize() {
@ -195,24 +191,24 @@ function sidebarCustomize() {
var windowManager = cwindowManager.QueryInterface(iwindowManager); var windowManager = cwindowManager.QueryInterface(iwindowManager);
var customizeWindow = windowManager.GetMostRecentWindow('sidebar:customize'); var customizeWindow = windowManager.GetMostRecentWindow('sidebar:customize');
if (customizeWindow) {
debug("Reuse existing customize dialog");
customizeWindow.focus();
} else {
debug("Open a new customize dialog");
if (true == gDisableCustomize) { if (customizeWindow) {
debug("Recently opened one. Wait a little bit."); debug("Reuse existing customize dialog");
return; customizeWindow.focus();
} } else {
debug("Open a new customize dialog");
if (true == gDisableCustomize) {
debug("Recently opened one. Wait a little bit.");
return;
}
gDisableCustomize = true; gDisableCustomize = true;
customizeWindow = window.openDialog( customizeWindow = window.openDialog(
'chrome://sidebar/content/customize.xul', 'chrome://sidebar/content/customize.xul',
'_blank','chrome', '_blank','chrome',
sidebar.datasource_uri, sidebar.resource); sidebar.datasource_uri, sidebar.resource);
setTimeout(enableCustomize, 2000); setTimeout(enableCustomize, 2000);
} }
} }
@ -225,7 +221,7 @@ function sidebarShowHide() {
debug("Showing the sidebar") debug("Showing the sidebar")
sidebar.setAttribute('hidden','') sidebar.setAttribute('hidden','')
sidebar_splitter.setAttribute('hidden','') sidebar_splitter.setAttribute('hidden','')
//sidebarOverlayInit() //sidebarOverlayInit()
} else { } else {
debug("Hiding the sidebar") debug("Hiding the sidebar")
sidebar.setAttribute('hidden','true') sidebar.setAttribute('hidden','true')

View File

@ -3,7 +3,7 @@
* The contents of this file are subject to the Mozilla Public License * The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in * Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at * compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/ * http://www.mozilla.org/MPL/
* *
* Software distributed under the License is distributed on an "AS IS" * Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
@ -30,8 +30,7 @@ var PANELS_RDF_FILE = 66626;
// the default sidebar: // the default sidebar:
var sidebar = new Object; var sidebar = new Object;
function debug(msg) function debug(msg) {
{
// uncomment for noise // uncomment for noise
// dump(msg+"\n"); // dump(msg+"\n");
} }
@ -40,12 +39,12 @@ var panel_observer = new Object;
panel_observer = { panel_observer = {
OnAssert : function(src,prop,target) OnAssert : function(src,prop,target)
{ {
debug("Setting timeout to open default"); debug("Setting timeout to open default");
//xxxslamm This timeout does not work. JS bug #???? (bugzilla is down). //xxxslamm This timeout does not work. JS bug #???? (bugzilla is down).
// Brendan said that norris is working on this. // Brendan said that norris is working on this.
//setTimeout("sidebarOpenDefaultPanel(100, 0)",100); //setTimeout("sidebarOpenDefaultPanel(100, 0)",100);
}, },
OnUnassert : function(src,prop,target) OnUnassert : function(src,prop,target)
{ debug("panel_observer: onUnassert"); }, { debug("panel_observer: onUnassert"); },
OnChange : function(src,prop,old_target,new_target) OnChange : function(src,prop,old_target,new_target)
@ -57,35 +56,34 @@ panel_observer = {
function getSidebarDatasourceURI(panels_file_id) { function getSidebarDatasourceURI(panels_file_id) {
try { try {
var fileLocatorInterface = Components.interfaces.nsIFileLocator; var fileLocatorInterface = Components.interfaces.nsIFileLocator;
var fileLocatorProgID = 'component://netscape/filelocator'; var fileLocatorProgID = 'component://netscape/filelocator';
var fileLocatorService = Components.classes[fileLocatorProgID].getService(); var fileLocatorService = Components.classes[fileLocatorProgID].getService();
// use the fileLocator to look in the profile directory // use the fileLocator to look in the profile directory
// to find 'panels.rdf', which is the // to find 'panels.rdf', which is the
// database of the user's currently selected panels. // database of the user's currently selected panels.
fileLocatorService = fileLocatorService.QueryInterface(fileLocatorInterface); fileLocatorService = fileLocatorService.QueryInterface(fileLocatorInterface);
// if <profile>/panels.rdf doesn't exist, GetFileLocation() will copy // if <profile>/panels.rdf doesn't exist, GetFileLocation() will copy
// bin/defaults/profile/panels.rdf to <profile>/panels.rdf // bin/defaults/profile/panels.rdf to <profile>/panels.rdf
var sidebar_file = fileLocatorService.GetFileLocation(panels_file_id); var sidebar_file = fileLocatorService.GetFileLocation(panels_file_id);
if (!sidebar_file.exists()) { if (!sidebar_file.exists()) {
// this should not happen, as GetFileLocation() should copy // this should not happen, as GetFileLocation() should copy
// defaults/panels.rdf to the users profile directory // defaults/panels.rdf to the users profile directory
return null; return null;
} }
debug("sidebar uri is " + sidebar_file.URLString); debug("sidebar uri is " + sidebar_file.URLString);
return sidebar_file.URLString; return sidebar_file.URLString;
} }
catch (ex) { catch (ex) {
// this should not happen // this should not happen
return null; return null;
} }
} }
function sidebarOverlayInit() function sidebarOverlayInit() {
{
sidebar.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE); sidebar.datasource_uri = getSidebarDatasourceURI(PANELS_RDF_FILE);
sidebar.resource = 'urn:sidebar:current-panel-list'; sidebar.resource = 'urn:sidebar:current-panel-list';
@ -95,31 +93,29 @@ function sidebarOverlayInit()
if (sidebar_element.getAttribute('hidden') == 'true') { if (sidebar_element.getAttribute('hidden') == 'true') {
sidebar_element.setAttribute('style', 'display:none') sidebar_element.setAttribute('style', 'display:none')
if (sidebar_menuitem) if (sidebar_menuitem)
sidebar_menuitem.setAttribute('checked', 'false') sidebar_menuitem.setAttribute('checked', 'false')
} else { } else {
if (sidebar_menuitem) if (sidebar_menuitem)
sidebar_menuitem.setAttribute('checked', 'true'); sidebar_menuitem.setAttribute('checked', 'true');
debug("sidebar = " + sidebar); debug("sidebar = " + sidebar);
debug("sidebar.resource = " + sidebar.resource); debug("sidebar.resource = " + sidebar.resource);
debug("sidebar.datasource_uri = " + sidebar.datasource_uri); debug("sidebar.datasource_uri = " + sidebar.datasource_uri);
// Add the user's current panel choices to the template builder, // Add the user's current panel choices to the template builder,
// which will aggregate it with the other datasources that describe // which will aggregate it with the other datasources that describe
// the individual panel's title, customize URL, and content URL. // the individual panel's title, customize URL, and content URL.
var panels = document.getElementById('sidebar-panels'); var panels = document.getElementById('sidebar-panels');
panels.database.AddDataSource(RDF.GetDataSource(sidebar.datasource_uri)); panels.database.AddDataSource(RDF.GetDataSource(sidebar.datasource_uri));
debug("Adding observer to database."); debug("Adding observer to database.");
panels.database.AddObserver(panel_observer); panels.database.AddObserver(panel_observer);
// XXX This is a hack to force re-display // XXX This is a hack to force re-display
panels.setAttribute('ref', 'urn:sidebar:current-panel-list'); panels.setAttribute('ref', 'urn:sidebar:current-panel-list');
sidebarOpenDefaultPanel(100, 0); sidebarOpenDefaultPanel(100, 0);
} }
} }
@ -132,19 +128,19 @@ function sidebarOpenDefaultPanel(wait, tries) {
debug(" target="+target); debug(" target="+target);
if (children.length < 3) { if (children.length < 3) {
if (tries < 5) { if (tries < 5) {
// No children yet, try again later // No children yet, try again later
setTimeout('sidebarOpenDefaultPanel('+(wait*2)+','+(tries+1)+')',wait); setTimeout('sidebarOpenDefaultPanel('+(wait*2)+','+(tries+1)+')',wait);
} }
return; return;
} }
if (target && target != '') { if (target && target != '') {
for (var ii=0; ii < children.length; ii++) { for (var ii=0; ii < children.length; ii++) {
if (children.item(ii).getAttribute('src') == target) { if (children.item(ii).getAttribute('src') == target) {
children.item(ii).removeAttribute('collapsed'); children.item(ii).removeAttribute('collapsed');
return; return;
} }
} }
} }
// Pick the first one // Pick the first one
var first_iframe = children.item(2); var first_iframe = children.item(2);
@ -160,27 +156,27 @@ function sidebarOpenClosePanel(titledbutton) {
var children = titledbutton.parentNode.childNodes; var children = titledbutton.parentNode.childNodes;
if (target == last_src) { if (target == last_src) {
return; return;
} }
for (var ii=0; ii < children.length; ii++) { for (var ii=0; ii < children.length; ii++) {
var src = children.item(ii).getAttribute('src') var src = children.item(ii).getAttribute('src')
if (src == target) { if (src == target) {
children.item(ii).removeAttribute('collapsed'); children.item(ii).removeAttribute('collapsed');
titledbutton.parentNode.setAttribute('open-panel-src',target); titledbutton.parentNode.setAttribute('open-panel-src',target);
} }
if (src == last_src) { if (src == last_src) {
children.item(ii).setAttribute('collapsed','true'); children.item(ii).setAttribute('collapsed','true');
} }
} }
} }
function sidebarReload() { function sidebarReload() {
sidebarOverlayInit(sidebar) sidebarOverlayInit(sidebar);
} }
// Set up a lame hack to avoid opening two customize // Set up a lame hack to avoid opening two customize
// windows on a double click. // windows on a double click.
var gDisableCustomize = false; var gDisableCustomize = false;
function enableCustomize() { function enableCustomize() {
@ -195,24 +191,24 @@ function sidebarCustomize() {
var windowManager = cwindowManager.QueryInterface(iwindowManager); var windowManager = cwindowManager.QueryInterface(iwindowManager);
var customizeWindow = windowManager.GetMostRecentWindow('sidebar:customize'); var customizeWindow = windowManager.GetMostRecentWindow('sidebar:customize');
if (customizeWindow) {
debug("Reuse existing customize dialog");
customizeWindow.focus();
} else {
debug("Open a new customize dialog");
if (true == gDisableCustomize) { if (customizeWindow) {
debug("Recently opened one. Wait a little bit."); debug("Reuse existing customize dialog");
return; customizeWindow.focus();
} } else {
debug("Open a new customize dialog");
if (true == gDisableCustomize) {
debug("Recently opened one. Wait a little bit.");
return;
}
gDisableCustomize = true; gDisableCustomize = true;
customizeWindow = window.openDialog( customizeWindow = window.openDialog(
'chrome://sidebar/content/customize.xul', 'chrome://sidebar/content/customize.xul',
'_blank','chrome', '_blank','chrome',
sidebar.datasource_uri, sidebar.resource); sidebar.datasource_uri, sidebar.resource);
setTimeout(enableCustomize, 2000); setTimeout(enableCustomize, 2000);
} }
} }
@ -225,7 +221,7 @@ function sidebarShowHide() {
debug("Showing the sidebar") debug("Showing the sidebar")
sidebar.setAttribute('hidden','') sidebar.setAttribute('hidden','')
sidebar_splitter.setAttribute('hidden','') sidebar_splitter.setAttribute('hidden','')
//sidebarOverlayInit() //sidebarOverlayInit()
} else { } else {
debug("Hiding the sidebar") debug("Hiding the sidebar")
sidebar.setAttribute('hidden','true') sidebar.setAttribute('hidden','true')