淘宝 常用js_1

本文介绍了一段用于淘宝网站的JavaScript代码,该代码负责显示用户的登录状态、站内消息数量及相应链接,并根据条件播放新消息的声音提醒。
ContractedBlock.gifExpandedBlockStart.gifCode
ExpandedBlockStart.gifContractedBlock.gif<script>
ExpandedSubBlockStart.gifContractedSubBlock.gif     
var FP = {};
ExpandedSubBlockStart.gifContractedSubBlock.gif     (
function(){
ExpandedSubBlockStart.gifContractedSubBlock.gif         
var K = function(N){
             
var O = document.cookie.match("(?:^|;)\\s*" + N + "=([^;]*)");
             
return O ? unescape(O[1]) : ""
         }
;
ExpandedSubBlockStart.gifContractedSubBlock.gif         
var I = function(U){
ExpandedSubBlockStart.gifContractedSubBlock.gif             
var S = {};
             
var T = U.split("&");
             
var Q = /([^=]*)=(.*)/;
ExpandedSubBlockStart.gifContractedSubBlock.gif             
for (var O = 0; O < T.length; O++{
                 
var N = Q.exec(T[O]);
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
if (!N) {
                     
continue
                 }

                 
var P = decodeURIComponent(N[1]);
                 
var R = N[2? decodeURIComponent(N[2]) : undefined;
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
if (S[P] !== undefined) {
ExpandedSubBlockStart.gifContractedSubBlock.gif                     
if (S[P].constructor != Array) {
                         S[P] 
= [S[P]]
                     }

ExpandedSubBlockStart.gifContractedSubBlock.gif                     
if (R) {
                         S[P].push(R)
                     }

                 }

ExpandedSubBlockStart.gifContractedSubBlock.gif                 
else {
                     S[P] 
= R
                 }

             }

             
return S
         }
;
ExpandedSubBlockStart.gifContractedSubBlock.gif         
var H = function(P, N, O){
ExpandedSubBlockStart.gifContractedSubBlock.gif             
if (P.addEventListener) {
                 P.addEventListener(N, O, 
false)
             }

ExpandedSubBlockStart.gifContractedSubBlock.gif             
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
if (P.attachEvent) {
                     P.attachEvent(
"on" + N, O)
                 }

             }

         }
;
         
var L = K("cookie1");
         
var A = K("_nk_");
         
var M = K("tracknick");
         
var E = I(K("uc1"));
         FP._ucMap 
= E;
         
var C = navigator.userAgent.toLowerCase(), D = C.indexOf("opera"!= -1, J = C.indexOf("safari"!= -1, B = !&& !&& C.indexOf("gecko"> -1, F = !&& C.indexOf("msie"!= -1, G = !&& C.indexOf("msie 6"!= -1;
ExpandedSubBlockStart.gifContractedSubBlock.gif         FP.writeLoginStatus 
= function(S, Y, P, O, R, U){
             
var X = parseInt(E._msg_) || 0;
             
var T = O + "/logout.jhtml?f=top";
             
var Q = O + "/newbie.htm";
             
var V = O + "/login.jhtml?f=top";
ExpandedSubBlockStart.gifContractedSubBlock.gif             
if (U && U != ""{
                 V 
+= "&redirectURL=" + U
             }

             
var W = Y + "/message/list_private_msg.htm";
             
var Z = "http://space.taobao.com/blog/index/my_space.htm?nekot=" + new Date().getTime();
             
var N = "";
ExpandedSubBlockStart.gifContractedSubBlock.gif             
if (L != ""{
                 N 
+= '<li>\u60a8\u597d\uff0c<a href="' + Z + '" target="_blank">' + unescape(A.replace(/\\u/g, "%u")) + '</a>\uff01<a href="' + T + '" target="_top" id="J_Logout">[\u9000\u51fa]</a></li>';
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
if (X > 0{
                     N 
+= '<li class="HasMsgMail"><a href="' + Y + '/message/list_private_msg.htm" target="_top">\u7ad9\u5185\u4fe1</a>(' + X + ")</li>"
                 }

ExpandedSubBlockStart.gifContractedSubBlock.gif                 
else {
                     N 
+= '<li><a href="' + W + '" target="_top">\u7ad9\u5185\u4fe1</a></li>'
                 }

             }

ExpandedSubBlockStart.gifContractedSubBlock.gif             
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
if (M == ""{
                     N 
+= "<li>\u60a8\u597d\uff0c\u6b22\u8fce\u6765\u6dd8\u5b9d\uff01</li>";
                     N 
+= '<li><a href="' + Q + '" target="_top">[\u514d\u8d39\u6ce8\u518c]</a></li>';
                     N 
+= '<li><a href="' + V + '" target="_top">[\u767b\u5f55]</a></li>'
                 }

ExpandedSubBlockStart.gifContractedSubBlock.gif                 
else {
                     N 
+= "<li>\u60a8\u597d\uff0c" + unescape(M.replace(/\\u/g, "%u")) + '\uff01<a href="' + V + '" target="_top">[\u8bf7\u767b\u5f55]</a></li>';
                     N 
+= '<li><a href="' + Q + '" target="_top">[\u514d\u8d39\u6ce8\u518c]</a></li>';
                     N 
+= '<li><a href="' + W + '" target="_top">\u7ad9\u5185\u4fe1</a></li>'
                 }

             }

             document.write(N)
         }
;
ExpandedSubBlockStart.gifContractedSubBlock.gif         FP.writeMsgSound 
= function(O){
             
var N = O || "www.taobao.com";
             
var P = parseInt(E._msg_) || 0;
             
var Q = (E._msg_v != "false");
ExpandedSubBlockStart.gifContractedSubBlock.gif             
if (L != "" && P > 0 && Q) {
                 document.write(
'<embed src="' + N + '/sounds/newpm.swf" loop="false" hidden="true" volume="50" autostart="true" width="0" height="0" name="foobar" mastersound="mastersound" class="hidden" />')
             }

         }
;
ExpandedSubBlockStart.gifContractedSubBlock.gif         FP.writeWatch 
= function(){
             
var N = "";
ExpandedSubBlockStart.gifContractedSubBlock.gif             
if (L != "" || M != ""{
                 N 
+= "<li><a href='http://favorite.taobao.com/collect_list.htm' target='_top'>\u6536\u85cf\u5939</a></li>"
             }

             document.write(N)
         }
;
ExpandedSubBlockStart.gifContractedSubBlock.gif         FP.initSearchSelector 
= function(P){
             P 
= document.getElementById(P);
ExpandedSubBlockStart.gifContractedSubBlock.gif             
if (!P) {
                 
return
             }

             
var O = "item";
             
var R = P.getElementsByTagName("a");
ExpandedSubBlockStart.gifContractedSubBlock.gif             
for (var Q = 0, N = R.length; Q < N; ++Q) {
ExpandedSubBlockStart.gifContractedSubBlock.gif                 (
function(){
                     
var T = R[Q];
ExpandedSubBlockStart.gifContractedSubBlock.gif                     T.onclick 
= function(){
ExpandedSubBlockStart.gifContractedSubBlock.gif                         
for (var U = 0; U < N; ++U) {
                             
var V = R[U].parentNode.className;
                             R[U].parentNode.className 
= V.replace("selected""")
                         }

                         T.parentNode.className 
= "selected";
                         O 
= T.getAttribute("rel");
                         
return false
                     }

                 }
)()
             }

             
var S = document.forms.search;
ExpandedSubBlockStart.gifContractedSubBlock.gif             S.onsubmit 
= function(T){
ExpandedSubBlockStart.gifContractedSubBlock.gif                 
if (S.q.value == "" && O === "item"{
                     location.href 
= "http://list.taobao.com/browse/cat-0.htm";
                     
return false
                 }

ExpandedSubBlockStart.gifContractedSubBlock.gif                 
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                     
if (O === "mall"{
                         S.action 
= "http://list.mall.taobao.com/search_dispatcher.htm"
                     }

ExpandedSubBlockStart.gifContractedSubBlock.gif                     
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                         
if (O === "shop"{
                             S.search_type.value 
= "shop"
                         }

ExpandedSubBlockStart.gifContractedSubBlock.gif                         
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                             
if (O === "dating"{
                                 S.action 
= "http://dating.taobao.com/search_question.htm"
                             }

ExpandedSubBlockStart.gifContractedSubBlock.gif                             
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                                 
if (O === "global"{
                                     S.promote.value 
= "2097152"
                                 }

ExpandedSubBlockStart.gifContractedSubBlock.gif                                 
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                                     
if (O === "auction"{
                                         S.atype.value 
= "a";
                                         S.isnew.value 
= "1,3"
                                     }

ExpandedSubBlockStart.gifContractedSubBlock.gif                                     
else {
ExpandedSubBlockStart.gifContractedSubBlock.gif                                         
if (S.search_type.value === "shop"{
                                             S.search_type.value 
= "auction"
                                         }

                                     }

                                 }

                             }

                         }

                     }

                 }

                 
return true
             }

         }

     }
)();
ExpandedSubBlockStart.gifContractedSubBlock.gif     FP.distractAd 
= function(C){
         
var D = /(?:<script.*?>)([\s\S]*?)(?:<\/script>)/img;
         var A = document.createElement("li");
         
var B = document.getElementById(C);
         A.innerHTML 
= B.innerHTML.replace(D, "");
         document.getElementById(
"J_textbox").appendChild(A);
         B.parentNode.removeChild(B)
     }
;
     
ExpandedSubBlockStart.gifContractedSubBlock.gif         (
function(){
ExpandedSubBlockStart.gifContractedSubBlock.gif        
function akrand(num){
            
return Math.floor(Math.random() * num) + 1
        }

        
var P = location.pathname;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if ((parent && parent.location == self.location) || P.indexOf('/list_forum'!= -1 || P.indexOf('/theme/info/info'!= -1 || P.indexOf('/promo/co_header.php'!= -1{
            
var R = escape(document.referrer);
            document.write(
'<img src="http://acookie.taobao.com/1.gif?cache=' + akrand(9999999+ '&pre=' + R + '&category=&userid=&channel=109&ad_id=" width="0" height="0" style="display:none;" />')
        }

    }
)();
    
    
ExpandedSubBlockStart.gifContractedSubBlock.gif    (
function(){
ExpandedSubBlockStart.gifContractedSubBlock.gif    
function atrand(num){
        
return Math.floor(Math.random() * num) + 1
    }

    
var P = location.pathname;
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if ((parent && parent.location == self.location) || P.indexOf('/list_forum'!= -1 || P.indexOf('/theme/info/info'!= -1 || P.indexOf('/promo/co_header.php'!= -1{
        
var R = escape(document.referrer);
        document.write(
'<img src="http://www.atpanel.com/1.gif?cache=' + atrand(9999999+ '&pre=' + R + '&category=&userid=&channel=109&ad_id=" width="0" height="0" style="display:none;" />')
    }

}
)();


</script>

转载于:https://www.cnblogs.com/zjm1126qqcom/archive/2009/02/19/1394312.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值