lib.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /*livequery*/
  2. eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4($){$.R($.7,{3:4(c,b,d){9 e=2,q;5($.O(c))d=b,b=c,c=z;$.h($.3.j,4(i,a){5(e.8==a.8&&e.g==a.g&&c==a.m&&(!b||b.$6==a.7.$6)&&(!d||d.$6==a.o.$6))l(q=a)&&v});q=q||Y $.3(2.8,2.g,c,b,d);q.u=v;$.3.s(q.F);l 2},T:4(c,b,d){9 e=2;5($.O(c))d=b,b=c,c=z;$.h($.3.j,4(i,a){5(e.8==a.8&&e.g==a.g&&(!c||c==a.m)&&(!b||b.$6==a.7.$6)&&(!d||d.$6==a.o.$6)&&!2.u)$.3.y(a.F)});l 2}});$.3=4(e,c,a,b,d){2.8=e;2.g=c||S;2.m=a;2.7=b;2.o=d;2.t=[];2.u=v;2.F=$.3.j.K(2)-1;b.$6=b.$6||$.3.I++;5(d)d.$6=d.$6||$.3.I++;l 2};$.3.p={y:4(){9 b=2;5(2.m)2.t.16(2.m,2.7);E 5(2.o)2.t.h(4(i,a){b.o.x(a)});2.t=[];2.u=Q},s:4(){5(2.u)l;9 b=2;9 c=2.t,w=$(2.8,2.g),H=w.11(c);2.t=w;5(2.m){H.10(2.m,2.7);5(c.C>0)$.h(c,4(i,a){5($.B(a,w)<0)$.Z.P(a,b.m,b.7)})}E{H.h(4(){b.7.x(2)});5(2.o&&c.C>0)$.h(c,4(i,a){5($.B(a,w)<0)b.o.x(a)})}}};$.R($.3,{I:0,j:[],k:[],A:v,D:X,N:4(){5($.3.A&&$.3.k.C){9 a=$.3.k.C;W(a--)$.3.j[$.3.k.V()].s()}},U:4(){$.3.A=v},M:4(){$.3.A=Q;$.3.s()},L:4(){$.h(G,4(i,n){5(!$.7[n])l;9 a=$.7[n];$.7[n]=4(){9 r=a.x(2,G);$.3.s();l r}})},s:4(b){5(b!=z){5($.B(b,$.3.k)<0)$.3.k.K(b)}E $.h($.3.j,4(a){5($.B(a,$.3.k)<0)$.3.k.K(a)});5($.3.D)1j($.3.D);$.3.D=1i($.3.N,1h)},y:4(b){5(b!=z)$.3.j[b].y();E $.h($.3.j,4(a){$.3.j[a].y()})}});$.3.L(\'1g\',\'1f\',\'1e\',\'1b\',\'1a\',\'19\',\'18\',\'17\',\'1c\',\'15\',\'1d\',\'P\');$(4(){$.3.M()});9 f=$.p.J;$.p.J=4(a,c){9 r=f.x(2,G);5(a&&a.8)r.g=a.g,r.8=a.8;5(14 a==\'13\')r.g=c||S,r.8=a;l r};$.p.J.p=$.p})(12);',62,82,'||this|livequery|function|if|lqguid|fn|selector|var|||||||context|each||queries|queue|return|type||fn2|prototype|||run|elements|stopped|false|els|apply|stop|undefined|running|inArray|length|timeout|else|id|arguments|nEls|guid|init|push|registerPlugin|play|checkQueue|isFunction|remove|true|extend|document|expire|pause|shift|while|null|new|event|bind|not|jQuery|string|typeof|toggleClass|unbind|addClass|removeAttr|attr|wrap|before|removeClass|empty|after|prepend|append|20|setTimeout|clearTimeout'.split('|'),0,{}))
  3. /*query*/
  4. new function(settings){var $separator=settings.separator||'&';var $spaces=settings.spaces===false?false:true;var $suffix=settings.suffix===false?'':'[]';var $prefix=settings.prefix===false?false:true;var $hash=$prefix?settings.hash===true?"#":"?":"";var $numbers=settings.numbers===false?false:true;jQuery.query=new function(){var is=function(o,t){return o!=undefined&&o!==null&&(!!t?o.constructor==t:true)};var parse=function(path){var m,rx=/\[([^[]*)\]/g,match=/^(\S+?)(\[\S*\])?$/.exec(path),base=match[1],tokens=[];while(m=rx.exec(match[2]))tokens.push(m[1]);return[base,tokens]};var set=function(target,tokens,value){var o,token=tokens.shift();if(typeof target!='object')target=null;if(token===""){if(!target)target=[];if(is(target,Array)){target.push(tokens.length==0?value:set(null,tokens.slice(0),value))}else if(is(target,Object)){var i=0;while(target[i++]!=null);target[--i]=tokens.length==0?value:set(target[i],tokens.slice(0),value)}else{target=[];target.push(tokens.length==0?value:set(null,tokens.slice(0),value))}}else if(token&&token.match(/^\s*[0-9]+\s*$/)){var index=parseInt(token,10);if(!target)target=[];target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value)}else if(token){var index=token.replace(/^\s*|\s*$/g,"");if(!target)target={};if(is(target,Array)){var temp={};for(var i=0;i<target.length;++i){temp[i]=target[i]}target=temp}target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value)}else{return value}return target};var queryObject=function(a){var self=this;self.keys={};if(a.queryObject){jQuery.each(a.get(),function(key,val){self.SET(key,val)})}else{jQuery.each(arguments,function(){var q=""+this;q=q.replace(/^[?#]/,'');q=q.replace(/[;&]$/,'');if($spaces)q=q.replace(/[+]/g,' ');jQuery.each(q.split(/[&;]/),function(){var key=decodeURIComponent(this.split('=')[0]);var val=decodeURIComponent(encodeURIComponent(this.split('=')[1]));if(!key)return;if($numbers){if(/^[+-]?[0-9]+\.[0-9]*$/.test(val))val=parseFloat(val);else if(/^[+-]?[0-9]+$/.test(val))val=parseInt(val,10)}val=(!val&&val!==0)?true:val;if(val!==false&&val!==true&&typeof val!='number')val=val;self.SET(key,val)})})}return self};queryObject.prototype={queryObject:true,has:function(key,type){var value=this.get(key);return is(value,type)},GET:function(key){if(!is(key))return this.keys;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];while(target!=null&&tokens.length!=0){target=target[tokens.shift()]}return typeof target=='number'?target:target||""},get:function(key){var target=this.GET(key);if(is(target,Object))return jQuery.extend(true,{},target);else if(is(target,Array))return target.slice(0);return target},SET:function(key,val){var value=!is(val)?null:val;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];this.keys[base]=set(target,tokens.slice(0),value);return this},set:function(key,val){return this.copy().SET(key,val)},REMOVE:function(key){return this.SET(key,null).COMPACT()},remove:function(key){return this.copy().REMOVE(key)},EMPTY:function(){var self=this;jQuery.each(self.keys,function(key,value){delete self.keys[key]});return self},load:function(url){var hash=url.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1");var search=url.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new queryObject(url.length==search.length?'':search,url.length==hash.length?'':hash)},empty:function(){return this.copy().EMPTY()},copy:function(){return new queryObject(this)},COMPACT:function(){function build(orig){var obj=typeof orig=="object"?is(orig,Array)?[]:{}:orig;if(typeof orig=='object'){function add(o,key,value){if(is(o,Array))o.push(value);else o[key]=value}jQuery.each(orig,function(key,value){if(!is(value))return true;add(obj,key,build(value))})}return obj}this.keys=build(this.keys);return this},compact:function(){return this.copy().COMPACT()},toString:function(){var i=0,queryString=[],chunks=[],self=this;var addFields=function(arr,key,value){if(!is(value)||value===false)return;var o=[encodeURIComponent(key)];if(value!==true){o.push("=");o.push(encodeURIComponent(value))}arr.push(o.join(""))};var build=function(obj,base){var newKey=function(key){return!base||base==""?[key].join(""):[base,"[",key,"]"].join("")};jQuery.each(obj,function(key,value){if(typeof value=='object')build(value,newKey(key));else addFields(chunks,newKey(key),value)})};build(this.keys);if(chunks.length>0)queryString.push($hash);queryString.push(chunks.join($separator));return queryString.join("")}};return new queryObject(location.search,location.hash)}}(jQuery.query||{});
  5. /*cookie*/
  6. eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('n.5=v(a,b,c){4(7 b!=\'w\'){c=c||{};4(b===o){b=\'\';c.3=-1}2 d=\'\';4(c.3&&(7 c.3==\'p\'||c.3.q)){2 e;4(7 c.3==\'p\'){e=x y();e.z(e.A()+(c.3*B*r*r*C))}s{e=c.3}d=\';3=\'+e.q()}2 f=c.8?\';8=\'+(c.8):\'\';2 g=c.9?\';9=\'+(c.9):\'\';2 h=c.t?\';t\':\'\';6.5=[a,\'=\',D(b),d,f,g,h].E(\'\')}s{2 j=o;4(6.5&&6.5!=\'\'){2 k=6.5.F(\';\');G(2 i=0;i<k.m;i++){2 l=n.H(k[i]);4(l.u(0,a.m+1)==(a+\'=\')){j=I(l.u(a.m+1));J}}}K j}};',47,47,'||var|expires|if|cookie|document|typeof|path|domain|||||||||||||length|jQuery|null|number|toUTCString|60|else|secure|substring|function|undefined|new|Date|setTime|getTime|24|1000|encodeURIComponent|join|split|for|trim|decodeURIComponent|break|return'.split('|'),0,{}))
  7. /*utility by springChun*/
  8. Function.prototype.overwrite=function(f){
  9. var result=f;
  10. if(!result.original){
  11. result.original=this;}
  12. return result;}
  13. Date.prototype.toString=Date.prototype.toString.overwrite(
  14. function(format){
  15. var result=new String();
  16. if(typeof(format)=="string"){
  17. result=format;
  18. result=result.replace(/yyyy|YYYY/,this.getFullYear());
  19. result=result.replace(/yy|YY/,this.getFullYear().toString().substr(2,2));
  20. result=result.replace(/MM/,this.getMonth()>=9?this.getMonth()+1:"0"+(this.getMonth()+1));
  21. result=result.replace(/M/,this.getMonth());
  22. result=result.replace(/dd|DD/,this.getDate()>9?this.getDate():"0"+this.getDate());
  23. result=result.replace(/d|D/,this.getDate());
  24. result=result.replace(/hh|HH/,this.getHours()>9?this.getHours():"0"+this.getHours());
  25. result=result.replace(/h|H/,this.getHours());
  26. result=result.replace(/mm/,this.getMinutes()>9?this.getMinutes():"0"+this.getMinutes());
  27. result=result.replace(/m/,this.getMinutes());
  28. result=result.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds():"0"+this.getSeconds());
  29. result=result.replace(/s|S/,this.getSeconds());}
  30. return result;});
  31. String.prototype.format=function(){
  32. var result=this;
  33. if(arguments.length>0){
  34. parameters=$.makeArray(arguments);
  35. $.each(
  36. parameters,
  37. function(i,n){
  38. result=result.replace(new RegExp("\\{"+i+"\\}","g"),n);});}
  39. return result;}
  40. function StringBuilder(){
  41. this.strings=new Array();
  42. this.length=0;}
  43. StringBuilder.prototype.append=function(string){
  44. this.strings.push(string);
  45. this.length+=string.length;}
  46. StringBuilder.prototype.toString=function(start,length){
  47. return this.strings.join("").substr(start,length);}
  48. /*login*/
  49. $.login=function(options){options=$.extend({loginService:"http://passport.360buy.com/loginservice.aspx?callback=?",loginMethod:"Login",loginUrl:"https://passport.360buy.com/new/login.aspx",returnUrl:location.href,automatic:true,complete:null},options||{});if(options.loginService!=""&&options.loginMethod!=""){$.getJSON(options.loginService,{method:options.loginMethod},function(result){if(result!=null){if(options.complete!=null){options.complete(result.Identity)}if(!result.Identity.IsAuthenticated&&options.automatic&&options.loginUrl!=""){location.href=options.loginUrl+"?ReturnUrl="+escape(options.returnUrl)}}})}};
  50. /*jmsajax*/
  51. (function($){$.jmsajax=function(options){var defaults={type:"POST",dataType:"msjson",data:{},beforeSend:function(xhr){xhr.setRequestHeader("Content-type","application/json; charset=utf-8");},contentType:"application/json; charset=utf-8",error:function(x,s,m){alert("Status: "+((x.statusText)?x.statusText:"Unknown")+"\nMessage: "+msJSON.parse(((x.responseText)?x.responseText:"Unknown")).Message);}};var options=$.extend(defaults,options);if(options.method)
  52. options.url+="/"+options.method;if(options.data){if(options.type=="GET"){var data="";for(var i in options.data){if(data!="")
  53. data+="&";data+=i+"="+msJSON.stringify(options.data[i]);}
  54. options.url+="?"+data;data=null;options.data="{}";}
  55. else if(options.type=="POST"){options.data=msJSON.stringify(options.data);}}
  56. if(options.success){if(options.dataType){if(options.dataType=="msjson"){var base=options.success;options.success=function(response,status){var y=dateparse(response);if(options.version){if(options.version>=3.5)
  57. y=y.d;}
  58. else{if(response.indexOf("{\"d\":")==0)
  59. y=y.d;}
  60. base(y,status);}}}}
  61. return $.ajax(options);};dateparse=function(data){try{return msJSON.parse(data,function(key,value){var a;if(typeof value==="string"){if(value.indexOf("Date")>=0){a=/^\/Date\(([0-9]+)\)\/$/.exec(value);if(a){return new Date(parseInt(a[1],10));}}}
  62. return value;});}
  63. catch(e){return null;}}
  64. msJSON=function(){function f(n){return n<10?'0'+n:n;}
  65. var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapeable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapeable.lastIndex=0;return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
  66. return'\\u'+('0000'+(+(a.charCodeAt(0))).toString(16)).slice(-4);})+'"':'"'+string+'"';}
  67. function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
  68. if(typeof rep==='function'){value=rep.call(holder,key,value);}
  69. switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
  70. if(value.toUTCString){return '"\\/Date('+(value.getTime())+')\\/"';}
  71. gap+=indent;partial=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
  72. v=partial.length===0?'[]':gap?'[\n'+gap+
  73. partial.join(',\n'+gap)+'\n'+
  74. mind+']':'['+partial.join(',')+']';gap=mind;return v;}
  75. if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value,rep);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value,rep);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
  76. v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
  77. mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
  78. return{stringify:function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
  79. rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
  80. return str('',{'':value});},parse:function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
  81. return reviver.call(holder,key,value);}
  82. cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+(+(a.charCodeAt(0))).toString(16)).slice(-4);});}
  83. if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
  84. throw new SyntaxError('JSON.parse');}};}();})(jQuery);
  85. /*trimpath*/
  86. var TrimPath;(function(){
  87. if(TrimPath==null)
  88. TrimPath=new Object();
  89. if(TrimPath.evalEx==null)
  90. TrimPath.evalEx=function(src){return eval(src);};
  91. var UNDEFINED;
  92. if(Array.prototype.pop==null)
  93. Array.prototype.pop=function(){
  94. if(this.length===0){return UNDEFINED;}
  95. return this[--this.length];};
  96. if(Array.prototype.push==null)
  97. Array.prototype.push=function(){
  98. for(var i=0;i<arguments.length;++i){this[this.length]=arguments[i];}
  99. return this.length;};
  100. TrimPath.parseTemplate=function(tmplContent,optTmplName,optEtc){
  101. if(optEtc==null)
  102. optEtc=TrimPath.parseTemplate_etc;
  103. var funcSrc=parse(tmplContent,optTmplName,optEtc);
  104. var func=TrimPath.evalEx(funcSrc,optTmplName,1);
  105. if(func!=null)
  106. return new optEtc.Template(optTmplName,tmplContent,funcSrc,func,optEtc);
  107. return null;}
  108. try{
  109. String.prototype.process=function(context,optFlags){
  110. var template=TrimPath.parseTemplate(this,null);
  111. if(template!=null)
  112. return template.process(context,optFlags);
  113. return this;}}catch(e){}
  114. TrimPath.parseTemplate_etc={};
  115. TrimPath.parseTemplate_etc.statementTag="forelse|for|if|elseif|else|var|macro";
  116. TrimPath.parseTemplate_etc.statementDef={
  117. "if":{delta:1,prefix:"if (",suffix:") {",paramMin:1},
  118. "else":{delta:0,prefix:"} else {"},
  119. "elseif":{delta:0,prefix:"} else if (",suffix:") {",paramDefault:"true"},
  120. "/if":{delta:-1,prefix:"}"},
  121. "for":{delta:1,paramMin:3,
  122. prefixFunc:function(stmtParts,state,tmplName,etc){
  123. if(stmtParts[2]!="in")
  124. throw new etc.ParseError(tmplName,state.line,"bad for loop statement: "+stmtParts.join(' '));
  125. var iterVar=stmtParts[1];
  126. var listVar="__LIST__"+iterVar;
  127. return["var ",listVar," = ",stmtParts[3],";",
  128. "var __LENGTH_STACK__;",
  129. "if (typeof(__LENGTH_STACK__) == 'undefined' || !__LENGTH_STACK__.length) __LENGTH_STACK__ = new Array();",
  130. "__LENGTH_STACK__[__LENGTH_STACK__.length] = 0;",
  131. "if ((",listVar,") != null) { ",
  132. "var ",iterVar,"_ct = 0;",
  133. "for (var ",iterVar,"_index in ",listVar,") { ",
  134. iterVar,"_ct++;",
  135. "if (typeof(",listVar,"[",iterVar,"_index]) == 'function') {continue;}",
  136. "__LENGTH_STACK__[__LENGTH_STACK__.length - 1]++;",
  137. "var ",iterVar," = ",listVar,"[",iterVar,"_index];"].join("");}},
  138. "forelse":{delta:0,prefix:"} } if (__LENGTH_STACK__[__LENGTH_STACK__.length - 1] == 0) { if (",suffix:") {",paramDefault:"true"},
  139. "/for":{delta:-1,prefix:"} }; delete __LENGTH_STACK__[__LENGTH_STACK__.length - 1];"},
  140. "var":{delta:0,prefix:"var ",suffix:";"},
  141. "macro":{delta:1,
  142. prefixFunc:function(stmtParts,state,tmplName,etc){
  143. var macroName=stmtParts[1].split('(')[0];
  144. return["var ",macroName," = function",
  145. stmtParts.slice(1).join(' ').substring(macroName.length),
  146. "{ var _OUT_arr = []; var _OUT = { write: function(m) { if (m) _OUT_arr.push(m); } }; "].join('');}},
  147. "/macro":{delta:-1,prefix:" return _OUT_arr.join(''); };"}}
  148. TrimPath.parseTemplate_etc.modifierDef={
  149. "eat":function(v){return "";},
  150. "escape":function(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");},
  151. "capitalize":function(s){return String(s).toUpperCase();},
  152. "default":function(s,d){return s!=null?s:d;}}
  153. TrimPath.parseTemplate_etc.modifierDef.h=TrimPath.parseTemplate_etc.modifierDef.escape;
  154. TrimPath.parseTemplate_etc.Template=function(tmplName,tmplContent,funcSrc,func,etc){
  155. this.process=function(context,flags){
  156. if(context==null)
  157. context={};
  158. if(context._MODIFIERS==null)
  159. context._MODIFIERS={};
  160. if(context.defined==null)
  161. context.defined=function(str){return(context[str]!=undefined);};
  162. for(var k in etc.modifierDef){
  163. if(context._MODIFIERS[k]==null)
  164. context._MODIFIERS[k]=etc.modifierDef[k];}
  165. if(flags==null)
  166. flags={};
  167. var resultArr=[];
  168. var resultOut={write:function(m){resultArr.push(m);}};
  169. try{
  170. func(resultOut,context,flags);}catch(e){
  171. if(flags.throwExceptions==true)
  172. throw e;
  173. var result=new String(resultArr.join("")+"[ERROR: "+e.toString()+(e.message?'; '+e.message:'')+"]");
  174. result["exception"]=e;
  175. return result;}
  176. return resultArr.join("");}
  177. this.name=tmplName;
  178. this.source=tmplContent;
  179. this.sourceFunc=funcSrc;
  180. this.toString=function(){return "TrimPath.Template ["+tmplName+"]";}}
  181. TrimPath.parseTemplate_etc.ParseError=function(name,line,message){
  182. this.name=name;
  183. this.line=line;
  184. this.message=message;}
  185. TrimPath.parseTemplate_etc.ParseError.prototype.toString=function(){
  186. return("TrimPath template ParseError in "+this.name+": line "+this.line+", "+this.message);}
  187. var parse=function(body,tmplName,etc){
  188. body=cleanWhiteSpace(body);
  189. var funcText=["var TrimPath_Template_TEMP = function(_OUT, _CONTEXT, _FLAGS) { with (_CONTEXT) {"];
  190. var state={stack:[],line:1};
  191. var endStmtPrev=-1;
  192. while(endStmtPrev+1<body.length){
  193. var begStmt=endStmtPrev;
  194. begStmt=body.indexOf("{",begStmt+1);
  195. while(begStmt>=0){
  196. var endStmt=body.indexOf('}',begStmt+1);
  197. var stmt=body.substring(begStmt,endStmt);
  198. var blockrx=stmt.match(/^\{(cdata|minify|eval)/);
  199. if(blockrx){
  200. var blockType=blockrx[1];
  201. var blockMarkerBeg=begStmt+blockType.length+1;
  202. var blockMarkerEnd=body.indexOf('}',blockMarkerBeg);
  203. if(blockMarkerEnd>=0){
  204. var blockMarker;
  205. if(blockMarkerEnd-blockMarkerBeg<=0){
  206. blockMarker="{/"+blockType+"}";}else{
  207. blockMarker=body.substring(blockMarkerBeg+1,blockMarkerEnd);}
  208. var blockEnd=body.indexOf(blockMarker,blockMarkerEnd+1);
  209. if(blockEnd>=0){
  210. emitSectionText(body.substring(endStmtPrev+1,begStmt),funcText);
  211. var blockText=body.substring(blockMarkerEnd+1,blockEnd);
  212. if(blockType=='cdata'){
  213. emitText(blockText,funcText);}else if(blockType=='minify'){
  214. emitText(scrubWhiteSpace(blockText),funcText);}else if(blockType=='eval'){
  215. if(blockText!=null&&blockText.length>0)
  216. funcText.push('_OUT.write( (function() { '+blockText+' })() );');}
  217. begStmt=endStmtPrev=blockEnd+blockMarker.length-1;}}}else if(body.charAt(begStmt-1)!='$'&&
  218. body.charAt(begStmt-1)!='\\'){
  219. var offset=(body.charAt(begStmt+1)=='/'?2:1);
  220. if(body.substring(begStmt+offset,begStmt+10+offset).search(TrimPath.parseTemplate_etc.statementTag)==0)
  221. break;}
  222. begStmt=body.indexOf("{",begStmt+1);}
  223. if(begStmt<0)
  224. break;
  225. var endStmt=body.indexOf("}",begStmt+1);
  226. if(endStmt<0)
  227. break;
  228. emitSectionText(body.substring(endStmtPrev+1,begStmt),funcText);
  229. emitStatement(body.substring(begStmt,endStmt+1),state,funcText,tmplName,etc);
  230. endStmtPrev=endStmt;}
  231. emitSectionText(body.substring(endStmtPrev+1),funcText);
  232. if(state.stack.length!=0)
  233. throw new etc.ParseError(tmplName,state.line,"unclosed, unmatched statement(s): "+state.stack.join(","));
  234. funcText.push("}}; TrimPath_Template_TEMP");
  235. return funcText.join("");}
  236. var emitStatement=function(stmtStr,state,funcText,tmplName,etc){
  237. var parts=stmtStr.slice(1,-1).split(' ');
  238. var stmt=etc.statementDef[parts[0]];
  239. if(stmt==null){
  240. emitSectionText(stmtStr,funcText);
  241. return;}
  242. if(stmt.delta<0){
  243. if(state.stack.length<=0)
  244. throw new etc.ParseError(tmplName,state.line,"close tag does not match any previous statement: "+stmtStr);
  245. state.stack.pop();}
  246. if(stmt.delta>0)
  247. state.stack.push(stmtStr);
  248. if(stmt.paramMin!=null&&
  249. stmt.paramMin>=parts.length)
  250. throw new etc.ParseError(tmplName,state.line,"statement needs more parameters: "+stmtStr);
  251. if(stmt.prefixFunc!=null)
  252. funcText.push(stmt.prefixFunc(parts,state,tmplName,etc));
  253. else
  254. funcText.push(stmt.prefix);
  255. if(stmt.suffix!=null){
  256. if(parts.length<=1){
  257. if(stmt.paramDefault!=null)
  258. funcText.push(stmt.paramDefault);}else{
  259. for(var i=1;i<parts.length;i++){
  260. if(i>1)
  261. funcText.push(' ');
  262. funcText.push(parts[i]);}}
  263. funcText.push(stmt.suffix);}}
  264. var emitSectionText=function(text,funcText){
  265. if(text.length<=0)
  266. return;
  267. var nlPrefix=0;
  268. var nlSuffix=text.length-1;
  269. while(nlPrefix<text.length&&(text.charAt(nlPrefix)=='\n'))
  270. nlPrefix++;
  271. while(nlSuffix>=0&&(text.charAt(nlSuffix)==' '||text.charAt(nlSuffix)=='\t'))
  272. nlSuffix--;
  273. if(nlSuffix<nlPrefix)
  274. nlSuffix=nlPrefix;
  275. if(nlPrefix>0){
  276. funcText.push('if (_FLAGS.keepWhitespace == true) _OUT.write("');
  277. var s=text.substring(0,nlPrefix).replace('\n','\\n');
  278. if(s.charAt(s.length-1)=='\n')
  279. s=s.substring(0,s.length-1);
  280. funcText.push(s);
  281. funcText.push('");');}
  282. var lines=text.substring(nlPrefix,nlSuffix+1).split('\n');
  283. for(var i=0;i<lines.length;i++){
  284. emitSectionTextLine(lines[i],funcText);
  285. if(i<lines.length-1)
  286. funcText.push('_OUT.write("\\n");\n');}
  287. if(nlSuffix+1<text.length){
  288. funcText.push('if (_FLAGS.keepWhitespace == true) _OUT.write("');
  289. var s=text.substring(nlSuffix+1).replace('\n','\\n');
  290. if(s.charAt(s.length-1)=='\n')
  291. s=s.substring(0,s.length-1);
  292. funcText.push(s);
  293. funcText.push('");');}}
  294. var emitSectionTextLine=function(line,funcText){
  295. var endMarkPrev='}';
  296. var endExprPrev=-1;
  297. while(endExprPrev+endMarkPrev.length<line.length){
  298. var begMark="${",endMark="}";
  299. var begExpr=line.indexOf(begMark,endExprPrev+endMarkPrev.length);
  300. if(begExpr<0)
  301. break;
  302. if(line.charAt(begExpr+2)=='%'){
  303. begMark="${%";
  304. endMark="%}";}
  305. var endExpr=line.indexOf(endMark,begExpr+begMark.length);
  306. if(endExpr<0)
  307. break;
  308. emitText(line.substring(endExprPrev+endMarkPrev.length,begExpr),funcText);
  309. var exprArr=line.substring(begExpr+begMark.length,endExpr).replace(/\|\|/g,"#@@#").split('|');
  310. for(var k in exprArr){
  311. if(exprArr[k].replace)
  312. exprArr[k]=exprArr[k].replace(/#@@#/g,'||');}
  313. funcText.push('_OUT.write(');
  314. emitExpression(exprArr,exprArr.length-1,funcText);
  315. funcText.push(');');
  316. endExprPrev=endExpr;
  317. endMarkPrev=endMark;}
  318. emitText(line.substring(endExprPrev+endMarkPrev.length),funcText);}
  319. var emitText=function(text,funcText){
  320. if(text==null||
  321. text.length<=0)
  322. return;
  323. text=text.replace(/\\/g,'\\\\');
  324. text=text.replace(/\n/g,'\\n');
  325. text=text.replace(/"/g,'\\"');
  326. funcText.push('_OUT.write("');
  327. funcText.push(text);
  328. funcText.push('");');}
  329. var emitExpression=function(exprArr,index,funcText){
  330. var expr=exprArr[index];
  331. if(index<=0){
  332. funcText.push(expr);
  333. return;}
  334. var parts=expr.split(':');
  335. funcText.push('_MODIFIERS["');
  336. funcText.push(parts[0]);
  337. funcText.push('"](');
  338. emitExpression(exprArr,index-1,funcText);
  339. if(parts.length>1){
  340. funcText.push(',');
  341. funcText.push(parts[1]);}
  342. funcText.push(')');}
  343. var cleanWhiteSpace=function(result){
  344. result=result.replace(/\t/g," ");
  345. result=result.replace(/\r\n/g,"\n");
  346. result=result.replace(/\r/g,"\n");
  347. result=result.replace(/^(\s*\S*(\s+\S+)*)\s*$/,'$1');
  348. return result;}
  349. var scrubWhiteSpace=function(result){
  350. result=result.replace(/^\s+/g,"");
  351. result=result.replace(/\s+$/g,"");
  352. result=result.replace(/\s+/g," ");
  353. result=result.replace(/^(\s*\S*(\s+\S+)*)\s*$/,'$1');
  354. return result;}
  355. TrimPath.parseDOMTemplate=function(elementId,optDocument,optEtc){
  356. if(optDocument==null)
  357. optDocument=document;
  358. var element=optDocument.getElementById(elementId);
  359. var content=element.value;
  360. if(content==null)
  361. content=element.innerHTML;
  362. content=content.replace(/&lt;/g,"<").replace(/&gt;/g,">");
  363. return TrimPath.parseTemplate(content,elementId,optEtc);}
  364. TrimPath.processDOMTemplate=function(elementId,context,optFlags,optDocument,optEtc){
  365. return TrimPath.parseDOMTemplate(elementId,optDocument,optEtc).process(context,optFlags);}})();
  366. /*pagination*/
  367. jQuery.fn.pagination=function(maxentries,opts){
  368. opts=jQuery.extend({
  369. items_per_page:10,
  370. num_display_entries:10,
  371. current_page:0,
  372. num_edge_entries:0,
  373. link_to:"#",
  374. prev_text:"Prev",
  375. next_text:"Next",
  376. ellipse_text:"...",
  377. prev_show_always:true,
  378. next_show_always:true,
  379. callback:function(){return false;}},opts||{});
  380. return this.each(function(){
  381. function numPages(){
  382. return Math.ceil(maxentries/opts.items_per_page);}
  383. function getInterval(){
  384. var ne_half=Math.ceil(opts.num_display_entries/2);
  385. var np=numPages();
  386. var upper_limit=np-opts.num_display_entries;
  387. var start=current_page>ne_half?Math.max(Math.min(current_page-ne_half,upper_limit),0):0;
  388. var end=current_page>ne_half?Math.min(current_page+ne_half,np):Math.min(opts.num_display_entries,np);
  389. return[start,end];}
  390. function pageSelected(page_id,evt){
  391. current_page=page_id;
  392. drawLinks();
  393. var continuePropagation=opts.callback(page_id,panel);
  394. if(!continuePropagation){
  395. if(evt.stopPropagation){
  396. evt.stopPropagation();}
  397. else{
  398. evt.cancelBubble=true;}}
  399. return continuePropagation;}
  400. function drawLinks(){
  401. panel.empty();
  402. var interval=getInterval();
  403. var np=numPages();
  404. if(np==1){
  405. $(".Pagination").css({display:"none"});}
  406. var getClickHandler=function(page_id){
  407. return function(evt){return pageSelected(page_id,evt);}}
  408. var appendItem=function(page_id,appendopts){
  409. page_id=page_id<0?0:(page_id<np?page_id:np-1);
  410. appendopts=jQuery.extend({text:page_id+1,classes:""},appendopts||{});
  411. if(page_id==current_page){
  412. var lnk=$("<a href='javascript:void(0)' class='current'>"+(appendopts.text)+"</a>");}
  413. else{
  414. var lnk=$("<a>"+(appendopts.text)+"</a>")
  415. .bind("click",getClickHandler(page_id))
  416. .attr('href',opts.link_to.replace(/__id__/,page_id));}
  417. if(appendopts.classes){lnk.addClass(appendopts.classes);}
  418. panel.append(lnk);}
  419. if(opts.prev_text&&(current_page>0||opts.prev_show_always)){
  420. appendItem(current_page-1,{text:opts.prev_text,classes:"prev"});}
  421. if(interval[0]>0&&opts.num_edge_entries>0){
  422. var end=Math.min(opts.num_edge_entries,interval[0]);
  423. for(var i=0;i<end;i++){
  424. appendItem(i);}
  425. if(opts.num_edge_entries<interval[0]&&opts.ellipse_text){
  426. jQuery("<span>"+opts.ellipse_text+"</span>").appendTo(panel);}}
  427. for(var i=interval[0];i<interval[1];i++){
  428. appendItem(i);}
  429. if(interval[1]<np&&opts.num_edge_entries>0){
  430. if(np-opts.num_edge_entries>interval[1]&&opts.ellipse_text){
  431. jQuery("<span>"+opts.ellipse_text+"</span>").appendTo(panel);}
  432. var begin=Math.max(np-opts.num_edge_entries,interval[1]);
  433. for(var i=begin;i<np;i++){
  434. appendItem(i);}}
  435. if(opts.next_text&&(current_page<np-1||opts.next_show_always)){
  436. appendItem(current_page+1,{text:opts.next_text,classes:"next"});}}
  437. var current_page=opts.current_page;
  438. maxentries=(!maxentries||maxentries<0)?1:maxentries;
  439. opts.items_per_page=(!opts.items_per_page||opts.items_per_page<0)?1:opts.items_per_page;
  440. var panel=jQuery(this);
  441. this.selectPage=function(page_id){pageSelected(page_id);}
  442. this.prevPage=function(){
  443. if(current_page>0){
  444. pageSelected(current_page-1);
  445. return true;}
  446. else{
  447. return false;}}
  448. this.nextPage=function(){
  449. if(current_page<numPages()-1){
  450. pageSelected(current_page+1);
  451. return true;}
  452. else{
  453. return false;}}
  454. drawLinks();});};
  455. /*getSortData*/
  456. (function(){$.getJSONP("http://www.360buy.com/lishi.aspx?callback=getBrandService&id=a,915,925^b,916,926^c,917,927^d,918,928^e,919,929^f,920,930^g,921,931^h,922,932^i,923,933^j,924,934",getBrandService);})();function getBrandService(json){var data=json.data;$.each(data,function(i){var html="<dl class=\"brands\"><dt>推荐品牌</dt><dd>";var d1=data[i]["b"],d2=data[i]["p"];if (d1.length>0){$.each(d1,function(j){html+="<em><a href=\""+ d1[j]["u"] +"\">"+ d1[j]["n"] +"</a></em>";});}else{html+="<div class='norecode'>暂无推荐品牌!</div>";}html+="</dd></dl><dl class=\"promotion\"><dt>促销活动</dt><dd><ul>";if (d2.length>0){$.each(d2,function(k){html+="<li>·<a href=\""+ d2[k]["u"] +"\">"+ d2[k]["n"] +"</a></li>";});}else{html+="<div class='norecode'>暂无促销活动!</div>";}html+="</ul></dd></dl>";$("#JD_sort_"+data[i]["id"]).html(html);});}
  457. /*jdThickbox*/
  458. (function($){$.fn.jdPosition=function(option){var s=$.extend({mode:null},option||{});switch(s.mode){default:case "center":var ow=$(this).outerWidth(),oh=$(this).outerHeight();var w=$.browser.isMinW(ow),h=$.browser.isMinH(oh);$(this).css({left:(!$.browser.isIE6)?(w?0:Math.max(($.browser.client().width-ow)/2,0)+"px"):(w?0:Math.max($.browser.scroll().left+($.browser.client().width-ow)/2,0)+"px"),top:(!$.browser.isIE6)?(h?0:Math.max(($.browser.client().height-oh)/2,0)+"px"):(($.browser.scroll().top<=$.browser.client().bodyHeight-oh)?(Math.max($.browser.scroll().top+($.browser.client().height-oh)/2,0)+"px"):($.browser.client().bodyHeight-oh)+"px")});break;case "auto":break;case "fixed":break;}}})(jQuery);(function($){$.fn.jdThickBox=function(option,callback){if(typeof option=="function"){callback=option;option={};};var s=$.extend({type:"text",source:null,width:null,height:null,title:null,_frame:"",_div:"",_box:"",_con:"",_loading:"thickloading",close:false,_close:"",_fastClose:false,_close_val:"×",_titleOn:true,_title:"",_autoReposi:false},option||{});var object=(typeof this !="function")?$(this):null;var close=function(){$(".thickframe").add(".thickdiv").hide();$(".thickbox").empty().remove();if(s._autoReposi){$(window).unbind("resize.jdThickBox").unbind("scroll.jdThickBox");};};if(s.close){close();return false;};var reg=function(str){if(str!=""){return str.match(/\w+/);}else{return "";};};var init=function(element){if($(".thickframe").length==0||$(".thickdiv").length==0){$("<iframe class='thickframe' id='"+reg(s._frame)+"' marginwidth='0' marginheight='0' frameborder='0' scrolling='no'></iframe>").appendTo($(document.body));$("<div class='thickdiv' id='"+reg(s._div)+"'></div>").appendTo($(document.body));}else{$(".thickframe").add(".thickdiv").show();};$("<div class='thickbox' id='"+reg(s._box)+"'></div>").appendTo($(document.body));if(s._titleOn)initTitle(element);$("<div class='thickcon' id='"+reg(s._con)+"' style='width:"+s.width+"px;height:"+s.height+"px;'></div>").appendTo($(".thickbox"));$(".thickcon").addClass(s._loading);reposi();initClose();inputData(element);if(s._autoReposi){$(window).bind("resize.jdThickBox",reposi).bind("scroll.jdThickBox",reposi);};if(s._fastClose){$(document.body).bind("click.jdThickBox",function(e){e=e?e:window.event;var tag=e.srcElement?e.srcElement:e.target;if(tag.className=="thickdiv"){$(this).unbind("click.jdThickBox");close();}})}};var initTitle=function(element){s.title=(s.title==null&&element)?element.attr("title"):s.title;$("<div class='thicktitle' id='"+reg(s._title)+"' style='width:"+s.width+"'><span>"+s.title+"</span></div>").appendTo($(".thickbox"));s.title=null;};var initClose=function(){if(s._close!=null){$("<a href='#' class='thickclose' id='"+reg(s._close)+"'>"+s._close_val+"</a>").appendTo($(".thickbox"));$(".thickclose").one("click",function(){close();return false;});}};var inputData=function(element){s.source=(s.source==null)?element.attr("href"):s.source;switch(s.type){default:case "text":$(".thickcon").html(s.source);$(".thickcon").removeClass(s._loading);break;case "html":$(s.source).clone().appendTo($(".thickcon")).show();$(".thickcon").removeClass(s._loading);break;case "image":s._index=(s._index==null)?object.index(element):s._index;$(".thickcon").append("<img src='"+s.source+"' width='"+s.width+"' height='"+s.height+"'>");s.source=null;$(".thickcon").removeClass(s._loading);break;case "ajax":case "json":if(callback){callback(s.source,$(".thickcon"),function(){$(".thickcon").removeClass(s._loading);});};break;case "iframe":$("<iframe src='"+s.source+"' marginwidth='0' marginheight='0' frameborder='0' scrolling='no' style='width:"+s.width+"px;height:"+s.height+"px;border:0;'></iframe>").appendTo($(".thickcon"));$(".thickcon").removeClass(s._loading);break;};};var reposi=function(){var w1=$(".thickcon").outerWidth(),h1=(s._titleOn?$(".thicktitle").outerHeight():0)+$(".thickcon").outerHeight();$(".thickbox").css({width:w1+"px",height:h1+"px"});$(".thickbox").jdPosition({mode:"center"});if($.browser.isIE6){var ow=$(".thickbox").outerWidth(),oh=$(".thickbox").outerHeight();var w2=$.browser.isMinW(ow),h2=$.browser.isMinH(oh);$(".thickframe").add(".thickdiv").css({width:w2?ow:"100%",height:Math.max($.browser.client().height,$.browser.client().bodyHeight)+"px"});}};if(object!=null){object.click(function(){init($(this));return false;});}else{init();}};$.jdThickBox=$.fn.jdThickBox;})(jQuery);function jdThickBoxclose(){$.jdThickBox({close:true});};
  459. /*jdMarquee*/
  460. (function($){$.fn.jdMarquee=function(option,callback){if(typeof option=="function"){callback=option;option={};};var s=$.extend({deriction:"up",speed:10,auto:false,width:null,height:null,step:1,control:false,_front:null,_back:null,_stop:null,_continue:null,wrapstyle:"",stay:5000,delay:20,dom:"div>ul>li".split(">"),mainTimer:null,subTimer:null,tag:false,convert:false,btn:null,disabled:"disabled",pos:{ojbect:null,clone:null}},option||{});var object=this.find(s.dom[1]);var subObject=this.find(s.dom[2]);var clone;if(s.deriction=="up"||s.deriction=="down"){var height=object.eq(0).outerHeight();var step=s.step*subObject.eq(0).outerHeight();object.css({width:s.width+"px",overflow:"hidden"});};if(s.deriction=="left"||s.deriction=="right"){var width=subObject.length*subObject.eq(0).outerWidth();object.css({width:width+"px",overflow:"hidden"});var step=s.step*subObject.eq(0).outerWidth();};var init=function(){var wrap="<div style='position:relative;overflow:hidden;z-index:1;width:"+s.width+"px;height:"+s.height+"px;"+s.wrapstyle+"'></div>";object.css({position:"absolute",left:0,top:0}).wrap(wrap);s.pos.object=0;clone=object.clone();object.after(clone);switch(s.deriction){default:case "up":object.css({marginLeft:0,marginTop:0});clone.css({marginLeft:0,marginTop:height+"px"});s.pos.clone=height;break;case "down":object.css({marginLeft:0,marginTop:0});clone.css({marginLeft:0,marginTop:-height+"px"});s.pos.clone=-height;break;case "left":object.css({marginTop:0,marginLeft:0});clone.css({marginTop:0,marginLeft:width+"px"});s.pos.clone=width;break;case "right":object.css({marginTop:0,marginLeft:0});clone.css({marginTop:0,marginLeft:-width+"px"});s.pos.clone=-width;break;};if(s.auto){initMainTimer();object.hover(function(){clear(s.mainTimer);},function(){initMainTimer();});clone.hover(function(){clear(s.mainTimer);},function(){initMainTimer();});};if(callback){callback();};if(s.control){initControls();}};var initMainTimer=function(delay){clear(s.mainTimer);s.stay=delay?delay:s.stay;s.mainTimer=setInterval(function(){initSubTimer()},s.stay);};var initSubTimer=function(){clear(s.subTimer);s.subTimer=setInterval(function(){roll()},s.delay);};var clear=function(timer){if(timer!=null){clearInterval(timer);}};var disControl=function(A){if(A){$(s._front).unbind("click");$(s._back).unbind("click");$(s._stop).unbind("click");$(s._continue).unbind("click");}else{initControls();}};var initControls=function(){if(s._front!=null){$(s._front).click(function(){$(s._front).addClass(s.disabled);disControl(true);clear(s.mainTimer);s.convert=true;s.btn="front";if(!s.auto){s.tag=true;};convert();});};if(s._back!=null){$(s._back).click(function(){$(s._back).addClass(s.disabled);disControl(true);clear(s.mainTimer);s.convert=true;s.btn="back";if(!s.auto){s.tag=true;};convert();});};if(s._stop!=null){$(s._stop).click(function(){clear(s.mainTimer);});};if(s._continue!=null){$(s._continue).click(function(){initMainTimer();});}};var convert=function(){if(s.tag&&s.convert){s.convert=false;if(s.btn=="front"){if(s.deriction=="down"){s.deriction="up";};if(s.deriction=="right"){s.deriction="left";}};if(s.btn=="back"){if(s.deriction=="up"){s.deriction="down";};if(s.deriction=="left"){s.deriction="right";}};if(s.auto){initMainTimer();}else{initMainTimer(4*s.delay);}}};var setPos=function(y1,y2,x){if(x){clear(s.subTimer);s.pos.object=y1;s.pos.clone=y2;s.tag=true;}else{s.tag=false;};if(s.tag){if(s.convert){convert();}else{if(!s.auto){clear(s.mainTimer);}}};if(s.deriction=="up"||s.deriction=="down"){object.css({marginTop:y1+"px"});clone.css({marginTop:y2+"px"});};if(s.deriction=="left"||s.deriction=="right"){object.css({marginLeft:y1+"px"});clone.css({marginLeft:y2+"px"});}};var roll=function(){var y_object=(s.deriction=="up"||s.deriction=="down")?parseInt(object.get(0).style.marginTop):parseInt(object.get(0).style.marginLeft);var y_clone=(s.deriction=="up"||s.deriction=="down")?parseInt(clone.get(0).style.marginTop):parseInt(clone.get(0).style.marginLeft);var y_add=Math.max(Math.abs(y_object-s.pos.object),Math.abs(y_clone-s.pos.clone));var y_ceil=Math.ceil((step-y_add)/s.speed);switch(s.deriction){case "up":if(y_add==step){setPos(y_object,y_clone,true);$(s._front).removeClass(s.disabled);disControl(false);}else{if(y_object<=-height){y_object=y_clone+height;s.pos.object=y_object;};if(y_clone<=-height){y_clone=y_object+height;s.pos.clone=y_clone;};setPos((y_object-y_ceil),(y_clone-y_ceil));};break;case "down":if(y_add==step){setPos(y_object,y_clone,true);$(s._back).removeClass(s.disabled);disControl(false);}else{if(y_object>=height){y_object=y_clone-height;s.pos.object=y_object;};if(y_clone>=height){y_clone=y_object-height;s.pos.clone=y_clone;};setPos((y_object+y_ceil),(y_clone+y_ceil));};break;case "left":if(y_add==step){setPos(y_object,y_clone,true);$(s._front).removeClass(s.disabled);disControl(false);}else{if(y_object<=-width){y_object=y_clone+width;s.pos.object=y_object;};if(y_clone<=-width){y_clone=y_object+width;s.pos.clone=y_clone;};setPos((y_object-y_ceil),(y_clone-y_ceil));};break;case "right":if(y_add==step){setPos(y_object,y_clone,true);$(s._back).removeClass(s.disabled);disControl(false);}else{if(y_object>=width){y_object=y_clone-width;s.pos.object=y_object;};if(y_clone>=width){y_clone=y_object-width;s.pos.clone=y_clone;};setPos((y_object+y_ceil),(y_clone+y_ceil));};break;}};if(s.deriction=="up"||s.deriction=="down"){if(height>=s.height&&height>=s.step){init();}};if(s.deriction=="left"||s.deriction=="right"){if(width>=s.width&&width>=s.step){init();}}}})(jQuery);
  461. /*search_plug*/
  462. var $GLOBAL_VAR={"_text":"","_arr":null,"_count":0,"_num":0,"_select":null,"_out_select":null,"_flag":true};var $callback={"hidden":function(){if($GLOBAL_VAR._flag){$dt._div.style.display="none";}},"input_event":function(event){var _e=event||window.event;if($GLOBAL_VAR._text==$dt._tbox.value||_e.keyCode=="40"||_e.keyCode=="38"){$o.move(_e);}else{$GLOBAL_VAR._count=0;$GLOBAL_VAR._text=$dt._tbox.value;if(_e.keyCode=="13"){$callback.hidden();}else{$util.createElement($o.updatelist);}}}};var Operator=function(){this.updatelist=function(){if(text.length<1){$dt._div.style.display="none";return;}$GLOBAL_VAR._arr=text.split("|");var _t;var _html="";for(var _i=0;_i<$GLOBAL_VAR._arr.length-1;_i++){_t=$GLOBAL_VAR._arr[_i].split(",");_html+=$pro._htmls[0]+_t[0]+$pro._htmls[1]+(_i+1)+$pro._htmls[2]+_t[1]+$pro._htmls[3]+_t[0]+$pro._htmls[4];}_html+=$pro._htmls[5];$dt._div.innerHTML=_html;$dt._div.style.display="block";$dt._div.onmouseover=function(){$GLOBAL_VAR._flag=false;};$dt._div.onmouseout=function(){$GLOBAL_VAR._flag=true;};$GLOBAL_VAR._num=$GLOBAL_VAR._arr.length-1;};this.xg=function(){$GLOBAL_VAR._arr=text.split("|");var _t;var _html="";for(var _i=0;_i<$GLOBAL_VAR._arr.length-1;_i++){if(_i==10){continue;}_t=$GLOBAL_VAR._arr[_i].split(",");if(_t[0].length>10||_t[0]==$dt._tbox.value){continue;}_html+=$pro._xghtmls[0]+_t[0]+$pro._xghtmls[1]+_t[0]+$pro._xghtmls[2];}if(_html.length<1){$util.get("CorrSearch").style.display="none";}return _html;};this.move=function(_e){if(_e.keyCode=="40"){$GLOBAL_VAR._count++;if($GLOBAL_VAR._count>$GLOBAL_VAR._num){$GLOBAL_VAR._count=1;}this.moveDown();}if(_e.keyCode=="38"){$GLOBAL_VAR._count--;if($GLOBAL_VAR._count<1){$GLOBAL_VAR._count=$GLOBAL_VAR._num;}this.moveUp();}};this.moveUp=function(){$GLOBAL_VAR._select=$util.get("d_"+$GLOBAL_VAR._count);if($GLOBAL_VAR._count==$GLOBAL_VAR._num){$GLOBAL_VAR._out_select=$util.get("d_1");}else{$GLOBAL_VAR._out_select=$util.get("d_"+($GLOBAL_VAR._count+1));}$GLOBAL_VAR._out_select.style.backgroundColor="";$GLOBAL_VAR._select.style.backgroundColor="#FFFF99";$dt._tbox.value=$GLOBAL_VAR._arr[$GLOBAL_VAR._count-1].split(",")[0];};this.moveDown=function(){$GLOBAL_VAR._select=$util.get("d_"+$GLOBAL_VAR._count);if($GLOBAL_VAR._count==1){$GLOBAL_VAR._out_select=$util.get("d_"+$GLOBAL_VAR._num);}else{$GLOBAL_VAR._out_select=$util.get("d_"+($GLOBAL_VAR._count-1));}$GLOBAL_VAR._out_select.style.backgroundColor="";$GLOBAL_VAR._select.style.backgroundColor="#FFFF99";$dt._tbox.value=$GLOBAL_VAR._arr[$GLOBAL_VAR._count-1].split(",")[0];};this.selectText=function(_d){$GLOBAL_VAR._flag=true;$dt._tbox.value=_d.title;$callback.hidden();window.location.href="http://search.360buy.com/search?keyword="+_d.title;};this.over=function(_d){_d.style.backgroundColor="#FFFF99";};this.out=function(_d){_d.style.backgroundColor="";};};var MyUtil=function(){this.get=function(_id){return document.getElementById(_id);};this.createElement=function(_callback){if($dt._tbox.value.length<1){$dt._div.style.display="none";return;}var flag=function(){if(_callback==null)return;};var _element=null;var _e=this.get($pro._script_id);if(_e){_e.parentNode.removeChild(_e);}_element=document.createElement("script");_element.id=$pro._script_id;_element.src=$pro._action+($dt._tbox.value);_element.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(_element);if(document.all){_element.onreadystatechange=function(){var state=_element.readyState;if(state=="loaded"||state=="interactive"||state=="complete"){if(_callback==null){return;}_callback();}};}else{flag();_element.onload=_callback;}};};var Properties={"_action":"http://search.360buy.com/ks?keyword=","_input":"key","_div":"tie","_script_id":"_rs","_htmls":new Array("<li onmouseover=\"$o.over(this)\" onclick=\"$o.selectText(this)\" onmouseout=\"$o.out(this)\" title='","' id='d_","'><span>约","条</span><div>","</div></li>",""),"_xghtmls":new Array("<div><a href=\"Search?keyword=","\">","</a></div>")};var Dt=function(t,d){this._div=d;this._tbox=t;};var $util=new MyUtil();var $pro=Properties;var $o=new Operator();var $dt=new Dt($util.get($pro._input),$util.get($pro._div));if(null!==$dt._tbox){$dt._tbox.onkeyup=$callback.input_event;$dt._tbox.onblur=$callback.hidden;}
  463. /* friend */
  464. var jdFriendUrl='http://club.360buy.com/jdFriend/TuiJianService.aspx';function FriendScript(){var param=getparam();if(param!=""){var js=document.createElement('script');js.type='text/javascript';js.src=jdFriendUrl+'?roid='+Math.random()+param;js.charset='GB2312';document.getElementsByTagName('head')[0].appendChild(js)}}window.onload=function(){FriendScript()};function getparam(){var sid="";var type="";var args=new Object();var query=location.search.substring(1);var pairs=query.split("&");for(var i=0;i<pairs.length;i++){var pos=pairs[i].indexOf('=');if(pos==-1)continue;var argname=pairs[i].substring(0,pos);if(pairs[i].substring(0,pos)=="sid"){sid=unescape(pairs[i].substring(pos+1))}if(pairs[i].substring(0,pos)=="t"){type=unescape(pairs[i].substring(pos+1))}}if(sid!=""||type!=""){return"&sid="+escape(sid)+"&t="+escape(type)}else{return""}};
  465. /*jdCalcul*/
  466. (function($){$.jdCalcul=function(pids){var arr=null;var pids=pids.join(",");var dataUrl="http://www.360buy.com/limitBuy.aspx?callback=?&ids="+pids;var purl="http://www.360buy.com/product/";var init=function(data){var s=$.extend({contentid:"#limit",clockid:"#clock",rankid:"#rank",limitid:"#limitbuy"},data||{});if(data=={}||data==""||s.start==null||s.start==""||s.end==null||s.end==""){return;};s.start=format(s.start);s.start=($.browser.mozzia)?Date.parse(s.start):s.start;s.server=format(s.server);s.server=($.browser.mozzia)?Date.parse(s.server):s.server;s.end=format(s.end);s.end=($.browser.mozzia)?Date.parse(s.end):s.end;s.contentid=$(s.contentid+s.qid);s.clockid=$(s.clockid+s.qid);s.rankid=$(s.rankid+s.qid);s.limitid=$(s.limitid+s.qid);var ST=(s.start-s.server)/1000,H,M,S,timer;var ET=(s.end-s.server)/1000;var createHtml=function(){var html="<li><div class=\"p-img\"><a href=\"{6}{0}.html\" target=\"_blank\"><img src=\"{1}\" width=\"100\" height=\"100\" /></a>{2}</div><div class=\"p-name\"><a href=\"{6}{0}.html\" target=\"_blank\">{3}</a></div><div class=\"p-price\">抢购价:<strong>{4}</strong>{5}</div></li>";var html1="<ul>";$.each(s.pros,function(i){var id=s.pros[i].id,tp=s.pros[i].tp,zt=(s.pros[i].zt==1)?"<div class='pi9'></div>":"<div class='pi10'></div>",mc=unescape(s.pros[i].mc),qg=s.pros[i].qg,zk="("+s.pros[i].zk+"折)";html1+=html.replace(/\{0\}/g,id).replace("{1}",tp).replace("{2}",zt).replace("{3}",mc).replace("{4}",qg).replace("{5}",zk).replace(/\{6\}/g,purl);});html1+="</ul>";s.contentid.html(html1);};var run=function(){if(ST>0){return;}else{if(ET>0){H=Math.floor(ET/3600);M=Math.floor((ET-H*3600)/60);S=(ET-H*3600)%60;s.clockid.html("剩余<b>"+H+"</b>小时<b>"+M+"</b>分<b>"+S+"</b>秒");ET--;}else{s.clockid.html("抢购结束");clearInterval(timer);s.limitid.hide();if (s.rankid.length>0){s.rankid.show();}}}};if(ST<=0&&ET>0){createHtml();if (s.rankid.length>0){s.rankid.hide();}s.limitid.show();};run();timer=setInterval(function(){run()},1000);};var format=function(t){var T=t.split(" ");var A=T[0].split("-");var B=T[1].split(":");return new Date(A[0],A[1]-1,A[2],B[0],B[1],B[2]);};$.getJSON(dataUrl,function(json){if(json){arr=json.data;$.each(arr,function(i){init(arr[i]);})}});}})(jQuery);
  467. /* getrecent */
  468. var jdRecent={element:$("#recent ul"),jsurl:"http://www.360buy.com/lishiset.aspx?id=",cookiename:"_recent",list:$.cookie("_recent"),url:location.href,init:function(){var _matchStr=this.url.match(/\/(\d+).html/);var _id=(_matchStr!=null&&_matchStr[0].indexOf("html")!=-1)?_matchStr[1]:"";if(!this.list||this.list==null||this.list==""){if(_id==""){return this.getData(0);}else{this.list=_id;}}else{if(_id==""||this.list.indexOf(_id)!=-1){this.list=this.list;}else{if(this.list.split(".").length>=10){this.list=this.list.replace(/.\d+$/,"");}this.list=_id+"."+this.list;}}$.cookie(this.cookiename,this.list,{expires:7,path:"/",domain:"360buy.com",secure:false});this.getData(this.list);},clear:function(){$.cookie(this.cookiename,"",{expires:7,path:"/",domain:"360buy.com",secure:false});},getData:function(list){if(list==0){this.element.html("<li><div class='norecode'>暂无记录!</div></li>");return;}var rec=list.split(".");for(i in rec){if (i==0){this.element.empty()};$.getJSONP(this.jsurl+rec[i],this.setData);}},setData:function(result){this.element.append("<li><div class='p-img'><a href='"+result.url+"'><img src='"+result.img+"' /></a></div><div class='p-name'><a href='"+result.url+"'>"+decodeURI(result.name)+"</a></div></li>");}};if (jdRecent.element.length==1){jdRecent.init();}$("#clearRec").click(function(){jdRecent.clear();jdRecent.getData(0);});
  469. /*showTip2*/
  470. var display2=false;
  471. function showTip2(proobj){
  472. var TipDivW=$(proobj).width();
  473. var TipDivH=$(proobj).height();
  474. var TipDiv=$("<div id='c02tip' style='z-index:20000;position:absolute;width:"+eval(TipDivW+5)+"px;height:"+eval(TipDivH+5)+"px;'><div style='position:absolute;margin:5px 0 0 5px;width:"+TipDivW+"px;height:"+TipDivH+"px;background:#BCBEC0;z-index:20001;'></div></div>");
  475. if(display2==false){
  476. TipDiv.append($(proobj));
  477. $(document.body).prepend(TipDiv);
  478. $(proobj).show();
  479. display2=true;
  480. }else{
  481. $("#c02tip").show();
  482. }
  483. $("#c02tip").css({top:parseInt(document.documentElement.scrollTop+(document.documentElement.clientHeight-$("#c02tip").height())/2 )+"px",left:(document.documentElement.clientWidth-$("#c02tip").width())/2+"px"})
  484. $(".Tip_Close").click(function(){
  485. $("#c02tip").fadeOut();
  486. });
  487. timer_5=setTimeout("showTime()",1000);
  488. }
  489. function showTime(){
  490. clearTimeout(timer_5);
  491. var overtime=parseInt($("#timer_5").html())-1;
  492. if(overtime==0){
  493. $("#c02tip").fadeOut();
  494. return;
  495. }
  496. $("#timer_5").html(overtime);
  497. timer_5=setTimeout("showTime()",1000)
  498. }
  499. /*coll*/
  500. var homeServiceUrl = "http://jd2008.360buy.com/homeservice.aspx?callback=?";
  501. $(".btn-coll").livequery("click",function() {
  502. var current = $(this);
  503. $.login({
  504. complete: function(result) {
  505. if (result != null && result.IsAuthenticated != null && result.IsAuthenticated) {
  506. var productId = parseInt(current.attr("id").replace("coll", ""));
  507. if (productId > 0) {
  508. $.getJSON(homeServiceUrl, {
  509. method: "SaveFavorite",
  510. productId: productId
  511. },
  512. function(result) {
  513. if (result.SaveFavorite != null) {
  514. /*$.jdThickBox({
  515. type:"text",
  516. source:result.SaveFavorite.process(result),
  517. width:300,
  518. height:200,
  519. _titleOn:false
  520. })*/
  521. //alert(result.SaveFavorite.process(result))
  522. $("#Collect_Tip").html(result.SaveFavorite.process(result));
  523. showTip2("#Collect_Tip");
  524. }
  525. });
  526. }
  527. }
  528. }
  529. });
  530. });
  531. /*mycart*/
  532. var miniCartServiceUrl = "http://jd2008.360buy.com/purchase/minicartservice.aspx?tmp=0&callback=?";
  533. refreshMiniCart();
  534. $(function(){
  535. var object=$("#o-mycart-list");
  536. $("#i-mycart").bind("mouseover",function(){
  537. object.fadeIn();
  538. }).bind("mouseleave",function(){
  539. object.fadeOut();
  540. })
  541. })
  542. function refreshMiniCart() {
  543. $.login({
  544. automatic: false,
  545. complete: function(result) {
  546. $.getJSON(miniCartServiceUrl, {
  547. method: "GetCart"
  548. },
  549. function(result) {
  550. if (result.Cart != null && result.GetCartNew != null) {
  551. $("#mycart-amount").text(result.Cart.Num);
  552. $("#mycart-list").html(result.GetCartNew.process(result))
  553. }
  554. })
  555. }
  556. })
  557. }
  558. $("#mycart-list .extra a[id][name]").livequery("click",function() {
  559. var cartId = parseInt($(this).attr("id"));
  560. var cartType = $(this).attr("name");
  561. if (cartId > 0 && cartType != "") {
  562. $.getJSON(miniCartServiceUrl, {
  563. method: cartType,
  564. cartId: cartId
  565. },
  566. function(result) {
  567. if (result.Result) {
  568. refreshMiniCart()
  569. }
  570. })
  571. }
  572. });
  573. $("#btn-savetocart").livequery("click",function() {
  574. $.login({
  575. complete: function(result) {
  576. if (result.IsAuthenticated) {
  577. $.getJSON(miniCartServiceUrl, {
  578. method: "SaveCart"
  579. },
  580. function(result) {
  581. if (result.Result) {
  582. alert("寄存购物车成功")
  583. }
  584. })
  585. }
  586. }
  587. })
  588. });