Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
144
Merge Requests
144
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
570bfc6d
Commit
570bfc6d
authored
Nov 18, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_project_ui: parse web page content using DOMParser
parent
d0b270a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
bt5/erp5_web_project_ui/SkinTemplateItem/portal_skins/erp5_web_project/gadget_project_info.js.js
...m/portal_skins/erp5_web_project/gadget_project_info.js.js
+19
-13
No files found.
bt5/erp5_web_project_ui/SkinTemplateItem/portal_skins/erp5_web_project/gadget_project_info.js.js
View file @
570bfc6d
/*jslint nomen: true, indent: 2 */
/*global window, rJS, RSVP, document, ensureArray*/
(
function
(
window
,
rJS
,
RSVP
,
document
,
ensureArray
)
{
/*global window, rJS, RSVP, document, ensureArray
, DOMParser, XMLSerializer
*/
(
function
(
window
,
rJS
,
RSVP
,
document
,
ensureArray
,
DOMParser
,
XMLSerializer
)
{
"
use strict
"
;
function
addRedirectionToReference
(
href
,
url
)
{
if
(
!
href
.
startsWith
(
"
https
"
)
&&
!
href
.
startsWith
(
"
http
"
)
&&
!
href
.
startsWith
(
"
ftp
"
)
&&
!
href
.
includes
(
"
/
"
)
)
{
href
=
url
+
"
&n.reference=
"
+
href
;
}
return
href
;
}
function
parseHTMLLinks
(
html
,
url
)
{
var
content
=
document
.
createElement
(
'
html
'
),
regex
=
/href="
(
.*
?)
"/g
,
link
;
while
((
link
=
regex
.
exec
(
html
))
!==
null
)
{
if
(
!
link
[
1
].
startsWith
(
"
https
"
)
&&
!
link
[
1
].
startsWith
(
"
http
"
)
&&
!
link
[
1
].
startsWith
(
"
ftp
"
)
&&
!
link
[
1
].
includes
(
"
/
"
)
)
{
html
=
html
.
replace
(
link
[
1
],
url
+
"
&n.reference=
"
+
link
[
1
]);
}
var
parser
=
new
DOMParser
(),
i
,
oSerializer
=
new
XMLSerializer
(),
doc
=
parser
.
parseFromString
(
html
,
"
text/html
"
),
link_list
=
doc
.
getElementsByTagName
(
"
a
"
);
for
(
i
=
0
;
i
<
link_list
.
length
;
i
++
)
{
link_list
[
i
].
setAttribute
(
'
href
'
,
addRedirectionToReference
(
link_list
[
i
].
getAttribute
(
'
href
'
),
url
));
}
return
html
;
return
oSerializer
.
serializeToString
(
doc
)
;
}
function
enableLink
(
link_element
,
url
)
{
...
...
@@ -205,4 +211,4 @@
return
true
;
});
}(
window
,
rJS
,
RSVP
,
document
,
ensureArray
));
\ No newline at end of file
}(
window
,
rJS
,
RSVP
,
document
,
ensureArray
,
DOMParser
,
XMLSerializer
));
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment