|
30 | 30 | * the sidebar UI with the results from the privacy proxy. |
31 | 31 | */ |
32 | 32 | function getRecommendationsFromInput() { |
| 33 | + removeInfo(); |
33 | 34 | removeError(); |
| 35 | + |
34 | 36 | var keyword = $("#eexcess-search").val(); |
35 | 37 | if(keyword == "") { |
36 | | - showError("Please enter some text.", $('#button-bar')); |
| 38 | + showError("Please enter some text."); |
37 | 39 | } else { |
38 | 40 | this.disabled = true; |
39 | 41 | fetchAndDisplayRecommendations(keyword, this); |
|
86 | 88 | removeAjaxLoader(); |
87 | 89 |
|
88 | 90 | if (lastSearchedText == text) |
89 | | - showError("The server timed out waiting for the request.", $('#button-bar')); |
| 91 | + showError("The server timed out waiting for the request."); |
90 | 92 |
|
91 | 93 | if (button) |
92 | 94 | button.disabled = false; |
|
110 | 112 | function(errorMsg, button) { |
111 | 113 | if(!timeout && lastSearchedText == text) { |
112 | 114 | removeAjaxLoader(); |
113 | | - showError(errorMsg, $('#button-bar')); |
| 115 | + showError(errorMsg); |
114 | 116 |
|
115 | 117 | if (button) |
116 | 118 | button.disabled = false; |
|
195 | 197 | container.append(template); |
196 | 198 | }) |
197 | 199 | } else { |
198 | | - showError("No results found", $('#button-bar')); |
| 200 | + showError("No results found"); |
199 | 201 | } |
200 | 202 | } |
201 | 203 |
|
|
205 | 207 | * @param msg The error message to display. |
206 | 208 | * @param element The element after which to display the error. |
207 | 209 | */ |
208 | | - function showError(msg, element) { |
| 210 | + function showError(msg) { |
209 | 211 | removeError(); |
210 | 212 | var div = $('<div id="error" class="error">' + msg + '</div>'); |
211 | | - $(element).after(div); |
| 213 | + $("#eexcess-recommendations-list").after(div); |
212 | 214 | } |
213 | 215 |
|
214 | 216 | /** |
|
218 | 220 | $("#error").remove(); |
219 | 221 | } |
220 | 222 |
|
| 223 | + /** |
| 224 | + * Removes the initially added info message. |
| 225 | + */ |
| 226 | + function removeInfo() { |
| 227 | + $("#info").remove(); |
| 228 | + } |
| 229 | + |
221 | 230 | /** |
222 | 231 | * Inserts the ajax loader icon. |
223 | 232 | */ |
224 | 233 | function showAjaxLoader() { |
225 | | - if ($("#ajax-loader-container").length == 0) |
226 | | - $('<div id="ajax-loader-container"><img src="http://mics.fim.uni-passau.de/wp-content/uploads/2014/10/ajax-loader.gif" width="16px" height="16px" alt="ajax loader"/></div>').insertAfter("#eexcess-recommendations-list"); |
| 234 | + if ($("#ajax-loader-container").length == 0) { |
| 235 | + var div = $('<div id="ajax-loader-container"><img src="http://mics.fim.uni-passau.de/wp-content/uploads/2014/10/ajax-loader.gif" width="16px" height="16px" alt="ajax loader"/></div>'); |
| 236 | + $("#eexcess-recommendations-list").after(div); |
| 237 | + } |
227 | 238 | } |
228 | 239 |
|
229 | 240 | /** |
|
0 commit comments