(function () { var hidIsSearchShow = window.document.getElementById('hidIsSearchShow'); if(hidIsSearchShow && hidIsSearchShow.value == '1') { return; } var location = window.location, document = window.document, docElem = document.documentElement, body = window.body || window.document.getElementsByTagName('body')[0], DD = function (selector, context) { if (typeof selector === 'string') { if (selector.charAt(0) === '<' && selector.charAt(selector.length - 1) === '>' && selector.length >= 3) { this[0] = document.createElement(selector.replace(regTag, '')) this.length = 1 }else{ this[0] = document.getElementById(selector) this.length = this[0] ? 1 : 0; } } else { if (!selector.length) { this[0] = selector this.length = 1 }else{ if(selector && selector.parent == selector){ this[0] = selector this.length = 1 }else{ for(var i = 0; i < selector.length; i++){ this[i] = selector[i] } this.length = selector.length } } } }, regTag = /<|>/g; //fix ie if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (obj, start) { for (var i = (start || 0) ; i < this.length; i++) { if (this[i] === obj) return i; } return -1; } } DD.fn = DD.prototype = { constructor: DD, init: function (selector, context) { return this; }, bind: function (type, handler) { return this.each(function () { if (this.addEventListener) this.addEventListener(type, handler, false); else if (this.attachEvent) this.attachEvent('on' + type, handler); else this['on' + type] = handler; }) }, append: function (html) { if (html) this.innerHTML = ''; return this; }, attr: function (name, val){ if(typeof name === 'string'){ if(!val) return this[0].getAttribute(name); else { this.each(function(){ if(!this.hasAttribute) name = name.toLowerCase() === 'class' ? 'className' : name; this.setAttribute(name, val); }) } }else{ this.each(function () { for (p in name) { if(!this.hasAttribute) val = p.toLowerCase() === 'class' ? 'className' : p; this.setAttribute(val, name[p]); } }) } return this }, css: function (name, val) { if (typeof name === 'string') { if (!val) { if(window.getComputedStyle){ return window.getComputedStyle(this[0], null).getPropertyValue(name); } return this[0].style[name]; } else { this.each(function () { if (this && (name in this.style ) && val) { try { this.style[name] = val ; } catch(e) {} } }); } } else { this.each(function () { for (p in name) { this.style[p] = name[p]; } }) } return this }, hasClass: function (klass) { if (this[0] && this[0].className) { var l = this[0].className.split(' '); return l.indexOf(klass) > -1; } return false; }, is: function (tag) { if(typeof tag === 'string' && tag.charAt(0) === ':'){ switch(tag){ case ':show': return this.css('display') != 'none'; } }else{ if (this[0] && this[0].nodeName) return this[0].nodeName.toLowerCase() === tag.toLowerCase(); if(this[0] && tag === 'window') return this[0].parent == this[0] ; } return false; }, each: function (handle) { for (var i = 0; i < this.length; i++) { handle.call(this[i], i); } return this; }, html: function (str) { return this.each(function () { this.innerHTML = str; }); }, hide: function () { return this.each(function () { DD.css(this, 'display', 'none'); }); }, show: function(){ return this.each(function () { DD.css(this, 'display', 'block'); }); }, toggle: function(){ return this.each(function(){ var _this = new DD(this); _this.is(':show') ? _this.hide() : _this.show(); }); }, child: function(selector){ var child = []; this.each(function(){ for(var i = 0; i < this.children.length; i++){ if((new DD(this.children[i])).is(selector)) child.push(this.children[i]); } }); return new DD(child) }, parent: function(){ return new DD(this[0].parentElement); }, width: function(){ if(this.is('window')){ if(this[0].innerWidth) return this[0].innerWidth; if(docElem.offsetWidth) return docElem.offsetWidth; if(body.offsetWidth) return body.offsetWidth; return 0; } return this[0].clientWidth || this[0].offsetWidth || this[0].scrollWidth; }, height: function(){ if(this.is('window')){ if(this[0].innerHeight) return this[0].innerHeight; if(docElem.offsetHeight) return docElem.offsetHeight; if(body.offsetHeight) return body.offfsetHeight; return 0; } var total = 0; this.each(function(){ total += this.clientHeight || this.offsetHeight || this.scrollHeight; }); return total; }, first: function(){ return new DD(this[0]); }, last: function(){ return new DD(this[this.length-1]); } } DD.include = function (attr) { for (p in attr) DD.fn[p] = attr[p]; }; DD.extend = function (attr) { for (p in attr) DD[p] = attr[p]; }; DD.extend({ css: function (elem, name, val) { elem.style[name] = val; }, loadStyles: function (url) { var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = url; var head = document.getElementsByTagName('head')[0]; head.appendChild(link); }, loadStylesString: function (css) { var style = document.createElement('style'); style.type = 'text/css'; try { style.appendChild(document.createTextNode(css)); } catch (ex) { style.styleSheet.cssText = css; } var head = document.getElementsByTagName('head')[0]; head.appendChild(style); }, stopPropagation: function (e) { if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = false; }, toJson: function (str) { try { return window.JSON && window.JSON.parse ? JSON.parse(str) : eval('(' + str + ')'); } catch (e) { return ''; } }, clone: function(obj){ if (obj == null || typeof obj != 'object') return obj; if (obj instanceof Array) { var copy = []; copy = obj.slice(0); return copy; } if (obj instanceof Object) { var copy = {}; for (var attr in obj) { if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr]; } return copy; } }, support: { fixed: function(){ var a = new DD('
').css({ 'position': 'fixed', 'left': '10px', 'display': 'none' }); body.appendChild(a[0]); var _s = a[0].offsetLeft >= 0; body.removeChild(a[0]); return _s; }, ajax: function(){ var result = false; var _t; if(window.XMLHttpRequest){ _t = new window.XMLHttpRequest(); if('withCredentials' in _t){ result = true; _t = null; } }else if(window.XDomainRequest){ result = true ; } return result; } }, ready: function(handler){ }, cookie: function(name, value, h){ if(name && !value && !h){ var cookieValue = ""; var search = name + "="; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; cookieValue = unescape(document.cookie.substring(offset, end)); } } return cookieValue; } var expire = ""; if (h) { expire = new Date((new Date()).getTime() + h * 3600000); expire = "; expires=" + expire.toGMTString(); } document.cookie = name + "=" + escape(value) + expire + ";path=/"; }, ajax: function(options){ var xhr = null ; if(window.XMLHttpRequest){ xhr = new XMLHttpRequest(); } if(xhr && 'withCredentials' in xhr) { }else if (window.XDomainRequest){ xhr = new XDomainRequest(); }else{ xhr = null; } if(xhr){ xhr.open('GET', options.url, true); xhr.onload = function(){ options.callback(xhr.responseText); } xhr.send(); }else{ } }, reload: function(data){ var result = DD.toJson(data); if(typeof result === 'object' && _ul.hasClass('webdd-dduser')){ opts.userList = result; _ul.first().html(helper.getDDUser(true)); } } }) var opts = { chatList: DD.toJson('[]'), groupList: DD.toJson('[{"name":""}]'), userList: DD.toJson('[{"IsEnable":"True","OnLineState":"4","UserId":"123345","FloatPositionId":"2","StylePath":"Images/StyleImages/FloatImage/FloatImage/","IsAutoInviteEnable":"True","AutoInviteMessage":"鎮ㄥソ锛屾湁浠€涔堝彲浠ュ府鍒版偍鐨勫悧锛?,"WebName":"閲嶅簡娆у痉浠〃鏈夐檺鍏徃","NickName":"绠$悊鍛?,"InviteUserId":"0","InviteMessage":"","VisitorOnlineState":"1"}]'), cssHref: '', position: 2, ln: 'zh-cn' || 'zh-cn', isCn : 'zh-cn' == 'zh-cn', isUseGroup: 'False' == 'True', type: { qq: '0', msn: '0', taobao: '0', alibaba: '0', skype: '0', phone: '' }, autoInvite: 'True' == 'True', address: '娌冲寳鐪佷繚瀹氬競', message: '鎮ㄥソ锛屾湁浠€涔堝彲浠ュ府鍒版偍鐨勫悧锛?, callback: '', webName: '閲嶅簡娆у痉浠〃鏈夐檺鍏徃', imgPath: 'http://s02.yizimg.com/Images/StyleImages/FloatImage/FloatImage/', qrPath : 'http://qrcode.yi-z.cn/', qrUrl: '', ddStyle: '13', direction: function(){ if([3,6].indexOf(opts.position) > -1) { return 'top' }else if([5,8].indexOf(opts.position) > -1){ return 'bottom' }else{ return 'middle' } }, lang: (function(){ if('zh-cn' == 'zh-cn'){ return { otherGroup: '鍏朵粬鍒嗙粍', onlineService: '鍦ㄧ嚎瀹㈡湇', webdd: '鏄撳睍鍙綋', btnAccept: '鎺ュ彈瀵硅瘽', btnCancel: '鏆備笉瀵硅瘽', sendMessage: '鐐瑰嚮缁欐垜鍙戞秷鎭?, dear: '浜茬埍鐨?, user: '鐢ㄦ埛', welcome: '娆㈣繋鎮ㄧ殑鍏変复', invite: '閭€璇锋偍鍦ㄧ嚎娲借皥', help: '鎮ㄥソ锛屾湁浠€涔堣兘澶熷府鍔╁埌鎮ㄧ殑鍚楋紵', qr: '鐢ㄦ墜鏈鸿闂?, qrDetail: '鎵嬫満鎵弿璧扮潃鐬?, gotop: '鍥炲埌椤堕儴' } }else{ return { otherGroup: 'Other Group', onlineService: 'Online Service', webdd: 'YiZhan DingDang', btnAccept: 'Accept', btnCancel: 'Cancel', sendMessage: 'Click to send me a message', dear: 'Dear ', user: ' user', welcome: 'welcome', invite: 'invite you to discuss online', help: 'Hello! What can I do for you?', qr: 'Mobile Visit', qrDetail: 'Visit website by Mobile', gotop: 'Go to top' } } })() } var helper = { scroll: { getPosition: function(over) { var result = over - helper.scroll.start.pageY + helper.scroll.start.top; if (result <= 0) { return { top: 0, persent: 0 }; } else if (result + helper.scroll.scrollHeight > helper.scroll.conHeight) { return { top: helper.scroll.scrollMax, persent: 100 } } return { top: result, persent: result / helper.scroll.scrollMax } } }, getGroup: function(obj, index){ var chat = helper.getChatByGroup(obj.name), h = []; h.push('
'); //h.push(''); h.push(''); h.push(obj.name || opts.lang.otherGroup); h.push('
'); //h.push('