Tyler Scott | 3c17d5f | 2015-06-23 17:49:29 -0600 | [diff] [blame] | 1 | var catalog = "/catalog/myUniqueName"; |
Tyler Scott | a1ac69d | 2015-07-02 17:42:03 -0600 | [diff] [blame] | 2 | var config = { |
Tyler Scott | 087aef7 | 2015-07-14 14:11:59 -0600 | [diff] [blame] | 3 | host: "atmos-csu.research-lan.colostate.edu", |
Tyler Scott | 3c17d5f | 2015-06-23 17:49:29 -0600 | [diff] [blame] | 4 | port: 9696 |
Tyler Scott | a1ac69d | 2015-07-02 17:42:03 -0600 | [diff] [blame] | 5 | }; |
Tyler Scott | 3c17d5f | 2015-06-23 17:49:29 -0600 | [diff] [blame] | 6 | |
Tyler Scott | a1ac69d | 2015-07-02 17:42:03 -0600 | [diff] [blame] | 7 | //Run when the document loads. |
| 8 | $(function () { |
Tyler Scott | bb01356 | 2015-07-16 15:52:40 -0600 | [diff] [blame] | 9 | new Atmos(catalog, config); |
Tyler Scott | 3c17d5f | 2015-06-23 17:49:29 -0600 | [diff] [blame] | 10 | }); |
| 11 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 12 | var Atmos = (function(){ |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 13 | "use strict"; |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 14 | /** |
| 15 | * Atmos |
| 16 | * @version 2.0 |
| 17 | * |
| 18 | * Configures an Atmos object. This manages the atmos interface. |
| 19 | * |
| 20 | * @constructor |
| 21 | * @param {string} catalog - NDN path |
| 22 | * @param {Object} config - Object of configuration options for a Face. |
| 23 | */ |
| 24 | function Atmos(catalog, config){ |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 25 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 26 | //Internal variables. |
| 27 | this.results = []; |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 28 | this.resultCount = 0; |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 29 | this.name = null; |
| 30 | this.page = 0; |
| 31 | this.lastPage = -1; |
| 32 | //this.itemsPerPage = 25; //TODO |
Tyler Scott | e815d3e | 2015-07-09 16:56:17 -0600 | [diff] [blame] | 33 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 34 | this.catalog = catalog; |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 35 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 36 | this.face = new Face(config); |
| 37 | this.categories = $('#side-menu'); |
| 38 | this.resultTable = $('#resultTable'); |
| 39 | this.filters = $('#filters'); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 40 | this.searchInput = $('#search'); |
| 41 | this.searchBar = $('#searchBar'); |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 42 | this.searchButton = $('#searchButton'); |
| 43 | this.pagers = $('.pager'); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 44 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 45 | var scope = this; |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 46 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 47 | this.resultTable.on('click', '.interest-button', function(){ |
| 48 | var button = $(this); |
Tyler Scott | 087aef7 | 2015-07-14 14:11:59 -0600 | [diff] [blame] | 49 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 50 | if (button.is(':disabled')){ |
| 51 | console.warn("Attempt to request again!"); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 52 | } |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 53 | |
| 54 | var name = button.parent().prev().text(); |
| 55 | var interest = new Interest(new Name('/retrieve' + name)); |
| 56 | scope.face.expressInterest(interest, function(){}, function(){}); |
| 57 | |
| 58 | button.text("Requested!") |
| 59 | .removeClass('btn-primary') |
| 60 | .addClass('btn-default') |
| 61 | .addClass('disabled') |
| 62 | .prop('disabled', true); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 63 | }); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 64 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 65 | //Filter setup |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 66 | $.getJSON("search_catagories.json").done(function (data) { |
| 67 | $.each(data, function (pageSection, contents) { |
| 68 | if (pageSection == "SearchCatagories") { |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 69 | $.each(contents, function (category, searchOptions) { |
| 70 | //Create the category |
| 71 | var e = $('<li><a href="#">' + category.replace(/\_/g, " ") + '</a><ul class="subnav nav nav-pills nav-stacked"></ul></li>'); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 72 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 73 | var sub = e.find('ul.subnav'); |
| 74 | $.each(searchOptions, function(index, name){ |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 75 | //Create the filter list inside the category |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 76 | var item = $('<li><a href="#">' + name + '</a></li>'); |
| 77 | sub.append(item); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 78 | item.click(function(){ //Click on the side menu filters |
| 79 | if (item.hasClass('active')){ //Does the filter already exist? |
| 80 | item.removeClass('active'); |
| 81 | scope.filters.find(':contains(' + category + ':' + name + ')').remove(); |
| 82 | } else { //Add a filter |
| 83 | item.addClass('active'); |
| 84 | var filter = $('<span class="label label-default"></span>'); |
| 85 | filter.text(category + ':' + name); |
| 86 | |
| 87 | scope.filters.append(filter); |
| 88 | |
| 89 | filter.click(function(){ //Click on a filter |
| 90 | filter.remove(); |
| 91 | item.removeClass('active'); |
| 92 | }); |
| 93 | } |
| 94 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 95 | }); |
| 96 | }); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 97 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 98 | //Toggle the menus. (Only respond when the immediate tab is clicked.) |
| 99 | e.find('> a').click(function(){ |
| 100 | scope.categories.find('.subnav').slideUp(); |
| 101 | var t = $(this).siblings('.subnav'); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 102 | if ( !t.is(':visible') ){ //If the sub menu is not visible |
| 103 | t.slideDown(function(){ |
| 104 | t.triggerHandler('focus'); |
| 105 | }); //Make it visible and look at it. |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 106 | } |
| 107 | }); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 108 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 109 | scope.categories.append(e); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 110 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 111 | }); |
| 112 | } |
| 113 | }); |
| 114 | }); |
| 115 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 116 | this.searchInput.autoComplete(function(field, callback){ |
| 117 | scope.autoComplete(field, callback); |
| 118 | }); |
| 119 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 120 | this.searchBar.submit(function(e){ |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 121 | e.preventDefault(); |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 122 | scope.searchInput.trigger('autoComplete'); |
| 123 | }); |
| 124 | |
| 125 | this.searchButton.click(function(){ |
| 126 | console.log("Search Button Pressed"); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 127 | scope.search(); |
| 128 | }); |
| 129 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 130 | this.pagers.find('.next').click(function(){ |
| 131 | if (!$(this).hasClass('disabled')){ |
| 132 | scope.getResults(scope.page + 1); |
| 133 | } |
| 134 | }); |
| 135 | this.pagers.find('.previous').click(function(){ |
| 136 | if (!$(this).hasClass('disabled')){ |
| 137 | scope.getResults(scope.page - 1); |
| 138 | } |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 139 | }); |
| 140 | |
| 141 | } |
| 142 | |
| 143 | Atmos.prototype.search = function(){ |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 144 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 145 | var filters = this.getFilters(); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 146 | |
| 147 | console.log("Search started!", this.searchInput.val(), filters); |
| 148 | |
| 149 | console.log("Initiating query"); |
| 150 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 151 | this.results = []; //Drop any old results. |
| 152 | this.resultTable.empty(); |
| 153 | |
Tyler Scott | d90f84e | 2015-07-27 12:43:04 -0600 | [diff] [blame] | 154 | var scope = this; |
| 155 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 156 | this.query(this.catalog, filters, |
| 157 | function(interest, data){ //Response function |
| 158 | console.log("Query Response:", interest, data); |
| 159 | |
Tyler Scott | d90f84e | 2015-07-27 12:43:04 -0600 | [diff] [blame] | 160 | var parameters = JSON.stringify(filters); |
| 161 | |
| 162 | var ack = data.getName(); |
| 163 | |
Tyler Scott | b6e329f | 2015-07-28 16:08:33 -0600 | [diff] [blame^] | 164 | scope.name = new Name(scope.catalog).append("query-results").append(parameters).append(ack.get(-3)).append(ack.get(-2)); |
Tyler Scott | d90f84e | 2015-07-27 12:43:04 -0600 | [diff] [blame] | 165 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 166 | scope.getResults(0); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 167 | |
| 168 | }, function(interest){ //Timeout function |
Tyler Scott | b6e329f | 2015-07-28 16:08:33 -0600 | [diff] [blame^] | 169 | console.warn("Request failed! Timeout"); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 170 | }); |
| 171 | |
| 172 | } |
| 173 | |
| 174 | Atmos.prototype.autoComplete = function(field, callback){ |
| 175 | console.log("Autocomplete triggered"); |
| 176 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 177 | if (this.searchInput.val().length === 0 && !filters.hasOwnProperty()){ |
| 178 | if (!this.searchBar.hasClass('has-error')){ |
| 179 | this.searchBar.addClass('has-error').append('<span class="help-block">A filter or search value is required!</span>'); |
| 180 | } |
| 181 | return; |
| 182 | } else { |
| 183 | this.searchBar.removeClass('has-error').find('.help-block').fadeOut(function(){$(this).remove()}); |
| 184 | } |
| 185 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 186 | var filters = this.getFilters(); |
| 187 | |
| 188 | filters["?"] = this.searchInput.val(); |
| 189 | |
Tyler Scott | b6e329f | 2015-07-28 16:08:33 -0600 | [diff] [blame^] | 190 | var scope = this; |
| 191 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 192 | this.query(this.catalog, filters, |
| 193 | function(interest, data){ |
Tyler Scott | b6e329f | 2015-07-28 16:08:33 -0600 | [diff] [blame^] | 194 | |
| 195 | var ack = data.getName(); |
| 196 | |
| 197 | var name = new Name(scope.catalog).append('query-results').append(JSON.stringify(filters)).append(ack.get(-3)).append(ack.get(-2)); |
| 198 | |
| 199 | console.log(name.toUri(), filters); |
| 200 | |
| 201 | scope.face.expressInterest(new Interest(name).setInterestLifetimeMilliseconds(5000), |
| 202 | function(interest, data){ |
| 203 | console.log("Autocomplete query return: ", data.getContent().toString()); |
| 204 | }, function(interest){ |
| 205 | console.warn("Interest timed out!", interest); |
| 206 | }); |
| 207 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 208 | }, function(interest){ |
Tyler Scott | b6e329f | 2015-07-28 16:08:33 -0600 | [diff] [blame^] | 209 | console.error("Request failed! Timeout", interest); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 210 | }); |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 211 | |
Tyler Scott | 424ee10 | 2015-07-14 16:50:41 -0600 | [diff] [blame] | 212 | } |
| 213 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 214 | Atmos.prototype.showResults = function(resultIndex) { |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 215 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 216 | var results = $('<tr><td>' + this.results[resultIndex].join('</td><td><button class="interest-button btn btn-primary btn-sm">Retrieve</button></td></tr><tr><td>') + |
| 217 | '</td><td><button class="interest-button btn btn-primary btn-sm">Retrieve</button></td></tr>'); //Fastest way to generate the table. |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 218 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 219 | this.resultTable.empty().append(results); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 220 | |
Tyler Scott | b6e329f | 2015-07-28 16:08:33 -0600 | [diff] [blame^] | 221 | this.pagers.find('.totalResults').text('(Page' + (resultIndex + 1) + ') Showing ' + this.results[resultIndex].length + ' of ' + this.resultCount + ' results'); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 222 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 223 | if (resultIndex === this.lastPage) { |
| 224 | this.pagers.find('.next').addClass('disabled'); |
| 225 | } |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 226 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 227 | if (resultIndex === 0){ |
| 228 | this.pagers.find('.next').removeClass('disabled'); |
| 229 | this.pagers.find('.previous').addClass('disabled'); |
| 230 | } else if (resultIndex === 1) { |
| 231 | this.pagers.find('.previous').removeClass('disabled'); |
| 232 | } |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 233 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 234 | } |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 235 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 236 | Atmos.prototype.getResults = function(index){ |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 237 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 238 | if (this.results[index]){ |
| 239 | //console.log("We already have index", index); |
| 240 | this.page = index; |
| 241 | this.showResults(index); |
| 242 | return; |
| 243 | } |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 244 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 245 | if (this.name === null) { |
| 246 | console.error("This shouldn't be reached! We are getting results before a search has occured!"); |
| 247 | throw new Error("Illegal State"); |
| 248 | } |
Tyler Scott | 424ee10 | 2015-07-14 16:50:41 -0600 | [diff] [blame] | 249 | |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 250 | var first = new Name(this.name).appendSegment(index); |
| 251 | |
Tyler Scott | b6e329f | 2015-07-28 16:08:33 -0600 | [diff] [blame^] | 252 | console.log("Requesting data index: (", index, ") at ", first.toUri()); |
Tyler Scott | c55879f | 2015-07-28 14:56:37 -0600 | [diff] [blame] | 253 | |
| 254 | var scope = this; |
| 255 | |
| 256 | this.face.expressInterest(new Interest(first).setInterestLifetimeMilliseconds(5000), |
| 257 | function(interest, data){ //Response |
| 258 | |
| 259 | if (data.getContent().length === 0){ |
| 260 | console.log("Empty response."); |
| 261 | return; |
| 262 | } |
| 263 | |
| 264 | if (data.getName().get(-1).equals(data.getMetaInfo().getFinalBlockId())) { //Final page. |
| 265 | scope.lastPage = index; |
| 266 | //The next buttons will be disabled by showResults. |
| 267 | } |
| 268 | |
| 269 | var content = JSON.parse(data.getContent().toString().replace(/[\n\0]/g,"")); |
| 270 | |
| 271 | var results = scope.results[index] = content.results; |
| 272 | |
| 273 | scope.resultCount = content.resultCount; |
| 274 | |
| 275 | scope.pagers.find('.totalResults').text(scope.resultCount + " Results"); |
| 276 | |
| 277 | //console.log("Got results:", results); |
| 278 | |
| 279 | scope.page = index; |
| 280 | |
| 281 | if (!results){ |
| 282 | console.log("No results were found!"); |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | scope.showResults(index); |
| 287 | |
| 288 | }, |
| 289 | function(interest){ //Timeout |
| 290 | console.error("Failed to retrieve results: timeout"); |
| 291 | } |
| 292 | ); |
| 293 | |
| 294 | } |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 295 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 296 | Atmos.prototype.query = function(prefix, parameters, callback, timeout) { |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 297 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 298 | var queryPrefix = new Name(prefix); |
| 299 | queryPrefix.append("query"); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 300 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 301 | var jsonString = JSON.stringify(parameters); |
| 302 | queryPrefix.append(jsonString); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 303 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 304 | var queryInterest = new Interest(queryPrefix); |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 305 | queryInterest.setInterestLifetimeMilliseconds(4000); |
Tyler Scott | 7d076e2 | 2015-07-06 19:21:50 -0600 | [diff] [blame] | 306 | |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 307 | this.face.expressInterest(queryInterest, callback, timeout); |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 308 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 309 | } |
| 310 | |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 311 | /** |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 312 | * This function returns a map of all the categories active filters. |
| 313 | * @return {Object<string, string>} |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 314 | */ |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 315 | Atmos.prototype.getFilters = function(){ |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 316 | var filters = this.filters.children().toArray().reduce(function(prev, current){ |
Tyler Scott | 575c61b | 2015-07-13 13:42:16 -0600 | [diff] [blame] | 317 | var data = $(current).text().split(/:/); |
| 318 | prev[data[0]] = data[1]; |
| 319 | return prev; |
Tyler Scott | a153005 | 2015-07-24 00:13:28 -0600 | [diff] [blame] | 320 | }, {}); //Collect a map<category, filter>. |
| 321 | //TODO Make the return value map<category, Array<filter>> |
| 322 | return filters; |
Tyler Scott | 93cae87 | 2015-07-21 14:58:23 -0600 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | return Atmos; |
| 326 | |
| 327 | })(); |
| 328 | |
| 329 | |