blob: 6e41e6746a8096276e57784d4708a6aa5a2eda4c [file] [log] [blame]
Tyler Scottf08ab962015-06-30 16:31:29 -06001//{@ @todo: this need to be configured before the document load
Tyler Scott3c17d5f2015-06-23 17:49:29 -06002var catalog = "/catalog/myUniqueName";
Tyler Scotta1ac69d2015-07-02 17:42:03 -06003var config = {
Tyler Scott087aef72015-07-14 14:11:59 -06004 host: "atmos-csu.research-lan.colostate.edu",
Tyler Scott3c17d5f2015-06-23 17:49:29 -06005 port: 9696
Tyler Scotta1ac69d2015-07-02 17:42:03 -06006};
Tyler Scott3c17d5f2015-06-23 17:49:29 -06007
8// @}
9
Tyler Scotta1ac69d2015-07-02 17:42:03 -060010var atmos = {}; //Comment this out if you don't want debug access.
11
12//Run when the document loads.
13$(function () {
Tyler Scott7d076e22015-07-06 19:21:50 -060014
15 //remove "atmos =" if you don't want debug access
Tyler Scotta1ac69d2015-07-02 17:42:03 -060016 atmos = new Atmos(catalog, config);
Tyler Scottf65b7102015-06-30 18:40:14 -060017
Tyler Scott3c17d5f2015-06-23 17:49:29 -060018});
19
Tyler Scott7d076e22015-07-06 19:21:50 -060020/*
Tyler Scotte815d3e2015-07-09 16:56:17 -060021
Tyler Scott7d076e22015-07-06 19:21:50 -060022*/
23
Tyler Scotte815d3e2015-07-09 16:56:17 -060024/**
25 * Atmos
26 * @version 2.0
27 *
28 * Configures an Atmos object. This manages the atmos interface.
29 *
30 * @constructor
31 * @param {string} catalog - NDN path
32 * @param {Object} config - Object of configuration options for a Face.
33 */
Tyler Scott7d076e22015-07-06 19:21:50 -060034function Atmos(catalog, config){
35 "use strict";
36 //Internal variables.
37 this.results = []
38 this.resultCount = 0;
39 this.page = 1;
40 this.totalPages = 1;
41 this.selectedSearch = {};
42 this.dropdown = [];
43 this.state = {};
44 this.currentViewIndex = 0;
45
Tyler Scotte815d3e2015-07-09 16:56:17 -060046 this.catalog = catalog;
47
Tyler Scott7d076e22015-07-06 19:21:50 -060048 this.face = new Face(config);
49 this.categories = $('#side-menu');
50 this.resultTable = $('#resultTable');
Tyler Scotte815d3e2015-07-09 16:56:17 -060051 this.filters = $('#filters');
Tyler Scott7d076e22015-07-06 19:21:50 -060052
53 var scope = this;
54
55 this.resultTable.on('click', '.interest-button', function(){
56 var button = $(this);
57
Tyler Scott087aef72015-07-14 14:11:59 -060058 if (button.is(':disabled')){
59 console.warn("Attempt to request again!");
60 }
61
Tyler Scott7d076e22015-07-06 19:21:50 -060062 var name = button.parent().prev().text();
63 var interest = new Interest(new Name('/retrieve' + name));
Tyler Scott087aef72015-07-14 14:11:59 -060064 scope.face.expressInterest(interest, function(){}, function(){});
65
66 button.text("Requested!")
67 .removeClass('btn-primary')
68 .addClass('btn-default')
69 .addClass('disabled')
70 .prop('disabled', true);
Tyler Scott7d076e22015-07-06 19:21:50 -060071
72 });
73
74 $.getJSON("search_catagories.json").done(function (data) {
75 $.each(data, function (pageSection, contents) {
76 if (pageSection == "SearchCatagories") {
77 $.each(contents, function (search, searchOptions) {
78 var e = $('<li><a href="#">' + search.replace(/\_/g, " ") + '</a><ul class="subnav nav nav-pills nav-stacked"></ul></li>');
79
80 var sub = e.find('ul.subnav');
81 $.each(searchOptions, function(index, name){
82 var item = $('<li><a href="#">' + name + '</a></li>');
83 sub.append(item);
84 item.click(function(){
Tyler Scott575c61b2015-07-13 13:42:16 -060085 scope.addFilter(name, search);
Tyler Scott7d076e22015-07-06 19:21:50 -060086 });
87 });
88
Tyler Scott424ee102015-07-14 16:50:41 -060089 //Toggle the menus. (Only respond when the immediate tab is clicked.)
90 e.find('> a').click(function(){
Tyler Scott7d076e22015-07-06 19:21:50 -060091 scope.categories.find('.subnav').slideUp();
Tyler Scott424ee102015-07-14 16:50:41 -060092 var t = $(this).siblings('.subnav');
Tyler Scott7d076e22015-07-06 19:21:50 -060093 if ( !t.is(':visible')){
94 t.slideDown().triggerHandler('focus'); //Cancel other animations and slide down.
95 }
96 });
97
98 scope.categories.append(e);
99 });
100 }
101 });
102 });
103
104 $('#searchBar').submit(function(e){
105 e.preventDefault();
Tyler Scotte815d3e2015-07-09 16:56:17 -0600106 console.log("Search started!", $('#search'));
Tyler Scott7d076e22015-07-06 19:21:50 -0600107 })
108
109}
110
111Atmos.prototype.onData = function(data) {
112 var payloadStr = data.content.toString().split("\n")[0];
113
Tyler Scott424ee102015-07-14 16:50:41 -0600114 if (!payloadStr || payloadStr.length === 0){
115 this.populateResults(0);
116 return; //No results were returned.
117 }
118
Tyler Scott7d076e22015-07-06 19:21:50 -0600119 var queryResults = JSON.parse(payloadStr);
120
121 var scope = this;
122
Tyler Scott087aef72015-07-14 14:11:59 -0600123 //TODO Fix paging.
124
Tyler Scott424ee102015-07-14 16:50:41 -0600125 try {
Tyler Scott7d076e22015-07-06 19:21:50 -0600126
Tyler Scott424ee102015-07-14 16:50:41 -0600127 $.each(queryResults, function (queryResult, field) {
Tyler Scott7d076e22015-07-06 19:21:50 -0600128
Tyler Scott424ee102015-07-14 16:50:41 -0600129 if (queryResult == "next") {
130 scope.populateAutocomplete(field);
131 }
132
133 if (queryResult == "results" && field == null){
134 return; //Sometimes the results are null. (We should skip this.)
135 }
136
137 $.each(field, function (entryCount, name) {
138 scope.results.push(name);
139 });
Tyler Scott7d076e22015-07-06 19:21:50 -0600140 });
Tyler Scott7d076e22015-07-06 19:21:50 -0600141
Tyler Scott424ee102015-07-14 16:50:41 -0600142 // Calculating the current page and the view
143 this.totalPages = Math.ceil(this.resultCount / 20);
144 this.populateResults(0);
145
146 } catch (e) {
147 console.error(e.message, e.stack);
148 }
Tyler Scott7d076e22015-07-06 19:21:50 -0600149}
150
151Atmos.prototype.query = function(prefix, parameters, callback, pipeline) {
152 this.results = [];
153 this.dropdown = [];
154 this.resultTable.empty();
Tyler Scott7d076e22015-07-06 19:21:50 -0600155
156 var queryPrefix = new Name(prefix);
157 queryPrefix.append("query");
158
159 var jsonString = JSON.stringify(parameters);
160 queryPrefix.append(jsonString);
161
162 this.state = {
163 prefix: new Name(prefix),
164 userOnData: callback,
165 outstanding: {},
166 nextSegment: 0,
Tyler Scott575c61b2015-07-13 13:42:16 -0600167 parameters: jsonString
Tyler Scott7d076e22015-07-06 19:21:50 -0600168 };
169
170 /*if (state.hasOwnProperty("version")) {
171 console.log("state already has version");
172 }*/
173
174 var queryInterest = new Interest(queryPrefix);
175 queryInterest.setInterestLifetimeMilliseconds(10000);
176
177 var scope = this;
178
179 this.face.expressInterest(queryInterest,
Tyler Scotte815d3e2015-07-09 16:56:17 -0600180 function(interest, data){
181 scope.onQueryData(interest, data);
182 }, function(interest){
183 scope.onQueryTimeout(interest);
Tyler Scott7d076e22015-07-06 19:21:50 -0600184 }
185 );
186
187 this.state["outstanding"][queryInterest.getName().toUri()] = 0;
188}
189
Tyler Scotte815d3e2015-07-09 16:56:17 -0600190/**
191 * @deprecated
192 * Use applyFilters/addFilters as appropriate.
193 */
Tyler Scott7d076e22015-07-06 19:21:50 -0600194Atmos.prototype.submitCatalogSearch = function(field) {
Tyler Scotte815d3e2015-07-09 16:56:17 -0600195 console.warn("Use of deprecated function submitCatalogSearch! (Use applyFilters/addFilters as appropriate)");
Tyler Scott7d076e22015-07-06 19:21:50 -0600196}
197
198Atmos.prototype.expressNextInterest = function() {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600199 // @todo pipelines
Tyler Scotte815d3e2015-07-09 16:56:17 -0600200 var nextName = new Name(this.state["results"]);
201 nextName.appendSegment(this.state["nextSegment"]);
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600202
203 var nextInterest = new Interest(nextName);
204 nextInterest.setInterestLifetimeMilliseconds(10000);
205
Tyler Scott7d076e22015-07-06 19:21:50 -0600206 var scope = this;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600207
Tyler Scott7d076e22015-07-06 19:21:50 -0600208 this.face.expressInterest(nextInterest,
Tyler Scotte815d3e2015-07-09 16:56:17 -0600209 function(interest, data){
210 scope.onQueryResultsData(interest, data);
Tyler Scott7d076e22015-07-06 19:21:50 -0600211 },
Tyler Scotte815d3e2015-07-09 16:56:17 -0600212 function(interest){
213 scope.onQueryResultsTimeout(interest);
Tyler Scott7d076e22015-07-06 19:21:50 -0600214 });
215
216 this.state["nextSegment"] ++;
217 this.state["outstanding"][nextName.toUri()] = 0;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600218}
219
Tyler Scott7d076e22015-07-06 19:21:50 -0600220Atmos.prototype.onQueryData = function(interest, data) {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600221 var name = data.getName();
222
Tyler Scott7d076e22015-07-06 19:21:50 -0600223 delete this.state["outstanding"][interest.getName().toUri()];
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600224
Tyler Scott7d076e22015-07-06 19:21:50 -0600225 this.state["version"] = name.get(this.state["prefix"].size() + 2).toVersion();
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600226
Tyler Scott575c61b2015-07-13 13:42:16 -0600227 this.state["results"] = new Name(this.state["prefix"]).append("query-results").append(this.state['parameters']).appendVersion(this.state["version"]);
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600228
Tyler Scott7d076e22015-07-06 19:21:50 -0600229 this.expressNextInterest();
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600230}
231
Tyler Scott7d076e22015-07-06 19:21:50 -0600232Atmos.prototype.onQueryResultsData = function(interest, data) {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600233 var name = data.getName();
Tyler Scott7d076e22015-07-06 19:21:50 -0600234 delete this.state["outstanding"][interest.getName().toUri()];
Tyler Scottf08ab962015-06-30 16:31:29 -0600235 if (!name.get(-1).equals(data.getMetaInfo().getFinalBlockId())) {
Tyler Scott7d076e22015-07-06 19:21:50 -0600236 this.expressNextInterest();
Tyler Scottf08ab962015-06-30 16:31:29 -0600237 } //else {
238 //alert("found final block");
239 //}
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600240
Tyler Scott7d076e22015-07-06 19:21:50 -0600241 this.state["userOnData"](data);
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600242}
243
Tyler Scott7d076e22015-07-06 19:21:50 -0600244Atmos.prototype.onQueryTimeout = function(interest) {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600245 var uri = interest.getName().toUri();
Tyler Scott7d076e22015-07-06 19:21:50 -0600246 if (this.state["outstanding"][uri] < 1) {
247 this.state["outstanding"][uri] ++;
248 var scope = this;
249 this.face.expressInterest(interest,
Tyler Scott575c61b2015-07-13 13:42:16 -0600250 function(interest, data){
251 scope.onQueryData(interest, data);
Tyler Scott7d076e22015-07-06 19:21:50 -0600252 },
Tyler Scott575c61b2015-07-13 13:42:16 -0600253 function(interest){
254 scope.onQueryTimeout(interest);
Tyler Scott7d076e22015-07-06 19:21:50 -0600255 });
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600256 } else {
Tyler Scott7d076e22015-07-06 19:21:50 -0600257 delete this.state["outstanding"][uri];
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600258
259 // We modify the autocomplete box here because we need to know
260 // we have all of the entries first. Fairly hacky.
Tyler Scott7d076e22015-07-06 19:21:50 -0600261 /* TODO FIXME
262 var autocompleteFullName = this.autocompleteText.value;
263 for (var i = 0; i < dropdown.length; ++i) {
264 if (this.dropdown[i].substr(0, dropdown[i].length - 1).toUpperCase === this.autocompleteText.value.toUpperCase || dropdown.length == 1) {
265 autocompleteText.value = dropdown[i];
266 }
267 }
268 */
269 }
270}
271
272Atmos.prototype.onQueryResultsTimeout = function(interest) {
273 var uri = interest.getName().toUri();
274 if (this.state["outstanding"][uri] < 1) {
275 this.state["outstanding"][uri] ++;
276 var scope = this;
277 this.face.expressInterest(interest,
278 function(){
279 scope.onQueryResultsData.apply(scope, arguments);
280 },
281 function(){
282 scope.onQueryResultsTimeout.apply(scope, arguments);
283 });
284 } else {
285 delete this.state["outstanding"][uri];
286 // We modify the autocomplete box here because we need to know
287 // we have all of the entries first. Fairly hacky.
288 /* TODO FIXME
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600289 var autocompleteFullName = autocompleteText.value;
290 for (var i = 0; i < dropdown.length; ++i) {
291 if (dropdown[i].substr(0, dropdown[i].length - 1).toUpperCase === autocompleteText.value.toUpperCase || dropdown.length == 1) {
292 autocompleteText.value = dropdown[i];
293 }
294 }
Tyler Scott7d076e22015-07-06 19:21:50 -0600295 */
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600296 }
297}
298
Tyler Scott7d076e22015-07-06 19:21:50 -0600299Atmos.prototype.populateResults = function(startIndex) {
300 this.resultTable.empty();
Tyler Scott424ee102015-07-14 16:50:41 -0600301 //this.resultTable.append('<tr><th colspan="2">Results</th></tr>');
Tyler Scott7d076e22015-07-06 19:21:50 -0600302
303 for (var i = startIndex; i < startIndex + 20 && i < this.results.length; ++i) {
Tyler Scott087aef72015-07-14 14:11:59 -0600304 this.resultTable.append('<tr><td>' + this.results[i]
305 + '</td><td><button class="interest-button btn btn-primary btn-xs">Retrieve</button></td></tr>');
Tyler Scott7d076e22015-07-06 19:21:50 -0600306 }
307
308 if (this.results.length <= 20) {
309 this.page = 1;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600310 } else {
Tyler Scott7d076e22015-07-06 19:21:50 -0600311 this.page = startIndex / 20 + 1;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600312 }
313
Tyler Scott7d076e22015-07-06 19:21:50 -0600314 this.totalPages = Math.ceil(this.results.length / 20);
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600315
Tyler Scott7d076e22015-07-06 19:21:50 -0600316 //TODO Fix the page to fit the theme.
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600317 var currentPage = $(".page");
318 currentPage.empty();
Tyler Scott7d076e22015-07-06 19:21:50 -0600319 if (this.page != 1) {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600320 currentPage.append('<a href="#" onclick="getPage(this.id);" id="<"><</a>');
321 }
322 // This section of code creates the paging for the results.
323 // To prevent it from having a 1000+ pages, it will only show the 5 pages before/after
324 // the current page and the total pages (expect users not to really jump around a lot).
Tyler Scott7d076e22015-07-06 19:21:50 -0600325 for (var i = 1; i <= this.totalPages; ++i) {
326 if (i == 1 || i == this.totalPages // Min or max
327 || (i <= this.page && i + 5 >= this.page) // in our current page range
328 || (i >= this.page && i - 5 <= this.page)) { // in our current page range
329 if (i != this.page) {
Tyler Scottf08ab962015-06-30 16:31:29 -0600330 currentPage.append(' <a href="#" onclick="getPage(' + i + ');">' + i + '</a>')
Tyler Scott7d076e22015-07-06 19:21:50 -0600331 if (i == 1 && this.page > i + 5) {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600332 currentPage.append(' ... ');
333 }
334 } else {
335 currentPage.append(' ' + i);
336 }
337 } else { // Need to skip ahead
Tyler Scott087aef72015-07-14 14:11:59 -0600338 if (i == this.page + 6) {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600339 currentPage.append(' ... ');
340
Tyler Scottf08ab962015-06-30 16:31:29 -0600341 currentPage.append(' <a href="#" onclick="getPage(this.id);" id=">">></a>')
Tyler Scott7d076e22015-07-06 19:21:50 -0600342 i = this.totalPages - 1;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600343 }
344 }
345 }
Tyler Scott7d076e22015-07-06 19:21:50 -0600346 currentPage.append(' ' + this.results.length + ' results');
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600347}
348
Tyler Scott7d076e22015-07-06 19:21:50 -0600349Atmos.prototype.getPage = function(clickedPage) {
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600350 console.log(clickedPage);
351
352 var nextPage = clickedPage;
353 if (clickedPage === "<") {
Tyler Scott7d076e22015-07-06 19:21:50 -0600354 nextPage = this.page - 5;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600355 } else if (clickedPage === ">") {
356 console.log("> enabled");
357
Tyler Scott7d076e22015-07-06 19:21:50 -0600358 nextPage = this.page + 5;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600359 }
360
361 nextPage--; // Need to adjust for starting at 0
362
363 if (nextPage < 0 ) {
364 nextPage = 0;
365 console.log("0 enabled");
Tyler Scott7d076e22015-07-06 19:21:50 -0600366 } else if (nextPage > this.totalPages - 1) {
367 nextPage = this.totalPages - 1;
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600368 console.log("total enabled");
369 }
370
Tyler Scott7d076e22015-07-06 19:21:50 -0600371 this.populateResults(nextPage * 20);
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600372 return false;
373}
374
Tyler Scott7d076e22015-07-06 19:21:50 -0600375
376Atmos.prototype.submitAutoComplete = function() {
377 /* FIXME TODO
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600378 if (autocompleteText.value.length > 0) {
379 var selection = autocompleteText.value;
380 $.each(dropdown, function (i, dropdownEntry) {
381 if (dropdownEntry.substr(0, dropdownEntry.length - 1) == selection) {
382 selection = dropdownEntry;
383 }
384 });
385
386 selectedSearch["?"] = selection;
387 query(catalog, selectedSearch, onData, 1);
388 delete selectedSearch["?"];
389 }
Tyler Scott7d076e22015-07-06 19:21:50 -0600390 */
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600391}
392
Tyler Scott7d076e22015-07-06 19:21:50 -0600393Atmos.prototype.populateAutocomplete = function(fields) {
394 /* FIXME TODO
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600395 var isAutocompleteFullName = (autocompleteText.value.charAt(autocompleteText.value.length - 1) === "/");
396 var autocompleteFullName = autocompleteText.value;
397 for (var i = 0; i < fields.length; ++i) {
398 var fieldFullName = fields[i];
399 var entry = autocompleteFullName;
400 var skipahead = "";
401
402 if (isAutocompleteFullName) {
403 skipahead = fieldFullName.substr(autocompleteText.value.length, fieldFullName.length);
404 } else {
405 if (fieldFullName.charAt(autocompleteText.value.length) === "/") {
406 entry += "/";
407 skipahead = fieldFullName.substr(autocompleteText.value.length + 1, fieldFullName.length);
408 } else {
409 skipahead = fieldFullName.substr(autocompleteText.value.length, fieldFullName.length);
410 }
411 }
412 if (skipahead.indexOf("/") != -1) {
413 entry += skipahead.substr(0, skipahead.indexOf("/") + 1);
414 } else {
415 entry += skipahead;
416 }
417
418 var added = false;
419 for (var j = 0; j < dropdown.length && !added; ++j) {
420 if (dropdown[j] === entry) {
421 added = true;
422 } else if (dropdown[j] > entry) {
423 dropdown.splice(j, 0, entry);
424 added = true;
425 }
426 }
427 if (!added) {
428 dropdown.push(entry);
429 }
430
431 }
432 $("#autocompleteText").autocomplete({
433 source: dropdown
434 });
Tyler Scott7d076e22015-07-06 19:21:50 -0600435 */
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600436}
437
Tyler Scotte815d3e2015-07-09 16:56:17 -0600438/**
439 * Adds a filter to the list of filters.
Tyler Scott087aef72015-07-14 14:11:59 -0600440 * If a filter is already added, it will be removed instead.
Tyler Scotte815d3e2015-07-09 16:56:17 -0600441 *
442 * @param {string} filter
443 */
Tyler Scott575c61b2015-07-13 13:42:16 -0600444Atmos.prototype.addFilter = function(name, category){
Tyler Scotte815d3e2015-07-09 16:56:17 -0600445 var existing = this.filters.find('span:contains(' + name + ')');
446 if (existing.length){
447 //If the category is clicked twice, then we delete it.
448 existing.remove();
449 this.applyFilters();
450
451 } else {
452
453 var filter = $('<span class="label label-default"></span>');
Tyler Scott575c61b2015-07-13 13:42:16 -0600454 filter.text(category + ':' + name);
Tyler Scotte815d3e2015-07-09 16:56:17 -0600455
456 this.filters.append(filter);
457
458 this.applyFilters();
459
460 var scope = this;
461 filter.click(function(){
462 $(this).remove();
463 scope.applyFilters();
464 });
465
466 }
467
468}
469
470Atmos.prototype.applyFilters = function(){
Tyler Scott575c61b2015-07-13 13:42:16 -0600471 var filters = this.filters.children().toArray().reduce(function(prev, current){
472 var data = $(current).text().split(/:/);
473 prev[data[0]] = data[1];
474 return prev;
475 }, {});
Tyler Scotte815d3e2015-07-09 16:56:17 -0600476 console.log('Collected filters:', filters);
Tyler Scott087aef72015-07-14 14:11:59 -0600477 var scope = this;
Tyler Scotte815d3e2015-07-09 16:56:17 -0600478 this.query(this.catalog, filters, function(data){
479 scope.onData(data);
480 }, 1);
481}
482
483/**
484 * @deprecated
485 * Use addFilter instead.
486 */
487Atmos.prototype.populateCurrentSelections = function() {
488 console.warn("Use of deprecated function populateCurrentSelections! (Use addFilter instead)");
489 /*
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600490 var currentSelection = $(".currentSelections");
491 currentSelection.empty();
492
493 currentSelection.append("<p>Filtering on:");
494
Tyler Scott7d076e22015-07-06 19:21:50 -0600495 var scope = this;
496
497 $.each(this.selectedSearch, function (searchMenuCatagory, selection) {
498 var e = $('<a href="#">[X] ' + searchMenuCatagory + ":" + selection + '</a>');
499 e.onclick(function(){
500 var searchFilter = $(this).text();
501
502 var search = "";
503 for (var j = 0; j < searchFilter.length; ++j) {
504 search += searchFilter[j] + " ";
505 }
506 console.log("Split values: '" + search + "'");
507
508 delete this.selectedSearch[searchFilter[0]];
509 this.query(catalog, selectedSearch, onData, 1);
510 populateCurrentSelections();
511 });
512 currentSelection.append(e);
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600513 });
514
515 currentSelection.append("</p>");
Tyler Scotte815d3e2015-07-09 16:56:17 -0600516 */
Tyler Scott3c17d5f2015-06-23 17:49:29 -0600517}