//2016-1-12 10:36 creep !function(t,e,o,i,r){function n(t){this.options=m.extend({},g,t||{}),this._id="passport"+(u+Math.random()).replace(/\D/g,""),this.appid=this.options.appid||9998,this.domain=this.options.domain||this.parseDomain(),this._iframe=null,this._form=null,this.cookie=this.parseCookie(),this.on("reloadcookie",m.bind(this.reloadCookie,this))}function a(){var t,e=i.get("lastdomain");return e&&(t=function(t){var e,i=t.split("|"),r=[];if(i.length>=3){e=o.decode(i[1]).split("|");for(var n=0;nt;t++)if(null!==(o=arguments[t]))for(e in o)i=o[e],i!==r&&(n[e]=i);return n},inArray:function(t,e){for(var o=0;o-1&&i.splice(r,1)}else this.data[t][e]=[];else this.data[t]={};return!0},fire:function(t,e,o){if(!t)return!1;if(e instanceof n||"object"!=typeof e||(o=e,e=null),e)this.data[e._id]&&this.exec(this.data[e._id][t]||[],o);else for(var i in this.data)this.exec(this.data[i][t]||[],o)},fireWithout:function(t,e,o){if(!t)return!1;if(e instanceof n||"object"!=typeof e||(o=e,e=null),e)for(var i in this.data)i!==e._id&&this.exec(this.data[i][t]||[],o);else this.fire(t,o)},exec:function(t,e){for(var o=0;o'):(e=document.createElement("iframe"),e.setAttribute("name",t)),e.style.display="none",document.body.appendChild(e),e},createForm:function(t){var e,o,i,r=document.createElement("form");for(o in t)i=t[o],e=document.createElement("input"),e.type="hidden",e.name=o,e.value=i,r.appendChild(e);return r.style.display="none",document.body.appendChild(r),r},formData:function(t,o){var i={domain:t.domain||this.domain,callback:this.randomName("cb")};if("login"===o||"dclogin"===o){i.appid=this.appid;for(var r in t)"password"===r?i.password=e(m.trim(t.password)):"pc"===r?i.persistentcookie=t.pc?1:0:i[r]=m.trim(t[r])}return i},postLoginCallback:function(t){v=!1,s&&clearTimeout(s),this.clearTempElements(),l.fire("reloadcookie",{}),0===t.code?(l.fire("login",this,t),l.fireWithout("login",this,t)):l.fire("error",this,t)},postLogoutCallback:function(t){C=!1,c&&clearTimeout(c),this.clearTempElements(),l.fire("reloadcookie",{}),0===t.code&&(l.fire("logout",this,t),l.fireWithout("logout",this,t))},getLoginCallback:function(t){v=!1,s&&clearTimeout(s),0===t.code?this.setOtherDomainCookie("login"):l.fire("error",this,t)},getLogoutCallback:function(t){C=!1,c&&clearTimeout(c),0===t.code&&this.setOtherDomainCookie("logout")},clearTempElements:function(){this._form&&(document.body.removeChild(this._form),this._form=null),this._iframe&&(document.body.removeChild(this._iframe),this._iframe=null)},setOtherDomainCookie:function(t){function e(){a++,a>=s&&(l.fire("reloadcookie",{}),l.fire(t,n,data),l.fireWithout(t,n,data))}var o,i,r,n=this,a=0,s=this.options.otherdomain.length;for(r=0;s>r;r++)i=this.options.otherdomain[r],o="//passport.sohu.com/sso/crossdomain.jsp?"+m.param({action:t,domain:i}),this.script(o,e)},getLastdomain:a,parseCookie:function(){var t,e=i.get("ppinf")||i.get("ppinfo")||i.get("passport");return e&&(t=this.parseUserInfo(o.decode(e.split("|")[3]))),t},parseUserInfo:function(t){for(var e,o=t.split("|"),i={},r=0;r',t=t.getElementsByTagName("a")[0].href}return e=o.exec(t.toLowerCase())||[],{href:t,url:e[0],protocol:e[1],hostname:e[2],port:e[3]||""}},reloadCookie:function(){this.cookie=this.parseCookie()},getJSONP:function(e,o,i){var n,a=this.randomName("cb"),s=document.getElementsByTagName("head")[0],c=document.createElement("script"),u=/\?/,h=/(=)\?(?=&|$)|\?\?/,f=/([?&])_=[^&]*/,d=(new Date).getTime();e=e.replace(h,"$1"+a),n=e.replace(f,"$1_="+d),e=n+(n===e?(u.test(e)?"&":"?")+"_="+d:""),t[a]=function(e){m.isFunction(o)&&o(e),t[a]=r,s.removeChild(c)},c.type="text/javascript",c.charset=i||"UTF-8",c.src=e,s.appendChild(c)},script:function(t,e,o){var i=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.charset=o||"UTF-8",n.src=t,n.onload=n.onreadystatechange=function(){(!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,i&&n.parentNode&&i.removeChild(n),n=r,m.isFunction(e)&&e())},i.appendChild(n)}};var k=function(t){function e(){o&&(clearInterval(o),o=null)}var o,i=new n(t);return{isLogin:function(){return!!this.cookie(!0)},login:function(t,e){return i.login(t,e),this},loginByDynamicCode:function(t,e){return i.loginByDynamicCode(t,e),this},logout:function(t,e){return i.logout(t,e),this},on:function(t,e){return i.on(t,e),this},off:function(t,e){return i.off(t,e),this},location:function(){return i.parseLocation()},abortLoginSubmit:function(){return i.abortLoginSubmit(),this},cookie:function(t,e){if((m.isBool(t)&&t===!0||m.isString(t)&&e)&&i.reloadCookie(),!m.isString(t)||!i.cookie)return i.cookie;var o;switch(t){case"uniqname":case"nickname":o=decodeURIComponent(i.cookie.uniqname);break;case"passport":case"userid":o=i.cookie.userid;break;default:o=i.cookie[t]}return o},provider:function(){var t=this.cookie("userid",!0)||"",e=t.match(/^[^@]+@(\w+)\.sohu\.com$/)||"";return e&&e[1]},lastdomain:function(){return i.getLastdomain()},watchOAuth:function(t){var i=this,r=+new Date;return t=1e3*(t||60),e(),o=setInterval(function(){var o=+new Date-r;i.isLogin()?(e(),l.fire("login",{})):o>t&&e()},500),this}}};k.debug=function(t){f=t},k.version=u,k.utils=m,k.browser=d,k.quickLogout=function(t){var e=new n;e.on("logout",function(){t?h.href=t:h.reload()}),e.logout()},t.SohuPassport=k,"function"==typeof define&&define.amd&&define("sohupassport",[],function(){return k})}}(window,function(){var t=function(t){function e(t){return f(o(h(t),t.length*d))}function o(t,e){t[e>>5]|=128<>>9<<4)+14]=e;for(var o=1732584193,i=-271733879,u=-1732584194,h=271733878,f=0;f>16)+(e>>16)+(o>>16);return i<<16|65535&o}function u(t,e){return t<>>32-e}function h(t){for(var e=Array(),o=(1<>5]|=(t.charCodeAt(i/d)&o)<>2]>>i%4*8+4&15)+e.charAt(t[i>>2]>>i%4*8&15);return o}var m=0,d=8;return e(t)};return t}(),function(){var t={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var o,i,r,n,a,s,c,u="",h=0;for(e=this.encodeURL(e),e=t._utf8_encode(e);h>2,a=(3&o)<<4|i>>4,s=(15&i)<<2|r>>6,c=63&r,isNaN(i)?s=c=64:isNaN(r)&&(c=64),u=u+this._keyStr.charAt(n)+this._keyStr.charAt(a)+this._keyStr.charAt(s)+this._keyStr.charAt(c);return u},decode:function(e){var o,i,r,n,a,s,c,u="",h=0;for(e=this.decodeUrl(e),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");h>4,i=(15&a)<<4|s>>2,r=(3&s)<<6|c,u+=String.fromCharCode(o),64!=s&&(u+=String.fromCharCode(i)),64!=c&&(u+=String.fromCharCode(r));return u=t._utf8_decode(u)},_utf8_encode:function(t){t=t.replace(/\r\n/g,"\n");for(var e="",o=0;oi?e+=String.fromCharCode(i):i>127&&2048>i?(e+=String.fromCharCode(i>>6|192),e+=String.fromCharCode(63&i|128)):(e+=String.fromCharCode(i>>12|224),e+=String.fromCharCode(i>>6&63|128),e+=String.fromCharCode(63&i|128))}return e},_utf8_decode:function(t){for(var e="",o=0,i=0,r=0;oi?(e+=String.fromCharCode(i),o++):i>191&&224>i?(r=t.charCodeAt(o+1),e+=String.fromCharCode((31&i)<<6|63&r),o+=2):(r=t.charCodeAt(o+1),c3=t.charCodeAt(o+2),e+=String.fromCharCode((15&i)<<12|(63&r)<<6|63&c3),o+=3);return e},encodeURL:function(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")},decodeUrl:function(t){var e,o;return t.length%4===0?e=t:(o=t.length%4,e=(t+"===").slice(0,t.length+4-o)),e.replace(/-/g,"+").replace(/_/g,"/")}};return t}(),function(){function t(t,o){var i={};if(e(t)&&t.length>0)for(var n,s,c,u=o?a:r,h=t.split(/;\s/g),f=0,m=h.length;m>f;f++){if(c=h[f].match(/([^=]+)=/i),c instanceof Array)try{n=a(c[1]),s=u(h[f].substring(c[1].length+1))}catch(d){}else n=a(h[f]),s="";n&&(i[n]=s)}return i}function e(t){return"string"==typeof t}function o(t){return e(t)&&""!==t}function i(t){if(!o(t))throw new TypeError("Cookie name must be a non-empty string")}function r(t){return t}var n={},a=decodeURIComponent,s=encodeURIComponent;return n.get=function(e,o){i(e),o="function"==typeof o?{converter:o}:o||{};var n=t(document.cookie,!o.raw);return(o.converter||r)(n[e])},n.set=function(t,e,r){i(t),r=r||{};var n=r.expires,a=r.domain,c=r.path;r.raw||(e=s(String(e)));var u=t+"="+e,h=n;return"number"==typeof h&&(h=new Date,h.setDate(h.getDate()+n)),h instanceof Date&&(u+="; expires="+h.toUTCString()),o(a)&&(u+="; domain="+a),o(c)&&(u+="; path="+c),r.secure&&(u+="; secure"),document.cookie=u,u},n.remove=function(t,e){return e=e||{},e.expires=new Date(0),this.set(t,"",e)},n}());