diff --git a/public/src/app.js b/public/src/app.js index ecb17de0c9..7a3a13d080 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -435,7 +435,9 @@ app.cacheBuster = null; $('#search-form').on('submit', function () { var input = $(this).find('input'); require(['search'], function(search) { - search.query({term: input.val()}, function() { + var data = search.getSearchPreferences(); + data.term = input.val(); + search.query(data, function() { input.val(''); }); }); diff --git a/public/src/client/search.js b/public/src/client/search.js index 6ca5b8dc41..bf07ad70b6 100644 --- a/public/src/client/search.js +++ b/public/src/client/search.js @@ -1,6 +1,6 @@ 'use strict'; -/* globals app, define, utils, socket*/ +/* globals app, define, utils*/ define('forum/search', ['search', 'autocomplete'], function(searchModule, autocomplete) { var Search = {}; @@ -67,7 +67,7 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco function fillOutForm() { var params = utils.params(); - var searchData = getSearchPreferences(); + var searchData = searchModule.getSearchPreferences(); params = utils.merge(searchData, params); if (params) { @@ -156,14 +156,6 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco }); } - function getSearchPreferences() { - try { - return JSON.parse(localStorage.getItem('search-preferences')); - } catch(e) { - return {}; - } - } - function enableAutoComplete() { autocomplete.user($('#posted-by-user')); } diff --git a/public/src/modules/search.js b/public/src/modules/search.js index e24ecbed61..e376c30639 100644 --- a/public/src/modules/search.js +++ b/public/src/modules/search.js @@ -73,6 +73,14 @@ define('search', ['navigator', 'translator'], function(nav, translator) { return decodeURIComponent($.param(query)); } + Search.getSearchPreferences = function() { + try { + return JSON.parse(localStorage.getItem('search-preferences')); + } catch(e) { + return {}; + } + }; + Search.queryTopic = function(tid, term, callback) { socket.emit('topics.search', { tid: tid,