var ruite = {}; ruite.context = ''; ruite.http = 8080; ruite.https = null; ruite.version = 75861; if (!window.ruite) var ruite = {}; if (!ruite.context) ruite.context = ""; if (!window.crossDomain) window.crossDomain = ""; if (!window.localpath) window.localpath = ""; // "/phone/" //兼容低版本不支持startsWith的浏览器 if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function(prefix) { return this.slice(0, prefix.length) === prefix; }; } $path = function(path, v) { if (path && window.crossDomain !== "") { var localLength = window.localpath.length; if (localLength > 0) { if (path.startsWith(window.localpath)) { path = path.substring(localLength); return $getRootPath(path); } } } if (path && path.charAt(0) !== '/') path = '/' + path; path = window.crossDomain + ruite.context + path; if (v !== false && ruite.version) { if (path.indexOf('?') >= 0) { path = path + '&v=' + ruite.version; } else { path = path + '?v=' + ruite.version; } } return path; }; $getRootPath = function(path) { if (window.crossDomain == "") return $path(path); //获取当前网址, var curWwwPath = window.document.location.href; var root = curWwwPath.substring(0, curWwwPath.lastIndexOf('/')); if (path && path.charAt(0) !== '/') path = '/' + path; return root + path; //获取主机地址之后的目录, var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); //获取主机地址,如: var localhostPaht = curWwwPath.substring(0, pos); //获取带"/"的项目名 var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); var p = localhostPaht + projectName + path; return p; } /** * 导入一个库文件 * * 参数使用绝对路径, $import函数将自己处理context问题 */ $import = (function() { var files = {}; // 所有导入的文件 var main = function(file) { if (!file) return; // 避免重复导入 if (files[file]) return; files[file] = true; var regexJS = /(\.(js|debugjs)(\?.*)?$)/i; var regexCSS = /\.css$/i; // 分类型加载JavaScript文件或者CSS文件 if (regexCSS.test(file)) { document.write(""); return; } if (regexJS.test(file)) { document.write("