复制代码 代码如下:
/**************************************************
*TheBasicLibforHUTIAframework
*Author:Hutia
*E-Mail:Hutia2@gmail.com
*Create:2006-08-21
*LastModify:2006-08-26
*Version:1.02
*CopyrightDeclare:Everybodycanuseforfreelybutcannotbeusedincommerce.
*
*Pleasekeepthisinformationwhilequote.
**/
//********BEFOREALL**************
varcurrentLibName="main.basic";
try{//catchalltheexceptionsduringloading
//=================DeclareCONSTANTSection===Start===========
varvbOK=0;varvbOKCancel=1;varvbAbortRetryIgnor=2;varvbYesNoCancel=3;
varvbYesNo=4;varvbRetryCacel=5;varvbStop=16;varvbQuest=32;varvbAlert=48;
varvbInfo=64;varvbReturnOK=1;varvbReturnCacel=2;varvbReturnAbort=3;
varvbReturnRetry=4;varvbReturnIgnor=5;varvbReturnYes=6;varvbReturnNo=7;
varvbCrLf="rn";
//-----------------DeclareCONSTANTSection-End---------------
/////////////////////////////////////////////////////////////////////////
//=================DeclareGlobalVariableSection===Start===========
varSITE_ROOT="E:hutiaprogramDevelopingGJS_v3".replace(//g,"/").replace(/([^/])$/,"$1/");
//-----------------DeclareGlobalVariableSection-End---------------
/////////////////////////////////////////////////////////////////////////
//=================DeclareGlobalFunctionSection===Start===========
//AliaNameforAsynLoader.depend
$depend=function(str,currentLibName,defer){
AsynLoader.depend(str,currentLibName,defer);
}
//AliaNameforAsynLoader.include
$include=function(str){
AsynLoader.include(str);
}
functionsay(str){
alert(str);
}
functionuid(){
return("u"+(newDate()).getTime().toString(35)+parseInt(Math.random()*999999).toString(35));
}
//-----------------DeclareGlobalFunctionSection-End---------------
/////////////////////////////////////////////////////////////////////////
//=================DeclareGlobalObjectSection===Start===========
//Theasynchronousloader
varAsynLoader=newfunction(){
//delareprivatevariable
varalias,currentPath,dependences,dependent,libs,paths;
}
AsynLoader.alertLoadResult=function(){
varstr="";
for(variinlibs){if(libs[i]=="loaded"){str+="Load""+i+""Successfully.rn";}else{str+=libs[i]+"rn";}}
say(str);
}
AsynLoader.alias=function(aliasName,strPath,singleInstance){
strPath=this.getPath(strPath);
if(!strPath||typeof(aliasName)!="string"||aliasName=="")return;
alias[aliasName]=strPath;
alias[aliasName][2]=Boolean(singleInstance);
}
AsynLoader.depend=function(strLibName,strSrcLibName,defer){
if(typeof(strLibName)!="string"||strLibName=="")throw("InvalidLibName.");
if(libs[strLibName]!="loaded"){
if(defer&&alias[strLibName]){
AsynLoader.include(strLibName);
}elsethrow("Dependencevalidationfailure.rn"+libs[strLibName]);
}
if(typeof(strSrcLibName)=="string"&&strSrcLibName!=""){
temp=strSrcLibName+"=>"+strLibName;
dependences.push(temp);
}
}
AsynLoader.getDependBy=function(str){
varre=newArray();
for(vari=0;i
return(re.join(";"));
}
AsynLoader.getDependOn=function(str){
varre=newArray();
for(vari=0;i
return(re.join(";"));
}
AsynLoader.getLibs=function(){
varre=newArray(),hash=newArray();
for(variinlibs)if(!hash[i]){hash[i]=true;re.push(i);}
re.sort();
return(re.join(";"));
}
AsynLoader.getPath=function(strPath){
varext,i,re,strPath;
if(typeof(strPath)!="string"||strPath=="")return(false);
ext="js";
if(strPath.indexOf(":")==-1)if(this.pathType=="absolute"){strPath=SITE_ROOT+currentPath+strPath;}else{strPath=currentPath+strPath;}
i=strPath.lastIndexOf(".");
if(i!=-1&&i
}else{
strPath=strPath+"."+ext;
}
return([strPath,ext]);
}
AsynLoader.include=function(strPath,className){
varext,i,singleInstance,strPath;
if(alias[strPath]){
strPath=alias[strPath];
}else{
strPath=this.getPath(strPath);
}
if(!strPath)return(false);
ext=strPath[1];
singleInstance=Boolean(strPath[2])||className=="singleInstance"||paths[strPath]=="singleInstance";
strPath=strPath[0];
if(singleInstance&&paths[strPath])return;
paths[strPath]=singleInstance?"singleInstance":true;
switch(ext){
case"js":
document.write("
break;
case"vbs":
document.write("
break;
case"css":
document.write("
break;
case"jpg":case"gif":case"bmp":case"jpeg":case"png":
document.write("
break;
default:
document.write("
break;
}
}
AsynLoader.init=function(){
alias=newArray();
currentPath="";
dependences=newArray();
dependent=newArray();
libs=newArray();
paths=newArray();
this.pathType="absolute";
}
AsynLoader.libs=function(blnNotLoaded){
varre=newArray();
for(variinlibs)if((libs[i]=="loaded")^blnNotLoaded)re.push(i);
return(re);
}
AsynLoader.loadFailure=function(strLibName,e){
if(e=="exit")return;
libs[strLibName]="Loading"+strLibName+"modelFailed:rn";
for(variine)libs[strLibName]+=""+i+":"+e[i]+"rn";
}
AsynLoader.loadSuccess=function(strLibName){
libs[strLibName]="loaded";
}
AsynLoader.setPath=function(strPath){
if(typeof(strPath)!="string")return;
currentPath=strPath.replace(//g,"/").replace(/([^/])$/,"$1/");
}
AsynLoader.singleInstance=function(strPath){
if(alias[strPath]){
strPath=alias[strPath];
}else{
strPath=this.getPath(strPath);
}
if(!strPath)return(false);
strPath=strPath[0];
if(paths[strPath]){
throw("exit");
}else{
paths[strPath]=true;
}
}
AsynLoader.init();
//-----------------DeclareGlobalObjectSection-End---------------
/////////////////////////////////////////////////////////////////////////
//=================InitializationSection===Start===========
AsynLoader.pathType="relative";
AsynLoader.include("js/main.alias.js");
//-----------------InitializationSection-End---------------
//*****************AFTERALL***********************
AsynLoader.loadSuccess(currentLibName);
}catch(e){AsynLoader.loadFailure(currentLibName);}
////////////////////////////////////////////////////////////////
///////////////////FileEnd//////////////////////////
////////////////////////////////////////////////////////////////