1// Generated by CoffeeScript 1.9.3 2(function() { 3 "use strict"; 4 jQuery(function($) { 5 $.ajaxSetup({ 6 cache: true 7 }); 8 var preload, prepareSdk, sdkLoaded; 9 $.support.cors = true; 10 FS2.ns("amazon", { 11 logout: function() { 12 if (typeof amazon !== "undefined") { 13 amazon.Login.logout(); 14 } 15 document.cookie = "amazon_Login_accessToken=; expires=Thu, 01 Jan 1970 00:00:00 GMT"; 16 document.cookie = "amazon_Login_state_cache=; expires=Thu, 01 Jan 1970 00:00:00 GMT"; 17 }, 18 showLwaButtonV2: function() { 19 var buttonConfig = { 20 // set checkout environment 21 merchantId: FS2.val.sellerId, 22 ledgerCurrency: 'JPY', 23 // customize the buyer experience 24 checkoutLanguage: 'ja_JP', 25 productType: 'SignIn', 26 placement: 'Other', 27 buttonColor: FS2.val.amazonButtonColor, 28 // configure sign in 29 signInConfig: { 30 payloadJSON: FS2.val.payload, 31 signature: FS2.val.signature, 32 publicKeyId: FS2.val.publicKeyId, 33 authtoken: FS2.val.v2AuthToken, 34 } 35 }; 36 if (FS2.val.sandboxMode) { 37 buttonConfig.sandbox = true; 38 } 39 amazon.Pay.renderButton('#fs2_lwaButton', buttonConfig); 40 }, 41 showPwaButtonV2: function() { 42 var buttonConfig = { 43 // set checkout environment 44 merchantId: FS2.val.sellerId, 45 ledgerCurrency: 'JPY', 46 // customize the buyer experience 47 checkoutLanguage: 'ja_JP', 48 productType: 'PayAndShip', 49 placement: 'Cart', 50 buttonColor: FS2.val.amazonButtonColor 51 }; 52 if (FS2.val.sandboxMode) { 53 buttonConfig.sandbox = true; 54 } 55 var amazonPayButton = amazon.Pay.renderButton('#fs2_pwaButton', buttonConfig); 56 amazonPayButton.onClick(function() { 57 if (FS2.val.googleAnalyticsEnabled && (ga && !ga.q)) { 58 ga('send', 'event', 'fs2_pay-amazon', 'click', FS2.val.pageName, { 59 'hitCallback': function() { 60 FS2.amazon.submitAndCheckout(amazonPayButton); 61 } 62 }); 63 } else { 64 FS2.amazon.submitAndCheckout(amazonPayButton); 65 } 66 }); 67 }, 68 submitAndCheckout: function(amazonPayButton) { 69 var form = $('#form'); 70 $("<input>").attr("type", "hidden").attr("name", "payWithAmazonV2").appendTo(form); 71 form.submit(); 72 } 73 }); 74 75 preload = function() { 76 var deferred; 77 deferred = $.Deferred(); 78 if (typeof window.preAmazonLogin === "function") { 79 window.preAmazonLogin(deferred); 80 } else { 81 deferred.resolve(); 82 } 83 return deferred.promise(); 84 }; 85 sdkLoaded = false; 86 if (typeof amazon !== "undefined" && typeof amazon.Login !== "undefined" && typeof amazon.Login.authorize !== "undefined") { 87 sdkLoaded = true; 88 } 89 prepareSdk = function() { 90 var deferred; 91 deferred = $.Deferred(); 92 if (sdkLoaded) { 93 deferred.resolve(); 94 return deferred.promise(); 95 } 96 window.onAmazonLoginReady = function() { 97 amazon.Login.setClientId(FS2.val.clientId); 98 amazon.Login.setRegion(amazon.Login.Region.AsiaPacific); 99 amazon.Login.setUseCookie(true); 100 amazon.Login.setSandboxMode(FS2.val.sandboxMode); 101 }; 102 $.getScript("https://assets.loginwithamazon.com/sdk/na/login1.js").done(function(script, textStatus) { 103 sdkLoaded = true; 104 deferred.resolve(); 105 }).fail(function(jqxhr, settings, exception) { 106 throw new Error("[Amazon login1.js error]exception:" + exception); 107 }); 108 return deferred.promise(); 109 }; 110 111 if (FS2.val.v2Enabled) { 112 $("#fs2_lwaButton,#fs2_pwaButton").each(function(i, e) { 113 var button; 114 button = $(e); 115 button.css("cursor", "pointer"); 116 117 if (e.id == 'fs2_pwaButton') { 118 FS2.amazon.showPwaButtonV2(); 119 } else { 120 FS2.amazon.showLwaButtonV2(); 121 } 122 }); 123 } else { 124 $(".FS2_lwaButton,.FS2_pwaButton").each(function(i, e) { 125 var button, isPopup; 126 button = $(e); 127 button.css("cursor", "pointer"); 128 129 isPopup = true; 130 if (FS2.val.popup === false || button.hasClass("FS2_nonpopup")) { 131 isPopup = false;
132 } 133 if (location.pathname.indexOf('/ShoppingCart.html') !== -1 134 || location.pathname.indexOf('/ShoppingCartDetail.html') !== -1) { 135 isPopup = false; 136 } 137 if (FS2.utils.isSSL() && isPopup) { 138 prepareSdk().done(function() { 139 button.click(function(e) { 140 var interactiveOption; 141 e.preventDefault(); 142 interactiveOption = "auto"; 143 if (FS2.val.amazonLoggedOut === true) { 144 FS2.amazon.logout(); 145 interactiveOption = "always"; 146 } 147 amazon.Login.authorize({ 148 scope: "profile payments:widget payments:shipping_address", 149 popup: isPopup, 150 interactive: interactiveOption 151 }, function(response) { 152 if (response.error) { 153 FS2.amazon.logout(); 154 } else { 155 location.href = FS2.val.loginUrl + "?action=" + FS2.val.actionType + "&access_token=" + response.access_token; 156 } 157 }); 158 }); 159 }); 160 } else { 161 button.click(function(e) { 162 e.preventDefault(); 163 if (FS2.val.submit) { 164 return $("#amazonHiddenSubmit").val(encodeURIComponent(location.href)).click(); 165 } else { 166 preload().done(function(callback) { 167 var loginUrl, option, res, timestamp; 168 if (typeof callback === "function") { 169 res = callback(); 170 if (res === false) { 171 return; 172 } 173 } 174 if (isPopup) { 175 loginUrl = FS2.val.loginUrl + "?action=" + FS2.val.actionType; 176 option = FS2.utils.getCenterWindowOption(770, 600); 177 window.open(loginUrl, "fs2_amazon_login", option); 178 } else { 179 timestamp = new Date().getTime(); 180 location.href = FS2.val.loginUrl + "?action=" + FS2.val.actionType + "&popup=0&from=" + (encodeURIComponent(location.href)) + "&ts=" + timestamp; 181 } 182 }); 183 } 184 }); 185 } 186 }); 187 } 188 }); 189}).call(this);
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.