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