1var shoppingListObject; 2window.shoppingListState = { value: 0 }; 3 4if (typeof shoppingListOffset === "undefined") { var shoppingListOffset = 0; } 5 6function getListItem(tempListItem) { 7 var ingredientID = null, ingredient = null, department = null, dealDetails = null, details = null, recipeID = null, 8 terminationDate = null, storeID = null, quantity = null, manualFlag = false, thumbnailURL = null, eCouponID = null; 9 10 if (typeof tempListItem !== 'undefined') { 11 if (typeof tempListItem.ingredientID !== 'undefined') { 12 ingredientID = tempListItem.ingredientID; 13 } 14 if (typeof tempListItem.ingredient !== 'undefined') { 15 ingredient = tempListItem.ingredient; 16 } 17 if (typeof tempListItem.department !== 'undefined') { 18 department = tempListItem.department; 19 } 20 if (typeof tempListItem.dealDetails !== 'undefined') { 21 dealDetails = tempListItem.dealDetails; 22 } 23 if (typeof tempListItem.details !== 'undefined') { 24 details = tempListItem.details; 25 } 26 if (typeof tempListItem.recipeID !== 'undefined') { 27 recipeID = tempListItem.recipeID; 28 } 29 if (typeof tempListItem.terminationDate !== 'undefined') { 30 terminationDate = tempListItem.terminationDate; 31 } 32 if (typeof tempListItem.storeID !== 'undefined') { 33 storeID = tempListItem.storeID; 34 } 35 if (typeof tempListItem.quantity !== 'undefined') { 36 quantity = tempListItem.quantity; 37 } 38 if (typeof tempListItem.manualFlag !== 'undefined') { 39 manualFlag = tempListItem.manualFlag; 40 } 41 if (typeof tempListItem.thumbnailURL !== 'undefined') { 42 thumbnailURL = tempListItem.thumbnailURL; 43 } 44 if (typeof tempListItem.eCouponID !== 'undefined') { 45 eCouponID = tempListItem.eCouponID; 46 } 47 } 48 49 return { 50 ingredientID: ingredientID, 51 ingredient: ingredient, 52 department: department, 53 dealDetails: dealDetails, 54 details: details, 55 recipeID: recipeID, 56 terminationDate: terminationDate, 57 storeID: storeID, 58 quantity: quantity, 59 manualFlag: manualFlag, 60 thumbnailURL: thumbnailURL, 61 eCouponID: eCouponID 62 }; 63} 64 65function populateList() { 66 var $clippedLinks = $jq('#shopping-list'); 67 $jq('#shopping-list .menu-item').remove(); 68 69 if (typeof shoppingListObject !== 'undefined' && typeof shoppingListObject.items !== 'undefined') { 70 $jq.each(shoppingListObject.items, function (i, v) { 71 var $link = $jq('<li />', { id: v.ingredientID, 'class': 'menu-item' }); 72 $link.html(v.ingredient + '<a class="shopping-list-x remove-ingredient" data-ingredient-id="' + v.ingredientID + '" href=""><img alt="Remove Ingredient" src="/stc/images/x.png" /></a>'); 73 $clippedLinks.append($link); 74 }); 75 } 76 77 if ($jq('#shopping-list .menu-item').length === 0) { 78 $jq('#empty-shoppinglist-message').show(); 79 } else { 80 $jq('#empty-shoppinglist-message').hide(); 81 } 82 83 var $clippedSpan = $jq('#clipped').find('span'); 84 let count = $jq('#shopping-list .menu-item').length; 85 $clippedSpan.html(count); 86 stc_shoppinglist_count_update(count); 87} 88 89function stc_shoppinglist_count_update(newValue) { 90 if (window.shoppingListState.value != newValue) { 91 window.shoppingListState.value = newValue; 92 window.dispatchEvent(new CustomEvent('shoppingListCountChange', { detail: newValue })); 93 } 94} 95 96function quickAddItem() { 97 if ($jq('#newingredient').val() == 'Quick Add Item...') { 98 return; 99 } 100 try { 101 //gtag('event', 'quick_add_to_shoppinglist', { 'value': $jq('#newingredient').val() }); 102 gtag('event', 'quick_add_to_shoppinglist'); 103 } catch (err) { 104 105 } 106 addToList({ ingredient: cleanEmptyObject($jq('#newingredient').val()), department: cleanEmptyObject($jq('#newingredientdepartment').val()) }); 107 $jq('#newingredient').val(''); 108} 109 110function initializeList() { 111 var $shoppingListMenu = $jq('#shoppinglist-menu'); 112 var $shoppingListTable = $jq('#shoppinglist-table'); 113 var $customTemplateInner = $jq('.custom-template-inner'); 114 115 var menuTop = $shoppingListMenu.parent('div').offset().top; 116 //var menuBuffer = 30; 117 var menuBuffer = $shoppingListTable.css("top").substring(0, ($shoppingListTable.css("top").length - 2)); 118 var minBuffer = menuTop - menuBuffer; 119 120 // Menu scroll 121 $jq(window).scroll(function (event) { 122 var y = $jq(this).scrollTop() + shoppingListOffset; 123 124 var dfpBuffer = 0; 125 if ($jq("#div-gpt-ad-footer-1").length !== 0) { 126 dfpBuffer = $jq("#div-gpt-ad-footer-1").height() + 10; 127 } 128 129 var bottomOfInnerTemplate = ($customTemplateInner.offset().top + $customTemplateInner.height()); 130 var bottomBuffer = (bottomOfInnerTemplate - y - $shoppingListTable.height() - dfpBuffer - 30); 131 var topBuffer = (bottomOfInnerTemplate - $shoppingListMenu.offset().top - $shoppingListTable.height() - dfpBuffer); 132 133 if (y > minBuffer && bottomBuffer >= 0) { 134 $shoppingListTable.css('position', 'fixed'); 135 $shoppingListTable.css('margin-top', shoppingListOffset + 'px'); 136 } else { 137 $shoppingListTable.css('position', 'static'); 138 $shoppingListTable.css('margin-top', '0px'); 139 } 140 if (bottomBuffer <= 0) { 141 $shoppingListTable.css('margin-top', topBuffer + 'px'); 142 } 143 });
144 145 $jq(document).on('click', '.clear-shopping-list', function (e) { 146 clearShoppingList(true); 147 return false; 148 }); 149 $jq(document).on('click', '.remove-ingredient', function (e) { 150 var ingredientID = $jq(this).data('ingredient-id'); 151 removeFromList(ingredientID); 152 return false; 153 }); 154 155 shoppinglist_controller.initializeList(initializeListCallback); 156} 157 158function initializeListCallback(result) { 159 shoppingListObject = result; 160 populateList(); 161 162 if (result && result.items) { 163 stc_shoppinglist_count_update(result.items.length); 164 } 165 166 try { 167 shoppinglist_callback_object.initializeListCallback(); 168 } catch (err) { 169 } 170} 171 172function addToList(tempItem) { 173 var item = getListItem(tempItem); 174 if (typeof item === 'undefined' || item.ingredient === null) { 175 return; 176 } 177 178 try { 179// gtag('event', 'add_to_shoppinglist', { 'category': 'Weekly Ad', 'value': item.ingredient }); 180 gtag('event', 'add_to_shoppinglist'); 181 } catch (err) { 182 } 183 184 shoppinglist_controller.addToList(item, addToListCallback); 185} 186 187function addToListCallback(result, item) { 188 shoppingListObject = result; 189 populateList(); 190 191 if (result && result.items) { 192 stc_shoppinglist_count_update(result.items.length); 193 } 194 195 try { 196 shoppinglist_callback_object.addToListCallback(item); 197 } catch (err) { 198 } 199} 200 201function removeFromList(ingredientID) { 202 try { 203 gtag('event', 'remove_from_shoppinglist', { 'value': $jq('#' + ingredientID).text() }); 204 } catch (err) { 205 206 } 207 shoppinglist_controller.removeFromList(ingredientID, removeFromListCallback); 208} 209 210function removeFromListCallback(result, ingredientID) { 211 shoppingListObject = result; 212 populateList(); 213 214 try { 215 shoppinglist_callback_object.removeFromListCallback(ingredientID); 216 } catch (err) { 217 } 218} 219 220function clearShoppingList(checkShoppingList) { 221 if (checkShoppingList) { 222 if (!confirm("Are you sure you want to clear your shopping list?")) { 223 return; 224 } 225 } 226 try { 227 gtag('event', 'clear_shoppinglist'); 228 } catch (err) { 229 230 } 231 shoppinglist_controller.clearShoppingList(clearShoppingListCallback); 232} 233 234function clearShoppingListCallback(result) { 235 shoppingListObject = result; 236 populateList(); 237 238 try { 239 shoppinglist_callback_object.clearShoppingListCallback(); 240 } catch (err) { 241 } 242} 243 244function transferShoppingList() { 245 shoppinglist_controller.transferShoppingList(transferShoppingListCallback); 246} 247 248function transferShoppingListCallback() { 249 shoppinglist_controller.initializeList(transferShoppingListCallbackStep2); 250} 251 252function transferShoppingListCallbackStep2(result) { 253 shoppingListObject = result; 254 populateList(); 255 256 try { 257 shoppinglist_callback_object.transferShoppingListCallback(); 258 } catch (err) { 259 } 260}
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.