1var 2 currencySelectObj, 3 languageSelectObj, 4 recentCategoriesObj, 5 recentItemsObj; 6 7jQuery(document).ready(function(){ 8 currencySelectObj = jQuery('#select_currency'); 9 languageSelectObj = jQuery('#ml'); 10 recentCategoriesObj = jQuery('#recentCategories'); 11 recentItemsObj = jQuery('#recentItems'); 12 13 updateLoginArea(); 14 15 createLanguageSelect(); 16 createCurrencySelect(); 17 18 if(recentCategoriesObj.length > 0){ 19 renderRecentlyViewedCategories(); 20 } 21 22 if(recentItemsObj.length > 0){ 23 renderRecentlyViewedItems(); 24 } 25 26// update_top_basket(); 27}); 28 29 30function updateLoginArea() { 31 jQuery.ajax({ 32 url: 'getlogin.ajx?vid=' + vendorIdentifier, 33 dataType: 'json', 34 cache: false, 35 data: {}, 36 success: function(repsonse) { 37 var 38 result = repsonse['__Result'], 39 html = ''; 40 if (jQuery(window).width() < 1025) { 41 if(result['loggedin']){ 42 jQuery('#welcome_user_name').html('<a href=\''+ userWelcome['account_link'] +'\'>'+'<i class="fa fa-user-circle-o fa-lg ada_screen_icon" data-srtext="User icon"></i> ' + result['loginname']+ '</a>') 43 jQuery('#user_login').html('<a href=\''+ userWelcome['logout_link'] +'\'> <i class="ti-power-off ada_screen_icon" data-srtext="Logout icon"></i> </a>'); 44 }else{ 45 jQuery('#welcome_user_name').html('<a><i class="fa fa-user-circle-o fa-lg ada_screen_icon" data-srtext="User icon"></i> Welcome</a>') 46 jQuery('#user_login').html('<a href=\''+ userWelcome['login_link'] +'\'><i class="fa fa-user-circle-o fa-lg ada_screen_icon" data-srtext="User icon"></i></a>'); 47 } 48 } else{ 49 if(result['loggedin']){ 50 html = '<a href=\''+ userWelcome['account_link'] +'\'>' + result['loginname']+'!'+ '</a>' + '<a href=\''+ userWelcome['logout_link'] +'\'>' + '<i class="fa fa-sign-out ada_screen_icon" data-srtext="Signout icon"></i>' + '</a>'; 51 }else{ 52 html = '<a href=\''+ userWelcome['login_link'] +'\'>' + userWelcome['login'] +'</a>'; 53 } 54 55 jQuery('#welcome-data').html(html); 56 57 if(result['loggedin']){ 58 html = '<a href=\''+ userWelcome['account_link'] +'\'>' + '<i class="fa fa-user ada_screen_icon" data-srtext="User icon"></i>' + '</a>' + '<a href=\''+ userWelcome['logout_link'] +'\'>' + '<i class="fa fa-sign-out ada_screen_icon" data-srtext="Signout icon"></i>' + '</a>'; 59 }else{ 60 html = '<a href=\''+ userWelcome['login_link'] +'\'>' + '<i class="fa fa-user ada_screen_icon" data-srtext="User icon"></i>'+ '<span>' + userWelcome['login'] +'</span>' + '</a>'; 61 } 62 63 jQuery('#welcome-data2').html(html); 64 65 } 66 67 68 } 69 }); 70} 71 72function renderRecentlyViewedCategories () { 73 jQuery.ajax({ 74 url: 'getrecentlyviewedcategories.ajx?vid=' + vendorIdentifier + '&cid=' + categoryId, 75 dataType: 'json', 76 cache: false, 77 data: {}, 78 success: function(response) { 79 var 80 i = 0, 81 result = response['__Result']; 82 83 var len = result.length; 84 85 if(len > 0){ 86 var 87 data = {}, 88 partials = Avetti.partials, 89 template = Avetti.mustaches.recentlyViewedCategories, 90 HTML = ''; 91 92 data.categories = result; 93 HTML = Mustache.render(template, data, partials); 94 95 recentCategoriesObj.html(HTML); 96 recentCategoriesObj.show(); 97 } else { 98 recentCategoriesObj.hide(); 99 } 100 } 101 }); 102} 103 104function renderRecentlyViewedItems() { 105 var vid = recentItemsObj.attr('data-vid'); 106 107 jQuery.ajax({ 108 url: 'getrecentlyvieweditems.ajx?vid=' + vid, 109 dataType: 'json', 110 cache: false, 111 data: {}, 112 success: function(response) { 113 114 var 115 i = 0, 116 result = response['__Result']; 117 118 var len = result.length; 119 120 if(len > 0){ 121 var 122 data = {}, 123 partials = Avetti.partials, 124 template = Avetti.mustaches.recentlyViewedItems, 125 HTML = ''; 126 127 data.items = result; 128 HTML = Mustache.render(template, data, partials); 129 var varHTML = jQuery('<textarea />').html(HTML).text(); 130 recentItemsObj.html(varHTML); 131 recentItemsObj.show(); 132 } else { 133 recentItemsObj.hide(); 134 } 135 } 136 }); 137} 138 139function createLanguageSelect() { 140 jQuery.ajax({ 141 url: 'getlanguage.ajx?vid=' + vendorIdentifier, 142 dataType: 'json', 143 cache: false, 144 data: {}, 145 success: function(response) { 146 var result = response['__Result']; 147 148 if(languageSelectObj.length > 0){ 149 languageSelectObj.val(result); 150 bindLanguageSelect(); 151 } 152 } 153 }); 154} 155 156function bindLanguageSelect() { 157 if(languageSelectObj.length > 0){ 158 languageSelectObj.bind( 159 'change', 160 function(){ 161 if(jQuery(this).val() == 'es'){ 162 window.document.location.href = 'http://es.avetti.ca'; 163 } else { 164 jQuery.ajax({ 165 url: 'updatelanguage.ajx?vid=' + vendorIdentifier + '&ml=' + jQuery(this).val(), 166 dataType: 'json', 167 cache: false, 168 data: { }, 169 success: function(response) { 170 var result = response['__Result']; 171 window.location.reload(); 172 } 173 }); 174 } 175 } 176 ); 177 } 178} 179 180function createCurrencySelect () { 181 jQuery.ajax({ 182 url: 'getcurrencyid.ajx?vid=' + vendorIdentifier, 183 dataType: 'json', 184 cache: false, 185 data: {}, 186 success: function(response) { 187 var result = response['__Result']; 188 if(currencySelectObj.length > 0){ 189 currencySelectObj.val(result); 190 bindCurrencySelect(); 191 } 192 } 193 }); 194} 195 196function bindCurrencySelect () { 197 if(currencySelectObj.length > 0){ 198 currencySelectObj.bind( 199 'change', 200 function(){ 201 jQuery.ajax({ 202 url: 'updatecurrencyid.ajx?vid=' + vendorIdentifier + '¤cyid=' + jQuery(this).val(), 203 dataType: 'json', 204 cache: false, 205 data: { }, 206 success: function(response) { 207 var result = response['__Result']; 208 window.location.reload(); 209 } 210 }); 211 } 212 ); 213 } 214} 215 216function update_top_basket() { 217 jQuery.ajax({ 218 url: 'getbasket.ajx?vid=' + jQuery('#js-vid').val(), 219 dataType: 'json', 220 cache: false, 221 data: {}, 222 success: function(repsonse) { 223 var 224 result = repsonse['__Result'], 225 i = 0, 226 len = result['products'].length, 227 qty = 0; 228 229 if(len > 0){ 230 for(i; i < len; i+=1){ 231 qty = qty + result['products'][i]['qty']; 232 } 233 234 jQuery('#basket-amount,#basket-amount-m').text(''+len+''); 235 jQuery('.mobile-basket').text(len); 236 } 237 } 238 }); 239}
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.