1
0

ueditor.parse.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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(
  13. docUrl || self.document.URL || self.location.href,
  14. confUrl || getConfigFilePath()
  15. );
  16. }
  17. function getConfigFilePath() {
  18. var configPath = document.getElementsByTagName("script");
  19. return configPath[configPath.length - 1].src;
  20. }
  21. function getBasePath(docUrl, confUrl) {
  22. var basePath = confUrl;
  23. if (!/^[a-z]+:/i.test(confUrl)) {
  24. docUrl = docUrl.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, "");
  25. basePath = docUrl + "" + confUrl;
  26. }
  27. return optimizationPath(basePath);
  28. }
  29. function optimizationPath(path) {
  30. var protocol = /^[a-z]+:\/\//.exec(path)[0],
  31. tmp = null,
  32. res = [];
  33. path = path.replace(protocol, "").split("?")[0].split("#")[0];
  34. path = path.replace(/\\/g, "/").split(/\//);
  35. path[path.length - 1] = "";
  36. while (path.length) {
  37. if ((tmp = path.shift()) === "..") {
  38. res.pop();
  39. } else if (tmp !== ".") {
  40. res.push(tmp);
  41. }
  42. }
  43. return protocol + res.join("/");
  44. }
  45. var baseURL = getUEBasePath() + "_parse/";
  46. for (var i = 0, pi; (pi = paths[i++]); ) {
  47. document.write(
  48. '<script type="text/javascript" src="' + baseURL + pi + '"></script>'
  49. );
  50. }
  51. })();