1/* 2Powered by ueeshop.com http://www.ueeshop.com 3广å·èé ç½ç»ç§ææéå ¬å¸ 020-83226791 4*/ 5 6var global_obj={ 7 timer:'', 8 check_form:function(notnull_obj, format_obj, type, is_new){ 9 var flag = false, 10 is_new = (typeof(arguments[3]) == 'undefined') ? 0 : 1, 11 errorObj = new Object; 12 if (notnull_obj) { 13 notnull_obj.each(function(){ 14 var $lang = $(this).parents('.tab_txt').attr('lang'); //åå°è¯è¨ç 15 if (!errorObj[$lang]) { 16 errorObj[$lang] = 0; 17 } 18 if (!$(this).find('input').length && $.trim($(this).val()) == '') { 19 if ($lang) { 20 //åå°è¯è¨ç 21 errorObj[$lang] += 1; 22 $(this).parents('.rows').find('.tab_box_btn[data-lang='+$lang+']').addClass('empty'); 23 $('.r_con_wrap').animate({scrollTop:$(this).parents('.rows').position().top}, 0); 24 } 25 if ($(this).attr('parent_null')) { 26 //æç¤ºå¨ç¶çº§ 27 $(this).parent().css('border', '1px solid red').addClass('null'); 28 $(this).parents('[parent_null]').css('border', '1px solid red').addClass('null'); 29 } else { 30 $(this).css('border', '1px solid red').addClass('null'); 31 } 32 flag == false && ($(this).focus()); 33 flag = true; 34 } else { 35 if (errorObj[$lang] == 0) { 36 $(this).parents('.rows').find('.tab_box_btn[data-lang='+$lang+']').removeClass('empty'); 37 } 38 if ($(this).attr('parent_null')) { 39 //æç¤ºå¨ç¶çº§ 40 $(this).parents('[parent_null]').removeAttr('style').removeClass('null'); 41 } else { 42 $(this).removeAttr('style').removeClass('null'); 43 } 44 } 45 }); 46 //åå°è¯è¨ç 47 $('.rows').find('.tab_box_row .tips').hide(); 48 $('.rows').find('.tab_box_row .tab_box_btn').each(function(){ 49 if ($(this).hasClass('empty')) { 50 $(this).parents('.tab_box_row').find('.tips').show(); 51 } 52 }); 53 if (flag){ return flag; }; 54 } 55 if(format_obj){ 56 var reg={ 57 'MobilePhone':/^1[34578]\d{9}$/, 58 'Telephone':/^(0\d{2,3})(-)?(\d{7,8})(-)?(\d{3,})?$/, 59 'Fax':/^(0\d{2,3})(-)?(\d{7,8})(-)?(\d{3,})?$/, 60 'Email':/^\w+[a-zA-Z0-9-.+_]+@[a-zA-Z0-9-.+_]+\.\w*$/, 61 'Length':/^.*/ 62 }; 63 var tips={ 64 'MobilePhone':lang_obj.format.mobilephone, 65 'Telephone':lang_obj.format.telephone, 66 'Fax':lang_obj.format.fax, 67 'Email':lang_obj.format.email, 68 'Length':lang_obj.format.length 69 }; 70 if(type==1){ 71 format_obj.each(function(){ 72 var o=$(this); 73 if($.trim(o.val())){ 74 if(reg[o.attr('format')].test($.trim(o.val()))===false){ 75 o.css('border', '1px solid red').addClass('null'); 76 o.focus(); 77 flag=true; 78 } 79 } 80 }); 81 }else{ 82 format_obj.each(function(){ 83 var o=$(this); 84 var s=o.attr('format').split('|'); 85 if(!$.trim(o.val())){ 86 flag=false; 87 }else if((s[0]=='Length' && $.trim(o.val()).length!=parseInt(s[1])) || (s[0]!='Length' && reg[s[0]].test($.trim(o.val()))===false)){ 88 if(is_new==1){ 89 global_obj.new_win_alert(tips[s[0]].replace('%num%', s[1])); 90 }else{ 91 global_obj.win_alert(tips[s[0]].replace('%num%', s[1])); 92 } 93 o.css('border', '1px solid red').addClass('null'); 94 o.focus(); 95 flag=true; 96 return false; 97 } 98 }); 99 } 100 } 101 return flag; 102 }, 103 104 win_alert:function(tips, callback, type, is_pop, status){ 105 var type=(typeof(arguments[2])=='undefined')?'alert':arguments[2], 106 is_pop=(typeof(arguments[3])=='undefined')?0:1, 107 status=(typeof(arguments[4])=='undefined')?'':arguments[4], //status => success(æå) fail(失败) 108 not_remove_mask=$('.not_remove_mask:visible').length?1:0, //ä¸å é¤é®ç½©å± 109 html; 110 $('#div_mask, .win_alert').remove();//ä¼å æ¸ ç©ºå¤ä½çå¼¹åºæ¡ 111 global_obj.div_mask(); 112 html='<div class="win_alert">'; 113 html+='<div class="win_close"><button class="close">x</button></div>'; 114 html+='<div class="win_tips '+status+'">'+tips+'</div>'; 115 html+='<div class="win_btns">'; 116 if(type=='confirm'){ 117 html+='<button class="btn btn_sure">'+lang_obj.global.confirm+'</button>'; 118 html+='<button class="btn btn_cancel">'+lang_obj.global.cancel+'</button>'; 119 }else{ 120 html+='<button class="btn btn_sure btn_once_sure">'+lang_obj.global.confirm+'</button>'; 121 } 122 html+='</div>'; 123 html+='</div>'; 124 $('body').prepend(html); 125 $('.win_alert').css({left:$(window).width()/2-$('.win_alert').outerWidth(true)/2,top:'30%'}); 126 if(type=='confirm'){ 127 $('.win_alert').delegate('.close, .btn_cancel', 'click', function(){ 128 $('.win_alert').remove(); 129 is_pop==0 && not_remove_mask==0 && global_obj.div_mask(1); 130 }).delegate('.btn_sure', 'click', function(){ 131 $.isFunction(callback) && callback(); 132 $('.win_alert .close').click(); 133 }); 134 /*$(document).keyup(function(event){ //EscãSpaceåæ¶æç¤ºï¼ç©ºæ ¼ãEnterç¡®å®æç¤º 135 if(event.keyCode==27 || event.keyCode==8){ 136 $('.win_alert .close').click(); 137 }else if(event.keyCode==32 || event.keyCode==13){ 138 $.isFunction(callback) && callback(); 139 $('.win_alert .close').click(); 140 } 141 });*/ 142 }else{ 143 $('.win_alert').delegate('.close, .btn_sure', 'click', function(){ 144 $.isFunction(callback) && callback(); 145 $('.win_alert').remove(); 146 is_pop==0 && not_remove_mask==0 && global_obj.div_mask(1); 147 }); 148 /*$(document).keyup(function(event){ //EscãEnterãSpaceãç©ºæ ¼åæ¶æç¤º 149 if(event.keyCode==13 || event.keyCode==8 || event.keyCode==27 || event.keyCode==32) { 150 $('.win_alert .close').click(); 151 } 152 });*/ 153 } 154 return false;
155 }, 156 157 new_win_alert:function(tips, callback, type, is_pop, status, btn){ //status => await(å¹å·) fail(红å) 158 var type=(typeof(arguments[2])=='undefined')?'alert':arguments[2], 159 is_pop=(typeof(arguments[3])=='undefined')?0:1, 160 status=(typeof(arguments[4])=='undefined')?'await':arguments[4], 161 btn=(typeof(arguments[5])=='undefined')?lang_obj.global.confirm:arguments[5], 162 html; 163 $('#div_mask, .new_win_alert').remove();//ä¼å æ¸ ç©ºå¤ä½çå¼¹åºæ¡ 164 global_obj.div_mask(); 165 html='<div class="new_win_alert themes_popups">'; 166 html+='<div class="win_close"><button class="close"></button></div>'; 167 html+='<div class="win_tips"><i class="icon_success_status '+status+'"></i>'+tips+'</div>'; 168 html+='<div class="win_btns">'; 169 if(type=='confirm') html+='<button class="btn btn_cancel">'+lang_obj.global.cancel+'</button>'; 170 html+='<button class="btn btn_sure">'+btn+'</button>'; 171 html+='<div class="clear"></div>'; 172 html+='</div>'; 173 html+='</div>'; 174 $('body').prepend(html); 175 $('.new_win_alert').css({left:$(window).width()/2-$('.new_win_alert').outerWidth()/2, top:'30%'}); 176 if(type=='confirm'){ 177 $('.new_win_alert').delegate('.close, .btn_cancel', 'click', function(){ 178 $('.new_win_alert').remove(); 179 is_pop==0 && global_obj.div_mask(1); 180 }).delegate('.btn_sure', 'click', function(){ 181 $.isFunction(callback) && callback(); 182 $('.new_win_alert .close').click(); 183 }); 184 /*$(document).keyup(function(event){ //EscãSpaceåæ¶æç¤ºï¼ç©ºæ ¼ãEnterç¡®å®æç¤º 185 if(event.keyCode==27 || event.keyCode==8){ 186 $('.new_win_alert .close').click(); 187 }else if(event.keyCode==32 || event.keyCode==13){ 188 $.isFunction(callback) && callback(); 189 $('.new_win_alert .close').click(); 190 } 191 });*/ 192 }else{ 193 $('.new_win_alert').delegate('.close, .btn_sure', 'click', function(){ 194 $.isFunction(callback) && callback(); 195 $('.new_win_alert').remove(); 196 is_pop==0 && global_obj.div_mask(1); 197 }); 198 /*$(document).keyup(function(event){ //EscãEnterãSpaceãç©ºæ ¼åæ¶æç¤º 199 if(event.keyCode==13 || event.keyCode==8 || event.keyCode==27 || event.keyCode==32) { 200 $('.win_alert .close').click(); 201 } 202 });*/ 203 } 204 return false; 205 }, 206 207 /* 208 * @param: tips æç¤ºå 容 209 * @param: status ç±»åï¼ç空(æé©) await(å¹å·) fail(红å) loading(å è½½ä¸) 210 * @param: time åçæ¶é´ (-1: é对loadingææåºå®æ¾ç¤º) 211 * @param: pos_top ä¸é¡¶é¨çè·ç¦» 212 * @param: no_remove_mask æ¯å¦ä¼å æ¸ é¤å¤ä½çå¼¹åºæ¡ 213 */ 214 win_alert_auto_close:function(tips, status, time, pos_top, no_remove_mask){ 215 var status=(typeof(arguments[1])=='undefined')?'await':arguments[1], 216 time=(typeof(arguments[2])=='undefined' || !arguments[2])?'2000':arguments[2], 217 pos_top=(typeof(arguments[3])=='undefined' || !arguments[3])?'40%':arguments[3], 218 no_remove_mask=(typeof(arguments[4])=='undefined')?1:arguments[4], 219 html=''; 220 if(no_remove_mask) $('#div_mask, .new_win_alert').remove();//ä¼å æ¸ ç©ºå¤ä½çå¼¹åºæ¡ 221 if(status!='loading' || (status=='loading' && time==-1)){ 222 //é¤äºloading Or åºå®æ¾ç¤ºloading 223 html+='<div class="new_win_alert win_alert_auto_close'+(status=='loading'?' win_alert_loading':'')+'">'; 224 html+= '<div class="win_tips"><i class="icon_success_status '+status+'"></i>'+tips+'</div>'; 225 html+='</div>'; 226 $('body').prepend(html); 227 $('.new_win_alert').css({left:$(window).width()/2-$('.new_win_alert').outerWidth(true)/2, top:pos_top}); 228 } 229 clearTimeout(global_obj.timer); 230 if(status!='loading' || (status=='loading' && time>=0)){ 231 //é¤äºloading Or 计æ¶èªå¨å ³éloading 232 global_obj.timer=setTimeout(function(){ 233 $('.new_win_alert').remove(); 234 }, time); 235 } 236 return false; 237 }, 238 239 div_mask:function(remove){ 240 var obj=(typeof(arguments[1])=='undefined')?'':arguments[1], 241 $obj = $('body'); 242 if (typeof(obj) == 'object') $obj = obj; 243 if(remove==1){ 244 $('#div_mask').remove(); 245 }else{ 246 if(!$('#div_mask').size()){ 247 $obj.prepend('<div id="div_mask"></div>'); 248 $('#div_mask').css({width:'100%', height:$(document).height(), overflow:'hidden', position:'fixed', top:0, left
248:0, background:'#000', opacity:0.6, 'z-index':10000}); 249 } 250 } 251 }, 252 253 data_posting:function(display, tips){ 254 if(display){ 255 $('body').prepend('<div id="data_posting"><img src="/static/ico/data_posting.gif" style="margin-top: 4px;display: inline-block;vertical-align: top;" width="16" height="16" align="absmiddle" /> '+tips+'</div>'); 256 $('#data_posting').css({ 257 width:'188px', 258 height:'24px', 259 'line-height':'24px', 260 padding:'0 8px', 261 overflow:'hidden', 262 border:'1px solid #bbb', 263 background:'#ddd', 264 position:'fixed', 265 top:'40%', 266 left:'0', 267 right:'0', 268 margin:'auto', 269 'z-index':10001 270 }); 271 }else{ 272 setTimeout('$("#data_posting").remove();', 500); 273 } 274 }, 275 276 urlencode:function(str) { 277 str = (str + '').toString(); 278 return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+'); 279 }, 280 281 json_encode_data:function(value){ 282 var result=new Object(); 283 if(typeof(value)=='string' && value){ 284 if(typeof(JSON)=='object'){ 285 result=JSON.parse(value); 286 }else{ 287 var ary, arr, key; 288 ary=value.substr(1,value.length-2).split(',"');//踢走{} 289 for(var i=0; i<ary.length; i++){ 290 arr=ary[i].split(':'); 291 key=parseInt(isNaN(arr[0]) ? (i==0?arr[0].substr(1,arr[0].length-2):arr[0].substr(0,arr[0].length-1)): arr[0]);//ç¡®ä¿é®æ¯æ°å 292 if(arr[1].substr(0,1)=='['){//å¼ä¸ºæ°ç» 293 result[key]=arr[1].substr(1,arr[1].length-2).split(','); 294 }else{ 295 result[key]=arr[1]; 296 } 297 } 298 } 299 }else{ 300 result=value; 301 } 302 return result; 303 }, 304 305 json_decode_data:function(value){ 306 var result; 307 if(typeof(value)=='object'){ 308 if(typeof(JSON)=='object'){ 309 result=JSON.stringify(value); 310 }else{ 311 result=''; 312 for(k in value){ 313 if(global_obj.is_array(value[k])){ 314 result+=('"'+k+'":['+value[k]+'],'); 315 }else{ 316 result+=('"'+k+'":"'+value[k]+'",'); 317 } 318 } 319 result='{'+result.substr(0,result.length-1)+'}'; 320 } 321 }else{ 322 result=value; 323 } 324 return result; 325 }, 326 327 in_array:function(needle, arr){ 328 for(var i=0; i<arr.length && arr[i]!=needle; i++); 329 return !(i==arr.length); 330 }, 331 332 is_array:function(data){ 333 if(Object.prototype.toString.call(data)=='[object Array]'){ 334 return true; 335 }else{ 336 return false; 337 } 338 }, 339 340 base64_encode:function(str){ 341 var c1, c2, c3; 342 var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 343 var i = 0, len= str.length, string = ''; 344 while (i < len){ 345 c1 = str.charCodeAt(i++) & 0xff; 346 if (i == len){ 347 string += base64EncodeChars.charAt(c1 >> 2); 348 string += base64EncodeChars.charAt((c1 & 0x3) << 4); 349 string += "=="; 350 break; 351 } 352 c2 = str.charCodeAt(i++); 353 if (i == len){ 354 string += base64EncodeChars.charAt(c1 >> 2); 355 string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
356 string += base64EncodeChars.charAt((c2 & 0xF) << 2); 357 string += "="; 358 break; 359 } 360 c3 = str.charCodeAt(i++); 361 string += base64EncodeChars.charAt(c1 >> 2); 362 string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); 363 string += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); 364 string += base64EncodeChars.charAt(c3 & 0x3F) 365 } 366 return string 367 }, 368 369 htmlspecialchars:function(str){ 370 str = str.replace(/&/g, '&'); 371 str = str.replace(/</g, '<'); 372 str = str.replace(/>/g, '>'); 373 str = str.replace(/"/g, '"'); 374 str = str.replace(/'/g, '''); 375 return str; 376 }, 377 378 htmlspecialchars_decode:function(str){ 379 str = str.replace(/&/g, '&'); 380 str = str.replace(/</g, '<'); 381 str = str.replace(/>/g, '>'); 382 str = str.replace(/"/g, '"'); 383 str = str.replace(/'/g, "'"); 384 return str; 385 }, 386 387 setCookie:function(name, value, expiredays){ 388 var exdate=new Date(); 389 exdate.setDate(exdate.getDate()+expiredays); 390 document.cookie=name+"="+escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); 391 }, 392 393 getCookie:function(name){ 394 if(document.cookie.length>0){ 395 start=document.cookie.indexOf(name+"="); 396 if(start!=-1){ 397 start=start+(name.length+1); 398 end=document.cookie.indexOf(";", start); 399 if(end==-1) end=document.cookie.length; 400 return unescape(document.cookie.substring(start, end)); 401 } 402 } 403 return ""; 404 }, 405 406 delCookie:function(name, expiredays){ 407 var exdate=new Date(); 408 exdate.setDate(exdate.getDate()-1); 409 var value=global_obj.getCookie(name) 410 if(value){ 411 document.cookie=name+"="+escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); 412 } 413 }, 414 415 Waterfall:function(container, colWidth, colCount, cls){ 416 function Waterfall(param){ 417 this.id = typeof param.container == 'string' ? document.getElementById(param.container) : param.container; 418 this.colWidth = param.colWidth; 419 this.colCount = param.colCount || 4; 420 this.cls = param.cls && param.cls != '' ? param.cls : 'wf-cld'; 421 this.init(); 422 } 423 //ç叿µ 424 Waterfall.prototype = { 425 getByClass:function(cls,p){ 426 var arr = [],reg = new RegExp("(^|\\s+)" + cls + "(\\s+|$)","g"); 427 var nodes = p.getElementsByTagName("*"),len = nodes.length; 428 for(var i = 0; i < len; i++){ 429 if(reg.test(nodes[i].className)){ 430 arr.push(nodes[i]);// 431 reg.lastIndex = 0; 432 } 433 } 434 return arr; 435 }, 436 maxArr:function(arr){ 437 var len = arr.length,temp = arr[0]; 438 for(var ii= 1; ii < len; ii++){ 439 if(temp < arr[ii]){ 440 temp = arr[ii]; 441 } 442 } 443 return temp; 444 }, 445 getMar:function(node){ 446 var dis = 0; 447 if(node.currentStyle){ 448 dis = parseInt(node.currentStyle.marginBottom); 449 }else if(document.defaultView){ 450 dis = parseInt(document.defaultView.getComputedStyle(node,null).marginBottom); 451 } 452 return dis; 453 }, 454 getMinCol:function(arr){ 455 var ca = arr,cl = ca.length,temp = ca[0],minc = 0; 456 for(var ci = 0; ci < cl; ci++){ 457 if(temp > ca[ci]){ 458 temp = ca[ci]; 459 minc = ci; 460 } 461 } 462 return minc; 463 }, 464 init:function(){ 465 var _this = this; 466 var col = [],//åé« 467 iArr = [];//ç´¢å¼ 468 var nodes = _this.getByClass(_this.cls,_this.id),len = nodes.length; 469 for(var i = 0; i < _this.colCount; i++){ 470 col[i] = 0; 471 } 472 for(var i = 0; i < len; i++){ 473 nodes[i].h = nodes[i].offsetHeight + _this.getMar(nodes[i]); 474 iArr[i] = i; 475 } 476 477 for(var i = 0; i < len; i++){ 478 var ming = _this.getMinCol(col); 479 nodes[i].style.left = ming * _this.colWidth + "px"; 480 nodes[i].style.top = col[ming] + "px"; 481 col[ming] += nodes[i].h; 482 } 483 484 _this.id.style.height = _this.maxArr(col) + "px"; 485 } 486 }; 487 488 new Waterfall({ 489 "container": container, //id 490 "colWidth": colWidth, 491 "colCount": colCount,//parseInt($('#themes_box').width()/220) 492 "cls": cls //class 493 }); 494 495 }, 496 497 sort:function(a,b){ //屿§é®å¼æåº Ov: æ¯æµ·å¤ä» è¦æå°æå 498 if(a.indexOf('Ov:')!=-1){ 499 a=99999999; 500 } 501 if(b.indexOf('Ov:')!=-1){ 502 b=99999999; 503 } 504 return a - b; 505 }, 506 507 checkCharLength:function(box,content){ //åé¿å¤æ 508 var e=$(box); 509 e.change(function(event){ 510 var curLength=e.val().length; 511 var maxlength=e.attr('maxlength'); 512 if(curLength>maxlength){ 513 e.val($.trim(e.val()).substr(0,maxlength)).trigger('change'); 514 return; 515 } 516 $('#review_form .font_tips em').text(curLength); 517 $(content).text(maxlength-curLength).parent().toggleClass('red', curLength>maxlength); 518 }).keyup(function(){ 519 e.trigger('change'); 520 }); 521 }, 522 523 /** 524 * è·åå½åå°åurlçgetåæ° 525 * @param value[string] éè¦è·ågetçåæ° 526 * @param selecter[string] éæ©å¨ï¼ä¸è¬ä¸éè¦ï¼æäºå¨iframeéé¢çï¼è¿éå°±åparent 527 */ 528 query_get:function(value, selecter) 529 { 530 if (selecter == 'parent') { 531 var query = window.parent.location.search.substring(1); 532 } else { 533 var query = window.location.search.substring(1); 534 } 535 var vars = query.split("&"); 536 for (var i = 0; i < vars.length; i++) { 537 var pair = vars[i].split("="); 538 if(pair[0] == value) return pair[1]; 539 } 540 return false;
541 } 542 543} 544 545//Object => string 546$.toJSON = typeof JSON == "object" && JSON.stringify ? JSON.stringify: function(e) { 547 if (e === null) return "null"; 548 var t, n, r, i, s = $.type(e); 549 if (s === "undefined") return undefined; 550 if (s === "number" || s === "boolean") return String(e); 551 if (s === "string") return $.quoteString(e); 552 if (typeof e.toJSON == "function") return $.toJSON(e.toJSON()); 553 if (s === "date") { 554 var o = e.getUTCMonth() + 1, 555 u = e.getUTCDate(), 556 a = e.getUTCFullYear(), 557 f = e.getUTCHours(), 558 l = e.getUTCMinutes(), 559 c = e.getUTCSeconds(), 560 h = e.getUTCMilliseconds(); 561 o < 10 && (o = "0" + o); 562 u < 10 && (u = "0" + u); 563 f < 10 && (f = "0" + f); 564 l < 10 && (l = "0" + l); 565 c < 10 && (c = "0" + c); 566 h < 100 && (h = "0" + h); 567 h < 10 && (h = "0" + h); 568 return '"' + a + "-" + o + "-" + u + "T" + f + ":" + l + ":" + c + "." + h + 'Z"' 569 } 570 t = []; 571 if ($.isArray(e)) { 572 for (n = 0; n < e.length; n++) t.push($.toJSON(e[n]) || "null"); 573 return "[" + t.join(",") + "]" 574 } 575 if (typeof e == "object") { 576 for (n in e) if (hasOwn.call(e, n)) { 577 s = typeof n; 578 if (s === "number") r = '"' + n + '"'; 579 else { 580 if (s !== "string") continue; 581 r = $.quoteString(n) 582 } 583 s = typeof e[n]; 584 if (s !== "function" && s !== "undefined") { 585 i = $.toJSON(e[n]); 586 t.push(r + ":" + i) 587 } 588 } 589 return "{" + t.join(",") + "}" 590 } 591}; 592 593//string => Object 594$.evalJSON = typeof JSON == "object" && JSON.parse ? JSON.parse: function(str) { 595 return eval("(" + str + ")") 596}; 597 598var //escape=/["\\\x00-\x1f\x7f-\x9f]/g, 599 meta={ 600 '\b': '\\b', 601 '\t': '\\t', 602 '\n': '\\n', 603 '\f': '\\f', 604 '\r': '\\r', 605 '"': '\\"', 606 '\\': '\\\\' 607 }, 608 hasOwn=Object.prototype.hasOwnProperty; 609 610$.quoteString = function (str) { 611 if (str.match(escape)) { 612 return '"' + str.replace(escape, function (a) { 613 var c = meta[a]; 614 if (typeof c === 'string') { 615 return c; 616 } 617 c = a.charCodeAt(); 618 return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); 619 }) + '"'; 620 } 621 return '"' + str + '"'; 622}; 623 624//è§£å³æµ®ç¹æ°ç²¾åº¦ä¸¢å¤±é®é¢ 625$.fn.floatingNumber = function(type, arg1, arg2) { 626 var result = ''; 627 if (type == 'addition') { 628 //å æ³ 629 var r1, r2, m; 630 try { 631 r1 = arg1.toString().split(".")[1].length; 632 } catch(e) { r1 = 0; } 633 try { 634 r2 = arg2.toString().split(".")[1].length; 635 } catch(e){ r2 = 0; } 636 m = Math.pow(10, Math.max(r1, r2)); 637 result = (Math.round(arg1 * m) + Math.round(arg2 * m)) / m; 638 } else if (type == 'subtraction') { 639 //åæ³ 640 var r1, r2, m, n; 641 try { 642 r1 = arg1.toString().split(".")[1].length; 643 } catch(e) { r1 = 0; } 644 try { 645 r2 = arg2.toString().split(".")[1].length; 646 } catch(e) { r2 = 0; } 647 m = Math.pow(10, Math.max(r1, r2)); //卿æ§å¶ç²¾åº¦é¿åº¦ 648 n = (r1 >= r2) ? r1 : r2; 649 result = parseFloat(((Math.round(arg1 * m) - Math.round(arg2 * m)) / m).toFixed(n)); 650 } else if (type == 'multiply') { 651 //乿³ 652 var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); 653 try { 654 m += s1.split(".")[1].length; 655 } catch(e) {} 656 try { 657 m += s2.split(".")[1].length; 658 } catch(e) {} 659 result = Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); 660 } else if (type == 'division') { 661 //餿³ 662 var t1 = 0, t2 = 0, r1, r2; 663 try { 664 t1 = arg1.toString().split(".")[1].length; 665 } catch(e) {} 666 try { 667 t2 = arg2.toString().split(".")[1].length; 668 } catch(e) {} 669 with (Math) { 670 r1 = Number(arg1.toString().replace(".", "")); 671 r2 = Number(arg2.toString().replace(".", "")); 672 result = (r1 / r2) * pow(10, t2 - t1); 673 } 674 } 675 return result; 676} 677Number.prototype.add = function(arg) { 678 return $('html').floatingNumber('addition', arg, this); 679}; 680Number.prototype.sub = function(arg) { 681 return $('html').floatingNumber('subtraction', this, arg); 682}; 683Number.prototype.mul = function (arg) { 684 return $('html').floatingNumber('multiply', arg, this); 685}; 686Number.prototype.div = function (arg) { 687 return $('html').floatingNumber('division', this, arg); 688}; 689 690//ä»·æ ¼æ¾ç¤ºæä»¶ 691$.fn.priceShow=function(){ 692 var $price=0; 693 $(this).find('.price_data[data]').each(function(){ 694 $price=parseFloat($(this).attr('data')).mul(parseFloat(ueeshop_config.currency_rate)); 695 $(this).text($('html').iconvPriceFormat($price, 2, '', 1)); 696 }); 697} 698 699//è´§å¸æ ¼å¼æ¾ç¤º 700$.fn.iconvPriceFormat = function(price) { 701 var method = (typeof(arguments[1]) == 'undefined') ? 0 : arguments[1], 702 currency = (typeof(arguments[2]) == 'undefined') ? '' : arguments[2], 703 is_currency = (typeof(arguments[3]) == 'undefined') ? 0 : arguments[3], 704 symbol = ueeshop_config.currency_symbols, 705 price = parseFloat(price), 706 result = 0; 707 currency == '' && (currency = ueeshop_config.currency); 708 if (method == 0) { 709 //符å·+ä»·æ ¼ 710 result = (Math.ceil(price.mul(10000).div(100)).div(100)).toFixed(2); 711 is_currency == 1 && currency && (result = $('html').currencyFormat(result, currency)); 712 result = symbol + result; 713 } else if (method == 1) { 714 //ç¬¦å· 715 result = symbol; 716 } else { 717 //ä»·æ ¼ 718 result = (Math.ceil(price.mul(10000).div(100)).div(100)).toFixed(2); 719 is_currency == 1 && currency && (result = $('html').currencyFormat(result, currency)); 720 } 721 return result; 722} 723 724//è´§å¸æ ¼å¼æ¾ç¤º 725$.fn.currencyFormat=function(price, currency){ 726 var result=0; 727 price=parseFloat(price); 728 switch(currency){ 729 case 'USD': 730 case 'GBP': 731 case 'CAD': 732 case 'AUD': 733 case 'CHF': 734 case 'HKD': 735 case 'ILS': 736 case 'MXN': 737 case 'CNY': 738 case 'SAR': 739 case 'SGD': 740 case 'NZD': 741 case 'AED': 742 result=price.formatMoney(2, '.', ','); break; 743 case 'RUB': 744 result=price.formatMoney(2, ',', ' '); break; 745 case 'EUR': 746 case 'BRL': 747 case 'ARS': 748 result=price.formatMoney(2, ',', '.'); break; 749 case 'CLP': 750 case 'NOK': 751 case 'DKK': 752 case 'COP': 753 result=price.formatMoney(0, '', '.'); break; 754 case 'JPY': 755 case 'SEK': 756 case 'KRW': 757 case 'INR': 758 case 'TWD': 759 result=price.formatMoney(0, '', ','); break; 760 default: 761 result=price.formatMoney(2, '.', ','); break; 762 } 763 return result; 764} 765 766/** 767 * å¯è§åæ»å¨æä»¶ 768 * 769 * @param: data[object] speed:æ»å¨é度,é»è®¤300 count:产åå¯è§æ°é,é»è®¤4 isTouch:å¼å¯è§¦æ¸äºä»¶,é»è®¤0 number:æä»¶åºå·,é»è®¤0 callback:æä»¶åè°å½æ°ï¼è´è´£æä»¶å è½½å®æ¯åæ§è¡ 770 * 771 * æé®åè: <a href="javascript:;" rel="nofollow" data-btn-srcoll="æä»¶åºå·" data-srcoll-direction="æ¹åprevæè next"></a>
772 * ç»å®åè: $('#xxx').visualSrcoll({'speed':'500', 'isTouch':1}); 773*/ 774$.fn.visualSrcoll = function(data) { 775 data = $.extend({ 776 obj: $(this), 777 init: function() { 778 this.self = data.obj.html(); 779 this.html = ''; 780 this.number = data.number; 781 this.index = 0; 782 this.speed = data.speed || 300; 783 this.count = 4; 784 this.isTouch = data.isTouch || 0; 785 this.element = data.obj[0]; 786 this.callback = data.callback || ''; 787 if (!this.element) { 788 return false; 789 } 790 if (this.element.addEventListener) { 791 if (this.isTouch == 1) { 792 this.element.addEventListener('touchstart', this, false); 793 this.element.addEventListener('touchmove', this, false); 794 this.element.addEventListener('touchend', this, false); 795 } 796 window.addEventListener('resize', this, false); 797 } 798 if (typeof(data.number) == 'undefined' && $('.box_visual_srcoll').size() > 0) { 799 this.number = $('.box_visual_srcoll').size(); 800 } 801 if (typeof(data.number) == 'undefined' && $('.box_visual_srcoll').size() == 0) { 802 this.number = 0; 803 } 804 this.html += '<div class="srcoll_list">'; 805 this.html += '<a href="javascript:;" rel="nofollow" class="srcoll_btn srcoll_btn_prev" data-btn-srcoll="' + this.number + '" data-srcoll-direction="prev"></a>'; 806 this.html += '<a href="javascript:;" rel="nofollow" class="srcoll_btn srcoll_btn_next" data-btn-srcoll="' + this.number + '" data-srcoll-direction="next"></a>'; 807 this.html += '<div class="srcoll_suit" style="width:100%; overflow:hidden;">'; 808 this.html += '<div class="srcoll_suit_box">' + this.self + '</div>'; 809 this.html += '</div>'; 810 this.html += '</div">'; 811 data.obj.addClass('box_visual_srcoll').attr('data-box-srcoll', this.number).html(this.html); 812 this.setup(); 813 this.bind(); 814 if ($.isFunction(this.callback)) { 815 this.callback(); 816 } 817 }, 818 setup: function() { 819 this.suit = data.obj.find('.srcoll_list .srcoll_suit'); 820 this.box = data.obj.find('.srcoll_list .srcoll_suit_box'); 821 this.box.element = this.box[0]; 822 this.children = this.box.children(); 823 this.length = this.children.size(); 824 //this.width = this.children.eq(0).outerWidth(true); 825 if (this.children.eq(0)[0].currentStyle) { 826 //IEãOpera 827 this.cElement = this.children.eq(0)[0].currentStyle; 828 } else { 829 //FFãChromeãSafari 830 this.cElement = getComputedStyle(this.children.eq(0)[0], false); 831 } 832 this.width = parseFloat(this.cElement.width) + parseFloat(this.cElement.marginRight) + parseFloat(this.cElement.marginLeft); //ç²¾åå°å°æ°ç¹ 833 if (this.length < 2) { 834 return false; 835 } 836 this.box.element.style.width = parseFloat(this.length * this.width + 1).toFixed(2) + 'px'; //1px为é¢å¤çåç§»é 837 this.slide(this.index, 0); 838 for (i = 1; i <= this.length; ++i) { 839 //å ¼å®¹å¯è§å 840 if ((i * this.width) >= this.suit.width()) { 841 this.count = i; 842 if (((i - .5) * this.width) >= this.suit.width()) { 843 //å°æªè¶ è¿å个 844 this.count = i - 1; 845 } 846 break; 847 } 848 } 849 }, 850 bind: function() { 851 $('*[data-btn-srcoll="' + this.number + '"]').on('click', function() { 852 $(this).data('srcoll-direction') == 'prev' ? data.prev() : data.next(); 853 }); 854 }, 855 prev: function() { 856 if (this.index) { 857 this.slide(this.index - 1, this.speed); 858 } 859 }, 860 next: function() { 861 if (this.index < this.length - this.count) { 862 this.slide(this.index + 1, this.speed); 863 } 864 }, 865 slide: function(index, speed) { 866 var moveWith = index * this.width; 867 var Offset = moveWith + this.suit.width() - this.length * this.width; 868 if(Offset > 0) { 869 moveWith = moveWith - Offset; 870 } 871 style = this.box.element.style; 872 style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration = speed + 'ms'; 873 style.MozTransform = style.webkitTransform = 'translate3d(' + -(moveWith) + 'px, 0, 0)'; 874 style.msTransform = style.OTransform = 'translateX(' + -(moveWith) + 'px)'; 875 this.index = index; 876 }, 877 handleEvent: function(e) { 878 var that = this; 879 if (!e.touches) { 880 e.touches = new Array(e); 881 e.scale = false;
882 } 883 switch (e.type) { 884 case 'touchstart': this.touchStart(e); break; 885 case 'touchmove': this.touchMove(e); break; 886 case 'touchend': this.touchEnd(e); break; 887 case 'resize': this.setup(); break; 888 } 889 }, 890 touchStart: function(e) { 891 this.tConfig = { 892 pageX: e.touches[0].pageX, 893 pageY: e.touches[0].pageY, 894 moveX: this.box.element.style.msTransform ? parseFloat(this.box.element.style.msTransform.replace('translateX(', '')) : 0 895 }; 896 this.movingX = 0; 897 this.surplus = parseFloat(this.box.width() - this.suit.width()) * -1; 898 this.tMoveX = 0; 899 }, 900 touchMove: function(e) { 901 if (e.touches.length > 1 || e.scale && e.scale !== 1) return; 902 this.movingX = e.touches[0].pageX - this.tConfig.pageX; 903 if (this.count == 1) { 904 this.movingX = this.movingX / (((this.index == 0 && this.movingX > 0) || (this.index == this.length - this.count && this.movingX < 0)) ? (Math.abs(this.movingX) / this.width + 1) : 1); //å·¦å³å°½å¤´çç¼å²ææ 905 style = this.box.element.style; 906 style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration = '0ms'; 907 style.MozTransform = style.webkitTransform = 'translate3d(' + (this.movingX - this.index * this.width) + 'px, 0, 0)'; 908 style.msTransform = style.OTransform = 'translateX(' + (this.movingX - this.index * this.width) + 'px)'; 909 } else { 910 this.tMoveX = parseFloat(this.tConfig.moveX + this.movingX); 911 if (this.tMoveX > 0 || (this.tMoveX < 0 && this.tMoveX < this.surplus)) { 912 //å·¦å³å°½å¤´çç¼å²ææ 913 this.tMoveX = this.tConfig.moveX + (this.movingX / (Math.abs(this.tMoveX) / this.width + 1)); 914 } 915 style = this.box.element.style; 916 style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration = '0ms'; 917 style.MozTransform = style.webkitTransform = 'translate3d(' + this.tMoveX + 'px, 0, 0)'; 918 style.msTransform = style.OTransform = 'translateX(' + this.tMoveX + 'px)'; 919 } 920 }, 921 touchEnd: function(e) { 922 if (this.movingX == 0) return false; // åå°ç¹å»ï¼éåº 923 if (this.count == 1) { 924 var isSlideHalf = 1; //Math.abs(this.movingX) > this.width / 2, 925 isBoundary = (this.index == 0 && this.movingX > 0) || (this.index == this.length - this.count && this.movingX < 0); //å·¦å³ä¸¤è¾¹å°½å¤´ 926 this.slide(this.index + (isSlideHalf && !isBoundary ? (this.movingX < 0 ? 1 : -1) : 0), this.speed); //æå³è´æ°ï¼æå·¦æ£æ° 927 } else { 928 this.tMoveX = this.tConfig.moveX + this.movingX; 929 if (this.tMoveX > 0) { 930 //左尽头 931 this.slide(0, 0); 932 } else if (this.tMoveX < 0 && this.tMoveX < this.surplus) { 933 //å³å°½å¤´ 934 this.slide(this.length - 1, 0); 935 } 936 } 937 } 938 }, data); 939 data.init(); 940} 941 942/** 943 * å¯è§åé项塿件 944 * 945 * @param: data[object] button:äºä»¶è§¦åæé®(éæ©å¨) box:äºä»¶è§¦åçå(éæ©å¨) current:éä¸ç¸å ³çæ ·å¼ç±»å,é»è®¤current 946 * 947 * ç»å®åè: $('#xxx').visualTab({'button':'.category a', 'box':'.box', 'current':'cur FontBgColor', 'box_current':'cur FontBgColor'}); 948 */ 949$.fn.visualTab = function(data) { 950 data = $.extend({ 951 obj: $(this), 952 init: function() { 953 this.button = data.button; 954 this.box = data.box; 955 this.current = data.current || 'current'; 956 this.box_current= data.box_current || 'current'; 957 this.selector = data.obj.find(this.button + ':visible').selector; 958 this.selectorBox= data.obj.find(this.box).selector; 959 this.bind(); 960 }, 961 bind: function() { 962 data.obj.find(this.button + ':visible').on('click', function() { 963 index = $(this).index(this.selector); 964 data.display(index); 965 }); 966 }, 967 display: function(index) { 968 data.obj.find(this.button).eq(index).addClass(this.current).siblings(this.selector).removeClass(this.current); 969 data.obj.find(this.box).eq(index).show().addClass(this.box_current).siblings(this.selectorBox).hide().removeClass(this.box_current); 970 }, 971 }, data); 972 data.init(); 973} 974 975//å ·æå ¨å±æ å¿gçæ£å表达å¼çå®ä¹æ¹æ³ 976String.prototype.replaceAll = function(s1, s2) { 977 return this.replace(new RegExp(s1, "gm"), s2); 978} 979 980// å¯è§åç«å³è´ä¹°æä»¶æ¨¡å 981$.fn.VisualBuyNow = function (options) { 982 $.fn.VisualBuyNow.defaults = { 983 'item' : '.visual_buynow_item', // 屿§item 984 'button' : '.visual_buynow_btn', // buynowæé® 985 'current' : 'current' // çè²æ è®° 986 }; 987 let _this = this; 988 let opts = $.extend({},$.fn.VisualBuyNow.defaults,options); 989 let tips = function(tips){ 990 if ($(window).width() < 768) { // ç§»å¨ç«¯ 991 $('html').tips_box(tips, 'error', '', 1); 992 } else { 993 global_obj.new_win_alert(tips); 994 } 995 }; 996 // 鿩屿§ 997 _this.find(opts.item).on('click', function () { 998 $(this).addClass(opts.current).find('input[type=hidden]').prop('disabled', false); 999 $(this).siblings().removeClass(opts.current).find('input[type=hidden]').prop('disabled', true); 1000 }); 1001 // ç¹å»buynowæé® 1002 _this.find(opts.button).on('click', function () { 1003 if (!_this.find(opts.item + '.current').size()) { // 没æéæ©å±æ§ 1004 tips(lang_obj.cart.batch_buy_option); 1005 return false;
1006 } 1007 let $Formdata = new FormData(_this[0]); 1008 $Formdata.append('IsBuyNow', 1); 1009 $Formdata.append('back', 1); 1010 _this.find(opts.button).attr('disabled', true); 1011 $.ajax({ 1012 type: 'POST', 1013 url: '/?do_action=cart.additem', 1014 data: $Formdata, 1015 dataType: 'json', 1016 async: false, 1017 cache: false, 1018 contentType: false, 1019 processData: false, 1020 success: function(data) { 1021 if (data.ret == 1) { 1022 parseInt(ueeshop_config.FbPixelOpen)==1 && $('html').fbq_addtocart(data.msg.item_price); 1023 //BuyNowç»è®¡ 1024 analytics_click_statistics(1);//ææ¶ç»è®¡ä¸ºæ·»å è´ç©è½¦äºä»¶ 1025 $.post('/?do_action=cart.check_low_consumption&t='+Math.random(), {'CId':data.msg.CId, 'ProId':data.msg.ProId}, function(json){ //æä½æ¶è´¹éé¢å¤æ 1026 if(json.ret==1){ 1027 window.location.href=data.msg.location; 1028 }else{ 1029 //ä¸ç¬¦å 1030 var tips=(lang_obj.cart.consumption).replace('%low_price%', ueeshop_config.currency_symbols+$('html').currencyFormat(json.msg.low_price, ueeshop_config.currency)).replace('%difference%', ueeshop_config.currency_symbols+$('html').currencyFormat(json.msg.difference, ueeshop_config.currency)); 1031 //global_obj.new_win_alert(tips, function(){ _this.find(opts.button).attr('disabled', false); }, '', undefined, 'await'); 1032 tips(tips); 1033 } 1034 }, 'json'); 1035 } else { 1036 _this.find(opts.button).attr('disabled', false); 1037 tips(data.msg); 1038 } 1039 } 1040 }); 1041 return false; 1042 }); 1043} 1044 1045$.fn.GetTruePixel = function (options) { 1046 $.fn.GetTruePixel.defaults = { 1047 'type' : 'width', // width-宽度 height-é«åº¦ 1048 'padding' : true, // æ¯å¦éè¦padding 1049 'border' : true, // æ¯å¦éè¦border 1050 'margin' : false // æ¯å¦éè¦margin 1051 }; 1052 let _this = this; 1053 let opts = $.extend({},$.fn.GetTruePixel.defaults,options); 1054 let result; 1055 // getBoundingClientRectè·åå°çæ¯å å«border,padding,marginç 1056 if (opts.type == 'width') { 1057 result = _this[0].getBoundingClientRect().width; 1058 } else if (opts.type == 'height') { 1059 result = _this[0].getBoundingClientRect().height; 1060 } 1061 let type_obj = { 1062 'width' : { 1063 'margin' : {'left':'margin-left', 'right':'margin-right'}, 1064 'padding' : {'left':'padding-left', 'right':'padding-right'}, 1065 'border' : {'left':'border-left-width', 'right':'border-right-width'} 1066 }, 1067 'height' : { 1068 'margin' : {'left':'margin-top', 'right':'margin-bottom'}, 1069 'padding' : {'left':'padding-top', 'right':'padding-bottom'}, 1070 'border' : {'left':'border-top-width', 'right':'border-bottom-width'} 1071 } 1072 }; 1073 if (opts.border == false) { 1074 result = result - parseFloat(_this.css(type_obj[opts.type].border.left)) - parseFloat(_this.css(type_obj[opts.type].border.right)); 1075 } 1076 if (opts.padding == false) { 1077 result = result - parseFloat(_this.css(type_obj[opts.type].padding.left)) - parseFloat(_this.css(type_obj[opts.type].padding.right)); 1078 } 1079 if (opts.margin == true) { 1080 result = result + parseFloat(_this.css(type_obj[opts.type].margin.left)) + parseFloat(_this.css(type_obj[opts.type].margin.right)); 1081 } 1082 return result; 1083}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.