|
|
|
@ -7,24 +7,14 @@ define('search', ['navigator', 'translator', 'storage'], function (nav, translat
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Search.query = function (data, callback) {
|
|
|
|
|
var term = data.term;
|
|
|
|
|
|
|
|
|
|
// Detect if a tid was specified
|
|
|
|
|
var topicSearch = term.match(/^in:topic-([\d]+) /);
|
|
|
|
|
var topicSearch = data.term.match(/^in:topic-([\d]+) /);
|
|
|
|
|
|
|
|
|
|
if (!topicSearch) {
|
|
|
|
|
term = term.replace(/^[ ?#]*/, '');
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
term = encodeURIComponent(term);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return app.alertError('[[error:invalid-search-term]]');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ajaxify.go('search?' + createQueryString(data));
|
|
|
|
|
callback();
|
|
|
|
|
} else {
|
|
|
|
|
var cleanedTerm = term.replace(topicSearch[0], '');
|
|
|
|
|
var cleanedTerm = data.term.replace(topicSearch[0], '');
|
|
|
|
|
var tid = topicSearch[1];
|
|
|
|
|
|
|
|
|
|
if (cleanedTerm.length > 0) {
|
|
|
|
@ -36,8 +26,15 @@ define('search', ['navigator', 'translator', 'storage'], function (nav, translat
|
|
|
|
|
function createQueryString(data) {
|
|
|
|
|
var searchIn = data.in || 'titlesposts';
|
|
|
|
|
var postedBy = data.by || '';
|
|
|
|
|
var term = data.term.replace(/^[ ?#]*/, '');
|
|
|
|
|
try {
|
|
|
|
|
term = encodeURIComponent(term);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return app.alertError('[[error:invalid-search-term]]');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var query = {
|
|
|
|
|
term: data.term,
|
|
|
|
|
term: term,
|
|
|
|
|
in: searchIn,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|