1/* 2 * @Author: your name 3 * @Date: 2021-05-14 14:02:25 4 * @LastEditTime: 2021-07-16 17:02:00 5 * @LastEditors: Please set LastEditors 6 * @Description: In User Settings Edit 7 * @FilePath: \amazon-backend\rank-monitor\src\main\webapp\assets-v2\js\module-publick-IPS-language.js 8 */ 9$(function () { 10 var Fn = { 11 node: { 12 $body: $("body"), 13 text: {}, 14 handler: null, 15 $globalBindWechatModal: $("#global-bind-wechat-modal"), 16 current_clientId: null, 17 // æä»¶ç¸å ³ä¿¡æ¯ï¼ä¸ºç©ºæ¶è¡¨ç¤ºæªå®è£ æä»¶ï¼å¼ç¤ºä¾:{id:'xxx', version:'3.0.0'} 18 // v3.0.3èµ·æå¼å§èµå¼ 19 // v3.0.7èµ·ï¼å¢å 屿§ source S=store(å¨çº¿å®è£ ) L=local(æ¬å°å®è£ ) éç¨äºchromeå æ ¸æµè§å¨ 20 extension: null, 21 }, 22 init: function (lang, module) { 23 let that = this; 24 that.initCustomEventListener(); 25 // å ¨å±å è´¹ç¨æ·ç»å®äºç»´ç 26 that.node.$body.on("click", ".globalBindWechatBtn", function () { 27 that.showGlobalBindWechat($(this)); 28 return; 29 }); 30 that.node.$globalBindWechatModal.on("click", ".qr-code.islose", function () { 31 that.getQrCode(); 32 return; 33 }); 34 that.node.$globalBindWechatModal.on("show.bs.modal", function (event) { 35 that.getQrCode(); 36 }); 37 that.node.$globalBindWechatModal.on('hide.bs.modal', function (event) { 38 that.node.handler && clearInterval(that.node.handler); 39 }); 40 // 夿æ¯å¦å«æäºé©¬éurl 妿æåæªåasinï¼å¦ææç©ºæ ¼åéå·å·åä¸å 41 that.node.$body.on("input",'.searchGetLinkAsin',function(){ 42 that.detectionGetLinkAsin($(this)); 43 return 44 }); 45 if(that.newBeginnerLocalStorage(false, 'RESTRICTED_fREE_PROMOTION') != 'N' && $(".restricted-free-promotion-modal").length){ 46 $(".restricted-free-promotion-modal").addClass("isopen"); 47 } 48 // éæ¶å è´¹æ¨å¹¿ 49 that.node.$body.on("click",".restricted-free-promotion-modal .switch-restricted",function(){ 50 let itemSwitch = $(this).is(".show-restricted"); 51 $(".restricted-free-promotion-modal").removeClass("isopen").addClass(itemSwitch?"isopen":""); 52 that.newBeginnerLocalStorage(!itemSwitch, 'RESTRICTED_fREE_PROMOTION',); 53 window.localStorage.setItem('RESTRICTED_fREE_PROMOTION', itemSwitch?'Y':'N'); 54 return; 55 }); 56 }, 57 AddTopIPSDynamically: function () { 58 let that = this; 59 if ($("#add-topIPS-dynamically").length) { 60 return; 61 } 62 // 1å°æ¶è¯·æ±ä¸æ¬¡ 63 let local_cached_hour_key = 'TOP_SCROLL_HIT_HOUR_TIME', 64 cached = localStorage.getItem(local_cached_hour_key); 65 try{if (cached != null && new Date(parseInt(cached)).getTime() > new Date().getTime() - 3600000) return false;}catch (e) {} 66 67 let TopIPShtml = '<div class="add-topIPS-dynamically" id="add-topIPS-dynamically" style="display:block"><div class="d-flex topIPS-dynamically-flex" >' 68 TopIPShtml += '<div class="topIPS-dynamically-content flex-customer-1"></div>' 69 TopIPShtml += '<i class="iconfont icon-shanchu ml-4" style="margin:0"></i>' 70 TopIPShtml += '</div></div>' 71 $.ajax({ 72 type: 'get', 73 url: '/v2/top-scroll/one', 74 contentType: "application/json;charset=UTF-8", 75 data: {}, 76 dataType: 'json', 77 async: false, 78 success: function (result) { 79 if (result && result.code === "OK") localStorage.setItem(local_cached_hour_key, new Date().getTime()); 80 81 if (result && result.code === "OK" && result.data) { 82 // å 餿 è¯ç¬¦ï¼æ¯æ¬¡é½è¯·æ± 83 localStorage.removeItem(local_cached_hour_key); 84 85 $("body").prepend(TopIPShtml); 86 if (result.backgroundImage) { 87 const img = new Image(); 88 img.onload = function() { 89 $("#add-topIPS-dynamically").css({ 90 "background-image": "url(" + result.backgroundImage
90+ ")" 91 }) 92 }; 93 img.src = result.backgroundImage; 94 } 95 $("#add-topIPS-dynamically").attr("data-url", result.url).attr("data-tipsId", result.tipsId).find(".topIPS-dynamically-content").html(result.content).end() 96 .fadeIn(); 97 $("#add-topIPS-dynamically").on("click", ".icon-shanchu", function (event) { 98 that.readTipIPSDynamically($(this)); 99 event.stopPropagation(); 100 }); 101 $("#add-topIPS-dynamically").on("click", ".topIPS-dynamically-flex", function () { 102 that.readTipIPSDynamically($(this), 'link'); 103 }); 104 } else { 105 $("#add-topIPS-dynamically").remove(); 106 } 107 108 } 109 }) 110 }, 111 112 readTipIPSDynamically: function ($this, isUrl) { 113 let tipsId = $this.parents(".add-topIPS-dynamically").attr("data-tipsId"), 114 isLinkUrl = $this.parents(".add-topIPS-dynamically").attr("data-url"); 115 isUrl ? window.open(isLinkUrl) : null; 116 $this.parents(".add-topIPS-dynamically").remove(); 117 if (!tipsId) { 118 return 119 } 120 $.ajax({ 121 type: 'get', 122 url: '/v2/top-scroll/read?tipsId=' + tipsId, 123 contentType: "application/json;charset=UTF-8", 124 data: {}, 125 dataType: 'json', 126 async: false, 127 success: function (result) { 128 if (result && result.code == "OK") {} else {} 129 } 130 }) 131 }, 132 // å ¨å±å è´¹ç¨æ·ç»å®å¾®ä¿¡ 133 showGlobalBindWechat: function ($this) { 134 let that = this; 135 that.node.current_clientId = $this.attr("data-current_clientId"); 136 that.node.current_clientId ? that.node.$globalBindWechatModal.modal("show") : null; 137 }, 138 showGlobalBindWechatInit:function(ele){ 139 this.showGlobalBindWechat($(ele)); 140 }, 141 // ç»å®å¾®ä¿¡ 142 getQrCode: function () { 143 let that = this; 144 that.node.handler && clearInterval(that.node.handler); 145 that.node.$globalBindWechatModal.find('.qr-tips').text('').end().find(".qr-code").removeClass("islose"); 146 $.ajax({ 147 type: "get", 148 url: "/v2/wx/getQrCodeTicket/" + that.node.current_clientId + "?fresh=" + true + "&bind=" + false, 149 dataType: "json", 150 success: function (data) { 151 if (data.code === 200) { 152 var url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + data.ticket; 153 that.node.$globalBindWechatModal.find('.qr-code').attr('src', url); 154 setTimeout(function () { 155 that.node.$globalBindWechatModal.find(".qr-code").addClass("islose").end().find('.qr-tips').addClass('text-danger').text('äºç»´ç è¿æ,ç¹å»äºç»´ç å·æ°'); 156 }, 60000); 157 that.getScanState(data); 158 } 159 } 160 }); 161 }, 162 getScanState: function (data) { 163 let that = this, 164 k = 40; 165 that.node.handler = setInterval(function () { 166 if (k < 0) { 167 that.node.handler && clearInterval(that.node.handler); 168 return; 169 } 170 k--; 171 $.ajax({ 172 type: "get", 173 url: "/v2/wx/getQrState?ticket=" + data.ticket, 174 dataType: "json", 175 success: function (state) { 176 clearInterval(that.node.handler); 177 var code = state.code; 178 if (code === 1003) { 179 // 微信ç»å®æåå妿ä¹åææéå¯åä¸ç¨è°ç¨å次æéæ¥å£ 180 swal({ 181 title: '微信ç»å®æå!', 182 text: '', 183 imageUrl: '../../../assets/images/bounced-successful.png', 184 imageSize: '70x70',
185 showConfirmButton: false, 186 timer: 2000 187 }).then(function(){ 188 that.node.$globalBindWechatModal.modal("hide"); 189 // 妿æ¯ç»å®å¾®ä¿¡æååå ³éå¼¹çª 190 window.location.reload(); 191 }); 192 } else if (code === 404) { 193 swal({ 194 type: 'error', 195 title: 'ç»å®å¤±è´¥ï¼', 196 text: state.message, 197 showConfirmButton: false, 198 timer: 2000 199 }).then(function () { 200 that.getQrCode(); 201 }); 202 } 203 } 204 }) 205 }, 1500); 206 }, 207 // 夿æ¯å¦è¾å ¥urlå°å 208 fGetAsin:function(url){ 209 if (/(product[-reviews]?)|(dp)\/[A-Z0-9]{8,15}(([\/|\b|\s|\\?]+)|($))/i.test(url)) { 210 let match = url.match(/\/([A-Z0-9]{8,15})(([\/|\b|\s|\\?]+)|($))/i); 211 return match ? match[1].toUpperCase() : null; 212 } 213 return null; 214 }, 215 // æªåurlå°åä¸çasin 216 fIsAtListingPage:function(url){ 217 return url && this.fGetWebsite(url).indexOf('www.amazon.') >= 0 && /\/(dp|product)\/[A-Z0-9]{8,15}(([\/|\b|\s|\\?]+)|($))/i.test(url); 218 }, 219 fGetWebsite:function(url){ 220 let match = url.match(/(?:http(?:s)?:\/\/)?(?:www\.)?(.*?)(\.[-\w]+)+/); 221 return match ? match[0] : ''; 222 }, 223 detectionGetLinkAsin:function($this){ 224 let val = $this.val(),linkVal = null,isLink=null,that = this; 225 let isMoreLinkAsin = $this.is(".isMoreLinkAsin") || false,queryAsins = [],parameters; 226 let errorTips = GLOBAL_MOMENT_LANGUAGE == 'jp'?'è§£æã§ããªããã¾ãã¯ãªã³ã¯ã«æå¹ãªASINãå«ã¾ãã¦ããªã': (GLOBAL_MOMENT_LANGUAGE == 'en'?'The link cannot be resolved or the link does not contain any valid ASIN':'æ æ³è§£ææè¯¥é¾æ¥ä¸å 嫿æASIN') 227 // æ¯æå¤ä¸ªasin linkè§£æ 228 if(isMoreLinkAsin){ 229 let asin = $this.val(),isShowAllAsin = false,isLinkVal = false,asinParameters, 230 asinsArry = asin.split(/[,ï¼\s]/); 231 if(asinsArry.length>1){ 232 for (var x in asinsArry){ 233 if (!asinsArry[x].trim()) continue; 234 asinParameters = that.singleOrMultiple(asinsArry[x]); 235 if(asinParameters.linkVal){ 236 isLinkVal = true; 237 queryAsins.push(asinParameters.val); 238 }else{ 239 if(asinParameters.isLink){ 240 isShowAllAsin = true; 241 break; 242 }else{ 243 queryAsins.push(asinsArry[x]); 244 } 245 } 246 } 247 if(isShowAllAsin){ 248 asinParameters.isLink?createYgtoastError(errorTips,6000):null; 249 return; 250 } 251 if(!isLinkVal){ 252 return; 253 } 254 parameters={ 255 val:queryAsins.join(" "), 256 linkVal:true, 257 isLink:false 258 }; 259 }else{ 260 parameters = that.singleOrMultiple(val); 261 } 262 }else{ 263 parameters = that.singleOrMultiple(val); 264 } 265 if(parameters.linkVal){ 266 $this.val(parameters.val); 267 }else{ 268 parameters.isLink?createYgtoastError(errorTips,6000):null; 269 } 270 }, 271 singleOrMultiple:function(val){
272 linkVal = (/[,ï¼\s]/).test(val)?false:window.ModulePublickIPSJPENCN.fIsAtListingPage(val); 273 isLink = window.ModulePublickIPSJPENCN.fGetWebsite(val),parameters={ 274 val:linkVal?window.ModulePublickIPSJPENCN.fGetAsin(val):null, 275 linkVal:linkVal, 276 isLink:isLink 277 }; 278 return parameters; 279 }, 280 // 䏿çæçå·é£é©çåè´¦å·æç¤º 281 riskSubClientTips:function(){ 282 swal({ 283 html: "<div>æ¨çè´¦å·æè¢«çé£é©ï¼</div> <div>请尽快èç³»æ¨ç主账å·ç®¡çåä¿®æ¹å¯ç ï¼</div>", 284 imageUrl:'../../../assets/images/bounced-warning.png', 285 showConfirmButton: true, 286 confirmButtonColor: '#FB8C1E', 287 confirmButtonText: 'ç¡®å®', 288 }).then((isConfirm) => { 289 try { 290 window.location.replace("/w/user/logout") 291 } catch (e) { 292 293 } 294 } 295 ); 296 }, 297 rentAccountTips: function () { 298 swal({ 299 title: "ðç³ç³ï¼åç°ä½ çåå®¶ç²¾çµè´¦å·æä¸ªå®å ¨é£é©â¦â¦", 300 html: "<br><p style='text-align:left;'>è¿æåç°ä½ çè´¦å·æå¤äºº/å¤å°ä½¿ç¨å«çï¼è¿æå³çä½ å¨åå®¶ç²¾çµä¸ç使ç¨è®°å½ï¼æå¯è½è¢«ä»äººå·çª¥ðæå©ç¨å¦ï¼</p>" + 301 "<p style='text-align:left;'>è¾è¾è¦è¦éå°çæ½åçåæä¼è´¨æµéè¯ï¼å¯ä¸è¦å°±è¿æ ·è¢«äººå·å·æ¿èµ°å¦ã</p>" + 302 "<p style='text-align:left;'>â 建议账å·ä¸å ±äº«ï¼ä¸å¤åï¼å®æ¤æ°æ®éç§ï¼å°±æ¯å®æ¤è´¢å¯ï¼ </p>" + 303 "<p style='text-align:left;'>â 请å°ä¸ªäººä¸å¿ç»å®å¾®ä¿¡éæ°ç»å½ï¼è¿æ ·è´¦å·æ´æå®å ¨ä¿éå¦ï¼</p>", 304 width:500, 305 showConfirmButton: true, 306 confirmButtonColor: '#FB8C1E', 307 confirmButtonText: 'åå¾ä¸ªäººä¸å¿', 308 }).then((isConfirm) => { 309 try { 310 // æ è®°å¼¹çªæ¶é´ 311 localStorage.setItem('popViewModal',new Date().getTime()); 312 window.location.replace("/v2/me") 313 } catch (e) { 314 } 315 } 316 ); 317 }, 318 // èªå®ä¹äºä»¶çå¬ 319 initCustomEventListener: function () { 320 let that = this; 321 322 // æä»¶çæ¬ 323 const EXT_VERSION_EVENT = 'sellersprite_ext_version'; 324 window.removeEventListener(EXT_VERSION_EVENT, function () {}); 325 window.addEventListener(EXT_VERSION_EVENT, function (e) { 326 const detail = e && e.detail; 327 if (null == detail) return; 328 that.node.extension = detail; 329 }); 330 }, 331 newBeginnerLocalStorage:function(newbie_switch, beginner_guide) { 332 newbie_switch = newbie_switch ? newbie_switch : false; 333 if (window.localStorage) { 334 let itemLen = window.localStorage.getItem(beginner_guide); 335 if (!newbie_switch) { 336 return itemLen; 337 } else { 338 window.localStorage.setItem(beginner_guide, newbie_switch); 339 } 340 } 341 return false; 342 } 343 344 }; 345 window.ModulePublickIPSJPENCN = Fn; 346 window.ModulePublickIPSJPENCN.init(); 347}); 348 349//sceneTips已读 350function sceneTipsRead(sceneTipsId, sceneTipsUri) { 351 $.ajax({ 352 type: 'POST', 353 url: '/v2/fragment/sceneTipsRead', 354 dataType: 'json', 355 data: { 356 id: sceneTipsId 357 }, 358 async: false, 359 success: function (result) { 360 if (result.code === "OK") { 361 let sceneTipsUriClass = "." + sceneTipsUri; 362 $(sceneTipsUriClass).popover("hide").popover('dispose'); 363 } 364 } 365 }); 366} 367function sceneTipsReadNext(sceneTipsId, sceneTipsUri,nextUrl) { 368 $.ajax({ 369 type: 'POST', 370 url: '/v2/fragment/sceneTipsRead', 371 dataType: 'json', 372 data: { 373 id: sceneTipsId 374 }, 375 async: false, 376 success: function (result) { 377 if (result.code === "OK") { 378 let sceneTipsUriClass = "." + sceneTipsUri; 379 handleSetSceneTips(nextUrl) 380 $(sceneTipsUriClass).popover("hide").popover('dispose'); 381 382 } 383 } 384 }); 385} 386function createYgtoastError(str,duration) { 387 let toastHtml = '<div class="toast-content-box position-center"><div class="toast toast-error" aria-live="polite"><div class="toast-message"></div></div></div>'; 388 document.querySelector(".toast-content-box")?'':$("body").append(toastHtml); //å½è¿æ²¡hideæ¶ç¦æ¢éå¤ç¹å» 389 $(".toast-content-box").fadeIn().find(".toast-message").html('<i class="iconfont icon-sigh mr-2"></i>'+str); 390 setTimeout(function(){ 391 $(".toast-content-box").fadeOut(); 392 },duration) 393} 394 395String.prototype.format = function () { 396 let a = this; 397 for (let b = 0; b < arguments.length; b++) { 398 a = a.replace(RegExp("\\{" + (b + 1) + "\\}", "ig"), arguments[b]); 399 } 400 return a 401};
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.