PluginProbe
Welcart e-Commerce / 2.11.30
Welcart e-Commerce v2.11.30
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / js / member_escott.js

member_escott.js in Welcart e-Commerce 2.11.30, at js/member_escott.js

161 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready( function($) {
2 $(document).on( "change", "#expmm", function(e) {
3 $("input[name='expmm']").val($("#expmm option:selected").val());
4 });
5 $(document).on( "change", "#expyy", function(e) {
6 $("input[name='expyy']").val($("#expyy option:selected").val());
7 });
8 if ( 'on' == escott_params.sec3d_activate ) {
9 if( !$("#memberinfo").length ) {
10 $('body input[type="submit"]').each( function(i,e) {
11 if( "editmember" == $(this).attr("name") ) {
12 $(this).parents("form").attr("id","memberinfo");
13 }
14 });
15 }
16 var agree_dialog = '<div id="escott-agree-dialog">'
17 +'<textarea class="escott_agreement_message" readonly>'+escott_params.message.agreement+'</textarea>'
18 +'<div class="send agree_form_send">'
19 +'<input type="button" id="escott_agree_cancel" class="back_to_delivery_button" value="'+escott_params.message.disagree+'" />&nbsp;&nbsp;'
20 +'<input type="button" id="escott_agree_next" class="to_confirm_button" value="'+escott_params.message.agree+'" />'
21 +'</div>'
22 +'</div><input type="hidden" id="escott_agree" value=""><input type="hidden" id="escott_settlement_mode" value="">';
23 $("#memberinfo").after(agree_dialog);
24 $("#escott-agree-dialog .send").css("text-align","center");
25 $("#escott-agree-dialog").css("display","none");
26 }
27 });
28 jQuery( function($) {
29
30 const isNumberString = n => typeof n === 'string' && n !== '' && !isNaN(n);
31
32 memberEScott = {
33 getToken: function() {
34 if( $("#register").val() != undefined ) {
35 var check = true;
36 if( !isNumberString($("#cardno").val()) ) {
37 check = false;
38 }
39 if( undefined == $("#expyy").get(0) || undefined == $("#expmm").get(0) ) {
40 check = false;
41 } else if( !isNumberString($("#expyy option:selected").val()) || !isNumberString($("#expmm option:selected").val()) ) {
42 check = false;
43 }
44 if( $("#seccd").val() != undefined ) {
45 if( !isNumberString($("#seccd").val()) ) {
46 check = false;
47 }
48 }
49 if( !check ) {
50 alert(uscesL10n.escott_token_error_message);
51 return false;
52 }
53 }
54 if( !isValidInput($("#cardname").val()) ) {
55 alert(uscesL10n.escott_token_error_message);
56 return false;
57 }
58
59 var cardno = $("#cardno").val();
60 var expyy = $("#expyy option:selected").val();
61 if( "" != expyy ) {
62 expyy = expyy.substr(-2,2);
63 }
64 var expmm = $("#expmm option:selected").val();
65 var seccd = ( $("#seccd").val() != undefined ) ? $("#seccd").val() : "";
66
67 SpsvApi.spsvCreateToken(cardno,expyy,expmm,seccd,"","","","","");
68 }
69 };
70
71 $(document).on( "click", "#card-register", function(e) {
72 if( $("#token").val() != undefined ) {
73 memberEScott.getToken();
74 } else {
75 $("#member-card-info").submit();
76 }
77 });
78
79 $(document).on( "click", "#card-update", function(e) {
80 if( $("#token").val() != undefined ) {
81 if( "" == $("#cardno").val() ) {
82 if( 'on' == escott_params.sec3d_activate ) {
83 if( !isValidInput($("#cardname").val()) ) {
84 alert(uscesL10n.escott_token_error_message);
85 return false;
86 }
87 }
88 $("#member-card-info").submit();
89 } else {
90 memberEScott.getToken();
91 }
92 } else {
93 $("#member-card-info").submit();
94 }
95 });
96
97 $("#escott-agree-dialog").dialog({
98 bgiframe: true,
99 autoOpen: false,
100 height: "400",
101 width: "200",
102 resizable: true,
103 modal: true,
104 create: function() {
105 $("#escott-agree-dialog").parent(".ui-dialog").attr("id","escott-dialog");
106 },
107 open: function() {
108 },
109 close: function() {
110 }
111 });
112
113 $(document).on( "click", "#escott_agree_next", function(e) {
114 $("#escott_agree").val("agree");
115 $("#escott-agree-dialog").dialog("close");
116 if ( $("#escott_settlement_mode").val() == "update" ) {
117 location.href = decodeURIComponent(escott_params.update_settlement_url);
118 } else {
119 location.href = decodeURIComponent(escott_params.register_settlement_url);
120 }
121 return false;
122 });
123
124 $(document).on( "click", "#escott_agree_cancel", function(e) {
125 $("#escott_agree").val("");
126 $("#escott-agree-dialog").dialog("close");
127 });
128
129 $(document).on( "click", ".escott_agreement", function(e) {
130 if( 1 != escott_params.edit_flag || escott_params.edit_auth.length > 0 ) {
131 e.preventDefault();
132 e.stopPropagation();
133 $("#escott_settlement_mode").val($(this).attr("data-mode"));
134 $("#escott-agree-dialog").dialog("open");
135 return false;
136 }
137 });
138 });
139
140 function setToken(token,card) {
141 if( token ) {
142 document.getElementById("token").value = token;
143 document.getElementById("billingname").value = document.getElementById("cardname").value;
144 document.getElementById("member-card-info").submit();
145 }
146 }
147
148 function isValidInput(str) {
149 let len = str.length;
150 if( 0 === len ) {
151 return false;
152 }
153 for( let i = 0; i < len; i++ ) {
154 let char = str.charAt(i);
155 if( !( char >= 'A' && char <= 'Z' ) && !( char >= 'a' && char <= 'z' ) && char !== ' ' ) {
156 return false;
157 }
158 }
159 return true;
160 }
161