//12306入口引导脚本 (function (window, document) { var basePath = window.location.protocol + "//" + window.location.host + "/js/"; var pagename = /\/(\w+?)\.html/.exec(location.pathname) && RegExp.$1 || "index"; var loadScript = function (path, callback) { var script = document.createElement("script"); script.src = basePath + path; script.onload = function () { callback(); document.head.removeChild(script); }; document.head.appendChild(script); }; //extend underscore _.mixin({ mapObject: function (array, keySelector) { var obj = {}; _.each(array, function (e) { obj[keySelector(e)] = e; }); return obj; } }); //确保内容脚本启动 var start = $.Deferred(); start.done(function() { loadScript("modules/seajs/sea.js", function() { seajs.config({ base: basePath, alias: { "jquery": "modules/jquery/jquery.js", "underscore": "modules/underscore/underscore.js" }, vars: { 'locale': 'zh-cn' }, charset: "utf-8", debug: true }); seajs.use("ui/" + pagename); }); }); start.fail(function() { alert("没有安装扩展!"); }); if (document.body.dataset["mobileSupportInitialized"]) { start.resolve(); } else { var timer = setTimeout(function() { start.reject(); }, 3000); document.addEventListener("mobileSupportInitialized", function () { window.clearTimeout(timer); start.resolve(); }); } })(window, document);