-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPicasaWebAlbumsSimpleGallery.xml
More file actions
336 lines (308 loc) · 13.7 KB
/
PicasaWebAlbumsSimpleGallery.xml
File metadata and controls
336 lines (308 loc) · 13.7 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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Picasa Web Albums Simple Gallery: __UP_album__"
title_url="http://picasaweb.google.com/__UP_email__/__UP_album__"
directory_title="Picasa Web Albums Simple Gallery"
author="Vladimir Tarasow"
author_email="netrat@netrat.eu"
author_affiliation="NetRat"
author_location="Latvia"
category="Picasa Web Albums, Gallery"
description="Simple gallery gadget which is using Picasa Web Albums service as image storage. More details here: http://github.com/NetRat/PicasaWebAlbumsSimpleGallery"
author_link="http://about.me/NetRat">
<Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref name="email" display_name="E-mail" required="true" default_value="picasaweb account here" />
<UserPref name="album" display_name="Picasa album name" datatype="string" required="true" default_value="Metal"/>
<UserPref name="rowsQnt" display_name="Rows quantity" datatype="string" required="true" default_value="2"/>
<UserPref name="columnsQnt" display_name="Columns quantity" datatype="string" required="true" default_value="3"/>
<UserPref name="cellSpacing" display_name="Cell spacing" datatype="string" required="true" default_value="6"/>
<UserPref name="backgroundColor" display_name="Background color" datatype="string" required="true" default_value="transparent"/>
<UserPref name="photoScale" display_name="Photo scale, %" datatype="string" required="true" default_value="100"/>
<UserPref name="photoDescShow" display_name="Show photo description" datatype="bool" required="true" default_value="false"/>
<UserPref name="photoDescHeight" display_name="Photo description height" datatype="string" required="false" default_value="30"/>
<UserPref name="photoBackgroundColor" display_name="Photo background color" datatype="string" required="true" default_value="transparent"/>
<UserPref name="pagerTopShow" display_name="Show pager on top" datatype="bool" required="true" default_value="true"/>
<UserPref name="pagerBottomShow" display_name="Show pager at bottom" datatype="bool" required="true" default_value="false"/>
<UserPref name="pagerStyle" display_name="Pager style" datatype="enum" required="true" default_value="arrows">
<EnumValue value="arrows" />
<EnumValue value="numbers" />
</UserPref>>
<UserPref name="pagerHeight" display_name="Pager height, px" datatype="string" required="true" default_value="20"/>
<UserPref name="pagerFontSize" display_name="Pager font size" datatype="enum" required="true" default_value="small">
<EnumValue value="large" />
<EnumValue value="larger" />
<EnumValue value="medium" />
<EnumValue value="small" />
<EnumValue value="smaller" />
<EnumValue value="x-large" />
<EnumValue value="x-small" />
<EnumValue value="xx-large" />
<EnumValue value="xx-small" />
</UserPref>>
<UserPref name="pagerFontColor" display_name="Pager font color" datatype="string" required="false" />
<UserPref name="pagerBackgroundColor" display_name="Pager background color" datatype="string" required="false" default_value="transparent"/>
<Content type="html">
<![CDATA[
<div id="content_div"></div>
<style>
body {
background-color: transparent !important;
}
.img__MODULE_ID__ {
border-width:1px;
}
.arrow__MODULE_ID__ {
text-decoration:none;
font-size:larger;
cursor:pointer;
vertical-align:top;
margin-bottom:4px;
}
.pages__MODULE_ID__ {
text-decoration:none;
font-size:larger;
vertical-align:top;
margin-bottom:4px;
}
.sourceLink__MODULE_ID__ A:link {
color:#7777cc;
}
.sourceLink__MODULE_ID__ A:visited {
color:#7777cc;
}
#photoDiv__MODULE_ID__ {
}
#description__MODULE_ID__ {
padding-top:4px;
font-size:11px;
text-align:center;
}
#photoNum__MODULE_ID__ {
font-size:smaller;
padding-right:6px;
padding-left:6px;
}
</style>
<script type="text/javascript">
var _IMAGE_HEIGHT = 150;
var _MAX_TEXT_LEN = 2 * _IMAGE_HEIGHT / 5;
var _GPHOTO_NS = 'http://schemas.google.com/photos/2007';
var _MEDIA_NS = 'http://search.yahoo.com/mrss/';
var current_page = 0;
var num_pages = 1;
var num_photos = 0;
var prefs = new _IG_Prefs(__MODULE_ID__);
var email = _esc(prefs.getString('email'));
var album = _esc(prefs.getString('album'));
var _rowsQnt = parseInt(prefs.getString('rowsQnt'));
var _columnsQnt = parseInt(prefs.getString('columnsQnt'));
var entryList = [];
var album_feed_url = 'http://picasaweb.google.com/data/feed/api' +
'/user/' + email +
'/album/' + album +
'?kind=photo';
var pagerStyle = '';
if (prefs.getString('pagerFontSize').length > 0) {
pagerStyle += ('font-size:' + prefs.getString('pagerFontSize') + ';');
}
if (prefs.getString('pagerFontColor').length > 0) {
pagerStyle += ('color:' + prefs.getString('pagerFontColor') + ';');
}
if (prefs.getString('pagerBackgroundColor').length > 0) {
pagerStyle += ('background-color:' + prefs.getString('pagerBackgroundColor') + ';');
}
// Calculating cell width.
var gadgetWidth = gadgets.window.getViewportDimensions().width;
var cellWidth = (gadgetWidth - prefs.getString('cellSpacing') *
(prefs.getString('columnsQnt') - 1)) / prefs.getString('columnsQnt');
// Calculating cell height.
var pagerQnt = 0;
if (prefs.getBool("pagerTopShow") == true) pagerQnt++;
if (prefs.getBool("pagerBottomShow") == true) pagerQnt++;
var gadgetHeight = gadgets.window.getViewportDimensions().height;
var cellHeight =
(gadgetHeight - prefs.getString('cellSpacing') * (prefs.getString('rowsQnt') - 1) -
prefs.getString('cellSpacing') * pagerQnt - prefs.getString('pagerHeight') * pagerQnt) / prefs.getString('rowsQnt');
// Set the background color according to the backgroundColor userpref
var element = document.getElementById('content_div');
element.style.backgroundColor=prefs.getString("backgroundColor");
function ShowInvalidPrefsMsg() {
_gel('content_div').innerHTML =
'<i>Please, review gadgets settings.</i>';
};
function GetElementListItem(element, namespace, tagname, index){
var list_item;
if (namespace != '' &&
typeof document.getElementsByTagNameNS != 'undefined')
list_item = element.getElementsByTagNameNS(namespace, tagname)[index];
else {
if (namespace == _GPHOTO_NS)
tagname = 'gphoto:' + tagname;
else if (namespace == _MEDIA_NS)
tagname = 'media:' + tagname;
list_item = element.getElementsByTagName(tagname)[index];
}
return list_item;
};
function GetChildElementValue(element, namespace, tagname){
var child_element = GetElementListItem(element, namespace, tagname, 0);
if (child_element && child_element.firstChild){
return child_element.firstChild.nodeValue;
}
return '';
};
function prevPage(){
if (current_page > 0)
current_page -= 1;
RefreshPage();
};
function nextPage(){
if (current_page < num_pages -1)
current_page += 1;
RefreshPage();
};
function goToPage(i){
current_page = i;
RefreshPage();
};
function GetHtmlForNavigation(){
var html = '';
if (num_pages > 1) {
html +=
'<tr>' +
'<td colspan="' + _columnsQnt + '" align="center" valign="middle" height="' +
parseInt(prefs.getString('pagerHeight')) + 'px" style="' + pagerStyle + '">';
if (prefs.getString('pagerStyle') == 'arrows') {
html += ('<span class="arrow__MODULE_ID__" onclick="prevPage()">«</span>' +
'<span class="pages__MODULE_ID__"> ' + (current_page + 1) + ' of ' + num_pages + ' </span>' +
'<span class="arrow__MODULE_ID__" onclick="nextPage()">»</span></td>');
}
else {
for (var i = 0; i < (num_pages - 1); i++)
html += ('<span class="arrow__MODULE_ID__" onclick="goToPage(' + i + ')">' + (i + 1) + '</span> ');
html += ('<span class="arrow__MODULE_ID__" onclick="goToPage(' + (num_pages - 1) + ')">' + num_pages + '</span></td>');
}
}
html += '</tr>';
return html;
};
function GetHtmlForPhotoDesc(photoDesc, href){
var shortPhotoDesc = photoDesc;
if (photoDesc.length == 0)
shortPhotoDesc = ' <br> ';
else if (photoDesc.length < _MAX_TEXT_LEN / 2)
shortPhotoDesc = photoDesc + '<br> ';
else if (photoDesc.length > _MAX_TEXT_LEN)
shortPhotoDesc = photoDesc.substring(0, _MAX_TEXT_LEN) + '...';
var html = '<small><a style="text-decoration: none; color: #333333;" href="' +
href + '" target="_top" >'+
shortPhotoDesc + '</a></small>';
return html;
};
function GetHtmlForPhotoImage(imgSrc, imgHeight, imgWidth) { //photoDescHeight
var html = '<img src="' + imgSrc +
'" style="border-style: none"';
if (cellWidth >= cellHeight) {
if (prefs.getString("photoDescHeight").length > 0)
html += (' height="' + ((cellHeight - prefs.getString("photoDescHeight") - 2) / 100 * prefs.getString('photoScale')) + 'px">');
else
html += (' height="' + ((cellHeight - 2) / 100 * prefs.getString('photoScale')) + 'px">');
}
else {
// if (imgWidth >= cellWidth) imgWidth = cellWidth;
html += (' width="' + ((cellWidth - 2) / 100 * prefs.getString('photoScale')) + 'px">');
}
return html;
};
function GetHtmlForPhoto(photoDesc, imgSrc, imgHeight, imgWidth, href){
var html =
'<a href="' + href + '" target="_blank" ' +
//'onMouseover="fixedtooltip(\'' + photoDesc + '\')" ' +
//'onMouseout="delayhidetip()" ' +
'title="' + photoDesc + '" ' +
'>' +
GetHtmlForPhotoImage(imgSrc, imgHeight, imgWidth) +
'</a>';
if (prefs.getBool("photoDescShow") == true)
html += '<div align="center" style="height:' +
prefs.getString("photoDescHeight") + 'px;">' +
GetHtmlForPhotoDesc(photoDesc, href) + '</div>';
return html;
};
function GetHtmlHeader(){
var html = '<div align="center">' +
'<table border="0" cellpadding="0" cellspacing="6" width="' + gadgetWidth + '">';
if (prefs.getBool("pagerTopShow") == true) {
html += GetHtmlForNavigation();
}
return html;
};
function GetHtmlFooter(){
var html = '';
if (prefs.getBool("pagerBottomShow") == true) {
html += GetHtmlForNavigation();
}
html += '</table></div>';
return html;
};
function GetPrePhotoHtml(index){
var html = '';
if (index % _columnsQnt == 0){
html += '<tr>';
}
html += '<td align="center" height="' + cellHeight + '" width="' + cellWidth + '" ';
if (prefs.getString("photoBackgroundColor").length > 0)
html += 'style="background-color:' + prefs.getString("photoBackgroundColor") + ';">';
else
html += '>';
return html;
};
function GetPostPhotoHtml(index){
var html = '</td>';
if (index % _columnsQnt == _columnsQnt-1 || index == num_photos){
html += '</tr>';
}
return html;
};
_IG_FetchXmlContent(album_feed_url, function (response) {
if (!response || typeof(response) != 'object' || !response.firstChild ) {
ShowInvalidPrefsMsg();
return;
}
entryList = response.getElementsByTagName('entry');
num_photos = entryList.length;
num_pages = Math.ceil(num_photos / (_rowsQnt * _columnsQnt));
RefreshPage();
});
function RefreshPage(){
var html = '';
html += GetHtmlHeader();
var photos_per_page = _rowsQnt * _columnsQnt;
var start_index = current_page * photos_per_page;
var stop_index = start_index + photos_per_page;
if (stop_index > num_photos)
stop_index = num_photos;
for (var i = start_index; i < stop_index; i++){
var photoTitle = GetChildElementValue(entryList[i], '', 'title');
var photoDesc = GetChildElementValue(entryList[i], '', 'summary');
var photoID = GetChildElementValue(entryList[i], _GPHOTO_NS, 'id');
var imgSrc = GetElementListItem(entryList[i], _MEDIA_NS, 'thumbnail', 2).getAttribute('url');
var imgHeight = GetElementListItem(entryList[i], _MEDIA_NS, 'thumbnail', 2).getAttribute('height');
var imgWidth = GetElementListItem(entryList[i], _MEDIA_NS, 'thumbnail', 2).getAttribute('width');
var href = GetElementListItem(entryList[i], '', 'link', 1).getAttribute('href');
href = href.replace(photoID, 'slideshow/' + photoID);
href = href.replace('#', '?noredirect=1#')
html += GetPrePhotoHtml(i);
html += GetHtmlForPhoto(photoDesc, imgSrc, imgHeight, imgWidth, href);
html += GetPostPhotoHtml(i);
}
html += GetHtmlFooter();
_gel('content_div').innerHTML = html;
_IG_AdjustIFrameHeight();
};
//_IG_RegisterOnloadHandler(RefreshPage);
</script>
]]>
</Content>
</Module>