www.gusucode.com > 中网景企业网站管理系统 2008源码程序 > common/chkuser03.js
// ============ ajaxClass ( XMLHttp Object Pool and XMLHttp chunnel Pool ) ============ var Request = new function(){ this.pool = new Array(); this.getXMLHttp = function (chunnel) { if(chunnel != null) { for (var a = 0; a < this.pool.length; a++) { if(this.pool[a]["chunnel"] == chunnel) { if(this.pool[a]["obj"].readyState == 0 || this.pool[a]["obj"].readyState == 4) { return this.pool[a]["obj"]; } else { return "busy"; } } } this.pool[this.pool.length] = new Array(); this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp(); this.pool[this.pool.length - 1]["chunnel"] = chunnel; return this.pool[this.pool.length - 1]["obj"]; } for (var i = 0; i < this.pool.length; i++) { if(this.pool[i]["obj"].readyState == 0 || this.pool[i]["obj"].readyState == 4) { return this.pool[i]["obj"]; } } this.pool[this.pool.length] = new Array(); this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp(); this.pool[this.pool.length - 1]["chunnel"] = ""; return this.pool[this.pool.length - 1]["obj"]; } this.createXMLHttp = function () { if(window.XMLHttpRequest) { var xmlObj = new XMLHttpRequest(); } else { var MSXML = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP']; for(var n = 0; n < MSXML.length; n++) { try { var xmlObj = new ActiveXObject(MSXML[n]); break; } catch(e) { } } } return xmlObj; } this.reSend = function (url,data,callback,extra,chunnel) { var objXMLHttp = this.getXMLHttp(chunnel) ; if(typeof(objXMLHttp) != "object") { return false ; } if(data == "") { objXMLHttp.open('GET' , url, true); objXMLHttp.setRequestHeader("If-Modified-Since", 0); // no cache objXMLHttp.send(''); } else { objXMLHttp.open('POST' , url, true); objXMLHttp.setRequestHeader("If-Modified-Since", 0); // no cache objXMLHttp.setRequestHeader("Content-Length",data.length); objXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); objXMLHttp.send(data); } if(typeof(callback) == "function" ) { objXMLHttp.onreadystatechange = function () { if(objXMLHttp.readyState == 4) { if(objXMLHttp.status == 200 || objXMLHttp.status == 304) { if(extra != null) { callback(objXMLHttp,extra) ; } else { callback(objXMLHttp) ; } } // else // { // alert("Error loading page\n" + objXMLHttp.status + ":" + objXMLHttp.statusText); // } } } } } } // ============================== json =================================== var JSON = { stringify: function (v) { var a = []; // Emit a string. function e(s) { a[a.length] = s; } // Convert a value. function g(x) { var c, i, l, v; switch (typeof x) { case 'object': if (x) { if (x instanceof Array) { e('['); l = a.length; for (i = 0; i < x.length; i += 1) { v = x[i]; if (typeof v != 'undefined' && typeof v != 'function') { if (l < a.length) { e(','); } g(v); } } e(']'); return; } else if (typeof x.valueOf == 'function') { e('{'); l = a.length; for (i in x) { v = x[i]; if (typeof v != 'undefined' && typeof v != 'function' && (!v || typeof v != 'object' || typeof v.valueOf == 'function')) { if (l < a.length) { e(','); } g(i); e(':'); g(v); } } return e('}'); } } e('null'); return; case 'number': e(isFinite(x) ? +x : 'null'); return; case 'string': l = x.length; e('"'); for (i = 0; i < l; i += 1) { c = x.charAt(i); if (c >= ' ') { if (c == '\\' || c == '"') { e('\\'); } e(c); } else { switch (c) { case '\b': e('\\b'); break; case '\f': e('\\f'); break; case '\n': e('\\n'); break; case '\r': e('\\r'); break; case '\t': e('\\t'); break; default: c = c.charCodeAt(); e('\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16)); } } } e('"'); return; case 'boolean': e(String(x)); return; default: e('null'); return; } } g(v); return a.join(''); }, parse: function (text) { // return eval('(' + text + ')'); return (/^(\s+|[,:{}\[\]]|"(\\["\\\/bfnrtu]|[^\x00-\x1f"\\]+)*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null)+$/.test(text)) && eval('(' + text + ')'); } }; // ============================== js prototype or for ie5.5 ↓ =================================== // -- for ie 5 push if(!Array.prototype.push) { Array.prototype.push = function (new_ele) { this[this.length] = new_ele; return this.length; } } // -- for ie 5 splice if(!Array.prototype.splice) { Array.prototype.splice = function () { var start = arguments[0]; var deleteCount = arguments[1]; var len = arguments.length - 2; var returnValue = this.slice(start); for (var i = 0; i < len; i++) { this[start + i] = arguments[i + 2]; } for (var i = 0; i < returnValue.length - deleteCount; i++) { this[start + len + i] = returnValue[deleteCount + i]; } this.length = start + len + returnValue.length - deleteCount; returnValue.length = deleteCount; return returnValue; } } // -- for ie 5.5↓ encodeURI if(typeof(encodeURI) == "undefined") { function encodeURI(str) { var l = ['%00', '%01', '%02', '%03', '%04', '%05', '%06', '%07', '%08', '%09', '%0A', '%0B', '%0C', '%0D', '%0E', '%0F', '%10', '%11', '%12', '%13', '%14', '%15', '%16', '%17', '%18', '%19', '%1A', '%1B', '%1C', '%1D', '%1E', '%1F', '%20', '!', '%22', '#', '$', '%25', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '%3C', '=', '%3E', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%5B', '%5C', '%5D', '%5E', '_', '%60', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '%7B', '%7C', '%7D', '~', '%7F']; var out, i, j, len, c, c2; out = []; len = str.length; for (i = 0, j = 0; i < len; i++) { c = str.charCodeAt(i); if (c <= 0x007F) { out[j++] = l[c]; continue; } else if (c <= 0x7FF) { out[j++] = '%' + (0xC0 | ((c >> 6) & 0x1F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ( c & 0x3F)).toString(16).toUpperCase(); continue; } else if (c < 0xD800 || c > 0xDFFF) { out[j++] = '%' + (0xE0 | ((c >> 12) & 0x0F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ((c >> 6) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase(); continue; } else { if (++i < len) { c2 = str.charCodeAt(i); if (c <= 0xDBFF && 0xDC00 <= c2 && c2 <= 0xDFFF) { c = ((c & 0x03FF) << 10 | (c2 & 0x03FF)) + 0x010000; if (0x010000 <= c && c <= 0x10FFFF) { out[j++] = '%' + (0xF0 | ((c >>> 18) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ((c >>> 12) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ((c >>> 6) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase(); continue; } } } } } return out.join(''); } } // -- for ie 5.5↓ encodeURIComponent if(typeof(encodeURIComponent) == "undefined") { function encodeURIComponent(str) { var l = ['%00', '%01', '%02', '%03', '%04', '%05', '%06', '%07', '%08', '%09', '%0A', '%0B', '%0C', '%0D', '%0E', '%0F', '%10', '%11', '%12', '%13', '%14', '%15', '%16', '%17', '%18', '%19', '%1A', '%1B', '%1C', '%1D', '%1E', '%1F', '%20', '!', '%22', '%23', '%24', '%25', '%26', "'", '(', ')', '*', '%2B', '%2C', '-', '.', '%2F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '%3A', '%3B', '%3C', '%3D', '%3E', '%3F', '%40', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%5B', '%5C', '%5D', '%5E', '_', '%60', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '%7B', '%7C', '%7D', '~', '%7F']; var out, i, j, len, c; out = []; len = str.length; for(i = 0, j = 0; i < len; i++) { c = str.charCodeAt(i); if (c <= 0x007F) { out[j++] = l[c]; continue; } else if (c <= 0x7FF) { out[j++] = '%' + (0xC0 | ((c >> 6) & 0x1F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ( c & 0x3F)).toString(16).toUpperCase(); continue; } else if (c < 0xD800 || c > 0xDFFF) { out[j++] = '%' + (0xE0 | ((c >> 12) & 0x0F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ((c >> 6) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase(); continue; } else { if (++i < len) { c2 = str.charCodeAt(i); if (c <= 0xDBFF && 0xDC00 <= c2 && c2 <= 0xDFFF) { c = ((c & 0x03FF) << 10 | (c2 & 0x03FF)) + 0x010000; if (0x010000 <= c && c <= 0x10FFFF) { out[j++] = '%' + (0xF0 | ((c >>> 18) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ((c >>> 12) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | ((c >>> 6) & 0x3F)).toString(16).toUpperCase(); out[j++] = '%' + (0x80 | (c & 0x3F)).toString(16).toUpperCase(); continue; } } } } } return out.join(''); } } // ============================== js ==> php =================================== // -- trim String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } // -- in_array function in_array(a, arr) { for(var i in arr) { if (arr[i] == a) return true ; } return false; } // -- array_merge => 返回一个arr2 后并 arr1 ,且直不等于 arr1 的数组 function array_merge(arr1, arr2) { var arr = arr1 ; for (var i in arr2) { if (!in_array(arr2[i], arr)) arr.push(arr2[i]); } return arr; } // -- array_diff => 返回一个 arr1 和 arr2 中不重复的数组 function array_diff(arr1, arr2) { var arr = new Array() ; for (var i in arr1) { if (!in_array(arr1[i], arr2)) arr.push(arr1[i]); } return arr; } // -- array_unique => 返回一个没有重复值的数组 (舍弃字符KEY) function array_unique(arr) { var ret = new Array() ; for (var i in arr) { if (!in_array(arr[i], ret)) ret.push(arr[i]) ; } return ret; } function my_split(se , str) { var arr = str.split(se) ; var ret = [] ; for(var i=0 ; i < arr.length ; i++) { if(arr[i]) ret.push(arr[i]) ; } return ret ; } function batchFun(arr , func) { for(var i=0 ; i < arr.length; i++) { func(arr[i]) ; } } // ============================== string html ubb =================================== // -- ubb bb => img function uncodeUbb(str){ str = str.replace(/\[BB(\d+)\]/gi, '<img alt="" src="/images/qqface/BB$1.gif" />'); return str ; } // -- limit ubb num function limitUbb(str){ var ubbNum = 3 ; for(var i=0 ; i < ubbNum ; i++){ str = str.replace(/\[BB(\d+)\]/i, '<BB$1>'); } str = str.replace(/\[BB(\d+)\]/ig, '') ; for(var i=0 ; i < ubbNum ; i++){ str = str.replace(/<BB(\d+)>/i, '[BB$1]'); } return str ; } // -- en htmlSpecialchars function enhtmlchars(str) { str = str.replace(/</g , '<').replace(/>/g , '>') ; str = str.replace(/"/g , '"').replace(/'/g , ''') ; str = str.replace(/ /g , ' ') ; return str ; } // -- de htmlSpecialchars function dehtmlchars(str) { str = str.replace(/</g , '<').replace(/>/g , '>') ; str = str.replace(/"/g , '"').replace(/'/g , "'") ; str = str.replace(/ /g , ' ') ; return str ; } // -- html to ubbcode function htmlToUbb(str,ext) { var arr = ext.split(',') ; if(in_array('all' , arr)) return str.replace(/</g , "[").replace(/>/g , "]") ; if(in_array('b' , arr)) str = str.replace(/<b[^>]*>([^<]*)<\/b>/ig , "[b]$1[/b]") ; if(in_array('img' , arr)) str = ((browser.msie) ? str.replace(/<img[^>]+src=['"][^>]*bb(\d+)\.gif[^>]*>/ig , "[BB$1]").replace(/<br[^>]*>/ig , "\n") : str.replace(/<img[^>]+src=['"][^>]*bb(\d+)\.gif[^>]*>/ig , "[BB$1]").replace(/<br[^>]*>/ig , "")) ; if(in_array('del' , arr)) str = str.replace(/<del>([^<]*)<\/del>/ig , "[del]$1[/del]") ; return str ; } // -- clear htmlContent function clearHtml(str,ext) { var arr = ext.split(',') ; if(in_array('a' , arr)) str = str.replace(/<a[^>]*>[^<]*<\/a>/ig , "") ; if(in_array('aimg' , arr)) str = str.replace(/<a[^>]*><img[^>]+><\/a>/ig , "") ; if(in_array('quote' , arr)) str = str.replace(/<blockquote>[\s\S]*<\/blockquote>/ig , "") ; return str ; } // --strip html function stripHtml(str,ext) { var arr = ext.split(',') ; if(in_array('a' , arr)) str = str.replace(/(<a[^>]*>)|(<\/a>)/ig ,"") ; if(in_array('s' , arr)) str = str.replace(/(<span[^>]*>)|(<\/span>)/ig ,"") ; if(in_array('em' , arr)) str = str.replace(/(<em[^>]*>)|(<\/em>)/ig ,"") ; return str ; } // ============================== num =================================== // -- get rand function getRand(n1, n2) { var equNum = Math.abs(n1 - n2) + 1; var lowNum = Math.min(n1 , n2) ; return n1 + Math.floor(equNum*Math.random()) ; } // ============================== browser navigator =================================== var browser = new Object(); function getBrowser() { var b = navigator.userAgent.toLowerCase(); browser = { safari: /webkit/.test(b), opera: /opera/.test(b), ie6: /msie 6/.test(b) && !/opera/.test(b), ie7: /msie 7/.test(b) && !/opera/.test(b), msie: /msie/.test(b) && !/opera/.test(b), mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b) }; } getBrowser() ; // ============================== element =================================== // --- by id function $(strId){ return document.getElementById(strId); } // --- extend function extend(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; } // --- by className function getElementsByClassName(oElm, strTagName, strClassName){ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/\-/g, "\\-"); var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); var oElement; for(var i=0; i<arrElements.length; i++){ oElement = arrElements[i]; if(oRegExp.test(oElement.className)){ arrReturnElements.push(oElement); } } return (arrReturnElements) } // --- by AttributeValue function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null; var oCurrent; var oAttribute; for(var i=0; i<arrElements.length; i++){ oCurrent = arrElements[i]; oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName); if(typeof oAttribute == "string" && oAttribute.length > 0){ if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){ arrReturnElements.push(oCurrent); } } } return arrReturnElements; } // --- add class function addClassName(oElm, strClassName){ var strCurrentClass = oElm.className; if(!new RegExp(strClassName, "i").test(strCurrentClass)){ oElm.className = strCurrentClass + ((strCurrentClass.length > 0)? " " : "") + strClassName; } } // --- remove calss function removeClassName(oElm, strClassName){ var oClassToRemove = new RegExp(('(^|\\s)' + strClassName + "($|\\s)"), "i"); oElm.className = oElm.className.replace(oClassToRemove, "").replace(/^\s*|\s*$/g, ""); } // --- renturn input value function sketch(objId){ return document.getElementById(objId).value; } // ------ appleLife ------ function $$$(v) { var element = typeof v == 'object' ? v : $(v) ; if(!element.appleSay) { extend(element , appleLife) ; } return element ; } var appleLife = { appleSay : '从不吃苹果' , interval : null , looop : function (funcName , speed , jobj){ var element = this ; if(this.interval) clearTimeout(this.interval) ; this.interval = setInterval( function (){ butterfly[funcName](element , jobj) } , speed ) ; } } var butterfly = { stepMove : function(element , jobj) { var nowStart = (element.style[jobj.style] == '') ? 0 : parseInt(element.style[jobj.style]); var than = jobj.than ? jobj.than : 8 ; var units = jobj.units ? jobj.units : 'px' ; var moveValue = jobj.end - nowStart ; var step = (moveValue > 0) ? Math.ceil(moveValue/than) : Math.floor(moveValue/than) ; element.style[jobj.style] = nowStart + step + units ; if(jobj.end == parseInt(element.style[jobj.style])) { clearTimeout(element.interval) ; if(jobj.func && jobj.func.constructor == Function) jobj.func() ; } } , avMove : function(element, jobj) { var units = jobj.units || 'px' ; jobj.than = jobj.than || 10 ; jobj.nowThan = jobj.nowThan || jobj.than ; for(var i=0 ; i < jobj.priv.length; i++) { var nowStart = getStyle(element , jobj.priv[i].style) ; nowStart = nowStart ? parseInt(nowStart) : 0 ; var moveValue = jobj.priv[i].end - nowStart ; var zf = moveValue/Math.abs(moveValue) ; var step = (zf > 0) ? Math.ceil(moveValue/jobj.nowThan) : Math.floor(moveValue/jobj.nowThan) ; var tmpValue = nowStart + step ; var nowValue = tmpValue*zf < jobj.priv[i].end*zf ? tmpValue : jobj.priv[i].end ; var o = new Object() ; o[jobj.priv[i].style] = nowValue + units ; setStyle(element , o ) ; } jobj.nowThan-- ; if(!jobj.nowThan) { clearTimeout(element.interval) ; if(jobj.func && jobj.func.constructor == Function) jobj.func() ; } } } butterfly.tmpoMove = function(element, jobj) { var units = jobj.units || 'px' ; jobj.than = jobj.than || 10 ; jobj.nowThan = jobj.nowThan || jobj.than ; var nowStart = getOpacity(element) ; nowStart = nowStart ? parseInt(nowStart) : 0 ; var moveValue = jobj.end - nowStart ; var zf = moveValue/Math.abs(moveValue) ; var step = (zf > 0) ? Math.ceil(moveValue/jobj.nowThan) : Math.floor(moveValue/jobj.nowThan) ; var tmpValue = nowStart + step ; var nowValue = tmpValue*zf < jobj.end*zf ? tmpValue : jobj.end ; setOpacity(element , nowValue ) ; jobj.nowThan-- ; if(!jobj.nowThan) { clearTimeout(element.interval) ; if(jobj.func && jobj.func.constructor == Function) jobj.func() ; } } // ============================== style =================================== // --- ai --- function setStyle (element, style) { for (var name in style) { if(name != 'opacity') element.style[name] = style[name] ; else setOpacity(element , parseInt(style[name])) ; } } // --- ai --- function setEsStyle (arr , style) { for(var i=0 ; i < arr.length ; i++) { setStyle(arr[i] , style) ; } } // --- ai --- function getStyle (element, style) { var value = null ; if(style != 'opacity') value = element.style[style] ; else value = getOpacity(element) ; return value == 'auto' ? null : value ; } function setOpacity(element,num) { num = (num > 1) ? num : num*100 ; if(browser.msie) element.filters.alpha.opacity = num ; else if(browser.mozilla) element.style.opacity = num/100 ; } function getOpacity(element) { if(browser.msie) return element.filters.alpha.opacity ; else if(browser.mozilla) { if (document.defaultView && document.defaultView.getComputedStyle) { var css = document.defaultView.getComputedStyle(element, null); value = css ? css.getPropertyValue('opacity') : null; return value*100 ; } } } function displaySelect(type) { var selArr = document.body.getElementsByTagName('select') ; var selValue = type ? 'visible' : 'hidden' ; for(var i=0 ; i < selArr.length ; i++) { selArr[i].style.visibility = selValue ; } } // ============================== attach css just for ie =================================== // - load fish function applefish(extra , tfish , strTagName , oElm , strClassName ) { var tempFun = function() { var elementArr = strClassName ? getElementsByClassName(oElm , strTagName , strClassName) : oElm.getElementsByTagName(strTagName) ; tfish(elementArr) ; } if(extra && window.attachEvent) { window.attachEvent("onload", tempFun); } else if (extra && window.addEventListener) { window.addEventListener('load' , tempFun , false); } } var sffocus = function(iptArr) { for (var i=0; i < iptArr.length; i++) { iptArr[i].attachEvent("onfocus" , function(evt) { element = returnEventValue('srcElement' , evt) addClassName(element , 'sffocus') ; }) ; iptArr[i].attachEvent("onblur", function(evt) { element = returnEventValue('srcElement' , evt) removeClassName(element , 'sffocus') ; }) ; } } var qlmouse = function(emArr) { for (var i=0; i < emArr.length; i++) { emArr[i].attachEvent("onmouseover" , function(evt) { element = returnEventValue('srcElement' , evt) addClassName(element , 'qklistOver') }) ; emArr[i].attachEvent("onmouseout", function(evt) { element = returnEventValue('srcElement' , evt) removeClassName(element , 'qklistOver') ; }) ; } } applefish( browser.msie , sffocus, "input" , document ); applefish( browser.msie , sffocus, "textarea" , document ); applefish( browser.ie6 , qlmouse , 'em' , document , 'addQlist' ); // ============================== event =================================== // -- add event function addEvent(oElm , strEvent , fuc) { strEvent = strEvent.replace(/^on/i , '') ; if(browser.msie) oElm.attachEvent('on' + strEvent , fuc) ; else oElm.addEventListener(strEvent , fuc , false) ; } // -- remove event function removeEvent(oElm , strEvent , fuc) { strEvent = strEvent.replace(/^on/i , '') ; if(browser.msie) oElm.detachEvent('on' + strEvent , fuc) ; else oElm.removeEventListener(strEvent , fuc , false) ; } // -- return event value function returnEventValue (type , evt) { var ret ; switch(type) { case 'srcElement' : ret = evt.srcElement ? evt.srcElement : evt.target ; break ; case 'clientX' : ret = evt.clientX ? evt.clientX : evt.pageX ; break ; case 'clientY' : ret = evt.clientY ? evt.clientY : evt.pageY ; break ; case 'keyCode' : ret = evt.keyCode ? evt.keyCode : evt.which ; break ; } return ret ; } // -- stop event down function stopEvent(evt){ if (evt.preventDefault) { evt.preventDefault(); evt.stopPropagation(); } else{ evt.returnValue = false; evt.cancelBubble = true; } } // ============================== cookie =================================== function getExpTime(time,type){ var expTime = new Date(); switch(type) { case 'year' : expTime.setFullYear(expTime.getFullYear() + time ); break ; case 'month' : expTime.setMonth( expTime.getMonth() + time ); break; case 'day' : expTime.setDate( expTime.getDate() + time ); break; case 'hour' : expTime.setHours( expTime.getHours() + time ); break; } return expTime.toGMTString(); } function getCookieVal(offset) { var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) endstr = document.cookie.length; return decodeURIComponent(document.cookie.substring(offset, endstr)); } function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen){ var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal(j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return ""; } function setCookie(name,value,expires,path,domain,secure) { document.cookie = name + "=" + encodeURIComponent(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } function delCookie(name){ var guoqu = new Date(); expiresTime = guoqu.setTime(guoqu.getTime() - 100); setCookie(name,'',expiresTime,'/','.6rooms.com') ; } // ============================== open new window =================================== // open kai function kai(page,name,width,height,left,top,type){ var left = (typeof(left) == 'undefined') ? (screen.availWidth - 400)/2 : left; var top = (typeof(top) == 'undefined') ? (screen.availHeight - 460)/2 : top; newopen = window.open(page,name,"width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + (type ? ',location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1' : '')); newopen.focus(); } // ============================== color Frame =================================== /* #colorFrame { width:228px; overflow:hidden; border:1px solid #000000; border-width:1px 0 0 1px; position:absolute; } #colorFrame em { width:11px; text-indent:-99px; cursor:pointer; height:11px; display:block; float:left; overflow:hidden; border:1px solid #000000; border-width:0 1px 1px 0; } */ colorFrame = { json : {curEle:null} , hideCheck : 0 , creat : function(evt , jobj) { var thisObj = this ; stopEvent(evt) ; this.json.curEle = returnEventValue('srcElement' , evt) ; if(!$('colorFrame')) { var colorHex=new Array('00','33','66','99','CC','FF') ; var SpColorHex = new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF') ; var colorHtml = '' ; for(var a=0 ; a < 12 ; a++) { for(var i=0 ; i < 3; i++) { for(var j=0 ; j < 6; j++) { if(i == 0 && j == 0) { var spColor = (a < 6) ? (colorHex[a] + colorHex[a] + colorHex[a]) : SpColorHex[a-6] ; colorHtml += '<em style="background-color:#' + spColor + '" >' + spColor + '</em>' ; } var color = colorHex[(a<6) ? i : (3+i)] + colorHex[j] + colorHex[(a<6) ? a : (a-6)] ; colorHtml += '<em style="background-color:#' + color + '" >' + color + '</em>' ; } } } var div1 = document.createElement("div") ; div1.innerHTML = colorHtml ; div1.id = 'colorFrame' ; document.body.appendChild(div1) ; } else { $('colorFrame').style.display = 'block' ; } if(!this.hideCheck) { addEvent(document.body , "onclick" , function() {thisObj.hide(jobj.hideFunc)}) ; this.hideCheck = 1 ; } $('colorFrame').style.left = returnEventValue('clientX' , evt) + 10 + 'px' ; $('colorFrame').style.top = returnEventValue('clientY' , evt) + document.documentElement.scrollTop + 'px' ; addEvent($('colorFrame') , 'onclick' , function(evt){if(returnEventValue('srcElement' , evt).tagName.toLowerCase() == 'em') jobj.eventFunc(evt);}) ; if(jobj.func && jobj.func.constructor == Function) jobj.func() ; } , hide : function (func) { if($('colorFrame')) $('colorFrame').style.display = 'none' ; if(func && func.constructor == Function) func() ; } } // ------ full screen watch ------ function fullScreen() { /* // ======= bug for tt && mx ====== var availW = window.screen.availWidth ; var availH = window.screen.availHeight ; window.moveTo(0,0) ; window.resizeTo(availW,availH) ; */ window.focus() ; var cW = document.documentElement.clientWidth ; var cH = document.documentElement.clientHeight ; var sW = document.documentElement.scrollWidth ; var sH = document.documentElement.scrollHeight; if(!$("cureBlack")){ var w = (cW > sW) ? cW : sW ; var h = (cH > sW) ? cH : sH ; var cureBlack = document.createElement("div"); with(cureBlack.style){ cureBlack.id = "cureBlack"; width = w + 'px'; height = h + 'px'; left = '0px'; top = '0px'; } document.body.appendChild(cureBlack) ; cureBlack.style.display = 'block' ; cureBlack.onclick = normalScreen ; } else { $("cureBlack").style.display = "block" ; } // get size var obj = $("flash_play") ; var content = $('flashWatch') ; // var fullH = cH*377/337.5; // var fullW = cH*4/3 ; // fuck displaySelect(0) ; $('video-others_bugs').style.display = 'none' ; document.documentElement.scrollTop = 0 ; if (document.removeEventListener) { document.addEventListener("keydown", nomalScreen_esc , false); } else if (document.body.detachEvent) { document.body.attachEvent("onkeydown", nomalScreen_esc); } // set size setStyle(obj , {width:cW + 'px' , height:cH + 'px'}) // obj.style.width = fullW + 'px' ; // obj.style.height = fullH + 'px' ; content.className = "fullWatch" ; setStyle(content , {top:0 , left:0}) ; // content.style.top = '0' ; // content.style.left = (sW - fullW)/2 + 'px' ; } function nomalScreen_esc (evt) { evt = evt ? evt : event ; var keyCode = returnEventValue('keyCode' , evt) ; if(keyCode == 27 && $('cureBlack').style.display == 'block') normalScreen() ; } function normalScreen() { with($("flash_play").style) { width = '460px' ; height = '385px' ; } $('flashWatch').style.left = '' ; $('flashWatch').style.top = '' ; $("cureBlack").style.display = 'none' ; // fuck displaySelect(1) ; $('video-others_bugs').style.display = 'block' ; $("flash_play").SetVariable('watch_play', 'normal') ; } function loadFullScreen() { if(window.location.hash == '#fullScreen') { fullScreen() ; } } // ------ 加入收藏 ------ function bookmark(){ var title = document.title var url = document.location.href if (browser.mozilla) window.sidebar.addPanel(title, url,""); else if(browser.opera){ var mbm = document.createElement('a'); mbm.setAttribute('rel','sidebar'); mbm.setAttribute('href',url); mbm.setAttribute('title',title); mbm.click(); } else if(browser.msie) window.external.AddFavorite( url, title); } function copyCode(e) { var text = '' ; if(typeof e != 'string') { var iptEle = e.parentNode.getElementsByTagName('input')[0] ; iptEle.select() ; text = iptEle.value ; } else text = e ; if(browser.ie6) { window.clipboardData.setData('text',text) alert('已复制,请使用Ctrl+V粘贴出来') ; } } // ------ json cookie ------ var jcookie = { limitTime : 1 , timeType : 'day' , cteate : function() { var json = {apple:'comeback'} ; var expiresTime = getExpTime(this.limitTime,this.timeType) ; var value = JSON.stringify(json) ; setCookie('json',value,expiresTime,'/','.6rooms.com') ; return json ; } , get : function() { var json = null var value = getCookie('json') ; var expiresTime = getExpTime(this.limitTime,this.timeType) if(!value) json = this.create() else { json = JSON.parse(value) ; if(typeof json != 'object') json = this.create() ; } return json ; } , set : function(name , value) { var json = this.get() ; json[name] = value ; var expiresTime = getExpTime(this.limitTime,this.timeType) ; var value = JSON.stringify(json) ; setCookie('json',value,expiresTime,'/','.6rooms.com') ; } } // ------ over frame ------ /* .overFrame { position:absolute; margin:0; padding:10px; z-index:100; background-color:#F4F4F4; border:3px solid #666666; } .overFrame h4 { font-size:1.1em; font-weight:bold; line-height:180%; padding-bottom:5px; overflow:hidden; } .overFrame h4 span { float:right; text-decoration:underline; cursor:pointer; font-weight:bold; } */ /* var appover = { creat : function(func) { // var availW = window.screen.availWidth ; // var availH = window.screen.availHeight ; // window.moveTo(0,0) // window.resizeTo(availW,availH) ; var cW = document.documentElement.clientWidth ; var cH = document.documentElement.clientHeight ; var sW = document.body.offsetWidth; var sH = document.documentElement.scrollHeight; var img1 = new Image(); img1.src = "http://r.6rooms.com/imges/overlay.png"; var img2 = new Image(); img2.src = "http://r.6rooms.com/imges/blank.gif"; var w = (cW > sW) ? cW : sW ; var h = (cH > sW) ? cH : sH ; var overlay = document.createElement("div"); with(overlay.style){ overlay.id = "overlay"; width = w + 'px'; height = h + 'px'; left = '0px'; top = '0px'; } document.body.appendChild(overlay) ; displaySelect(0) ; } , esc : function() { displaySelect(1) ; document.body.removeChild($('overlay')) ; document.body.removeChild($('overFrame')) ; } , frameMiddle : function(w) { var ele = $('overFrame') ; setStyle(ele , {top:document.documentElement.scrollTop + 100 + 'px' , marginLeft:-ele.offsetWidth/2 + 'px'}) ; } } */ function createOverFrame(title , idName , pe , htmlStr , func) { var div1 = document.createElement('div') ; div1.className = 'overFrame' ; div1.id = idName ; var h52 = document.createElement('h5') ; h52.innerHTML = '<span>关闭</span>' + title ; div1.innerHTML = htmlStr ; pe.appendChild(div1) ; h52.getElementsByTagName('span')[0].onclick = func || function(){this.parentNode.parentNode.style.display = 'none' ;} div1.insertBefore(h52 , div1.firstChild) ; } // ================ function luboPlayer_write() { var playerStr = '' ; if(browser.mozilla) playerStr = '<embed id="v6ocx" type="application/x-oleobject" width="500" HEIGHT="375" clsid="{E7181F81-7D6D-4A76-86AF-718F065CE7E4}" param_backcolor="16776960" />' ; else if(browser.msie) playerStr = '<object wmode="transparent" classid="clsid:E7181F81-7D6D-4A76-86AF-718F065CE7E4" id="v6ocx" width="500" height="375">' + '<param name="wmode" value="transparent" />' + '</object>' ; document.write(playerStr) ; }