1$(document).ready(function () { 2 var enable_status = $('#input-opc-status').val(); 3 if(enable_status == '1') { 4 ocajaxlogin.changeEvent(); 5 } 6}); 7 8$(document).ajaxComplete(function () { 9 var enable_status = $('#input-opc-status').val(); 10 if(enable_status == '1') { 11 ocajaxlogin.changeEvent(); 12 } 13}); 14 15var ocajaxlogin = { 16 'loginAction' : function(email, password) { 17 $.ajax({ 18 url: 'index.php?route=extension/module/ajaxlogin/login', 19 type: 'post', 20 data: { email: email, password: password }, 21 dataType: 'json', 22 beforeSend: function () { 23 $('.ajax-load-img').show(); 24 }, 25 success: function (json) { 26 if(json['success'] == true) { 27 if(json['enable_redirect']) { 28 location = json['redirect']; 29 } else { 30 // Update account top links 31 $('.ul-account').load('index.php?route=extension/module/ajaxlogin/toheaderhtml #top-links ul.ul-account li'); 32 33 // Update wishlish in top links 34 $('#wishlist-total span').html(json['wishlist_total']); 35 $('#wishlist-total').attr('title', json['wishlist_total']); 36 37 // Update cart total 38 $('#cart-total').html(json['cart_total']); 39 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 40 41 $('body').before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success_message'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 42 } 43 ocajaxlogin.closeForm(); 44 $('.ajax-load-img').hide(); 45 $('.login-form-content .alert-danger').remove(); 46 } else { 47 $('.ajax-load-img').hide(); 48 $('.login-form-content .alert-danger').remove(); 49 $('#input-email').val(''); 50 $('#input-password').val(''); 51 $('.ajax-content .login-form-content').append('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + 52 json['error_warning'] + 53 '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 54 } 55 } 56 }); 57 }, 58 59 'registerAction' : function () { 60 $('.for-error').removeClass('text-danger').hide(); 61 $('.form-group').removeClass('has-error'); 62 $.ajax({
63 url: 'index.php?route=extension/module/ajaxregister/register', 64 type: 'post', 65 data: $('#ajax-register-form').serialize(), 66 dataType: 'json', 67 beforeSend: function () { 68 $('.ajax-load-img').show(); 69 }, 70 success: function (json) { 71 $('.ajax-load-img').hide(); 72 if(json['success'] == true) { 73 ocajaxlogin.appendSuccess(); 74 } else { 75 76 // Error Warning 77 if(json['error_warning'] != '') { 78 $('.error-warning span').html(" " + json['error_warning']); 79 $('.error-warning').show(); 80 } 81 82 // First Name 83 if(json['error_firstname'] != '') { 84 $('.error-firstname').addClass('text-danger').html(json['error_firstname']).show(); 85 } 86 87 // Last Name 88 if(json['error_lastname'] != '') { 89 $('.error-lastname').addClass('text-danger').html(json['error_lastname']).show(); 90 } 91 92 // Email 93 if(json['error_email'] != '') { 94 $('.error-email').addClass('text-danger').html(json['error_email']).show(); 95 } 96 97 // Telephone 98 if(json['error_telephone'] != '') { 99 $('.error-telephone').addClass('text-danger').html(json['error_telephone']).show(); 100 } 101 102 // Custom Field 103 if(json['error_custom_field'] != '') { 104 $('.error-custom').addClass('text-danger').html(json['error_custom_field']).show(); 105 } 106 107 // Password 108 if(json['error_password'] != '') { 109 $('.error-password').addClass('text-danger').html(json['error_password']).show(); 110 } 111 112 // Confirm Password 113 if(json['error_confirm'] != '') { 114 $('.error-confirm').addClass('text-danger').html(json['error_confirm']).show(); 115 } 116 117 // Highlight any found errors 118 $('.text-danger').each(function() { 119 var element = $(this).parent().parent(); 120 121 if (element.hasClass('form-group')) { 122 element.addClass('has-error'); 123 } 124 }); 125 } 126 } 127 }); 128 }, 129 130 'logoutAction' : function () { 131 $.ajax({
132 url: 'index.php?route=extension/module/ajaxlogin/logout', 133 dataType: 'json', 134 beforeSend: function () { 135 $('#ajax-login-block').show(); 136 $('#ajax-loader').show(); 137 }, 138 success: function (json) { 139 if(json['enable_redirect']) { 140 location = json['redirect']; 141 } else { 142 // Update account top links 143 $('.ul-account').load('index.php?route=extension/module/ajaxlogin/toheaderhtml #top-links ul.ul-account li'); 144 145 // Update wishlish in top links 146 $('#wishlist-total span').html(json['wishlist_total']); 147 $('#wishlist-total').attr('title', json['wishlist_total']); 148 149 // Update cart total 150 $('#cart-total').html(json['cart_total']); 151 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 152 } 153 $('#ajax-loader').hide(); 154 ocajaxlogin.appendLogoutSuccess(); 155 } 156 }); 157 }, 158 159 'appendLoginForm' : function() { 160 ocajaxlogin.resetLoginForm(); 161 ocajaxlogin.resetRegisterForm(); 162 $('.ajax-body-login').show(); 163 $('.account-register').hide(); 164 $('#ajax-login-block').show(); 165 $('.account-login').show(); 166 }, 167 168 'appendRegisterForm' : function() { 169 ocajaxlogin.resetLoginForm(); 170 ocajaxlogin.resetRegisterForm(); 171 $('.ajax-body-login').show(); 172 $('.account-login').hide(); 173 $('#ajax-login-block').show(); 174 $('.account-register').show(); 175 }, 176 177 'appendSuccess' : function () { 178 $('.ajax-body-login').show(); 179 $('.account-register').hide(); 180 $('.account-success').show(); 181 }, 182 183 'appendLogoutSuccess' : function () { 184 $('.ajax-body-login').show(); 185 $('.logout-success').show(); 186 }, 187 188 'resetLoginForm' : function () { 189 $('.login-form-content .alert-danger').remove(); 190 $('#ajax-login-form')[0].reset(); 191 }, 192 193 'resetRegisterForm' : function () { 194 $('.for-error').removeClass('text-danger').hide(); 195 $('.form-group').removeClass('has-error'); 196 $('#ajax-register-form')[0].reset(); 197 }, 198 199 'closeForm' : function () { 200 $('#ajax-login-block').hide(); 201 $('#ajax-loader').hide(); 202 $('.account-login').hide(); 203 $('.account-register').hide(); 204 $('.account-success').hide(); 205 $('.logout-success').hide(); 206 $('.ajax-body-login').hide(); 207 ocajaxlogin.resetLoginForm(); 208 ocajaxlogin.resetRegisterForm(); 209 }, 210 211 'changeEvent' : function () { 212 $('#a-register-link').attr('href', 'javascript:void(0);') 213 .attr('onclick', 'ocajaxlogin.appendRegisterForm()'); 214 $('#a-login-link').attr('href', 'javascript:void(0);') 215 .attr('onclick', 'ocajaxlogin.appendLoginForm()'); 216 $('#a-logout-link').attr('href', 'javascript:void(0);') 217 .attr('onclick', 'ocajaxlogin.logoutAction()'); 218 } 219};
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.