ueditor.parse.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (function (){
  2. var paths = [
  3. 'parse.js',
  4. 'insertcode.js',
  5. 'table.js',
  6. 'charts.js',
  7. 'background.js',
  8. 'list.js',
  9. 'video.js'
  10. ];
  11. function getUEBasePath ( docUrl, confUrl ) {
  12. return getBasePath( docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath() );
  13. }
  14. function getConfigFilePath () {
  15. var configPath = document.getElementsByTagName('script');
  16. return configPath[ configPath.length -1 ].src;
  17. }
  18. function getBasePath ( docUrl, confUrl ) {
  19. var basePath = confUrl;
  20. if ( !/^[a-z]+:/i.test( confUrl ) ) {
  21. docUrl = docUrl.split( "#" )[0].split( "?" )[0].replace( /[^\\\/]+$/, '' );
  22. basePath = docUrl + "" + confUrl;
  23. }
  24. return optimizationPath( basePath );
  25. }
  26. function optimizationPath ( path ) {
  27. var protocol = /^[a-z]+:\/\//.exec( path )[ 0 ],
  28. tmp = null,
  29. res = [];
  30. path = path.replace( protocol, "" ).split( "?" )[0].split( "#" )[0];
  31. path = path.replace( /\\/g, '/').split( /\// );
  32. path[ path.length - 1 ] = "";
  33. while ( path.length ) {
  34. if ( ( tmp = path.shift() ) === ".." ) {
  35. res.pop();
  36. } else if ( tmp !== "." ) {
  37. res.push( tmp );
  38. }
  39. }
  40. return protocol + res.join( "/" );
  41. }
  42. var baseURL = getUEBasePath() + '_parse/';
  43. for (var i=0,pi;pi = paths[i++];) {
  44. document.write('<script type="text/javascript" src="'+ baseURL + pi +'"></script>');
  45. }
  46. })();