Skip to content

Commit

Permalink
ES6: migrated "search"
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann committed Apr 18, 2017
1 parent 8d42b37 commit 51335b0
Show file tree
Hide file tree
Showing 12 changed files with 335 additions and 279 deletions.
1 change: 0 additions & 1 deletion app/script/event/WebApp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ z.event.WebApp =
UPDATED: 'wire.webapp.properties.updated'
SEARCH:
HIDE: 'wire.webapp.search.hide'
ONBOARDING: 'wire.webapp.search.onboarding'
SHOW: 'wire.webapp.people-picker.show'
BADGE:
HIDE: 'wire.webapp.search.badge.hide'
Expand Down
43 changes: 0 additions & 43 deletions app/script/search/FullTextSearch.coffee

This file was deleted.

52 changes: 52 additions & 0 deletions app/script/search/FullTextSearch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.search = z.search || {};

z.search.FullTextSearch = (function() {

const _get_search_regex = function(query) {
const delimiter = ' ';
const flags = 'gumi';
const regex = query
.trim()
.split(delimiter)
.map((word) => `(${z.util.escape_regex(word)})`)
.join('(?:.*)');

return new RegExp(regex, flags);
};

const _search = function(text, query = '') {
query = query.trim();

if (query.length > 0) {
return _get_search_regex(query).test(text);
}
return false;
};

return {
get_search_regex: _get_search_regex,
search: _search,
};
})();
25 changes: 0 additions & 25 deletions app/script/search/SearchMode.coffee

This file was deleted.

29 changes: 29 additions & 0 deletions app/script/search/SearchMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.search = z.search || {};

// Enum of different search modes.
z.search.SEARCH_MODE = {
CONTACTS: 'contacts',
ON_BOARDING: 'onboarding',
};
119 changes: 0 additions & 119 deletions app/script/search/SearchRepository.coffee

This file was deleted.

Loading

0 comments on commit 51335b0

Please sign in to comment.