-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpicasa-slideshow.xml
252 lines (231 loc) · 6.67 KB
/
picasa-slideshow.xml
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Uninteruptable Web Album Slideshow"
directory_title="Picasa Web Album Slideshow"
description="Uninteruptable Picasa webAlbum slideshow"
author="R.Brouwer"
author_email="[email protected]">
<Require feature="setprefs"/>
<Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref name="feed" display_name="Picasa Album Web RSS Feed" default_value="http://picasaweb.google.com/data/feed/base/user/WebsiteCGK/albumid/5394398332883762641?alt=rss&kind=photo&hl=nl" datatype="string" required="true"/>
<UserPref name="width" display_name="Width of gadget" default_value="300" datatype="string" required="true"/>
<UserPref name="interval" display_name="Slide Show Interval" datatype="enum" default_value="10">
<EnumValue value="5" display_value="5 seconds"/>
<EnumValue value="10" display_value="10 seconds"/>
<EnumValue value="15" display_value="15 seconds"/>
<EnumValue value="20" display_value="20 seconds"/>
<EnumValue value="25" display_value="25 seconds"/>
<EnumValue value="30" display_value="30 seconds"/>
<EnumValue value="60" display_value="1 minute"/>
<EnumValue value="120" display_value="2 minutes"/>
</UserPref>
<UserPref name="bgColor" display_name="Background Color" default_value="ffffff" datatype="string"/>
<Content type="html"><![CDATA[
<style type="text/css">
html,div#content_div {
font-family:arial,sans-serif;
font-size: 12px;
font-style:normal;
font-weight:normal;
line-height:15px;
}
</style>
<script type="text/javascript">
<!--
//javascript variables and settings
var allImgUrlsTemp;
var allImgUrls = new Array();
var ggWidth;
var maxHeight;
var nextInterval;
var prefs;
var feedUrl;
var bgColor;
function makePicasaRequest(){
setCommonPrefs()
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.DOM;
// params[gadgets.io.RequestParameters.NUM_ENTRIES] = new Number(entries);
params[gadgets.io.RequestParameters.GET_SUMMARIES] = false;
gadgets.io.makeRequest(feedUrl, response, params);
}
function setCommonPrefs(){
prefs = new _IG_Prefs();
ggWidth = parseInt(prefs.getString("width"));
nextInterval = parseInt(prefs.getString("interval"));
feedUrl = prefs.getString("feed");
feedUrl = feedUrl.replace(/\/base\//g, '/api/');
feedUrl = feedUrl.replace(/&/g, '&');
bgColor = prefs.getString("bgColor");
try{
var hexColorTest = new RegExp("[A-Fa-f0-9]");
if(bgColor.length == 0){
bgColor = "#ffffff";
}
if(bgColor.length == 6 && hexColorTest.test(bgColor)){
bgColor = "#" + bgColor;
}
}catch(err){}
}
function response(obj){
if(typeof obj == "undefined" ){
failout();
}
allImgUrlsTemp = new Array();
var mediaItems = obj.data.getElementsByTagName("item");
if(mediaItems.length == 0){
failout();
}
for(var j = 0; j < mediaItems.length; j++){
var mediaItem = mediaItems[j];
var allImgUrlsXml = mediaItems[j].getElementsByTagName("media:content");
allImgUrlsTemp.push(allImgUrlsXml[0].getAttribute("url"));
}
loadSlideShow();
}
function failout(){
document.getElementById("topContainer").innerHTML = "An error occurred. Make sure that your feed and other settings are correct, or that your feed isn't too big.";
}
var currentImg;
var sequentialIndex = 0;
var setTimeoutThread;//clearTimeout(id_of_settimeout)
function loadSlideShow(){
for(var i = 0; i < allImgUrlsTemp.length; i++ ){
allImgUrls.push({imgUrl:allImgUrlsTemp[i], shown: false});
}
fisherYates(allImgUrls);
showNextImage();
}
function playback(){
//clearSelection();
var pause_btn = document.getElementById("pause_btn");
if (!pause_btn) {
showNextImage();
} else {
if(pause_btn.style.display != 'none'){
clearTimeout(setTimeoutThread);
pause_btn.style.display = 'block';
} else {
pause_btn.style.display = 'block';
showNextImage();
}
}
}
function fastforward(){
clearTimeout(setTimeoutThread);
clearSelection();
showNextImage();
}
function rewind(){
clearTimeout(setTimeoutThread);
sequentialIndex -= 2;
if(sequentialIndex < 0){
sequentialIndex = allImgUrls.length - 1;
}
clearSelection();
showNextImage();
}
function showNextImage(){
if(sequentialIndex + 1 > allImgUrls.length){
sequentialIndex = 0;
}
switchImage(allImgUrls[sequentialIndex++].imgUrl);
var pause_btn = document.getElementById("pause_btn");
if(!pause_btn || pause_btn.style.display != "none"){
setTimeoutThread = setTimeout("showNextImage()", nextInterval * 1000);
}
}
function switchImage(imgUrl){
var loader = new ImageLoader(imgUrl);
var prefs = new _IG_Prefs();
loader.loadEvent = this.imageLoaded;
loader.load();
}
function imageLoaded(url,image){
prefs = new _IG_Prefs();
ggWidth = parseInt(prefs.getString("width"));
//actions to perform when the image is loaded
var oldToRemove = document.getElementById("currentImg");
if(typeof oldToRemove != "undefined" && oldToRemove != null){
oldToRemove.parentNode.removeChild(oldToRemove);
}
currentImg = image;
currentImg.id = "currentImg";
currentImg.className = "currentImg";
currentImg.style.width=ggWidth;
document.getElementById("imgContainer").appendChild(currentImg);
gadgets.window.adjustHeight();
//hide loading indicator if applicable
}
function addListener(element, type, expression, bubbling)
{
bubbling = bubbling || false;
if(window.addEventListener) { // Standard
element.addEventListener(type, expression, bubbling);
return true;
} else if(window.attachEvent) { // IE
element.attachEvent('on' + type, expression);
return true;
} else{
return false;
}
}
var ImageLoader = function(url){
this.url = url;
this.image = null;
this.loadEvent = null;
};
ImageLoader.prototype = {
load:function(){
this.image = document.createElement('img');
var url = this.url;
var image = this.image;
var loadEvent = this.loadEvent;
addListener(this.image, 'load', function(e){
if(loadEvent != null){
loadEvent(url, image);
}
}, false);
this.image.src = this.url;
},
getImage:function(){
return this.image;
}
};
function fisherYates(myArray){
var i = myArray.length;
if(i == 0){
return false;
}
while(--i){
var j = Math.floor( Math.random() * ( i + 1 ) );
var tempi = myArray[i];
var tempj = myArray[j];
myArray[i] = tempj;
myArray[j] = tempi;
}
}
function clearSelection(){
try{
var sel;
if(document.selection && document.selection.empty){
document.selection.empty() ;
}
else if(window.getSelection){
sel=window.getSelection();
if(sel && sel.removeAllRanges){
sel.removeAllRanges();
}
}
}catch(err){}
}
gadgets.util.registerOnLoadHandler(makePicasaRequest);
// -->
</script>
<div id="topContainer">
<div id="imgContainer">
</div>
</div>
]]></Content>
</Module>