/**
 * 镜像中只需要修改这个文件中的host,其它不用动
 */
window.ServerHosts={
	host:location.host,
	pathMap: {},
	domain: document.domain,
	MASTER_HOST: "",
	PARENT_HOST: "",
	P_HOST:location.protocol + '//p.ananas.chaoxing.com',
	s1_HOST: location.protocol + '//s1.ananas.chaoxing.com',
	s2_HOST:location.protocol + '//s2.ananas.chaoxing.com',
	CLOUD_HOST :'http://cloud.ananas.' + document.domain,
	NEW_CLOUD_HOST :location.protocol  +  '//pan-yz.chaoxing.com',
	CS_HOST :location.protocol  + '//cs.ananas.' + document.domain,
	FANYA_HOST :'http://course.fanya.' + document.domain,
	PAN_HOST :'http://pan.ananas.' + document.domain,
	CXLIVE_HOST :'http://cxlive.' + document.domain,
	ERYA_TSK_HOST :'http://erya.tsk.' + document.domain,
	QUESTIONNAIRE_HOST : 'http://surveyapp.fy.' + document.domain,
	FX_HOST :'http://www.' + document.domain,
	PHONE_ZT_HOST :"https://special.rhky.com",
	CHAOXING_CLASS_HOST :"https://k.chaoxing.com",
	LIVE_HOST : location.protocol + "//live.chaoxing.com",
	APPCD_HOST : location.protocol + "//appcd.chaoxing.com",
	ZHIBO_HOST : "https://zhibo.chaoxing.com",
	CXCLASSTASL_HOST : location.protocol + "//noteyd.chaoxing.com",
	UPLOADDOMAIN : "https://mooc-upload-ans.chaoxing.com",
	MOOC2_HOST : location.protocol + '//mooc2-ans.' + document.domain,
	FANYALUBO : location.protocol + "//fanyalubodata.fanya.chaoxing.com",
	FANYALUBO_DOMAIN : location.protocol + "//fanyalubodata." + document.domain,
	ZHIBO_HOST2 : location.protocol + "//zhibo." + document.domain,
	LIVE_HOST2 : location.protocol + "//live." + document.domain,
	MOBILE3 : location.protocol + "//mobile3.chaoxing.com",
	APPCD_HOST2 : location.protocol + "//appcd." + document.domain,
	GROUPWEB : location.protocol + "//groupweb." + document.domain,
	MOOC_UPLOAD_ANS : location.protocol + "//mooc-upload-ans.chaoxing.com",
	SS_HOST : location.protocol + "//ss.chaoxing.com",
	SS_ZHEXUEZJ : location.protocol + "//ss.zhexuezj.cn",
	AUTHEN_HOST : "https://authen.chaoxing.com",
	DATA_XXT : location.protocol + "//data-xxt.aichaoxing.com",
	DATAXXT : "http://data.xxt.aichaoxing.com",
	PAN_HOST1 : "http://pan.chaoxing.com",
	HOMEWH_HOST : "https://homewh.chaoxing.com",
	MOBILELEARN : location.protocol + "//mobilelearn." + document.domain,
	MOBILEWX: location.protocol + "//mobilewx." + document.domain,
	QIKAN : location.protocol + "//qikan.chaoxing.com",
	SHAREWH : location.protocol + "//sharewh.chaoxing.com",
	SURVEYAPP_FY : "https://surveyapp-fy.chaoxing.com",
	SURVEYAPP_FY_ZHEZUEZJ : location.protocol + "//surveyapp-fy.zhexuezj.cn",
	CONVERTSERVICE : location.protocol + "//convertservice.chaoxing.com",
	HLS_ANS_HOST : "http://hls-ans.chaoxing.com",
	MOOC_API_HOST : location.protocol + "//mooc1-api.chaoxing.com",
	FANYA_HOST2 : "http://fanya.chaoxing.com",
	FANYA_ZYK2_HOST : location.protocol + "//fanyazyk2.chaoxing.com",
	SUPER_FY_HOST : "http://super.fy.chaoxing.com",
	SVIDEO_HOST : location.protocol + "//svideo.chaoxing.com",
	ECUST_FANYA_HOST: location.protocol + "//ecust.fanya." + document.domain,
	CVP_HOST: location.protocol + "//cv-p." + document.domain,
	init : function(){
		var defaultPathObj ={
			// 定制路径，没有时采用默认路径
			"mooc2-ans":"www.mooc.whu.edu.cn"
		};
		this.pathMap["www.mooc.whu.edu.cn"] = defaultPathObj;
		this.hostPathObj = this.pathMap[this.host];
		if(typeof this.hostPathObj != 'undefined'){
			this.NEW_CLOUD_HOST = this.getDomain("pan");
			this.CXCLASSTASL_HOST = this.getDomain("noteyd");
			this.GROUPWEB = this.getDomain("groupweb");
			this.MOBILELEARN = this.getDomain("ketang-mobilelearn");
			this.FANYA_ZYK2_HOST = this.getDomain("fanyazyk2");
			this.MOOC2_HOST = this.getDomain("mooc2-ans");
			this.MOOC_API_HOST = this.getDomain("mooc-ans");
			if(this.MOOC2_HOST.endsWith("/mooc2-ans")){
				this.MOOC2_HOST = this.MOOC2_HOST.substr(0,this.MOOC2_HOST.length - "/mooc2-ans".length);
			}
		}
		if (document.domain.indexOf('xueyinonline.com') >= 0) {
			this.QUESTIONNAIRE_HOST = location.protocol + "//surveyapp.xueyinonline.com";
		}
		if (document.domain.indexOf('xueyinonline.com') >= 0) {
			this.NEW_CLOUD_HOST = location.protocol + "//pan-yz.xueyinonline.com";
            this.MOBILE3 = location.protocol + "//mobile3.xueyinonline.com";
		}
		this.MASTER_HOST = this.getMasterHost();
		this.PARENT_HOST = this.getParentHost();
	},
	getDomain: function (pathKey) {
		var pathValue = this.hostPathObj[pathKey];
		if(typeof pathValue != 'undefined'){
			if(pathValue.indexOf('.')>-1){
				pathValue = pathValue.replace("http://",'').replace("https://",'');
				return location.protocol  +  '//' +  pathValue;
			}

			if(pathValue.length > 0){
				pathValue = "/" +  pathValue;
			}

			return location.protocol  +  '//' + this.host +  pathValue;
		} else {
			return location.protocol  +  '//' + this.host + "/" +  pathKey;
		}
	},
	getMasterHost: function() {
		try{
			return location.protocol + '//'+ top.location.host;
		}catch(e){
			return location.protocol + '//'+ location.host;
		}
	},
	getParentHost: function() {
		try {
			return parent.location.host !== "" ? location.protocol + '//'+ parent.location.host : this.MASTER_HOST;
		} catch(e) {
			return location.protocol + '//'+ location.host;
		}
	}
}
ServerHosts.init();
