-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathslideshow.js
More file actions
99 lines (84 loc) · 2.44 KB
/
slideshow.js
File metadata and controls
99 lines (84 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// for reference: Google AJAX feed Slideshow programming API is here:
// http://www.google.com/uds/solutions/slideshow/reference.html
// load Google Feeds API
google.load("feeds", "1");
// name used to set up cookie for the feed URL
var cookie_name = "rssfeed_url";
// will hold slideshow object
var ss;
/**
* set cookie.
*
* @param c_name cookie name
* @param value cookie value
* @param exdays expiration days from now
*/
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays==null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value + "; path=/";
}
/**
* get cookie's value.
* @param c_name cookie name
* @return value of the cookie of 'undefined' when cookie is not defined
*/
function getCookie(c_name) {
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name) {
return unescape(y);
}
}
return undefined;
}
function myThumbnailUrlResolver(entry) {
// the URL to the thumbnail is in entry.content
var c = entry.content;
var found = c.match(/<img.*>/);
if(found == null) {
return "/no_image.gif";
}
var f2 = found[0].match(/src=".*"/);
var f3 = f2[0].split("src=\"");
var f4 = f3[1].split("\"");
return f4[0];
}
// slideshow options
var options = {
numResults: 200,
displayTime: 2000,
transistionTime: 600,
scaleImages: false,
thumbnailTag: "content",
fullControlPanel : true,
thumbnailUrlResolver: myThumbnailUrlResolver
};
/**
* reinitialize slideshow with new feed URL
* @param newfeed URL to the new feed
*/
function reinit_slideshow(newfeed) {
setCookie(cookie_name, newfeed, 365);
ss = new GFslideShow(newfeed, "slideshow", options);
}
/**
* main entry point.
*/
function OnLoad() {
//resize window
resizeTo(700,1050);
var feedUrl = getCookie(cookie_name);
if(!feedUrl) {
setCookie(cookie_name, "http://feeds.feedburner.com/ffffound/everyone", 10);
feedUrl = getCookie(cookie_name);
}
reinit_slideshow(feedUrl);
}
// set callback on load to our function
google.setOnLoadCallback(OnLoad);