Commit 5104af10 authored by Alain Takoudjou's avatar Alain Takoudjou

Mynij Search: Fix error when there is no result from searx search.

parent 18460604
......@@ -169,6 +169,7 @@
.declareMethod("add_searx_results", function (key) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({
......@@ -177,12 +178,9 @@
});
})
.push(undefined, function (error) {
var error_html;
error_html = document.createElement("p");
error_html.className = "no-result";
error_html.textContent = "An error occured, please try again. " +
error.message || '';
return gadget.state.result_gadget.show_searx_result(error_html);
return gadget.state.result_gadget.add_searx_no_result(
"An error occured, please try again. " + error.message || ''
);
})
.push(function (resultHTML) {
var i,
......@@ -192,6 +190,10 @@
resultHTML.currentTarget.response,
"text/html");
elements = doc.body.querySelectorAll('div.result.result-default');
if (elements.length === 0)
return gadget.state.result_gadget.add_searx_no_result(
"No result from your input, please update and try again."
);
for (i = 0; i < elements.length; i += 1) {
promise_list.push(gadget.state.result_gadget.show_searx_result(
elements[i],
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.25983.38944.13892</string> </value>
<value> <string>987.26215.20691.32768</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1603109825.17</float>
<float>1603124167.5</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -95,6 +95,20 @@
});
})
.declareMethod("add_searx_no_result", function (msg) {
var error_html,
list_item = document.createElement("li"),
loader = document.getElementById("searx-loading"),
list = document.getElementById("searx-results");
loader.style.display = "none";
error_html = document.createElement("p");
error_html.className = "no-result";
error_html.textContent = msg;
list_item.appendChild(error_html);
list.appendChild(list_item);
})
.declareMethod("show_searx_result", function (item, key) {
var list,
list_item,
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.25959.50752.32221</string> </value>
<value> <string>987.26221.22837.50619</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1603109745.73</float>
<float>1603124223.76</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -32,6 +32,10 @@
display: none;
}
.no-result {
font-size: 1.5em;
}
@media (max-width: 600px) {
#mynij-results > li, #searx-results > li {
width: 100%;
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.26073.25277.8823</string> </value>
<value> <string>987.26223.8725.60620</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1603115441.29</float>
<float>1603124265.14</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment