| 1 |
/* |
| 2 |
* xbLibrary.js |
| 3 |
* $Revision: 1.3 $ $Date: 2003/03/17 03:44:20 $ |
| 4 |
*/ |
| 5 |
|
| 6 |
/* ***** BEGIN LICENSE BLOCK ***** |
| 7 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 8 |
* |
| 9 |
* The contents of this file are subject to the Mozilla Public License Version |
| 10 |
* 1.1 (the "License"); you may not use this file except in compliance with |
| 11 |
* the License. You may obtain a copy of the License at |
| 12 |
* http://www.mozilla.org/MPL/ |
| 13 |
* |
| 14 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 15 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 16 |
* for the specific language governing rights and limitations under the |
| 17 |
* License. |
| 18 |
* |
| 19 |
* The Original Code is Bob Clary code. |
| 20 |
* |
| 21 |
* The Initial Developer of the Original Code is |
| 22 |
* Bob Clary. |
| 23 |
* Portions created by the Initial Developer are Copyright (C) 2000 |
| 24 |
* the Initial Developer. All Rights Reserved. |
| 25 |
* |
| 26 |
* Contributor(s): Bob Clary <[email protected]> |
| 27 |
* |
| 28 |
* ***** END LICENSE BLOCK ***** */ |
| 29 |
|
| 30 |
if (!document.getElementById || navigator.userAgent.indexOf('Opera') != -1) |
| 31 |
{ |
| 32 |
// assign error handler for downlevel browsers |
| 33 |
// Note until Opera improves it's overall support |
| 34 |
// for JavaScript and the DOM, it must be considered downlevel |
| 35 |
|
| 36 |
window.onerror = defaultOnError; |
| 37 |
|
| 38 |
function defaultOnError(msg, url, line) |
| 39 |
{ |
| 40 |
// handle bug in NS6.1, N6.2 |
| 41 |
// where an Event is passed to error handlers |
| 42 |
if (typeof(msg) != 'string') |
| 43 |
{ |
| 44 |
msg = 'unknown error'; |
| 45 |
} |
| 46 |
if (typeof(url) != 'string') |
| 47 |
{ |
| 48 |
url = document.location; |
| 49 |
} |
| 50 |
|
| 51 |
alert('An error has occurred at ' + url + ', line ' + line + ': ' + msg); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
function xbLibrary(path) |
| 56 |
{ |
| 57 |
if (path.charAt(path.length-1) == '/') |
| 58 |
{ |
| 59 |
path = path.substr(0, path.length-1) |
| 60 |
} |
| 61 |
this.path = path; |
| 62 |
} |
| 63 |
|
| 64 |
// dynamically loaded scripts |
| 65 |
// |
| 66 |
// it is an error to reference anything from the dynamically loaded file inside the |
| 67 |
// same script block. This means that a file can not check its dependencies and |
| 68 |
// load the files for it's own use. someone else must do this. |
| 69 |
|
| 70 |
xbLibrary.prototype.loadScript = |
| 71 |
function (scriptName) |
| 72 |
{ |
| 73 |
document.write('<script language="javascript" src="' + this.path + '/' + scriptName + '"><\/script>'); |
| 74 |
}; |
| 75 |
|
| 76 |
// default xbLibrary |
| 77 |
|
| 78 |
xblibrary = new xbLibrary('./'); |
| 79 |
|
| 80 |
|