-
Notifications
You must be signed in to change notification settings - Fork 139
/
Copy pathufinder.config.js
125 lines (87 loc) · 3.29 KB
/
ufinder.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
(function(){
var URL = window.UFINDER_HOME_URL || (function(){
function PathStack() {
this.documentURL = self.document.URL || self.location.href;
this.separator = '/';
this.separatorPattern = /\\|\//g;
this.currentDir = './';
this.currentDirPattern = /^[.]\/]/;
this.path = this.documentURL;
this.stack = [];
this.push( this.documentURL );
}
PathStack.isParentPath = function( path ){
return path === '..';
};
PathStack.hasProtocol = function( path ){
return !!PathStack.getProtocol( path );
};
PathStack.getProtocol = function( path ){
var protocol = /^[^:]*:\/*/.exec( path );
return protocol ? protocol[0] : null;
};
PathStack.prototype = {
push: function( path ){
this.path = path;
update.call( this );
parse.call( this );
return this;
},
getPath: function(){
return this + "";
},
toString: function(){
return this.protocol + ( this.stack.concat( [''] ) ).join( this.separator );
}
};
function update() {
var protocol = PathStack.getProtocol( this.path || '' );
if( protocol ) {
//根协议
this.protocol = protocol;
//local
this.localSeparator = /\\|\//.exec( this.path.replace( protocol, '' ) )[0];
this.stack = [];
} else {
protocol = /\\|\//.exec( this.path );
protocol && (this.localSeparator = protocol[0]);
}
}
function parse(){
var parsedStack = this.path.replace( this.currentDirPattern, '' );
if( PathStack.hasProtocol( this.path ) ) {
parsedStack = parsedStack.replace( this.protocol , '');
}
parsedStack = parsedStack.split( this.localSeparator );
parsedStack.length = parsedStack.length - 1;
for(var i= 0,tempPath,l=parsedStack.length,root = this.stack;i<l;i++){
tempPath = parsedStack[i];
if(tempPath){
if( PathStack.isParentPath( tempPath ) ) {
root.pop();
} else {
root.push( tempPath );
}
}
}
}
var currentPath = document.getElementsByTagName('script');
currentPath = currentPath[ currentPath.length -1 ].src;
return new PathStack().push( currentPath ) + "";
})();
window.UFINDER_CONFIG = {
/* ufinder根目录 */
'URL': URL,
/* 工具栏按钮 */
'toolbars': [
'open pathparent touch mkdir rename remove upload download lookimage lookcode'
],
/* 服务器url */
'serverUrl': URL + '/server/ufinder.php',
'realUrl': URL + '/server/files',
/* 上传模块配置项 */
'uploaderFileName': 'file',
'uploaderSwfUrl': URL + '/lib/webuploader/Uploader.swf',
'uploaderJsUrl': URL + '/lib/webuploader/webuploader.js'
};
})();