document.write('
'); var QYT = new Object(); QYT.main = document.getElementById("qyt_main"); /*********通用函数库*********/ QYT.Common = { getRnd : function() { var rnd = Math.random() * 1000000; return rnd; }, includeJS : function(src, id) { var script = document.getElementById("qyt_script_"+id); if(script) QYT.main.removeChild(script); src += (src.match(/\?/) ? '&' : '?'); //+ "rnd=" + QYT.Common.getRnd(); if(QYT.main) { var scriptNew = document.createElement("script"); scriptNew.src = src; scriptNew.id = "qyt_script_"+id; scriptNew.type = "text/javascript"; //scriptNew.charset = "utf-8"; QYT.main.appendChild(scriptNew); } else { document.write(''); //document.write(""); } }, includeStyle : function(src) { if(document.createStyleSheet) { document.createStyleSheet(src); } else { var link = ''; document.getElementsByTagName("head")[0].innerHTML += link; } }, setCookie : function(sName, sValue) { var nextYear = new Date(); nextYear.setFullYear(nextYear.getFullYear()+2); document.cookie = sName + "=" +escape(sValue)+ ";path=/;expires="+ nextYear.toGMTString(); }, getCookie : function(sName) { var aCookie = document.cookie.split("; "); for (var i=0; i < aCookie.length; i++) { var aCrumb = aCookie[i].split("="); if (sName == aCrumb[0]) return unescape(aCrumb[1]); } return null; } } /**********End*********/ //焦点判断 if(!focu) { var focu=1; var sign=0; } QYT.getfocus= function getfocus() { //debugger; focu=1; if(sign==0) { return; } //setTimeout(QYT.update, 3000); clearTimeout(QYT.getfocu); QYT.update(); } QYT.blurfocus=function blurfocus() { focu=0; // setTimeout(QYT.update, 15000); //alert(focu); // clearTimeout(QYT.getfocu); //QYT.update(); } /*********系统设置数据*********/ QYT.setting = { home : "http://ww4.qyt.com:9999/", //需服务端打 //home : "http://192.168.0.31/QYT/BookSir.QYTV3.Web.Visit/", //需服务端打 siteId : "372", //需服务端打 position : "left", //需服务端打 //scroll : true //需服务端打 scroll : true, skin : "blue", mode : "list", autoRefuse : 5 //邀请框自动拒绝 } QYT.stat = { url : escape(document.URL), urlReferrer : escape(document.referrer), title : escape(document.title.substr(0,40)), screenWidth : screen.width, screenHeight : screen.height, siteId : QYT.setting.siteId, visitorId : (QYT.Common.getCookie("visitorId"))?QYT.Common.getCookie("visitorId"):"77970b23fc7143618ecde2568722ed75", codepage : document.charset || document.characterSet, language : 'zh-cn' } QYT.loaded = { base : 0, templet : 0, data : 0, js : 0, stat: 0, resources : 0 } /**********End*********/ if(QYT.main) QYT.Common.includeJS(QYT.setting.home + "js/prototype.js","base"); /*********控制*********/ QYT.preRender = function() { if(QYT.setting.mode=="icon") { QYT.main.innerHTML = QYT.templet.icon.replace(/\[HOME\]/g,QYT.setting.home); Event.observe(QYT.main, "mousemove", showHeader); Event.observe(QYT.main, "mouseout", hideHeader); } else { QYT.main.innerHTML = QYT.templet.container.replace(/\[HOME\]/g,QYT.setting.home).replace(/\[SKIN\]/g,QYT.setting.skin); } QYT.position(); function showHeader() { $("qyt_header").style.visibility = "visible"; } function hideHeader() { $("qyt_header").style.visibility = "hidden"; } } QYT.render = function() { if(QYT.setting.mode=="icon") { QYT.buildIcon(); } else { QYT.buildDept(); QYT.buildCs(); } QYT.loaded.data = 0; var action = QYT.setting.mode=="icon" ? 5 : 2; QYT.Common.includeJS(QYT.setting.home +"GetData.aspx?action=" +action+ "&id="+QYT.stat.visitorId+"&lang="+QYT.stat.language+ "&rnd=" + QYT.Common.getRnd(), "data"); //QYT.Common.includeJS(QYT.setting.home +"json/update.js", "data"); sign=1; setTimeout(QYT.update, 3000); //setTimeout(QYT.update, 3000); } QYT.update = function() { if(QYT.loaded.data) { if(QYT.setting.mode=="icon") { QYT.buildIcon(); } else { QYT.updateDept(); QYT.updateCs(); } QYT.handleMessages(); QYT.loaded.data = 0; var action = QYT.setting.mode=="icon" ? 5 : 2; QYT.Common.includeJS(QYT.setting.home +"GetData.aspx?action=" +action+ "&id="+QYT.stat.visitorId+"&lang="+QYT.stat.language+ "&rnd=" + QYT.Common.getRnd(), "data"); //QYT.Common.includeJS(QYT.setting.home +"json/update.js", "data"); if(focu==1) { QYT.getfocu=setTimeout(QYT.update, 3000); } else if(focu==0) { QYT.getfocu=setTimeout(QYT.update, 8000); } } else { setTimeout(QYT.update, 500); } } /**********End*********/ /*********图标模式*********/ QYT.buildIcon = function() { //第一次数据 if(QYT.online) { Element.show($("qyt_icon_online")); Element.hide($("qyt_icon_offline")); } else { Element.show($("qyt_icon_offline")); Element.hide($("qyt_icon_online")); } } /**********End*********/ /*********部门列表*********/ QYT.buildDept = function() { //第一次数据 if(QYT.dept) { QYT.dept.each ( function(dept) { var div = document.createElement("div"); div.id = "qyt_dept" + dept.deptId; div.innerHTML = '

' +dept.name+ '

'; $("qyt_list").appendChild(div); } ); } QYT.dept = null; } QYT.updateDept = function() { if(QYT.dept) location.reload(); } /**********End*********/ /*********客服列表*********/ QYT.buildCs = function() { //第一次数据 if(QYT.cs) { QYT.cs.each ( function(cs) { //找div var div = $("qyt_dept"+cs.deptId); if(div) { //找ul var ul = div.getElementsByTagName("ul")[0]; if(!ul) { var ul = document.createElement("ul"); div.appendChild(ul); } ul.appendChild( QYT.buildItem(cs) ); } } ); } QYT.cs = null; } QYT.updateCs = function() { if(QYT.cs) { QYT.cs.each ( function(cs) { var li = $("qyt_cs"+ cs.id); if(li&&cs.name) { //改 QYT.updateItem(li, cs); } else if(li&&!cs.name) { //删 li.parentNode.removeChild(li); } else if(!li&&cs.name) { //增 var div = $("qyt_dept"+cs.deptId); if(div) { var ul = div.getElementsByTagName("ul")[0]; if(!ul) { var ul = document.createElement("ul"); div.appendChild(ul); } ul.appendChild( QYT.buildItem(cs) ); } } } ); } QYT.cs = null; } //方法 QYT.buildItem = function(cs) { var li = document.createElement("li"); li.id = "qyt_cs" + cs.id; li.className = 'li' + cs.sex + cs.state; var title = cs.state ? QYT.templet.resource[0] : QYT.templet.resource[1]; var action=cs.state?"dialog":"board"; li.innerHTML = '' +cs.name+ ''; return li; } QYT.updateItem = function(li, cs) { li.className = 'li' + cs.sex + cs.state; var title = cs.state ? QYT.templet.resource[0] : QYT.templet.resource[1]; var action = cs.state ? "dialog":"board"; li.innerHTML = '' +cs.name+ ''; } /**********End*********/ /*********消息处理*********/ QYT.handleMessages = function() { if(QYT.messages) { QYT.messages.each ( function(message) { switch(message.type) { case 0 : QYT.invite.show(message); break; case 5 : window.opener = null; window.close(); break; default : break; } } ) } QYT.messages = null; } /**********End*********/ /*********Step 5,呈现*********/ QYT.entry = function() { if(QYT.loaded.templet && QYT.loaded.data && QYT.loaded.js) { QYT.preRender(); QYT.render(); } else { setTimeout(QYT.entry, 500); } } /**********End*********/ /*********Step 4,初始化*********/ QYT.init = function() { if(QYT.loaded.stat) { //数据、模板 QYT.Common.includeJS(QYT.setting.home +"Templet.aspx?lang=" +QYT.stat.language+ "&codepage=" +QYT.stat.codepage+ "&rnd=" + QYT.Common.getRnd(), "templet"); //QYT.Common.includeJS(QYT.setting.home +"json/templet.js", "templet"); var action = QYT.setting.mode=="icon" ? 5 : 1; QYT.Common.includeJS(QYT.setting.home +"GetData.aspx?action=" +action+ "&id="+QYT.stat.visitorId+"&lang="+QYT.stat.language+ "&rnd=" + QYT.Common.getRnd(), "data"); //QYT.Common.includeJS(QYT.setting.home +"json/first.js", "data"); QYT.Common.includeJS(QYT.setting.home +"js/main.js","main"); //皮肤 QYT.Common.includeStyle(QYT.setting.home+ "css/main.css"); QYT.Common.includeStyle(QYT.setting.home+ "Skins/" +QYT.setting.skin+ "/main.css"); QYT.Common.includeStyle(QYT.setting.home+ "Skins/" +QYT.setting.skin+ "/invite.css"); //下一步 QYT.entry(); } else { setTimeout(QYT.init, 100); } } /**********End*********/ /*********Step 3,发送统计信息*********/ QYT.sendStat = function() { if(QYT.loaded.base) { //添加命名空间引用 var setting = QYT.setting; var stat = QYT.stat; var src = setting.home+ "Stat.aspx?" +$H(stat).toQueryString(); QYT.Common.includeJS(src, "stat"); QYT.Common.setCookie("visitorId", QYT.stat.visitorId); //下一步 QYT.init(); } else { setTimeout(QYT.sendStat, 10); } } /**********End*********/ /*********Step 2,载入基本类库*********/ QYT.base = function() { if(QYT.main) { if(!QYT.loaded.base) QYT.Common.includeJS(QYT.setting.home + "js/prototype.js","base"); //下一步 QYT.sendStat(); } else { setTimeout(QYT.base, 80); } } /*********End*********/ /*********Step 1,建立企业通容器*********/ QYT.container = function() { if(!QYT.main) { if(document.body) { if(document.all) { window.attachEvent("onload", QYT.container.dom); //错误处理机制,三秒后强制打出 setTimeout(QYT.container.dom, 3000); } else { QYT.container.dom(); } //下一步 QYT.base(); } else { setTimeout(QYT.container, 60); } } else { //下一步 QYT.base(); } } QYT.container.dom = function() { if(!QYT.main) { QYT.main = document.createElement("div"); QYT.main.id = "qyt_main"; document.body.appendChild(QYT.main); } } QYT.container(); //判断是否获得焦点事件绑定 window.attachEvent("onfocus",QYT.getfocus); window.attachEvent("onblur",QYT.blurfocus); /*********End*********/