提交 7329ee3d 编写于 作者: H hancong03

路径自动寻找

Signed-off-by: Nhancong03 <121371790@qq.com>
上级 caae0b92
......@@ -23,7 +23,13 @@
function PathStack() {
this.protocol = self.location.protocol + '//';
this.protocolPattern = new RegExp( '^' + this.protocol + '/*' );
this.protocol = this.protocolPattern.exec( document.URL )[0];
this.separator = '/';
this.localSeparator = /\\|\//.exec( ( document.URL || self.location.href ).replace( this.protocol ) )[0];
this.separatorPattern = /\\|\//g;
this.currentDir = './';
this.currentDirPattern = /^[.]\/]/;
this.path = [];
}
......@@ -34,13 +40,12 @@
PathStack.prototype = {
push: function( path ){
if( path.indexOf( this.protocol ) === 0 ) {
this.path = [];
}
var hasProtocol = path.indexOf( this.protocol ) === 0;
path = path.replace( this.protocol , '' ).split( this.separator );
path.length = path.length - 1;
hasProtocol && ( this.path = [] );
path = path.replace( this.protocol , '').replace( this.currentDirPattern, '' ).split( hasProtocol ? this.localSeparator : this.separator );
path.length = path.length - 1;
for( var i= 0, tempPath, root = this.path; tempPath = path[ i ]; i++ ) {
......@@ -52,6 +57,8 @@
}
return this;
},
toString: function(){
return this.protocol + ( this.path.concat( [''] ) ).join( this.separator );
......@@ -65,11 +72,7 @@
var path = new PathStack();
path.push( root );
path.push( currentPath );
alert(path+"")
return path.push( root).push( currentPath ) + "";
})();
......@@ -90,7 +93,7 @@
//图片上传配置区
,imageUrl:URL+"php/imageUp.php" //图片上传提交地址
,imagePath:URL + "php/" //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置
//,imageFieldName:"upfile" //图片数据的key,若此处修改,需要在后台对应文件修改对应参数
//,imageFieldName:"upfile" //图片数据的key,若此处修改,需要在后台对应文件修改对应参数
//,compressSide:0 //等比压缩的基准,确定maxImageSideLength参数的参照对象。0为按照最长边,1为按照宽度,2为按照高度
//,maxImageSideLength:900 //上传图片最大允许的边长,超过会自动等比缩放,不缩放就设置一个比较大的值,更多设置在image.html中
......@@ -103,7 +106,7 @@
,filePath:URL + "php/" //附件修正地址,同imagePath
//,fileFieldName:"upfile" //附件提交的表单名,若此处修改,需要在后台对应文件修改对应参数
//远程抓取配置区
//远程抓取配置区
//,catchRemoteImageEnable:true //是否开启远程图片抓取,默认开启
,catcherUrl:URL +"php/getRemoteImage.php" //处理远程图片抓取的地址
,catcherPath:URL + "php/" //图片修正地址,同imagePath
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册