Commit 8f9368a1 authored by Alain Takoudjou's avatar Alain Takoudjou

erp5_web_mynij_search: clean a bit more result content page

parent cb98a3c9
...@@ -313,10 +313,10 @@ ...@@ -313,10 +313,10 @@
// remove all <script> sections // remove all <script> sections
.replace(/(<script[^>]*>[^>]*.*<\/script>)/gm, ''); .replace(/(<script[^>]*>[^>]*.*<\/script>)/gm, '');
// remove footers, headers // remove footers, headers
tmp_div.querySelectorAll('link, style, script, footer, header') tmp_div.querySelectorAll(
'link, style, script, footer, header, noscript, picture')
.forEach(function (item) { .forEach(function (item) {
let parent = item.parentNode; item.remove();
parent.remove(item);
}); });
} }
if (!tmp_div) if (!tmp_div)
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.50963.40839.11502</string> </value> <value> <string>988.6617.37252.48349</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1604610243.41</float> <float>1605884721.12</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80*/ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80*/
/*global window, RSVP, rJS, document, DOMParser*/ /*global window, RSVP, rJS, document, DOMParser, URL*/
(function (window, RSVP, rJS, document, DOMParser) { (function (window, RSVP, rJS, document, DOMParser, URL) {
"use strict"; "use strict";
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
title.href = item.link; title.href = item.link;
list_item.appendChild(title); list_item.appendChild(title);
link = document.createElement("a"); link = document.createElement("a");
link.appendChild(document.createTextNode(item.link)); link.appendChild(document.createTextNode(cut_link));
link.href = item.link; link.href = item.link;
link.className = "link"; link.className = "link";
link_par = document.createElement('p'); link_par = document.createElement('p');
...@@ -245,12 +245,27 @@ ...@@ -245,12 +245,27 @@
return extract_description(result[0]); return extract_description(result[0]);
}) })
.declareMethod("cut_link", function (link) { .declareMethod("cut_link", function (link) {
var url,
short_url = "",
page_name,
ext;
if (link === undefined) if (link === undefined)
return ""; return "";
if (link.length > 70) if (link.length < 70) {
return link.slice(0, 70) + "...";
else
return link; return link;
}
url = new URL(link);
short_url = url.origin + '/.../';
page_name = url.pathname.split('/').pop();
if (page_name.length > 50) {
ext = page_name.split('.').pop();
short_url += page_name.slice(0, 40) + '....' + ext;
} else {
short_url += page_name;
}
return short_url;
}); });
}(window, RSVP, rJS, document, DOMParser)); }(window, RSVP, rJS, document, DOMParser, URL));
\ No newline at end of file \ No newline at end of file
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.31610.30930.31436</string> </value> <value> <string>988.6676.48485.45158</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1604431247.07</float> <float>1605883520.14</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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