/*
* FullTextSearch - Full text search framework for Nextcloud
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange
* @copyright 2018
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*
*/
/** global: OCA */
/** global: _ */
var fullTextSearch = OCA.FullTextSearch.api;
var elements = {
searchTimeout: null,
search_input: null,
search_submit: null,
search_result: null,
search_json: null
};
var Navigate = function () {
this.init();
};
Navigate.prototype = {
currentTagsResult: {},
selectedTags: {},
init: function () {
var self = this;
elements.search_input = $('#search_input');
elements.search_submit = $('#search_submit');
elements.search_result = $('#search_result');
elements.search_panels = $('#search_navigation');
// elements.search_json = $('#search_json');
elements.divHeader = $('#search_header');
box_elements.searchError = $('#search_error');
// fullTextSearch.setEntryTemplate($('#template_entry'), self);
fullTextSearch.setResultContainer(elements.search_result);
elements.search_input.on('input', this.navigateTimedSearch);
// function () {
// self.resetSearch();
// if (elements.searchTimeout === null && self.initSearch()) {
// elements.searchTimeout = _.delay(function () {
// self.initSearch();
// elements.searchTimeout = null;
// }, 3000);
// }
// });
//
// $(document).keypress(function (e) {
// if (e.which === 13) {
// self.initSearch(true);
// }
// });
self.initPanels();
},
navigateTimedSearch: function () {
if (curr.lastSearchTimer !== null) {
window.clearTimeout(curr.lastSearchTimer);
}
curr.lastSearchTimer = window.setTimeout(function () {
OCA.FullTextSearch.navigate.initSearch();
}, settings.searchEntryTimer);
if (curr.lastRequestTimer === null) {
curr.lastRequestTimer = window.setTimeout(function () {
OCA.FullTextSearch.navigate.initSearch();
}, settings.searchRequestTimer);
}
},
initPanels: function () {
var self = this;
$.ajax({
method: 'GET',
url: OC.generateUrl('/apps/fulltextsearch/navigation/panels')
}).done(function (res) {
self.displayPanels(res);
});
},
displayPanels: function (data) {
var self = this;
var ak = Object.keys(data);
for (var i = 0; i < ak.length; i++) {
var providerAppId = ak[i];
var title = data[ak[i]]['title'];
var options = data[ak[i]]['options'];
var css = data[ak[i]]['css'];
var icon = data[ak[i]]['icon'];
var providerId = data[ak[i]]['provider'];
if (css !== '') {
OC.addStyle(providerAppId, css);
}
var li = $('