From: Norman Walsh Date: Fri, 19 Dec 2003 16:15:10 +0000 (+0000) Subject: Updated from devedge.netscape.com X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecc9943a18c16ec9a468e4e8e76ea42594ff0cf4;p=docbook-dsssl Updated from devedge.netscape.com --- diff --git a/slides/browser/CTOCWidget.js b/slides/browser/CTOCWidget.js new file mode 100644 index 000000000..a411ea995 --- /dev/null +++ b/slides/browser/CTOCWidget.js @@ -0,0 +1,169 @@ +/* + * CTOCWidget.js + * $Revision: 1.3 $ $Date: 2003/07/14 06:02:50 $ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * 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 compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ + +function CTOCWidget(domTOCModel, target) +{ + if (domTOCModel.documentElement.nodeName != 'toc') + { + throw 'CTOCWidget called on non toc Document: ' + domTOCModel.nodeName; + } + + this.model = domTOCModel; + this.target = target; + this.view = document.createElement('div'); + this.view.setAttribute('class', CTOCWidget._classprefix + '_view'); + + var modelItems = domTOCModel.documentElement.childNodes; + for (var i = 0; i < modelItems.length; i++) + { + var modelItem = modelItems.item(i); + if (modelItem.nodeType == Node.ELEMENT_NODE) + { + var viewItem = CTOCWidget.createItemView(modelItem, target); + this.view.appendChild(viewItem); + } + } +} + +CTOCWidget._handleImages = { open: '/toolbox/examples/2003/CTOCWidget/minus.gif', closed: '/toolbox/examples/2003/CTOCWidget/plus.gif', height: '12px', width: '16px'}; +CTOCWidget._classprefix = 'CTOCWidget'; + +CTOCWidget.createItemView = function (modelItem, target) +{ + if (modelItem.nodeType != Node.ELEMENT_NODE) + { + throw 'CTOCWidget.createItemView called on non-Element: ' + modelItem.nodeName; + } + + var i; + + var viewItem = document.createElement('div'); + viewItem.setAttribute('class', CTOCWidget._classprefix + '_item'); + + var viewItemHandle = document.createElement('div'); + viewItemHandle.setAttribute('class', CTOCWidget._classprefix + '_itemhandle'); + viewItemHandle.style.cursor = 'pointer'; + + var viewItemHandleImg = document.createElement('img'); + viewItemHandleImg.style.height = CTOCWidget._handleImages.height; + viewItemHandleImg.style.width = CTOCWidget._handleImages.width; + viewItemHandleImg.addEventListener('click', CTOCWidget.toggleHandle, false); + + var viewItemHandleLink; + if (!modelItem.getAttribute('url')) + { + viewItemHandleLink = document.createElement('span'); + } + else + { + viewItemHandleLink = document.createElement('a'); + viewItemHandleLink.setAttribute('href', modelItem.getAttribute('url')); + viewItemHandleLink.setAttribute('target', target); + } + viewItemHandleLink.appendChild(document.createTextNode(modelItem.getAttribute('title'))); + + viewItemHandle.appendChild(viewItemHandleImg); + viewItemHandle.appendChild(viewItemHandleLink); + viewItem.appendChild(viewItemHandle); + + if (modelItem.childNodes.length == 0) + { + viewItemHandleImg.setAttribute('src', CTOCWidget._handleImages.open); + } + else + { + viewItemHandleImg.setAttribute('src', CTOCWidget._handleImages.closed); + + var viewItemChildren = document.createElement('div'); + viewItemChildren.setAttribute('class', CTOCWidget._classprefix + '_itemchildren'); + viewItemChildren.style.display = 'none'; + viewItemChildren.style.position = 'relative'; + viewItemChildren.style.left = '1em'; + + for (i = 0; i < modelItem.childNodes.length; i++) + { + var modelItemChild = modelItem.childNodes.item(i); + if (modelItemChild.nodeType == Node.ELEMENT_NODE) + { + viewItemChildren.appendChild(CTOCWidget.createItemView(modelItemChild, target)); + } + } + + viewItem.appendChild(viewItemChildren); + } + + return viewItem; +}; + +// fires on img part of the handle +CTOCWidget.toggleHandle = function(e) +{ + switch (e.eventPhase) + { + case Event.CAPTURING_PHASE: + case Event.BUBBLING_PHASE: + return true; + + case Event.AT_TARGET: + + e.preventBubble(); + + var domHandle = e.target.parentNode; + var domChildren = domHandle.nextSibling; + + if (!domChildren) + { + return true; + } + + switch(domChildren.style.display) + { + case '': + case 'block': + domChildren.style.display = 'none'; + e.target.setAttribute('src', CTOCWidget._handleImages.closed); + break; + case 'none': + domChildren.style.display = 'block'; + e.target.setAttribute('src', CTOCWidget._handleImages.open); + break; + default: + return false; + } + + return true; + + default: + dump('Unknown Event Phase ' + e.eventPhase); + break; + } + + return true; +} + diff --git a/slides/browser/ua.js b/slides/browser/ua.js index 7521294d3..898765980 100644 --- a/slides/browser/ua.js +++ b/slides/browser/ua.js @@ -1,113 +1,135 @@ -/* -ua.js revision 0.200 2001-12-03 - -Contributor(s): Bob Clary, Netscape Communications, Copyright 2001 - -Netscape grants you a royalty free license to use, modify and -distribute this software provided that this copyright notice -appears on all copies. This software is provided "AS IS," -without a warranty of any kind. -*/ - -function xbDetectBrowser() -{ - var oldOnError = window.onerror; - var element = null; - - window.onerror = null; - - // work around bug in xpcdom Mozilla 0.9.1 - window.saveNavigator = window.navigator; - - navigator.OS = ''; - navigator.version = parseFloat(navigator.appVersion); - navigator.org = ''; - navigator.family = ''; - - var platform; - if (typeof(window.navigator.platform) != 'undefined') - { - platform = window.navigator.platform.toLowerCase(); - if (platform.indexOf('win') != -1) - navigator.OS = 'win'; - else if (platform.indexOf('mac') != -1) - navigator.OS = 'mac'; - else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1) - navigator.OS = 'nix'; - } - - var i = 0; - var ua = window.navigator.userAgent.toLowerCase(); - - if (ua.indexOf('opera') != -1) - { - i = ua.indexOf('opera'); - navigator.family = 'opera'; - navigator.org = 'opera'; - navigator.version = parseFloat('0' + ua.substr(i+6), 10); - } - else if ((i = ua.indexOf('msie')) != -1) - { - navigator.org = 'microsoft'; - navigator.version = parseFloat('0' + ua.substr(i+5), 10); - - if (navigator.version < 4) - navigator.family = 'ie3'; - else - navigator.family = 'ie4' - } - else if (ua.indexOf('gecko') != -1) - { - navigator.family = 'gecko'; - var rvStart = navigator.userAgent.indexOf('rv:') + 3; - var rvEnd = navigator.userAgent.indexOf(')', rvStart); - var rv = navigator.userAgent.substring(rvStart, rvEnd); - var decIndex = rv.indexOf('.'); - if (decIndex != -1) - { - rv = rv.replace(/\./g, '') - rv = rv.substring(0, decIndex-1) + '.' + rv.substr(decIndex) - } - navigator.version = parseFloat(rv); - - if (ua.indexOf('netscape') != -1) - navigator.org = 'netscape'; - else if (ua.indexOf('compuserve') != -1) - navigator.org = 'compuserve'; - else - navigator.org = 'mozilla'; - } - else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1)) - { - var is_major = parseFloat(navigator.appVersion); - - if (is_major < 4) - navigator.version = is_major; - else - { - i = ua.lastIndexOf('/') - navigator.version = parseFloat('0' + ua.substr(i+1), 10); - } - navigator.org = 'netscape'; - navigator.family = 'nn' + parseInt(navigator.appVersion); - } - else if ((i = ua.indexOf('aol')) != -1 ) - { - // aol - navigator.family = 'aol'; - navigator.org = 'aol'; - navigator.version = parseFloat('0' + ua.substr(i+4), 10); - } - else if ((i = ua.indexOf('hotjava')) != -1 ) - { - // hotjava - navigator.family = 'hotjava'; - navigator.org = 'sun'; - navigator.version = parseFloat(navigator.appVersion); - } - - window.onerror = oldOnError; -} - -xbDetectBrowser(); - +/* + * ua.js + * $Revision: 1.2 $ $Date: 2003/02/07 16:04:17 $ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * 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 compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ + +function xbDetectBrowser() +{ + var oldOnError = window.onerror; + var element = null; + + window.onerror = null; + + // work around bug in xpcdom Mozilla 0.9.1 + window.saveNavigator = window.navigator; + + navigator.OS = ''; + navigator.version = parseFloat(navigator.appVersion); + navigator.org = ''; + navigator.family = ''; + + var platform; + if (typeof(window.navigator.platform) != 'undefined') + { + platform = window.navigator.platform.toLowerCase(); + if (platform.indexOf('win') != -1) + navigator.OS = 'win'; + else if (platform.indexOf('mac') != -1) + navigator.OS = 'mac'; + else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1) + navigator.OS = 'nix'; + } + + var i = 0; + var ua = window.navigator.userAgent.toLowerCase(); + + if (ua.indexOf('opera') != -1) + { + i = ua.indexOf('opera'); + navigator.family = 'opera'; + navigator.org = 'opera'; + navigator.version = parseFloat('0' + ua.substr(i+6), 10); + } + else if ((i = ua.indexOf('msie')) != -1) + { + navigator.org = 'microsoft'; + navigator.version = parseFloat('0' + ua.substr(i+5), 10); + + if (navigator.version < 4) + navigator.family = 'ie3'; + else + navigator.family = 'ie4' + } + else if (ua.indexOf('gecko') != -1) + { + navigator.family = 'gecko'; + var rvStart = ua.indexOf('rv:'); + var rvEnd = ua.indexOf(')', rvStart); + var rv = ua.substring(rvStart+3, rvEnd); + var rvParts = rv.split('.'); + var rvValue = 0; + var exp = 1; + + for (var i = 0; i < rvParts.length; i++) + { + var val = parseInt(rvParts[i]); + rvValue += val / exp; + exp *= 100; + } + navigator.version = rvValue; + + if (ua.indexOf('netscape') != -1) + navigator.org = 'netscape'; + else if (ua.indexOf('compuserve') != -1) + navigator.org = 'compuserve'; + else + navigator.org = 'mozilla'; + } + else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1)) + { + var is_major = parseFloat(navigator.appVersion); + + if (is_major < 4) + navigator.version = is_major; + else + { + i = ua.lastIndexOf('/') + navigator.version = parseFloat('0' + ua.substr(i+1), 10); + } + navigator.org = 'netscape'; + navigator.family = 'nn' + parseInt(navigator.appVersion); + } + else if ((i = ua.indexOf('aol')) != -1 ) + { + // aol + navigator.family = 'aol'; + navigator.org = 'aol'; + navigator.version = parseFloat('0' + ua.substr(i+4), 10); + } + else if ((i = ua.indexOf('hotjava')) != -1 ) + { + // hotjava + navigator.family = 'hotjava'; + navigator.org = 'sun'; + navigator.version = parseFloat(navigator.appVersion); + } + + window.onerror = oldOnError; +} + +xbDetectBrowser(); + diff --git a/slides/browser/xbDOM.js b/slides/browser/xbDOM.js index d1a3ab374..39cc8bf01 100644 --- a/slides/browser/xbDOM.js +++ b/slides/browser/xbDOM.js @@ -1,293 +1,374 @@ -/* -xbDOM.js v 0.004 2002-03-09 - -Contributor(s): Bob Clary, Netscape Communications, Copyright 2001, 2002 - -Netscape grants you a royalty free license to use, modify and -distribute this software provided that this copyright notice -appears on all copies. This software is provided "AS IS," -without a warranty of any kind. - -Change Log: - -2002-03-15: v 0.004 - bclary - - fix bug in bugfix for 0.003 in xbGetElementsByName - to not confuse elements with length properties with arrays - -2002-03-09: v 0.003 - bclary - - fix bug in xbGetElementsByName in Internet Explorer when there is - only one instance of an element with name value. - -2002-01-19: v 0.002 - bclary - - nav4FindElementsByName - removed erroneous obj and return - added search of form elements - xbFindElementsByNameAndType - renamed from FindElementsByNameAndType - removed erroneouse obj and return - xbSetInnerHTML - ported over from xbStyle since it is more - appropriate here. - -2001-11-27: v 0.01 - bclary - - removed from xbStyle -*/ - -function xbToInt(s) -{ - var i = parseInt(s, 10); - if (isNaN(i)) - i = 0; - - return i; -} - -function xbGetWindowWidth(windowRef) -{ - var width = 0; - - if (!windowRef) - windowRef = window; - - if (typeof(windowRef.innerWidth) == 'number') - width = windowRef.innerWidth; - else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') - width = windowRef.document.body.clientWidth; - - return width; -} - -function xbGetWindowHeight(windowRef) -{ - var height = 0; - - if (!windowRef) - windowRef = window; - - if (typeof(windowRef.innerWidth) == 'number') - height = windowRef.innerHeight; - else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') - height = windowRef.document.body.clientHeight; - - return height; -} - -function nav4FindLayer(doc, id) -{ - var i; - var subdoc; - var obj; - - for (i = 0; i < doc.layers.length; ++i) - { - if (doc.layers[i].id && id == doc.layers[i].id) - return doc.layers[i]; - - subdoc = doc.layers[i].document; - obj = nav4FindLayer(subdoc, id); - if (obj != null) - return obj; - } - return null; -} - -function nav4FindElementsByName(doc, name, elmlist) -{ - var i; - var j; - var subdoc; - - for (i = 0; i < doc.images.length; ++i) - { - if (doc.images[i].name && name == doc.images[i].name) - elmlist[elmlist.length] = doc.images[i]; - } - - for (i = 0; i < doc.forms.length; ++i) - { - for (j = 0; j < doc.forms[i].elements.length; j++) - if (doc.forms[i].elements[j].name && name == doc.forms[i].elements[j].name) - elmlist[elmlist.length] = doc.forms[i].elements[j]; - - if (doc.forms[i].name && name == doc.forms[i].name) - elmlist[elmlist.length] = doc.forms[i]; - } - - for (i = 0; i < doc.anchors.length; ++i) - { - if (doc.anchors[i].name && name == doc.anchors[i].name) - elmlist[elmlist.length] = doc.anchors[i]; - } - - for (i = 0; i < doc.links.length; ++i) - { - if (doc.links[i].name && name == doc.links[i].name) - elmlist[elmlist.length] = doc.links[i]; - } - - for (i = 0; i < doc.applets.length; ++i) - { - if (doc.applets[i].name && name == doc.applets[i].name) - elmlist[elmlist.length] = doc.applets[i]; - } - - for (i = 0; i < doc.embeds.length; ++i) - { - if (doc.embeds[i].name && name == doc.embeds[i].name) - elmlist[elmlist.length] = doc.embeds[i]; - } - - for (i = 0; i < doc.layers.length; ++i) - { - if (doc.layers[i].name && name == doc.layers[i].name) - elmlist[elmlist.length] = doc.layers[i]; - - subdoc = doc.layers[i].document; - nav4FindElementsByName(subdoc, name, elmlist); - } -} - -function xbGetElementsByNameAndType(name, type, windowRef) -{ - if (!windowRef) - windowRef = window; - - var elmlist = new Array(); - - xbFindElementsByNameAndType(windowRef.document, name, type, elmlist); - - return elmlist; -} - -function xbFindElementsByNameAndType(doc, name, type, elmlist) -{ - var i; - var subdoc; - - for (i = 0; i < doc[type].length; ++i) - { - if (doc[type][i].name && name == doc[type][i].name) - elmlist[elmlist.length] = doc[type][i]; - } - - if (doc.layers) - { - for (i = 0; i < doc.layers.length; ++i) - { - subdoc = doc.layers[i].document; - xbFindElementsByNameAndType(subdoc, name, type, elmlist); - } - } -} - -//alert("layers: " + document.layers + " all: " + document.all); - -if (document.layers) -{ - xbGetElementById = function (id, windowRef) - { - if (!windowRef) - windowRef = window; - - return nav4FindLayer(windowRef.document, id); - }; - - xbGetElementsByName = function (name, windowRef) - { - if (!windowRef) - windowRef = window; - - var elmlist = new Array(); - - nav4FindElementsByName(windowRef.document, name, elmlist); - - return elmlist; - }; - -} -else if (document.all) -{ - xbGetElementById = function (id, windowRef) - { - if (!windowRef) windowRef = window; - var elm = windowRef.document.all[id]; - if (!elm) elm = null; - return elm; - }; - - xbGetElementsByName = function (name, windowRef) - { - if (!windowRef) windowRef = window; - - var i; - var idnamelist = windowRef.document.all.tags(name); - var elmlist = new Array(); - - if (!idnamelist) { - return null; - } - - if (!idnamelist.length || idnamelist.name == name) - { - if (idnamelist) - elmlist[elmlist.length] = idnamelist; - } - else - { - for (i = 0; i < idnamelist.length; i++) - { - if (idnamelist.item(i).tagName == name) - elmlist[elmlist.length] = idnamelist[i]; - } - } - - return elmlist; - } - -} -else if (document.getElementById) -{ - xbGetElementById = function (id, windowRef) { if (!windowRef) windowRef = window; return windowRef.document.getElementById(id); }; - xbGetElementsByName = function (name, windowRef) { if (!windowRef) windowRef = window; return windowRef.document.getElementsByTagName(name); }; -} -else -{ - xbGetElementById = function (id, windowRef) { return null; } - xbGetElementsByName = function (name, windowRef) { return new Array(); } -} - -if (typeof(window.pageXOffset) == 'number') -{ - xbGetPageScrollX = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.pageXOffset; }; - xbGetPageScrollY = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.pageYOffset; }; -} -else if (document.all) -{ - xbGetPageScrollX = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.document.body.scrollLeft; }; - xbGetPageScrollY = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.document.body.scrollTop; }; -} -else -{ - xbGetPageScrollX = function (windowRef) { return 0; }; - xbGetPageScrollY = function (windowRef) { return 0; }; -} - -if (document.layers) -{ - xbSetInnerHTML = function (element, str) { element.document.write(str); element.document.close(); }; -} -else if (document.all || document.getElementById) -{ - xbSetInnerHTML = function (element, str) { if (typeof(element.innerHTML) != 'undefined') element.innerHTML = str; }; -} -else -{ - xbSetInnerHTML = function (element, str) {}; -} - - -// eof: xbDOM.js +/* + * xbDOM.js + * $Revision: 1.2 $ $Date: 2003/02/07 16:04:18 $ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * 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 compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ + +function xbToInt(s) +{ + var i = parseInt(s, 10); + if (isNaN(i)) + i = 0; + + return i; +} + +function xbGetWindowWidth(windowRef) +{ + var width = 0; + + if (!windowRef) + { + windowRef = window; + } + + if (typeof(windowRef.innerWidth) == 'number') + { + width = windowRef.innerWidth; + } + else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') + { + width = windowRef.document.body.clientWidth; + } + + return width; +} + +function xbGetWindowHeight(windowRef) +{ + var height = 0; + + if (!windowRef) + { + windowRef = window; + } + + if (typeof(windowRef.innerWidth) == 'number') + { + height = windowRef.innerHeight; + } + else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') + { + height = windowRef.document.body.clientHeight; + } + return height; +} + +function xbGetElementsByNameAndType(name, type, windowRef) +{ + if (!windowRef) + windowRef = window; + + var elmlist = new Array(); + + xbFindElementsByNameAndType(windowRef.document, name, type, elmlist); + + return elmlist; +} + +function xbFindElementsByNameAndType(doc, name, type, elmlist) +{ + var i; + var subdoc; + + for (i = 0; i < doc[type].length; ++i) + { + if (doc[type][i].name && name == doc[type][i].name) + { + elmlist[elmlist.length] = doc[type][i]; + } + } + + if (doc.layers) + { + for (i = 0; i < doc.layers.length; ++i) + { + subdoc = doc.layers[i].document; + xbFindElementsByNameAndType(subdoc, name, type, elmlist); + } + } +} + +if (document.layers) +{ + nav4FindLayer = + function (doc, id) + { + var i; + var subdoc; + var obj; + + for (i = 0; i < doc.layers.length; ++i) + { + if (doc.layers[i].id && id == doc.layers[i].id) + return doc.layers[i]; + + subdoc = doc.layers[i].document; + obj = nav4FindLayer(subdoc, id); + if (obj != null) + return obj; + } + return null; + } + + nav4FindElementsByName = + function (doc, name, elmlist) + { + var i; + var j; + var subdoc; + + for (i = 0; i < doc.images.length; ++i) + { + if (doc.images[i].name && name == doc.images[i].name) + { + elmlist[elmlist.length] = doc.images[i]; + } + } + + for (i = 0; i < doc.forms.length; ++i) + { + for (j = 0; j < doc.forms[i].elements.length; j++) + { + if (doc.forms[i].elements[j].name && name == doc.forms[i].elements[j].name) + { + elmlist[elmlist.length] = doc.forms[i].elements[j]; + } + } + + if (doc.forms[i].name && name == doc.forms[i].name) + { + elmlist[elmlist.length] = doc.forms[i]; + } + } + + for (i = 0; i < doc.anchors.length; ++i) + { + if (doc.anchors[i].name && name == doc.anchors[i].name) + { + elmlist[elmlist.length] = doc.anchors[i]; + } + } + + for (i = 0; i < doc.links.length; ++i) + { + if (doc.links[i].name && name == doc.links[i].name) + { + elmlist[elmlist.length] = doc.links[i]; + } + } + + for (i = 0; i < doc.applets.length; ++i) + { + if (doc.applets[i].name && name == doc.applets[i].name) + { + elmlist[elmlist.length] = doc.applets[i]; + } + } + + for (i = 0; i < doc.embeds.length; ++i) + { + if (doc.embeds[i].name && name == doc.embeds[i].name) + { + elmlist[elmlist.length] = doc.embeds[i]; + } + } + + for (i = 0; i < doc.layers.length; ++i) + { + if (doc.layers[i].name && name == doc.layers[i].name) + { + elmlist[elmlist.length] = doc.layers[i]; + } + + subdoc = doc.layers[i].document; + nav4FindElementsByName(subdoc, name, elmlist); + } + } + + xbGetElementById = function (id, windowRef) + { + if (!windowRef) + windowRef = window; + + return nav4FindLayer(windowRef.document, id); + }; + + xbGetElementsByName = function (name, windowRef) + { + if (!windowRef) + windowRef = window; + + var elmlist = new Array(); + + nav4FindElementsByName(windowRef.document, name, elmlist); + + return elmlist; + }; + +} +else if (document.all) +{ + xbGetElementById = + function (id, windowRef) + { + if (!windowRef) + { + windowRef = window; + } + var elm = windowRef.document.all[id]; + if (!elm) + { + elm = null; + } + return elm; + }; + + xbGetElementsByName = function (name, windowRef) + { + if (!windowRef) + windowRef = window; + + var i; + var idnamelist = windowRef.document.all[name]; + var elmlist = new Array(); + + if (!idnamelist.length || idnamelist.name == name) + { + if (idnamelist) + elmlist[elmlist.length] = idnamelist; + } + else + { + for (i = 0; i < idnamelist.length; i++) + { + if (idnamelist[i].name == name) + elmlist[elmlist.length] = idnamelist[i]; + } + } + + return elmlist; + } + +} +else if (document.getElementById) +{ + xbGetElementById = + function (id, windowRef) + { + if (!windowRef) + { + windowRef = window; + } + return windowRef.document.getElementById(id); + }; + + xbGetElementsByName = + function (name, windowRef) + { + if (!windowRef) + { + windowRef = window; + } + return windowRef.document.getElementsByName(name); + }; +} +else +{ + xbGetElementById = + function (id, windowRef) + { + return null; + }; + + xbGetElementsByName = + function (name, windowRef) + { + return new Array(); + }; +} + +function xbGetPageScrollX(windowRef) +{ + if (!windowRef) + { + windowRef = window; + } + + if (typeof(windowRef.pageXOffset) == 'number') + { + return windowRef.pageXOffset; + } + + if (typeof(windowRef.document.body && windowRef.document.body.scrollLeft) == 'number') + { + return windowRef.document.body.scrollLeft; + } + + return 0; +} + +function xbGetPageScrollY(windowRef) +{ + if (!windowRef) + { + windowRef = window; + } + + if (typeof(windowRef.pageYOffset) == 'number') + { + return windowRef.pageYOffset; + } + + if (typeof(windowRef.document.body && windowRef.document.body.scrollTop) == 'number') + { + return windowRef.document.body.scrollTop; + } + + return 0; +} + +if (document.layers) +{ + xbSetInnerHTML = + function (element, str) + { + element.document.write(str); + element.document.close(); + }; +} +else +{ + xbSetInnerHTML = function (element, str) + { + if (typeof(element.innerHTML) != 'undefined') + { + element.innerHTML = str; + } + }; +} + +// eof: xbDOM.js diff --git a/slides/browser/xbDebug.js b/slides/browser/xbDebug.js index 000f8c77e..48fd010cb 100644 --- a/slides/browser/xbDebug.js +++ b/slides/browser/xbDebug.js @@ -1,223 +1,311 @@ -/* -xbDebug.js revision: 0.003 2002-02-26 - -Contributor(s): Bob Clary, Netscape Communications, Copyright 2001 - -Netscape grants you a royalty free license to use, modify and -distribute this software provided that this copyright notice -appears on all copies. This software is provided "AS IS," -without a warranty of any kind. - -ChangeLog: - -2002-02-25: bclary - modified xbDebugTraceOject to make sure - that original versions of wrapped functions were not - rewrapped. This had caused an infinite loop in IE. - -2002-02-07: bclary - modified xbDebug.prototype.close to not null - the debug window reference. This can cause problems with - Internet Explorer if the page is refreshed. These issues will - be addressed at a later date. -*/ - -function xbDebug() -{ - this.on = false; - this.stack = new Array(); - this.debugwindow = null; - this.execprofile = new Object(); -} - -xbDebug.prototype.push = function () -{ - this.stack[this.stack.length] = this.on; - this.on = true; -} - -xbDebug.prototype.pop = function () -{ - this.on = this.stack[this.stack.length - 1]; - --this.stack.length; -} - -xbDebug.prototype.open = function () -{ - if (this.debugwindow && !this.debugwindow.closed) - this.close(); - - this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes'); - - this.debugwindow.title = 'xbDebug Window'; - this.debugwindow.document.write('xbDebug Window

Javascript Debug Window

'); - this.debugwindow.focus(); -} - -xbDebug.prototype.close = function () -{ - if (!this.debugwindow) - return; - - if (!this.debugwindow.closed) - this.debugwindow.close(); - - // bc 2002-02-07, other windows may still hold a reference to this: this.debugwindow = null; -} - -xbDebug.prototype.dump = function (msg) -{ - if (!this.on) - return; - - if (!this.debugwindow || this.debugwindow.closed) - this.open(); - - this.debugwindow.document.write(msg + '
'); - - return; -} - -var xbDEBUG = new xbDebug(); - -window.onunload = function () { xbDEBUG.close(); } - -function xbDebugGetFunctionName(funcref) -{ - - if (funcref.name) - return funcref.name; - - var name = funcref + ''; - name = name.substring(name.indexOf(' ') + 1, name.indexOf('(')); - funcref.name = name; - - return name; -} - -function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall) -{ - var wrappedfunc; - var scopeobject = eval(scopename); - var funcref = scopeobject[funcname]; - - scopeobject['xbDebug_orig_' + funcname] = funcref; - - wrappedfunc = function () - { - precall(scopename, funcname, arguments); - var rv = funcref.apply(this, arguments); - postcall(scopename, funcname, arguments, rv); - return rv; - }; - - if (typeof(funcref.constructor) != 'undefined') - wrappedfunc.constructor = funcref.constuctor; - - if (typeof(funcref.prototype) != 'undefined') - wrappedfunc.prototype = funcref.prototype; - - scopeobject[funcname] = wrappedfunc; -} - -function xbDebugPersistToString(obj) -{ - var s = ''; - var p; - - if (obj == null) - return 'null'; - - switch(typeof(obj)) - { - case 'number': - return obj; - case 'string': - return '"' + obj + '"'; - case 'undefined': - return 'undefined'; - case 'boolean': - return obj + ''; - } - - return '[' + xbDebugGetFunctionName(obj.constructor) + ']'; -} - -function xbDebugTraceBefore(scopename, funcname, funcarguments) -{ - var i; - var s = ''; - var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname]; - if (!execprofile) - execprofile = xbDEBUG.execprofile[scopename + '.' + funcname] = { started: 0, time: 0, count: 0 }; - - for (i = 0; i < funcarguments.length; i++) - { - s += xbDebugPersistToString(funcarguments[i]); - if (i < funcarguments.length - 1) - s += ', '; - } - - xbDEBUG.dump('enter ' + scopename + '.' + funcname + '(' + s + ')'); - execprofile.started = (new Date()).getTime(); -} - -function xbDebugTraceAfter(scopename, funcname, funcarguments, rv) -{ - var i; - var s = ''; - var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname]; - if (!execprofile) - xbDEBUG.dump('xbDebugTraceAfter: execprofile not created for ' + scopename + '.' + funcname); - else if (execprofile.started == 0) - xbDEBUG.dump('xbDebugTraceAfter: execprofile.started == 0 for ' + scopename + '.' + funcname); - else - { - execprofile.time += (new Date()).getTime() - execprofile.started; - execprofile.count++; - execprofile.started = 0; - } - - for (i = 0; i < funcarguments.length; i++) - { - s += xbDebugPersistToString(funcarguments[i]); - if (i < funcarguments.length - 1) - s += ', '; - } - - xbDEBUG.dump('exit ' + scopename + '.' + funcname + '(' + s + ')==' + xbDebugPersistToString(rv)); -} - -function xbDebugTraceFunction(scopename, funcname) -{ - xbDebugCreateFunctionWrapper(scopename, funcname, xbDebugTraceBefore, xbDebugTraceAfter); -} - -function xbDebugTraceObject(scopename, objname) -{ - var objref = eval(scopename + '.' + objname); - var p; - - if (!objref || !objref.prototype) - return; - - for (p in objref.prototype) - { - if (typeof(objref.prototype[p]) == 'function' && (p+'').indexOf('xbDebug_orig') == -1) - { - xbDebugCreateFunctionWrapper(scopename + '.' + objname + '.prototype', p + '', xbDebugTraceBefore, xbDebugTraceAfter); - } - } -} - -function xbDebugDumpProfile() -{ - var p; - var execprofile; - var avg; - - for (p in xbDEBUG.execprofile) - { - execprofile = xbDEBUG.execprofile[p]; - avg = Math.round ( 100 * execprofile.time/execprofile.count) /100; - xbDEBUG.dump('Execution profile ' + p + ' called ' + execprofile.count + ' times. Total time=' + execprofile.time + 'ms. Avg Time=' + avg + 'ms.'); - } -} +/* + * xbDebug.js + * $Revision: 1.2 $ $Date: 2003/02/07 16:04:19 $ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * 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 compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ + +/* +ChangeLog: + +2002-02-25: bclary - modified xbDebugTraceOject to make sure + that original versions of wrapped functions were not + rewrapped. This had caused an infinite loop in IE. + +2002-02-07: bclary - modified xbDebug.prototype.close to not null + the debug window reference. This can cause problems with + Internet Explorer if the page is refreshed. These issues will + be addressed at a later date. +*/ + +function xbDebug() +{ + this.on = false; + this.stack = new Array(); + this.debugwindow = null; + this.execprofile = new Object(); +} + +xbDebug.prototype.push = function () +{ + this.stack[this.stack.length] = this.on; + this.on = true; +} + +xbDebug.prototype.pop = function () +{ + this.on = this.stack[this.stack.length - 1]; + --this.stack.length; +} + +xbDebug.prototype.open = function () +{ + if (this.debugwindow && !this.debugwindow.closed) + this.close(); + + this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes'); + this.debugwindow.moveTo(0,0); + window.focus(); + + this.debugwindow.document.write('xbDebug Window

Javascript Debug Window

'); +} + +xbDebug.prototype.close = function () +{ + if (!this.debugwindow) + return; + + if (!this.debugwindow.closed) + this.debugwindow.close(); + + // bc 2002-02-07, other windows may still hold a reference to this: this.debugwindow = null; +} + +xbDebug.prototype.dump = function (msg) +{ + if (!this.on) + return; + + if (!this.debugwindow || this.debugwindow.closed) + this.open(); + + this.debugwindow.document.write(msg + '
'); + + return; +} + +var xbDEBUG = new xbDebug(); + +window.onunload = function () { xbDEBUG.close(); } + +function xbDebugGetFunctionName(funcref) +{ + + if (!funcref) + { + return ''; + } + + if (funcref.name) + return funcref.name; + + var name = funcref + ''; + name = name.substring(name.indexOf(' ') + 1, name.indexOf('(')); + funcref.name = name; + + if (!name) alert('name not defined'); + return name; +} + + +// emulate functionref.apply for IE mac and IE win < 5.5 +function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref) +{ + var rv; + + if (!funcref) + { + alert('xbDebugApplyFunction: funcref is null'); + } + + if (typeof(funcref.apply) != 'undefined') + return funcref.apply(thisref, argumentsref); + + var applyexpr = 'thisref.xbDebug_orig_' + funcname + '('; + var i; + + for (i = 0; i < argumentsref.length; i++) + { + applyexpr += 'argumentsref[' + i + '],'; + } + + if (argumentsref.length > 0) + { + applyexpr = applyexpr.substring(0, applyexpr.length - 1); + } + + applyexpr += ')'; + + return eval(applyexpr); +} + +function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall) +{ + var wrappedfunc; + var scopeobject = eval(scopename); + var funcref = scopeobject[funcname]; + + scopeobject['xbDebug_orig_' + funcname] = funcref; + + wrappedfunc = function () + { + var rv; + + precall(scopename, funcname, arguments); + rv = xbDebugApplyFunction(funcname, funcref, scopeobject, arguments); + postcall(scopename, funcname, arguments, rv); + return rv; + }; + + if (typeof(funcref.constructor) != 'undefined') + wrappedfunc.constructor = funcref.constuctor; + + if (typeof(funcref.prototype) != 'undefined') + wrappedfunc.prototype = funcref.prototype; + + scopeobject[funcname] = wrappedfunc; +} + +function xbDebugCreateMethodWrapper(contextname, classname, methodname, precall, postcall) +{ + var context = eval(contextname); + var methodref = context[classname].prototype[methodname]; + + context[classname].prototype['xbDebug_orig_' + methodname] = methodref; + + var wrappedmethod = function () + { + var rv; + // eval 'this' at method run time to pick up reference to the object's instance + var thisref = eval('this'); + // eval 'arguments' at method run time to pick up method's arguments + var argsref = arguments; + + precall(contextname + '.' + classname, methodname, argsref); + rv = xbDebugApplyFunction(methodname, methodref, thisref, argsref); + postcall(contextname + '.' + classname, methodname, argsref, rv); + return rv; + }; + + return wrappedmethod; +} + +function xbDebugPersistToString(obj) +{ + var s = ''; + + if (obj == null) + return 'null'; + + switch(typeof(obj)) + { + case 'number': + return obj; + case 'string': + return '"' + obj + '"'; + case 'undefined': + return 'undefined'; + case 'boolean': + return obj + ''; + } + + if (obj.constructor) + return '[' + xbDebugGetFunctionName(obj.constructor) + ']'; + + return null; +} + +function xbDebugTraceBefore(scopename, funcname, funcarguments) +{ + var i; + var s = ''; + var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname]; + if (!execprofile) + execprofile = xbDEBUG.execprofile[scopename + '.' + funcname] = { started: 0, time: 0, count: 0 }; + + for (i = 0; i < funcarguments.length; i++) + { + s += xbDebugPersistToString(funcarguments[i]); + if (i < funcarguments.length - 1) + s += ', '; + } + + xbDEBUG.dump('enter ' + scopename + '.' + funcname + '(' + s + ')'); + execprofile.started = (new Date()).getTime(); +} + +function xbDebugTraceAfter(scopename, funcname, funcarguments, rv) +{ + var i; + var s = ''; + var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname]; + if (!execprofile) + xbDEBUG.dump('xbDebugTraceAfter: execprofile not created for ' + scopename + '.' + funcname); + else if (execprofile.started == 0) + xbDEBUG.dump('xbDebugTraceAfter: execprofile.started == 0 for ' + scopename + '.' + funcname); + else + { + execprofile.time += (new Date()).getTime() - execprofile.started; + execprofile.count++; + execprofile.started = 0; + } + + for (i = 0; i < funcarguments.length; i++) + { + s += xbDebugPersistToString(funcarguments[i]); + if (i < funcarguments.length - 1) + s += ', '; + } + + xbDEBUG.dump('exit ' + scopename + '.' + funcname + '(' + s + ')==' + xbDebugPersistToString(rv)); +} + +function xbDebugTraceFunction(scopename, funcname) +{ + xbDebugCreateFunctionWrapper(scopename, funcname, xbDebugTraceBefore, xbDebugTraceAfter); +} + +function xbDebugTraceObject(contextname, classname) +{ + var classref = eval(contextname + '.' + classname); + var p; + var sp; + + if (!classref || !classref.prototype) + return; + + for (p in classref.prototype) + { + sp = p + ''; + if (typeof(classref.prototype[sp]) == 'function' && (sp).indexOf('xbDebug_orig') == -1) + { + classref.prototype[sp] = xbDebugCreateMethodWrapper(contextname, classname, sp, xbDebugTraceBefore, xbDebugTraceAfter); + } + } +} + +function xbDebugDumpProfile() +{ + var p; + var execprofile; + var avg; + + for (p in xbDEBUG.execprofile) + { + execprofile = xbDEBUG.execprofile[p]; + avg = Math.round ( 100 * execprofile.time/execprofile.count) /100; + xbDEBUG.dump('Execution profile ' + p + ' called ' + execprofile.count + ' times. Total time=' + execprofile.time + 'ms. Avg Time=' + avg + 'ms.'); + } +} diff --git a/slides/browser/xbLibrary.js b/slides/browser/xbLibrary.js new file mode 100644 index 000000000..9bbfd6b14 --- /dev/null +++ b/slides/browser/xbLibrary.js @@ -0,0 +1,80 @@ +/* + * xbLibrary.js + * $Revision: 1.3 $ $Date: 2003/03/17 03:44:20 $ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * 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 compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Bob Clary code. + * + * The Initial Developer of the Original Code is + * Bob Clary. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ + +if (!document.getElementById || navigator.userAgent.indexOf('Opera') != -1) +{ + // assign error handler for downlevel browsers + // Note until Opera improves it's overall support + // for JavaScript and the DOM, it must be considered downlevel + + window.onerror = defaultOnError; + + function defaultOnError(msg, url, line) + { + // handle bug in NS6.1, N6.2 + // where an Event is passed to error handlers + if (typeof(msg) != 'string') + { + msg = 'unknown error'; + } + if (typeof(url) != 'string') + { + url = document.location; + } + + alert('An error has occurred at ' + url + ', line ' + line + ': ' + msg); + } +} + +function xbLibrary(path) +{ + if (path.charAt(path.length-1) == '/') + { + path = path.substr(0, path.length-1) + } + this.path = path; +} + +// dynamically loaded scripts +// +// it is an error to reference anything from the dynamically loaded file inside the +// same script block. This means that a file can not check its dependencies and +// load the files for it's own use. someone else must do this. + +xbLibrary.prototype.loadScript = +function (scriptName) +{ + document.write('