1var cartAddModule = (function ($) { 2 var module = {}; 3 4 module.data = {}; 5 module.dialog = {}; 6 module.apiUrl = ''; 7 module.ajaxErrorList = { 8 'successMsg': 'ã«ã¼ãã«è¿½å ãã¾ãã', 9 'errMsg': 'ã«ã¼ãã«è¿½å ã§ãã¾ããã§ãã', 10 'systemError': 'ã·ã¹ãã ã¨ã©ã¼ãçºçãã¾ããã', 11 'timeOut': 'éä¿¡ã¨ã©ã¼ãçºçãã¾ãããæéãããã¦ããå度ã試ããã ããã' 12 }; 13 module.formName = ''; 14 module.formObj = ''; 15 module.formClass = '.shopping_form'; 16 module.popupClass = '.sps-cartaddAutoPopup'; 17 module.popupInit = { 18 'effect': 'fade', 19 'options': {}, 20 'duration': 500 21 }; 22 module.isAjaxSend = 0; 23 module.isRelatedItem = 0; 24 module.postData = ''; 25 module.cartAddURI = { 26 'PC': 'pc_cart_add.php', 27 'SMP': 'smp_cart_add.php' 28 }; 29 module.apiContentType = 'application/x-www-form-urlencoded; charset=UTF-8'; 30 31 module.smartPhoneAccess = function () { 32 if ( navigator.userAgent.match(/Android/i) 33 || navigator.userAgent.match(/webOS/i) 34 || navigator.userAgent.match(/iPhone/i) 35 || navigator.userAgent.match(/iPod/i) 36 || navigator.userAgent.match(/BlackBerry/i) 37 || navigator.userAgent.match(/Windows Phone/i) 38 ) { 39 return true; 40 } 41 else { 42 return false; 43 } 44 }; 45 46 module.setContentTypeForOldTheme = function () { 47 module.apiContentType = 'application/x-www-form-urlencoded; charset=EUC-JP'; 48 }; 49 50 module.isIOS = function() { 51 return /iP(ad|hone|od)/i.test(navigator.userAgent); 52 }; 53 54 module.isMacOS = function() { 55 return /Mac/i.test(navigator.userAgent); 56 }; 57 58 module.isMSIE = function() { 59 var ua = window.navigator.userAgent; 60 var msie = ua.indexOf('MSIE '); 61 if (msie > -1) { 62 return 1; 63 } else if (navigator.userAgent.match(/Trident.*rv\:11\./)) { 64 return 1; 65 } 66 return 0; 67 }; 68 69 module.buildApiUrl = function (apiCall) { 70 var reqURL = '__CARTURL__/__API__'; 71 72 if (apiCall == undefined) { 73 apiCall = module.cartAddURI.PC; 74 if (module.smartPhoneAccess() == true && cartSmt.status == 1 && cartSmt.useFlg == 1 75 && (Number(cartSmt.redirectToPcSmpFlg) === REDIRECT_TO_PC_SMP_FLAG_JS_SMP 76 || Number(cartSmt.redirectToPcSmpFlg) === REDIRECT_TO_PC_SMP_FLAG_JS_SMP_CART 77 || Number(cartSmt.redirectToPcSmpFlg) === REDIRECT_TO_PC_SMP_FLAG_HTTP_SMP 78 || Number(cartSmt.redirectToPcSmpFlg) === REDIRECT_TO_PC_SMP_FLAG_HTTP_SMP_CART)) { 79 apiCall = module.cartAddURI.SMP; 80 } 81 } 82 83 reqURL = reqURL.replace('__CARTURL__', cartUrlDomain ) 84 .replace('__API__', apiCall); 85 86 module.apiUrl = reqURL; 87 }; 88 89 module.popupPositionAndSize = function() { 90 var w = $(window); 91 $(module.popupClass).css({ 92 'top':Math.abs(((w.height() - $(module.popupClass).outerHeight()) / 2) + w.scrollTop()), 93 'left':Math.abs(((w.width() - $(module.popupClass).outerWidth()) / 2) + w.scrollLeft()), 94 'z-index' : 101 95 }); 96 }; 97 98 module.openPopup = function () { 99 $('.sps-cartAddAutoMsg').append(module.ajaxErrorList.successMsg).show(); 100 module.popupPositionAndSize(); 101 $(module.popupClass).toggle(module.popupInit.effect, module.popupInit.options, module.popupInit.duration); 102 }; 103 104 module.closePopup = function (type) { 105 if (type === 'auto') { 106 setTimeout(function () { 107 $(module.popupClass).hide(module.popupInit.effect, module.popupInit.options, module.popupInit.duration); 108 module.buttonCartAction('enabled'); 109 module.isAjaxSend = 0; 110 }, 1000); 111 } else { 112 $(module.popupClass).hide(module.popupInit.effect, module.popupInit.options, module.popupInit.duration); 113 module.buttonCartAction('enabled'); 114 module.isAjaxSend = 0; 115 } 116 }; 117 118 module.buildDialog = function () { 119 module.dialog = $('div[class=sps-cartaddModal]').dialog({ 120 modal: true, 121 draggable: false, 122 autoOpen: false, 123 resizable: false, 124 width: 'auto', 125 height: 'auto', 126 hide: 'fade', 127 show: 'fade', 128 open: function (event, ui) { 129 module.removeMaskCartAdd(); 130 var isError = $(this).data('isError'); 131 if (isError == 1) { 132 $(".sps-cartaddModal").css("min-height", 0); 133 module.hideButtonDialog(); 134 } 135 $('div.sps-cartaddModal').find('a').css('outline', 'none'); 136 $(this).scrollTop(0); 137 }, 138 close: function() { 139 var needReload = $(this).data('needReload'); 140 if (needReload == 1) { 141 window.location.reload(true); 142 } 143 module.isAjaxSend = 0; 144 module.buttonCartAction('enabled'); 145 } 146 }); 147 }; 148 149 module.openDialog = function () { 150 module.dialog.dialog('open'); 151 }; 152 153 module.closeDialog = function () { 154 module.dialog.dialog('close'); 155 }; 156 157 module.setFormName = function (nameInput) { 158 if (nameInput != "" && nameInput != undefined) { 159 module.formName = 'form[name="' + nameInput + '"]'; 160 } 161 }; 162 163 module.setFormObj = function (formInput) { 164 if (formInput !== '' && formInput != undefined) { 165 module.formObj = formInput; 166 } 167 }; 168 169 module.clearMessage = function() { 170 $('.sps-cartAddAutoMsg').empty().hide(); 171 $('.sps-cartaddSuccessMsg').empty().hide(); 172 $('.sps-cartaddErrMsg').empty().hide(); 173 $('.sps-cartaddErrDetail').empty().hide(); 174 }; 175 176 module.maskCartAdd = function () { 177 var options = { 178 'opacity': 0.3, 179 'width': '100%', 180 'height': '100%', 181 'top': 0, 182 'left': 0, 183 'background-color': '#AAAAAA', 184 'z-index': 99999, 185 'position': 'fixed' 186 }; 187 188 $('body').append('<div class="sps-cartaddMask"></div>'); 189 $('.sps-cartaddMask').css(options); 190 }; 191 192 module.removeMaskCartAdd = function () { 193 $('.sps-cartaddMask').remove(); 194 }; 195 196 module.hideButtonDialog = function() { 197 $('.sps-cartaddBtnContent').hide(); 198 $('.sps-cartaddCartlink').hide(); 199 $('.sps-cartaddClose').hide(); 200 }; 201 202 module.showButtonDialog = function() { 203 $('.sps-cartaddBtnContent').show(); 204 $('.sps-cartaddCartlink').show(); 205 $('.sps-cartaddClose').show(); 206 }; 207 208 module.showError = function (errClass, errMsgClass, errMsg, errorList) { 209 module.dialog.data('isError', 1); 210 $(errMsgClass).removeAttr('style'); 211 $(errMsgClass).empty(); 212 $(errClass).removeAttr('style'); 213 $(errClass).empty(); 214 215 $(errMsgClass).append(errMsg); 216 217 if (errorList == undefined) { 218 $(errMsgClass).css('min-width', '225px'); 219 $(errClass).hide(); 220 return; 221 } 222 223 if ($.type(errorList) === 'string') { 224 if (errorList == '') { 225 $(errMsgClass).css('min-width', '225px'); 226 $(errClass).hide(); 227 } else { 228 $(errClass).append('<div>' + errorList + '</div>'); 229 } 230 return; 231 } 232 233 var errorString = ''; 234 $.each(errorList, function (index, value) { 235 if (index == 'C0032' || index == 'C0021' || index == 'CART-E0014' || index == 'CART-E0002') { 236 module.dialog.data('needReload', 1); 237 } 238 if ($.type(value) === 'array') { 239 $.each(value, function (valueIndex, valueVal) { 240 errorString += '<div>'+valueVal+'</div>'; 241 }); 242 } else { 243 errorString += '<div>'+value+'</div>'; 244 } 245 }); 246 $(errClass).append(errorString); 247 }; 248 249 module.showSuccess = function (successClass, successStr) { 250 module.dialog.data('isError', 0); 251 $(successClass).removeAttr('style'); 252 $(successClass).empty(); 253 $(successClass).append(successStr + '<br />'); 254 }; 255 256 module.replaceCart = function (data) { 257 if (data.length == 0) { 258 return false;
259 } 260 261 var cartClassList = { 262 '.sps-cartItmCnt': data.itemCnt, 263 '.sps-cartItmTotal': data.itemTotal, 264 '.sps-cartItmDiscountTotal': data.itmDiscountTotal, 265 '.sps-cartRemainingFreeShipping': data.remainFreeShipping 266 }; 267 268 $.each(cartClassList, function (index, value) { 269 if ($(index).length) { 270 if ($(index).hasClass('number_comma')) { 271 value = value.toLocaleString(); 272 if ($(index).parent('.member_cart_info').is(':hidden') && value > 0) { 273 $(index).parent('.member_cart_info').show(); 274 } 275 } 276 $(index).html(value); 277 } 278 }); 279 280 let memberInfoCartInfo = $('.member_info_cart_info'); 281 for (let i = 0; i <= memberInfoCartInfo.length; i++) { 282 let memberInfo = memberInfoCartInfo[i]; 283 if (memberInfo !== undefined) { 284 let memberInfoElements = $(memberInfo); 285 let objShippingBox = $('span', memberInfoElements).filter(function () { 286 return this?.className.match(/^shipping_box_(\d+|none)$/); 287 }); 288 if (objShippingBox.length > 1) { 289 for (let i = 1; i < objShippingBox.length; i++) { 290 objShippingBox[i].remove(); 291 } 292 } 293 if (data.hasScPatternMessages !== 'none') { 294 let messageMaru = $('span.' + objShippingBox[0]?.className).removeClass(objShippingBox[0]?.className).addClass('shipping_box_' + data.hasScPatternMessages); 295 messageMaru.find('.shipping_box').html(data.sc_pattern_messages); 296 } else if (objShippingBox.length) { 297 $('span.' + objShippingBox[0]?.className).removeClass(objShippingBox[0]?.className).addClass('shipping_box_' + data.remainFreeShipping); 298 } 299 } 300 } 301 var removeClassFreeShippingNum = 1, 302 addClassFreeShippingNum = data.isFreeShipping; 303 if (data.isFreeShipping == 1) { 304 removeClassFreeShippingNum = 0; 305 } 306 if ($('.more_maru_' + removeClassFreeShippingNum).length) { 307 $('.more_maru_' + removeClassFreeShippingNum).addClass('more_maru_' + addClassFreeShippingNum).removeClass('more_maru_' + removeClassFreeShippingNum); 308 } 309 if ($('.free_shipping_' + removeClassFreeShippingNum).length) { 310 $('.free_shipping_' + removeClassFreeShippingNum).addClass('free_shipping_' + addClassFreeShippingNum).removeClass('free_shipping_' + removeClassFreeShippingNum); 311 } 312 if (data.ga4AddToCartTrackingCode && typeof gtag === 'function') { 313 $('body').append(data.ga4AddToCartTrackingCode); 314 } 315 }; 316 317 module.buttonCartAction = function(action) { 318 var cartSubmit = $(module.formClass).find('input[type=submit]'), 319 cartButton = $(module.formClass).find('input[type=button]'), 320 cartImageButton = $(module.formClass).find('input[type=image]'), 321 wishlistCartButton = $('.wish_add_cart'); 322 323 if (action === 'disabled') { 324 cartSubmit.prop('disabled', true); 325 cartButton.prop('disabled', true); 326 cartImageButton.prop('disabled', true); 327 wishlistCartButton.prop('disabled', true); 328 } else if (action === 'enabled') { 329 cartSubmit.prop('disabled', false); 330 cartButton.prop('disabled', false); 331 cartImageButton.prop('disabled', false); 332 wishlistCartButton.prop('disabled', false); 333 } 334 }; 335 336 module.showModal = function() { 337 if (addCartBackground === 2) { 338 module.openPopup(); 339 module.closePopup('auto'); 340 } else if(addCartBackground === 1) { 341 module.openDialog(); 342 } 343 }; 344 345 module.numberFromTwoByteToOneByte = function (inputParam) { 346 return inputParam.replace(/[ï¼-ï¼]/g,function(s){return String.fromCharCode(s.charCodeAt(0)-0xFEE0)}); 347 }; 348 349 module.ajaxPostData = function(shoppingFormObj) { 350 var shoppingInputList = shoppingFormObj.serializeArray(); 351 $.each(shoppingInputList, function (inputKey, inputVal) { 352 if (inputVal.name.match(/CNT-/g) && inputVal.value != "") { 353 shoppingInputList[inputKey].value = module.numberFromTwoByteToOneByte(inputVal.value); 354 } 355 }); 356 var ajaxObject = { 357 'name': 'ajax', 358 'value': 1 359 }; 360 shoppingInputList.push(ajaxObject); 361 module.postData = $.param(shoppingInputList); 362 }; 363 364 module.blurFocus = function () { 365 if (module.formName != '') { 366 shoppingFormSelector = module.formName; 367 } else if (module.formObj != '') { 368 shoppingFormSelector = module.formObj 369 } 370 var shoppingForm = $(shoppingFormSelector), 371 inputCNT1 = $(shoppingForm).find('input[name="CNT-1"]'); 372 373 if (inputCNT1.length) { 374 inputCNT1.blur(); 375 } 376 module.buttonCartAction('disabled'); 377 }; 378 379 module.executeApi = function () { 380 var shoppingFormSelector = module.formClass; 381 if (module.formName != '') { 382 shoppingFormSelector = module.formName; 383 } else if (module.formObj != '') { 384 shoppingFormSelector = module.formObj 385 } 386 var shoppingForm = $(shoppingFormSelector); 387 if ((module.isIOS() || module.isMacOS()) && cartDomainName !== 'store_domain') { 388 shoppingForm.submit(); 389 return false;
390 } 391 if (module.isAjaxSend == 1) { 392 return false; 393 } 394 module.isAjaxSend = 1; 395 module.clearMessage(); 396 module.hideButtonDialog(); 397 398 if (addCartBackground !== 2) { 399 module.maskCartAdd(); 400 } 401 402 var inputCNT1 = $(shoppingForm).find('input[name="CNT-1"]'); 403 module.ajaxPostData(shoppingForm); 404 405 if (inputCNT1.length) { 406 inputCNT1.blur(); 407 } 408 409 module.buttonCartAction('disabled'); 410 module.dialog.data('shoppingFormSelector', shoppingFormSelector); 411 module.dialog.data('needReload', 0); 412 413 $.ajax({ 414 url: module.apiUrl, 415 timeout: 60000, 416 type: 'POST', 417 dataType: 'json', 418 data: module.postData, 419 xhrFields: { 420 withCredentials: true 421 }, 422 cache: true, 423 crossDomain: true 424 }).done(function (response) { 425 if (response.success == 0) { 426 if (response.errors.MEMBER_0001 != undefined) { 427 shoppingForm.submit(); 428 return false; 429 } 430 module.replaceCart(response.data); 431 module.showError('.sps-cartaddErrDetail', '.sps-cartaddErrMsg', module.ajaxErrorList.errMsg, response.errors); 432 module.openDialog(); 433 if (addCartBackground === 1 && typeof response.errors['CART-CAMPAIGN-002'] != 'undefined') { 434 module.showButtonDialog(); 435 } 436 } 437 if (response.success == 1) { 438 module.replaceCart(response.data); 439 module.showSuccess('.sps-cartaddSuccessMsg', module.ajaxErrorList.successMsg); 440 module.showButtonDialog(); 441 module.showModal(); 442 } 443 if (response.success == 3) { 444 module.showSuccess('.sps-cartaddErrDetail', response.errors['CART-CAMPAIGN-001']); 445 446 if (addCartBackground === 2) { 447 module.hideButtonDialog(); 448 } else { 449 module.showButtonDialog(); 450 } 451 452 module.replaceCart(response.data); 453 module.openDialog(); 454 } 455 }).fail(function (jqXHR, textStatus, thrownError) { 456 if (textStatus === 'timeout') { 457 module.showError('.sps-cartaddErrDetail', '.sps-cartaddErrMsg', module.ajaxErrorList.errMsg, module.ajaxErrorList.timeOut); 458 } else if (jqXHR.status === 0) { 459 module.showError('.sps-cartaddErrDetail', '.sps-cartaddErrMsg', module.ajaxErrorList.systemError, jqXHR.responseText); 460 } else { 461 module.showError('.sps-cartaddErrDetail', '.sps-cartaddErrMsg', module.ajaxErrorList.systemError, jqXHR.responseText); 462 } 463 module.hideButtonDialog(); 464 module.openDialog(); 465 }); 466 }; 467 468 module.dialogPosition = function() { 469 var w = $(window); 470 $("#sps-cartaddModal").parent().css({ 471 'top':Math.abs(((w.height() - $("#sps-cartaddModal").parent().outerHeight()) / 2) + w.scrollTop()), 472 'left':Math.abs(((w.width() - $("#sps-cartaddModal").parent().outerWidth()) / 2) + w.scrollLeft()) 473 }); 474 }; 475 476 return module; 477})(jQuery); 478 479(function ($) { 480 $(document).ready(function() { 481 cartAddModule.buildDialog(); 482 483 $(document).on('click', '.sps_smpCartAddBtn', function (e) { 484 var valid = $('.shopping_form')[0].checkValidity(); 485 if (valid) { 486 e.preventDefault(); 487 cartAddModule.buildApiUrl('smp_cart_add.php'); 488 cartAddModule.executeApi(); 489 } 490 }); 491 492 $(document).on('click', '.sps-cartaddClose, .sps-cartaddModalClose, .ui-widget-overlay', function () { 493 cartAddModule.closeDialog(); 494 }); 495 }); 496 497 $(window).resize(function() { 498 if (addCartBackground === 2) { 499 cartAddModule.popupPositionAndSize(); 500 } else if(addCartBackground === 1) { 501 cartAddModule.dialogPosition(); 502 } 503 }); 504})(jQuery);
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.