Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yPhil
Pétrolette
Commits
d658ffa8
Commit
d658ffa8
authored
Aug 07, 2020
by
yPhil
Browse files
Description in YTube channel items
parent
760c463e
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/js/PTL.feed.js
View file @
d658ffa8
...
...
@@ -263,11 +263,17 @@ PTL.feed = {
// PTL.util.console('PLOP', 'warning');
// function strip(html){
// var doc = new DOMParser().parseFromString(html, 'text/html');
// return doc.body.textContent || "";
// }
if
(
index
==
parseInt
(
feedLimit
))
return
false
;
// console.log('i: (%s)', JSON.stringify(item));
var
$description
=
$
.
parseHTML
(
item
.
description
),
summary
,
imageUrl
,
// imageUrls = [],
imgTypes
=
[
'
image
'
,
...
...
@@ -276,6 +282,26 @@ PTL.feed = {
'
image/gif
'
,
'
image/png
'
];
console
.
log
(
'
DESCRIPTION!! (%s)
'
,
feedUrl
);
if
(
item
.
summary
){
console
.
log
(
'
item.summary : %s
'
,
item
.
summary
)
summary
=
item
.
summary
;
}
if
(
item
.
description
){
console
.
log
(
'
item.description : %s
'
,
item
.
description
)
summary
=
item
.
description
;
}
if
(
item
[
'
media:group
'
])
{
if
(
item
[
'
media:group
'
][
'
media:description
'
])
{
console
.
log
(
'
group : %s
'
,
item
[
'
media:group
'
][
'
media:description
'
][
"
#
"
])
summary
=
item
[
'
media:group
'
][
'
media:description
'
][
"
#
"
];
}
}
var
$imageLink
=
$
(
'
<a>
'
).
attr
(
'
target
'
,
'
_blank
'
),
$itemLink
=
$
(
'
<a>
'
).
attr
(
'
target
'
,
'
_blank
'
),
$soundLink
=
$
(
'
<a>
'
).
attr
(
'
target
'
,
'
_blank
'
),
...
...
@@ -283,7 +309,7 @@ PTL.feed = {
$commentsIcon
=
$
(
'
<i>
'
),
$soundIcon
=
$
(
'
<i>
'
),
$image
,
$summary
=
$
(
'
<null>
'
).
append
(
item
.
summary
||
item
.
description
).
text
(),
$summary
=
$
(
'
<null>
'
).
append
(
PTL
.
util
.
sanitizeInput
(
summary
)
).
text
(),
$itemDiv
=
$
(
'
<div>
'
).
attr
(
'
class
'
,
'
itemDiv
'
),
$feedItem
=
$
(
'
<li>
'
).
attr
(
'
class
'
,
'
feed-item
'
).
attr
(
'
title
'
,
$summary
.
trim
());
...
...
@@ -332,9 +358,7 @@ PTL.feed = {
if
(
item
.
enclosures
[
0
].
url
&&
item
.
enclosures
[
0
].
url
.
endsWith
(
"
.jpg
"
))
{
console
.
log
(
'
Wopop on %s!: (%s) imageUrl: %s
'
,
feedUrl
,
item
.
enclosures
[
0
].
url
,
imageUrl
);
imageUrl
=
item
.
enclosures
[
0
].
url
;
}
if
(
imgTypes
.
indexOf
(
item
.
enclosures
[
0
].
type
)
>
-
1
)
{
...
...
public/js/PTL.util.js
View file @
d658ffa8
...
...
@@ -29,6 +29,10 @@ PTL.util = {
isUrl
:
function
(
u
)
{
return
new
RegExp
(
'
^(?:[a-z]+:)?//
'
,
'
i
'
).
test
(
u
);
},
sanitizeInput
:
function
(
i
)
{
var
doc
=
new
DOMParser
().
parseFromString
(
i
,
'
text/html
'
);
return
doc
.
body
.
textContent
||
""
;
},
isOldPTLStruct
:
function
(
o
)
{
PTL
.
tab
.
empty
();
var
groups
=
[],
...
...
Write
Preview
Supports
Markdown
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