Completed
Push — master ( 434333...96e84a )
by Maxence
01:59
created

Files_FullTextSearch.init   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.4285
1
/*
2
 * Files_FullTextSearch - Index the content of your files
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2018
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
27
/** global: OCA */
28
29
const fullTextSearch = OCA.FullTextSearch.api;
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
30
31
32
var elements = {
33
	old_files: null,
34
	search_result: null,
35
};
36
37
38
const Files_FullTextSearch = function () {
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
39
	this.init();
40
};
41
42
43
Files_FullTextSearch.prototype = {
44
45
	init: function () {
46
		var self = this;
47
48
		elements.old_files = $('#app-content-files');
49
50
		elements.search_result = $('<div>');
51
		elements.search_result.insertBefore(elements.old_files);
52
53
		fullTextSearch.setEntryTemplate(self.generateTemplateEntry());
54
		fullTextSearch.setResultContainer(elements.search_result);
55
		fullTextSearch.initFullTextSearch('files', self);
56
	},
57
58
59
	generateTemplateEntry: function () {
60
61
		var divLeft = $('<div>', {class: 'result_entry_left'});
62
		divLeft.append($('<div>', {id: 'title'}));
63
		divLeft.append($('<div>', {id: 'line1'}));
64
		divLeft.append($('<div>', {id: 'line2'}));
65
66
		var divRight = $('<div>', {class: 'result_entry_right'});
67
		divRight.append($('<div>', {id: 'score'}));
68
69
		var divDefault = $('<div>', {class: 'result_entry_default'});
70
		divDefault.append(divLeft);
71
		divDefault.append(divRight);
72
73
		return $('<div>').append(divDefault);
74
	},
75
76
77
	// searchResult: function (result) {
78
	// 	elements.old_files.fadeOut(150, function () {
79
	// 		elements.search_result.fadeIn(150);
80
	// 	});
81
	//
82
	// 	// console.log('> ' + JSON.stringify(result));
83
	// },
84
85
86
	onEntryGenerated: function (entry) {
0 ignored issues
show
Unused Code introduced by
The parameter entry is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
87
	},
88
89
90
91
	onResultDisplayed: function () {
92
		elements.old_files.fadeOut(150, function () {
93
			elements.search_result.fadeIn(150);
94
		});
95
	},
96
97
98
	onSearchReset: function () {
99
		elements.search_result.fadeOut(150, function () {
100
			elements.old_files.fadeIn(150);
101
		});
102
	}
103
104
};
105
106
107
OCA.FullTextSearch.Files = Files_FullTextSearch;
108
109
$(document).ready(function () {
110
	OCA.FullTextSearch.navigate = new Files_FullTextSearch();
111
});
112
113
114
115