/** * created by zb on 2017/2/23. */ var j_dev_mode = /sitrue.cc/.test(location.host); var global_setting; if(j_dev_mode) { global_setting = { ui : 'http://test.sitrue.cc', domain : '.sitrue.cc', domain_pub : '.sitrue.cc' } } else if(/sitrue.cn/.test(location.host)){ global_setting = { ui : 'http://test.sitrue.cn', domain : '.sitrue.cn', domain_pub : '.sitrue.cn' } } else { global_setting = { ui : 'http://www.cdjzw.com/', domain : '.http://www.cdjzw.com/', domain_pub : '.http://www.cdjzw.com/', } } var xiangmu = xiangmu || global_setting; xiangmu.load = xiangmu.load || (function(){ var loaded = {}; var tohead = true; var loadjsfile = function(file, notui){ if(loaded[file]){ console.log(file); return; } loaded[file] = true; var tohead = istohead(); if(file){ file = (notui ? '' : xiangmu.ui) + file; if(tohead) { var head = ghead(); var e = document.createelement("script"); e.type="text/javascript"; //e.setattribute('charset', 'utf-8'); e.src=file+"?random="+math.random(); head.appendchild(e); } else { file = file+"?random="+math.random(); document.write(unescape("%3cscript src='" + file + "' type='text/javascript'%3e%3c/script%3e")); } } }; var istohead = function () { return false; } var ghead = function(){ var head, o = document; ((head = o.getelementsbytagname('head')[0]) || (head = o.body.parentnode.appendchild(o.createelement("head")))); return head; } var loadcssfile = function(file, notui){ if(loaded[file]){ return; } loaded[file] = true; file = (notui ? '' : xiangmu.ui) + file; var head = ghead(); css = document.createelement('link'); css.setattribute('rel', 'stylesheet'); css.setattribute('type', 'text/css'); css.setattribute('href', file+"?random="+math.random()); head.appendchild(css); }; var f = function(apiname, opts){ opts = opts || {}; tohead = opts.head; if(apiname == 'jquery'){ if(typeof(jquery) == 'undefined'){ loadjsfile('/zhimatong/js/jquery-1.9.1.min.js'); } }else if(apiname == 'jquery2'){ if(typeof(jquery) == 'undefined'){ loadjsfile('/zhimatong/js/jquery-2.1.4.min.js'); loadjsfile('/zhimatong/js/jquery-migrate-1.2.1.min.js', true); } }else if(apiname == 'api'){ xiangmu.load('jquery'); loadjsfile('/zhimatong/js/papi.js'); }else if(apiname == 'hits'){ xiangmu.load('api'); loadjsfile('/zhimatong/js/hits.js'); }else if(apiname == 'validate'){ loadjsfile('/zhimatong/js/jquery.validate.js'); loadjsfile('/zhimatong/js/jquery-ui.min.js'); loadcssfile('/zhimatong/css/jquery-ui.min.css'); }else{ if(apiname){ if(opts=='css'){ loadcssfile(apiname); }else{ loadjsfile(apiname); } } } } return f; })();