insertcode.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. UE.parse.register('insertcode',function(utils){
  2. var pres = this.root.getElementsByTagName('pre');
  3. if(pres.length){
  4. if(typeof XRegExp == "undefined"){
  5. var jsurl,cssurl;
  6. if(this.rootPath !== undefined){
  7. jsurl = utils.removeLastbs(this.rootPath) + '/third-party/SyntaxHighlighter/shCore.js';
  8. cssurl = utils.removeLastbs(this.rootPath) + '/third-party/SyntaxHighlighter/shCoreDefault.css';
  9. }else{
  10. jsurl = this.highlightJsUrl;
  11. cssurl = this.highlightCssUrl;
  12. }
  13. utils.loadFile(document,{
  14. id : "syntaxhighlighter_css",
  15. tag : "link",
  16. rel : "stylesheet",
  17. type : "text/css",
  18. href : cssurl
  19. });
  20. utils.loadFile(document,{
  21. id : "syntaxhighlighter_js",
  22. src : jsurl,
  23. tag : "script",
  24. type : "text/javascript",
  25. defer : "defer"
  26. },function(){
  27. utils.each(pres,function(pi){
  28. if(pi && /brush/i.test(pi.className)){
  29. SyntaxHighlighter.highlight(pi);
  30. }
  31. });
  32. });
  33. }else{
  34. utils.each(pres,function(pi){
  35. if(pi && /brush/i.test(pi.className)){
  36. SyntaxHighlighter.highlight(pi);
  37. }
  38. });
  39. }
  40. }
  41. });