/** * @fileoverview Loads generic modules required for all widgets. * *
* Copyright (c) 2004-2006 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. **/ if (typeof Zapatec == 'undefined') { /** * Namespace definition. * @constructor */ Zapatec = function() {}; } /** * Returns path from the last loaded script element. Splits src attribute value * and returns path without js file name. * *
* Note: This function should not be called from another function. It must be * invoked during page load to determine path to js file from which it is called * correctly. *
* * @private * @return Path to the script, e.g. '../src/' or '' if path is not found * @type string */ Zapatec.getPath = function() { // Get last script element var objContainer = document.body; if (!objContainer) { objContainer = document.getElementsByTagName('head')[0]; if (!objContainer) { objContainer = document; } } var objScript = objContainer.lastChild; // Get path var strSrc = objScript.getAttribute('src'); if (!strSrc) { return ''; } var arrTokens = strSrc.split('/'); // Remove last token arrTokens = arrTokens.slice(0, -1); if (!arrTokens.length) { return ''; } return arrTokens.join('/') + '/'; }; /** * Simply writes script tag to the document. * * @private * @param {string} strSrc Src attribute value of the script element */ Zapatec.include = function(strSrc) { document.write('