/**************************************************************
* JSLoader - JavaScript on Loading Demand - jsloader.sourceforge.net
*
* Copyright (c) 2007, Morgan Stanley & Co. Incorporated
*
* THE FOLLOWING DISCLAIMER APPLIES TO ALL SOFTWARE CODE AND OTHER
* MATERIALS CONTRIBUTED IN CONNECTION WITH JSLoader:
*
* THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED AND ANY WARRANTY OF NON-
* INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE MAY
* BE REDISTRIBUTED TO OTHERS ONLY BY EFFECTIVELY USING THIS OR ANOTHER
* EQUIVALENT DISCLAIMER AS WELL AS ANY OTHER LICENSE TERMS THAT MAY APPLY.
*
* -------------------------------------------------------------
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* You can also find a copy of the GNU Lesser Public License at
* <http://www.gnu.org/licenses/>.
*
***********************************************************/
/*
* @fileoverview JSLoaderEnvironment is intended to model a simplified
* runtime environment for loading other web functionality, such
* as RIA/JavaScript files onto the page. Example code:
* <pre>
* @lt;script src="path/to/jsloader.js"></script>
* @lt;script type="text/javascript">
* // JSLoader is already defined by including jsloader.js
* JSLoader.load("meta","project","release");
* </script>
* </pre>
*/
/**
* Construct a new JSLoaderEnvironment instance
* @class JSLoaderEnvironment is the class designed to be a
* representation of a unix-like shell environment.
* The purpose of this is to allow the infrastructure to abstract
* away any library file location knowledge for rapid and enterprise
* adoption and deployment
*/
function JSLoaderEnvironment(){
// Default
this.prefix="/assets/";
// Auto-discover location
var _remote=false;
var s=0;
var _script_tags=document.getElementsByTagName("script");
var endsWith=function(str, substr){
return (str && str.indexOf(substr) == (str.length-substr.length));
};
for(s=0;s<_script_tags.length;++s){
var src=_script_tags[s].src;
var src_orig=src;
if(src){
if(src.indexOf("://")>-1)
{
src=src.substring(src.indexOf("://")+3);
src=src.substring(src.indexOf("/"));
}
if(endsWith(src,"jsloader.js") || endsWith(src,"jsloader-debug.js")) {
// If the domain is remote, assume we're running in hosted mode
_remote=(src_orig.indexOf(document.domain)==-1);
if(_remote) src=src_orig;
this.prefix=src.substring(0, src.lastIndexOf("/")+1);
}
}
}
/**
* @private
*/
this.suffix=".js";
/**
* @private
* Make the Path of a module to meta/proj/release
*/
this.makeJSLoaderPath=function(m,p,r,suff){
// if just a url is specified, use it
if(!p && !r) return this.stripExternalRef(m);
// build the m/p/r path
return this.prefix+m+"/"+p+"/incr/versions/"+r+ ((suff)?this.suffix:"");
}
/**
* The generate the path prefix for a MPR linked into the JSLoader Environmentiables
* @param m meta
* @param p project
* @param r release
*/
this.makePath=function(m,p,r){
// if just a url is specified, use it
if(!p && !r) return this.stripExternalRef(m);
// build the m/p/r path
return this.prefix + m +"/" + p + "/" + r + "/";
}
/**
* @private
*/
this.env=new Object();
/**
* @private
*/
this.loaders=new Object();
/**
* The sets an environment variable (make sure it's safe for JS Object[key] notation)
* The idea here is that modules could set this, and pages which load the module
* can then get the Environment variables
* @param k javascript object[key]
* @param v value (technically could be of any type...)
*/
this.setEnv=function(k,v){
this.env[k]=v;
}
/**
* The gets an environment variable previously set
* @param k javascript object[key]
* @returns the value set for this key
*/
this.getEnv=function(k){ return this.env[k];}
/**
* Lists all modules
* loaded in this environment.
* @private
*/
this._loadedJSLoaders=new Object();
/**
* This makes a normalized key to stick into loaded_modules and verify if things are loaded.
* @private
*/
this.normalize=function(m,p,r){ return (m+"__"+p+"__"+r).toLowerCase();};
/**
* This checks whether the given meta/project/release is already loaded.
* @param m metaproject (or the path of a JS file, if no other args are passed)
* @param p project
* @param r release
* @type boolean
* @returns Whether m/p/r is loaded
*/
this.isLoaded=function(m,p,r){
var xkey=this.normalize(m,p,r);
return(this._loadedJSLoaders[xkey]!=null);
};
/**
* Gets a "loader" based on the MPR specified in the arguments
* This is useful for loading subpackages. You can call {@link JSSubLoader#load} or {@link JSSubLoader#loadAll} on this
* and it will load submodules under a folder with the "release" number
* @see JSSubLoader
* @param m metaproject
* @param p project
* @param r release
* @returns void
*/
this.getLoader=function(m,p,r){
var key=this.normalize(m,p,r);
var loader=this.loaders[key];
if(loader) {
return loader;
}
else {
loader=new JSSubLoader(this,this.makeJSLoaderPath(m,p,r,false)+"/");
var __path=this.makePath(m,p,r);
this.setEnv(p.toUpperCase()+"_PATH",__path);
this.loaders[key]=loader;
return loader;
}
}
/**
* Loads the requested module into the environment
* You can also load your own module by calling loadJavascript(url) if you want
* @param m metaproject
* @param p project
* @param r release
* @type boolean
* @returns void
*/
this.load=function(m,p,r){
var key=this.normalize(m,p,r);
var url=this.makeJSLoaderPath(m,p,r,true);
try{
if(this.isLoaded(m,p,r)) {
return;
}
this.loadJavaScript(url);
this._loadedJSLoaders[key]="true";
} catch (e){ this.handleError(e); }
};
/**
* Loads a JavaScript file into the page
* @param {String} url the url of the javascript file
*/
this.loadJavaScript=function (url){
url = this.stripExternalRef(url);
document.writeln("<scri"+"pt src='"+url+"' type='text/javascript'></sc"+"ript>");
};
/**
* Loads a JavaScript file into the page
* @param {String} url the url of the javascript file
*/
this.loadStyleSheet=function(url){
url = this.stripExternalRef(url);
document.writeln("<li"+"nk rel='stylesheet' href='"+url+"' type='text/css'></li"+"nk>");
};
/**
* Strips out any double slashes, double dots, or cross domain references.
* @param s string
*/
this.stripExternalRef=function(s){
var exprs = [/\.\.+/g,/\/\/+/g,/\\\\+/g,/\:+/g,/\'+/g,/\%+/g];
// If it's hosted, we relax the protocol related regex
exprs = [/\.\.+/g,/\\\\+/g,/\'+/g,/\%+/g];
if (_remote)
for(var i=0; i<exprs.length; i++)
{
s = s.replace(exprs[i], '');
}
return s;
}
/**
* Overwritable error handler
*/
this.handleError=function(e) {
}
return this;
};
/**
* Construct a new JSSubLoader instance. You shoudl never need to call this, as {@link JSLoaderEnvironment#getLoader} gets you one of these from the environment.
* @class JSSubLoader is designed to load "sub" modules
* This is a wrapper which is produced when you call {@link JSLoaderEnvironment#getLoader}
* It is designed to allow sub-packages within a given MPR to be loaded easily. This is constructed by JSLoader.getLoader() call
* so you should never really need to construct one of these.
* @constructor
* @param {JSLoaderEnvironment} env_
* @param {String} prefix_ The path underneath which the submodules reside
*
*/
function JSSubLoader(env_, prefix_){
/**
* @private
*/
this.environment=env_;
/**
* @private
*/
this.prefix=prefix_;
/**
* @private
*/
this.loaded=new Object();
/**
* @private
*/
this.normalize=function(str){ return str.toLowerCase(); }
/**
* Loads an array of subpackages
* @param {Array} pkgs an array of packages.
*/
this.loadAll=function(pkgs_){
for(i=0;i<pkgs_.length;++i) this.load(pkgs_[i]);
};
/**
* Loads a subpackage, if it's not already loaded
* @param {String} url the url of the sub-package module file (m/p/r/submodule.js)
*/
this.load=function(pkg){
var p=this.normalize(pkg);
if (this.loaded[p]) {
return;
}
this.loaded[p]=pkg;
this.environment.loadJavaScript(prefix_+pkg+".js");
};
};
JSLoader = new JSLoaderEnvironment();
// LocalWords: fileoverview
分享到:
相关推荐
《EXT开发基础:详解"ext-base.js"与EXT框架》 EXT是一个强大的JavaScript库,它为Web应用程序提供了丰富的用户界面组件和数据管理功能。在EXT的开发中,"ext-base.js"扮演着至关重要的角色,它是EXT框架的核心部分...
标题中的"ext - 2.2 .zip"指的是一个特定版本的EXT库,EXT是一个流行的JavaScript框架,专门用于构建富互联网应用程序(RIA)。这个版本是2.2,可能包含了该框架在该时期的所有功能和更新。 描述部分提到,这个zip...
Sencha Ext JS是一个用于构建富互联网应用程序(RIA)的JavaScript框架,它提供了丰富的UI组件,如表格、按钮、表单、树视图等,使得Oozie的工作流设计和监控界面更加直观易用。 在安装Oozie时,通常会发现官方文档...
解压即可得到jcifs-ext-0.9.4.jar, java环境资源,jdk1.6及以上
在JavaScript编程中,`Ext.Ajax.request`是Ext JS库中的一个核心方法,用于发起Ajax(异步JavaScript和XML)请求。它允许开发者与服务器进行数据交互,无需刷新整个页面,提高了用户体验。然而,当你尝试将`Ext.Ajax...
xml-apis-ext-1.3.04.jar
3. `ext-all-rtl-dev.js` 和 `ext-all-rtl-debug-w-comments.js` - 这两个文件是针对右到左(RTL)语言布局的开发版本,包含了源代码和注释,用于调试和开发。 4. `ext-all-dev.js` 和 `ext-all-debug-w-comments.js` ...
从spket IDE 官网下载。 文件名: ext-4.2.1.883.jsb2 对应版本ext-4.2.*版本。spket自动提示ExtJs4,需要ext4.2.1.jsp2文件。
2.将下载的两个JAR文件复制到:JDK安装目录\jre\lib\ext下,例如我的就是D:\Program Files (x86)\java\JDK1.6\jre\lib\ext 3.打开java.security文件:在JDK安装目录\jre\lib\security下的java.security文件。
Extjs中实现国际化要用到的文件ext-lang-zh_CN.js和ext-lang-en.js
isr4300-universalk9.03.13.07.S.154-3.S7-ext.SPA .bin 思科4300 系列路由器
isr4300-universalk9.03.16.09.S.155-3.S9-ext.SPA.bin 思科路由器4300 系列ios
ext-all.js,ext-all.css
ext 是 ExtJs 的简称,是一个强大的js 类库。本资源主要包括三个大的文件ext-all.css,ext-base.js,ext-al.js。在引用ext 类库的时候,这三个文件必不可少。另外我还提供了ext2的一个简单例子,以便大家学习交流。
在CDH使用oozie 的时候需要安装ext-2.2.zip; 新增和改进的功能包括: 1、FileUploadField 文件上传 体验例子见:http://extjs.com/deploy/dev/examples/form/file-upload.html 2、GMapPanel GMap扩展 体验...
"bcprov-ext-jdk15on-154.jar" 和 "bcprov-jdk15on-154.jar" 是两个非常重要的工具jar包,它们属于Bouncy Castle加密库,专门用于解决Java中的加密和安全问题,尤其是当系统遇到"javax.net.ssl.SSLException: java....
ext-bootstrap.jsext-bootstrap.jsext-bootstrap.jsext-bootstrap.jsext-bootstrap.js
为了解决这个问题,我们可以引入Bouncy Castle提供的jar包:bcprov-ext-jdk15on-1.54.jar和bcprov-jdk15on-1.54.jar。 Bouncy Castle是一个开源的Java加密库,它提供了丰富的加密算法和协议实现,包括对称加密、非...