common.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function loadFile(filename,filetype)
  2. {
  3. if(filetype == "js")
  4. {
  5. var fileref = document.createElement('script');
  6. fileref.setAttribute("type","text/javascript");
  7. fileref.setAttribute("src",filename + '.' + filetype);
  8. }
  9. else if(filetype == "css")
  10. {
  11. var fileref = document.createElement('link');
  12. fileref.setAttribute("rel","stylesheet");
  13. fileref.setAttribute("type","text/css");
  14. fileref.setAttribute("href",filename + '.' + filetype);
  15. }
  16. if(typeof fileref != "undefined")
  17. {
  18. document.getElementsByTagName("head")[0].appendChild(fileref);
  19. }
  20. }
  21. var include_index = 0;
  22. function include()
  23. {
  24. var self = $(".include").eq(include_index);
  25. var system = self.attr('system');
  26. var path = self.attr('path');
  27. var name = self.attr('file');
  28. var file = '';
  29. if(path) file = path;
  30. if(system) file = file + '/' + system;
  31. file += name + '.html';
  32. $.ajax(
  33. {
  34. url: file,
  35. async: false,
  36. success: function (result)
  37. {
  38. document.write(result);
  39. }
  40. });
  41. include_index++;
  42. }
  43. Array.prototype.indexIn = function(val) {
  44. for (var i = 0; i < this.length; i++) {
  45. if (this[i] == val) return i;
  46. }
  47. return -1;
  48. };
  49. Array.prototype.remove = function(val) {
  50. var index = this.indexIn(val);
  51. if (index > -1) {
  52. this.splice(index, 1);
  53. }
  54. };
  55. //loadFile('../../lib/jquery/jquery.min', 'js');
  56. //loadFile('../../core/bootstrap/bootstrap.min', 'css');