Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tvlokal.ticker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wolfgang Berndt
tvlokal.ticker
Commits
94e128e5
Commit
94e128e5
authored
Feb 28, 2018
by
Wolfgang Berndt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Treat rss title as html field.
parent
5cc4160f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
ticker.js
src/ticker.js
+11
-8
ticker.min.js
src/ticker.min.js
+2
-2
No files found.
src/ticker.js
View file @
94e128e5
...
@@ -11,6 +11,15 @@ var feedCache = {
...
@@ -11,6 +11,15 @@ var feedCache = {
return
cb
(
self
.
data
);
return
cb
(
self
.
data
);
}
}
function
rss2html
(
jqueryEl
)
{
// try to get some sensible data from this xml-"html"-mess
return
jqueryEl
.
html
()
.
replace
(
"<![CDATA["
,
""
)
.
replace
(
"<!--[CDATA[<p-->"
,
""
)
.
replace
(
"]]>"
,
""
)
.
replace
(
"]]>"
,
""
);
}
// renew cache otherwise
// renew cache otherwise
$
.
ajax
({
$
.
ajax
({
url
:
(
useproxy
)
?
'http://proxy.doohmedia.net/get.php?url='
+
$
.
base64
.
encode
(
url
)
:
url
,
url
:
(
useproxy
)
?
'http://proxy.doohmedia.net/get.php?url='
+
$
.
base64
.
encode
(
url
)
:
url
,
...
@@ -19,14 +28,8 @@ var feedCache = {
...
@@ -19,14 +28,8 @@ var feedCache = {
var
result
=
[];
var
result
=
[];
$
(
data
).
find
(
"item"
).
each
(
function
()
{
$
(
data
).
find
(
"item"
).
each
(
function
()
{
var
item
=
$
(
this
);
var
item
=
$
(
this
);
var
title
=
item
.
find
(
"title"
).
text
();
var
title
=
rss2html
(
item
.
find
(
"title"
));
var
desc
=
rss2html
(
item
.
find
(
"description"
));
// try to get some sensible data from this xml-"html"-mess
var
desc
=
item
.
find
(
"description"
).
html
()
.
replace
(
"<![CDATA["
,
""
)
.
replace
(
"<!--[CDATA[<p-->"
,
""
)
.
replace
(
"]]>"
,
""
)
.
replace
(
"]]>"
,
""
);
if
(
!
title
&&
!
desc
)
return
false
;
if
(
!
title
&&
!
desc
)
return
false
;
if
(
!
title
&&
desc
===
"<p></p>"
)
return
false
;
if
(
!
title
&&
desc
===
"<p></p>"
)
return
false
;
...
...
src/ticker.min.js
View file @
94e128e5
var
feedCache
=
{
validCacheDuration
:
3
e5
,
lastRequestDate
:
null
,
data
:[],
getdata
:
function
(
a
,
b
,
c
){
var
d
=
this
,
e
=
new
Date
;
if
(
this
.
lastRequestDate
&&
e
-
this
.
lastRequestDate
<
this
.
validCacheDuration
)
return
c
(
d
.
data
);
$
.
ajax
({
url
:
b
?
"http://proxy.doohmedia.net/get.php?url="
+
$
.
base64
.
encode
(
a
):
a
,
type
:
"GET"
,
success
:
function
(
a
){
var
b
=
[];
return
$
(
a
).
find
(
"item"
).
each
(
function
(){
var
a
=
$
(
this
),
c
=
a
.
find
(
"title"
).
text
(),
d
=
a
.
find
(
"description"
).
html
().
replace
(
"<![CDATA["
,
""
).
replace
(
"
\
x3c!--[CDATA[<p--
\
x3e"
,
""
).
replace
(
"]]>"
,
""
).
replace
(
"]]>"
,
""
);
return
!
(
!
c
&&!
d
)
&&
(
!
(
!
c
&&
"<p></p>"
===
d
)
&&
void
b
.
push
({
title
:
c
,
desc
:
d
}))}),
b
.
length
>
0
&&
(
d
.
data
=
b
,
d
.
lastRequestDate
=
new
Date
),
c
(
d
.
data
)},
error
:
function
(
a
){
return
console
.
log
(
"error while getting feed data: "
,
a
),
c
(
d
.
data
)}})}},
ticker
=
{
currentFeedData
:[],
currentFeedIndex
:
-
1
,
config
:
null
,
viewportHeight
:
null
,
init
:
function
(
a
){
var
b
=
this
;
a
.
url
&&
(
b
.
config
=
a
,
b
.
_setupStyling
(),
feedCache
.
getdata
(
b
.
config
.
url
,
b
.
config
.
useproxy
,
function
(
a
){
b
.
currentFeedData
=
a
,
b
.
_setupNewTicker
(),
window
.
setInterval
(
function
(){
b
.
_updateFeedData
()},
6
e4
)}))},
_setupStyling
:
function
(){
if
(
this
.
viewportHeight
=
$
(
"#viewport"
).
height
(),
this
.
config
.
font
&&
this
.
config
.
font
.
file
&&
this
.
config
.
font
.
format
){
var
a
=
this
.
config
.
font
.
name
||
"customfont"
;
$
(
"head"
).
prepend
(
'<style type="text/css">@font-face {font-family: "'
+
a
+
'"; src: url("'
+
this
.
config
.
font
.
file
+
'") format("'
+
this
.
config
.
font
.
format
+
'");}</style>'
),
$
(
"body"
).
css
(
"font-family"
,
a
)}
this
.
config
.
background
.
color
&&
$
(
"body"
).
css
(
"background-color"
,
this
.
config
.
background
.
color
),
this
.
config
.
background
.
image
&&
$
(
"body"
).
css
(
"background"
,
'url("'
+
this
.
config
.
background
.
image
+
'") no-repeat center fixed'
).
css
(
"background-size"
,
"cover"
),
this
.
_styleFonts
()},
_styleFonts
:
function
(){
this
.
config
.
text
.
size
&&
$
(
"p"
).
css
(
"font-size"
,
this
.
config
.
text
.
size
),
this
.
config
.
text
.
color
&&
$
(
"p"
).
css
(
"color"
,
this
.
config
.
text
.
color
),
this
.
config
.
text
.
align
&&
$
(
"p"
).
css
(
"text-align"
,
this
.
config
.
text
.
align
),
this
.
config
.
headline
.
size
&&
$
(
"h1"
).
css
(
"font-size"
,
this
.
config
.
headline
.
size
),
this
.
config
.
headline
.
color
&&
$
(
"h1"
).
css
(
"color"
,
this
.
config
.
headline
.
color
),
this
.
config
.
spacer
.
color
&&
$
(
".spacer"
).
css
(
"color"
,
this
.
config
.
spacer
.
color
),
this
.
config
.
spacer
.
size
&&
$
(
".spacer"
).
css
(
"font-size"
,
this
.
config
.
spacer
.
size
)},
_updateFeedData
:
function
(){
var
a
=
this
;
feedCache
.
getdata
(
a
.
config
.
url
,
a
.
config
.
useproxy
,
function
(
b
){
a
.
currentFeedData
=
b
})},
_setupNewTicker
:
function
(){
var
a
=
this
;
0
!==
a
.
currentFeedData
.
length
&&
(
a
.
_createTicker
(),
setTimeout
(
function
(){
a
.
_createTicker
()},
500
))},
_createTicker
:
function
(){
var
a
=
this
;
if
(
0
!==
this
.
currentFeedData
.
length
){
var
b
=
$
(
".tickercontainer:last"
).
get
(
0
),
c
=
b
?
$
(
b
).
offset
().
top
+
$
(
b
).
height
():
this
.
viewportHeight
,
d
=
$
(
'<div class="tickercontainer"></div>'
);
$
(
"#viewport"
).
append
(
d
);
for
(
var
e
=
0
;
e
<
this
.
currentFeedData
.
length
;
e
++
){
if
(
this
.
config
.
spacer
.
text
.
length
>
0
)
var
f
=
$
(
'<div class="tickeritem"><h1>'
+
this
.
currentFeedData
[
e
].
title
+
"</h1>"
+
this
.
currentFeedData
[
e
].
desc
+
'</div><div class="spacer">'
+
this
.
config
.
spacer
.
text
+
"</div>"
);
else
var
f
=
$
(
'<div class="tickeritem"><h1>'
+
this
.
currentFeedData
[
e
].
title
+
"</h1>"
+
this
.
currentFeedData
[
e
].
desc
+
"</div>"
);
$
(
f
).
children
(
"p"
).
addClass
(
"text"
),
$
(
d
).
append
(
f
)}
a
.
_styleFonts
(),
$
(
d
).
css
(
"top"
,
c
+
"px"
);
var
g
=
c
+
$
(
d
).
height
()
+
20
,
h
=
Math
.
round
(
g
/
100
*
this
.
config
.
speed
);
$
(
d
).
css
(
"transition"
,
"transform "
+
h
+
"s linear"
),
$
(
d
).
css
(
"transform"
,
"translate3d(0px, -"
+
g
+
"px ,0px)"
),
$
(
d
).
on
(
"transitionend"
,
function
(){
a
.
_createTicker
(),
$
(
d
).
remove
()})}}};
var
feedCache
=
{
validCacheDuration
:
3
e5
,
lastRequestDate
:
null
,
data
:[],
getdata
:
function
(
a
,
b
,
c
){
function
d
(
a
){
return
a
.
html
().
replace
(
"<![CDATA["
,
""
).
replace
(
"
\
x3c!--[CDATA[<p--
\
x3e"
,
""
).
replace
(
"]]>"
,
""
).
replace
(
"]]>"
,
""
)}
var
e
=
this
,
f
=
new
Date
;
if
(
this
.
lastRequestDate
&&
f
-
this
.
lastRequestDate
<
this
.
validCacheDuration
)
return
c
(
e
.
data
);
$
.
ajax
({
url
:
b
?
"http://proxy.doohmedia.net/get.php?url="
+
$
.
base64
.
encode
(
a
):
a
,
type
:
"GET"
,
success
:
function
(
a
){
var
b
=
[];
return
$
(
a
).
find
(
"item"
).
each
(
function
(){
var
a
=
$
(
this
),
c
=
d
(
a
.
find
(
"title"
)),
e
=
d
(
a
.
find
(
"description"
));
return
!
(
!
c
&&!
e
)
&&
(
!
(
!
c
&&
"<p></p>"
===
e
)
&&
void
b
.
push
({
title
:
c
,
desc
:
e
}))}),
b
.
length
>
0
&&
(
e
.
data
=
b
,
e
.
lastRequestDate
=
new
Date
),
c
(
e
.
data
)},
error
:
function
(
a
){
return
console
.
log
(
"error while getting feed data: "
,
a
),
c
(
e
.
data
)}})}},
ticker
=
{
currentFeedData
:[],
currentFeedIndex
:
-
1
,
config
:
null
,
viewportHeight
:
null
,
init
:
function
(
a
){
var
b
=
this
;
a
.
url
&&
(
b
.
config
=
a
,
b
.
_setupStyling
(),
feedCache
.
getdata
(
b
.
config
.
url
,
b
.
config
.
useproxy
,
function
(
a
){
b
.
currentFeedData
=
a
,
b
.
_setupNewTicker
(),
window
.
setInterval
(
function
(){
b
.
_updateFeedData
()},
6
e4
)}))},
_setupStyling
:
function
(){
if
(
this
.
viewportHeight
=
$
(
"#viewport"
).
height
(),
this
.
config
.
font
&&
this
.
config
.
font
.
file
&&
this
.
config
.
font
.
format
){
var
a
=
this
.
config
.
font
.
name
||
"customfont"
;
$
(
"head"
).
prepend
(
'<style type="text/css">@font-face {font-family: "'
+
a
+
'"; src: url("'
+
this
.
config
.
font
.
file
+
'") format("'
+
this
.
config
.
font
.
format
+
'");}</style>'
),
$
(
"body"
).
css
(
"font-family"
,
a
)}
this
.
config
.
background
.
color
&&
$
(
"body"
).
css
(
"background-color"
,
this
.
config
.
background
.
color
),
this
.
config
.
background
.
image
&&
$
(
"body"
).
css
(
"background"
,
'url("'
+
this
.
config
.
background
.
image
+
'") no-repeat center fixed'
).
css
(
"background-size"
,
"cover"
),
this
.
_styleFonts
()},
_styleFonts
:
function
(){
this
.
config
.
text
.
size
&&
$
(
"p"
).
css
(
"font-size"
,
this
.
config
.
text
.
size
),
this
.
config
.
text
.
color
&&
$
(
"p"
).
css
(
"color"
,
this
.
config
.
text
.
color
),
this
.
config
.
text
.
align
&&
$
(
"p"
).
css
(
"text-align"
,
this
.
config
.
text
.
align
),
this
.
config
.
headline
.
size
&&
$
(
"h1"
).
css
(
"font-size"
,
this
.
config
.
headline
.
size
),
this
.
config
.
headline
.
color
&&
$
(
"h1"
).
css
(
"color"
,
this
.
config
.
headline
.
color
),
this
.
config
.
spacer
.
color
&&
$
(
".spacer"
).
css
(
"color"
,
this
.
config
.
spacer
.
color
),
this
.
config
.
spacer
.
size
&&
$
(
".spacer"
).
css
(
"font-size"
,
this
.
config
.
spacer
.
size
)},
_updateFeedData
:
function
(){
var
a
=
this
;
feedCache
.
getdata
(
a
.
config
.
url
,
a
.
config
.
useproxy
,
function
(
b
){
a
.
currentFeedData
=
b
})},
_setupNewTicker
:
function
(){
var
a
=
this
;
0
!==
a
.
currentFeedData
.
length
&&
(
a
.
_createTicker
(),
setTimeout
(
function
(){
a
.
_createTicker
()},
500
))},
_createTicker
:
function
(){
var
a
=
this
;
if
(
0
!==
this
.
currentFeedData
.
length
){
var
b
=
$
(
".tickercontainer:last"
).
get
(
0
),
c
=
b
?
$
(
b
).
offset
().
top
+
$
(
b
).
height
():
this
.
viewportHeight
,
d
=
$
(
'<div class="tickercontainer"></div>'
);
$
(
"#viewport"
).
append
(
d
);
for
(
var
e
=
0
;
e
<
this
.
currentFeedData
.
length
;
e
++
){
if
(
this
.
config
.
spacer
.
text
.
length
>
0
)
var
f
=
$
(
'<div class="tickeritem"><h1>'
+
this
.
currentFeedData
[
e
].
title
+
"</h1>"
+
this
.
currentFeedData
[
e
].
desc
+
'</div><div class="spacer">'
+
this
.
config
.
spacer
.
text
+
"</div>"
);
else
var
f
=
$
(
'<div class="tickeritem"><h1>'
+
this
.
currentFeedData
[
e
].
title
+
"</h1>"
+
this
.
currentFeedData
[
e
].
desc
+
"</div>"
);
$
(
f
).
children
(
"p"
).
addClass
(
"text"
),
$
(
d
).
append
(
f
)}
a
.
_styleFonts
(),
$
(
d
).
css
(
"top"
,
c
+
"px"
);
var
g
=
c
+
$
(
d
).
height
()
+
20
,
h
=
Math
.
round
(
g
/
100
*
this
.
config
.
speed
);
$
(
d
).
css
(
"transition"
,
"transform "
+
h
+
"s linear"
),
$
(
d
).
css
(
"transform"
,
"translate3d(0px, -"
+
g
+
"px ,0px)"
),
$
(
d
).
on
(
"transitionend"
,
function
(){
a
.
_createTicker
(),
$
(
d
).
remove
()})}}};
\ No newline at end of file
\ 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