1
|
|
|
/* |
2
|
|
|
* FullTextSearch - Full text search framework for Nextcloud |
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
|
|
|
/** global: OCA */ |
27
|
|
|
/** global: settings */ |
28
|
|
|
/** global: curr */ |
29
|
|
|
/** global: nav */ |
30
|
|
|
|
31
|
|
|
/** @namespace result.provider */ |
32
|
|
|
/** @namespace result.documents */ |
33
|
|
|
|
34
|
|
|
var result = { |
35
|
|
|
|
36
|
|
|
displayResult: function (res) { |
37
|
|
|
if (settings.resultContainer === null) { |
38
|
|
|
return; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
var searchResult = res.result; |
42
|
|
|
if (searchResult.length === 0) { |
43
|
|
|
result.displayNoResult(); |
44
|
|
|
return; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
for (var i = 0; i < searchResult.length; i++) { |
48
|
|
|
result.displayProviderResult(res.request, searchResult[i]); |
49
|
|
|
} |
50
|
|
|
}, |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
displayError: function (res) { |
|
|
|
|
54
|
|
|
}, |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
displayNoResult: function () { |
58
|
|
|
settings.divNoResult.fadeTo(settings.delay_result, 1); |
59
|
|
|
settings.resultContainer.find('.provider_header').each(function () { |
60
|
|
|
$(this).fadeTo(settings.delay_result, 0); |
61
|
|
|
}); |
62
|
|
|
}, |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
displayProviderResult: function (request, result) { |
66
|
|
|
|
67
|
|
|
settings.divNoResult.fadeTo(settings.delay_result, 0); |
68
|
|
|
|
69
|
|
|
var current = curr.getProviderResult(result.provider.id); |
70
|
|
|
var divProvider = nav.getDivProvider(result.provider.id, result.provider.name); |
71
|
|
|
|
72
|
|
|
nav.manageDivProviderNavigation(divProvider.children('.provider_navigation'), request, result.meta); |
73
|
|
|
nav.manageDivProviderResult(divProvider.children('.provider_result'), result.documents, |
74
|
|
|
current.documents); |
75
|
|
|
|
76
|
|
|
divProvider.slideDown(settings.delay_provider, function () { |
77
|
|
|
$(this).fadeTo(settings.delay_provider, 1); |
78
|
|
|
}); |
79
|
|
|
|
80
|
|
|
curr.setProviderResult(result.provider.id, result); |
81
|
|
|
}, |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
recalibrateResult: function (oldResult, newResult) { |
85
|
|
|
var tmpResult = []; |
86
|
|
|
for (var i = 0; i < oldResult.length; i++) { |
87
|
|
|
if (result.getResultIndex(oldResult[i].id, newResult) > -1) { |
88
|
|
|
tmpResult.push(oldResult[i]); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return tmpResult; |
93
|
|
|
}, |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
getResultIndex: function (id, result) { |
97
|
|
|
if (!result) { |
98
|
|
|
return -1; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
for (var i = 0; i < result.length; i++) { |
102
|
|
|
if (result[i].id === id) { |
103
|
|
|
return i; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return -1; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
}; |
112
|
|
|
|
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.