forked from fex-team/ueditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ueditor.parse.js
71 lines (46 loc) · 1.63 KB
/
ueditor.parse.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
(function (){
var paths = [
'parse.js',
'insertcode.js',
'table.js',
'charts.js',
'background.js',
'list.js',
'video.js'
];
function getUEBasePath ( docUrl, confUrl ) {
return getBasePath( docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath() );
}
function getConfigFilePath () {
var configPath = document.getElementsByTagName('script');
return configPath[ configPath.length -1 ].src;
}
function getBasePath ( docUrl, confUrl ) {
var basePath = confUrl;
if ( !/^[a-z]+:/i.test( confUrl ) ) {
docUrl = docUrl.split( "#" )[0].split( "?" )[0].replace( /[^\\\/]+$/, '' );
basePath = docUrl + "" + confUrl;
}
return optimizationPath( basePath );
}
function optimizationPath ( path ) {
var protocol = /^[a-z]+:\/\//.exec( path )[ 0 ],
tmp = null,
res = [];
path = path.replace( protocol, "" ).split( "?" )[0].split( "#" )[0];
path = path.replace( /\\/g, '/').split( /\// );
path[ path.length - 1 ] = "";
while ( path.length ) {
if ( ( tmp = path.shift() ) === ".." ) {
res.pop();
} else if ( tmp !== "." ) {
res.push( tmp );
}
}
return protocol + res.join( "/" );
}
var baseURL = getUEBasePath() + '_parse/';
for (var i=0,pi;pi = paths[i++];) {
document.write('<script type="text/javascript" src="'+ baseURL + pi +'"></script>');
}
})();