1 2var store = { 3 data: [], 4 total: 0, 5 filter: { 6 search: "", 7 size: 25, 8 page: 1, 9 sort: "name", 10 sortType: "asc" 11 }, 12 init: function() { 13 store.get(); 14 }, 15 get: function() { 16 service.call("stores", store.filter, store.returned); 17 }, 18 returned: function(e) { 19 if (e.error) growler.error(e.error); 20 else { 21 store.data = e.data; 22 store.total = e.total; 23 context.set("stores", store.data); 24 } 25 }, 26 save: function(name, code, id, address, allowOnline, allowInStore) { 27 var params = store.filter; 28 params.id = id; 29 params.name = name; 30 params.code = code; 31 params.address = address; 32 params.allowOnline = allowOnline; 33 params.allowInStore = allowInStore; 34 service.call("store", params, store.returned); 35 }, 36 importRemote: function(ids, callback) { 37 service.call("store/import", { ids: ids || [] }, callback); 38 }, 39 delete: function(ids) { 40 var params = store.filter; 41 params.ids = ids; 42 service.call("store", params, store.returned, "DELETE"); 43 }, 44 details: function(id) { 45 for (var i=0; i<store.data.length; i++) { 46 if (id==store.data[i].storeId) return store.data[i]; 47 } 48 return null; 49 }, 50 detailsFromCode: function(code) { 51 for (var i=0; i<store.data.length; i++) { 52 if (code==store.data[i].code) return store.data[i]; 53 } 54 return null; 55 }, 56 next: function() { 57 if (!isLast()) store.filter.page++; 58 else store.filter.page = 1; 59 store.get(); 60 }, 61 prev: function() { 62 if (store.filter.page>1) store.filter.page--; 63 else store.filter.page = Math.ceil(store.total/store.filter.size); 64 store.get(); 65 }, 66 isLast: function() { 67 return (store.total<=(store.filter.page*store.filter.size)); 68 }, 69 isFirst: function() { 70 return store.filter.page==1; 71 }, 72 pageTotal: function() { 73 return Math.ceil(store.total/store.filter.size); 74 }, 75 goto: function(page) { 76 if (page<=store.pageTotal()&&page>=1) { 77 store.filter.page = page; 78 store.get(); 79 } 80 } 81}
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.