1 2var discounts = { 3 data: [], 4 total: 0, 5 filter: { 6 search: "", 7 size: 25, 8 page: 1, 9 sort: "name", 10 sortType: "asc" 11 }, 12 get: function() { 13 service.call("discounts", discounts.filter, discounts.returned); 14 }, 15 returned: function(e) { 16 if (e.error) growler.error(e.error); 17 else { 18 discounts.data = e.data; 19 discounts.total = e.total; 20 context.set("discounts", discounts.data); 21 } 22 }, 23 save: function(id, type, perItem, code, amount, startDate, endDate, maxItems, minItems, mustSpend, usageMax, usagePerPerson, country, excludesSales, excludesRelay, excludeGiftCard, free, includeProducts, includeCategories, includeBrands, includeCustomers, excludeProducts, excludeBrands, excludeCategories, excludeCustomers, buyingProducts, buyingCategories, freeProducts, freeCategories, freeAmount, freeType, isFreeShipping) { 24 var params = discounts.filter; 25 params.id = id; 26 params.type = type; 27 params.perItem = perItem; 28 params.code = code; 29 params.amount = amount; 30 params.startDate = startDate; 31 params.endDate = endDate; 32 params.maxItems = maxItems; 33 params.minItems = minItems; 34 params.mustSpend = mustSpend; 35 params.usageMax = usageMax; 36 params.usagePerPerson = usagePerPerson; 37 params.country = country; 38 params.excludesSales = excludesSales; 39 params.excludesRelay = excludesRelay; 40 params.excludeGiftCard = excludeGiftCard; 41 params.free = free; 42 params.includeProducts = includeProducts; 43 params.includeCategories = includeCategories; 44 params.includeBrands = includeBrands; 45 params.includeCustomers = includeCustomers; 46 params.excludeProducts = excludeProducts; 47 params.excludeBrands = excludeBrands; 48 params.excludeCategories = excludeCategories; 49 params.excludeCustomers = excludeCustomers; 50 params.buyingProducts = buyingProducts; 51 params.buyingCategories = buyingCategories; 52 params.freeProducts = freeProducts; 53 params.freeCategories = freeCategories; 54 params.freeAmount = freeAmount; 55 params.freeType = freeType; 56 params.isFreeShipping = isFreeShipping; 57 58 service.call("discount", params, discounts.returned); 59 }, 60 delete: function(ids) { 61 var params = discounts.filter; 62 params.ids = ids;
63 service.call("discount", params, discounts.returned, "DELETE"); 64 }, 65 details: function(id) { 66 for (var i=0; i<discounts.data.length; i++) { 67 if (id==discounts.data[i].discountId) return discounts.data[i]; 68 } 69 return null; 70 }, 71 next: function() { 72 if (!isLast()) discounts.filter.page++; 73 else discounts.filter.page = 1; 74 discounts.get(); 75 }, 76 prev: function() { 77 if (discounts.filter.page>1) discounts.filter.page--; 78 else discounts.filter.page = Math.ceil(discounts.total/discounts.filter.size); 79 discounts.get(); 80 }, 81 isLast: function() { 82 return (discounts.total<=(discounts.filter.page*discounts.filter.size)); 83 }, 84 isFirst: function() { 85 return discounts.filter.page==1; 86 }, 87 pageTotal: function() { 88 return Math.ceil(discounts.total/discounts.filter.size); 89 }, 90 goto: function(page) { 91 if (page<=discounts.pageTotal()&&page>=1) { 92 discounts.filter.page = page; 93 discounts.get(); 94 } 95 } 96}
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.