Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
279 lines (247 sloc) 10.3 KB
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="__UP_title__"
directory_title="Flickr Photos"
title_url="http://flickr.com/photos/__UP_username__"
screenshot="http://static.flickr.com/56/171053807_d4c49563e9_o.png"
thumbnail="http://static.flickr.com/70/171053806_0ed946fb7a_o.png"
author="Chinson Yeh"
author_email="chinsonyeh@gmail.com"
author_affiliation="National Sun Yat-sen University"
author_location="Kaohsiung, Taiwan(ROC)"
scaling="true"
scrolling="true"
height="260"
category="tools"
description="Display images from any Flickr account.">
</ModulePrefs>
<UserPref name="title" display_name="Title" default_value="Flickr Photos - English"/>
<UserPref name="user_method" display_name="User Type" datatype="enum" default_value="username">
<EnumValue value="username" display_value="Screen Name"/>
<EnumValue value="userid" display_value="NSID"/>
</UserPref>
<UserPref name="username" display_name="Screen Name" default_value="chinson"/>
<UserPref name="userid" display_name="NSID" default_value=""/>
<UserPref name="count" display_name="Count" required="true" default_value="6"/>
<UserPref name="size" display_name="Photo Size" datatype="enum" default_value="s">
<EnumValue value="s" display_value="Small"/>
<EnumValue value="m" display_value="Medium"/>
</UserPref>
<UserPref name="display" display_name="Display" datatype="enum" default_value="random">
<EnumValue value="random" display_value="Random"/>
<EnumValue value="latest" display_value="Latest"/>
</UserPref>
<UserPref name="tags" display_name="Tags&#8203;(comma-&#8203;delimited)" default_value=""/>
<UserPref name="interval" display_name="Refresh Interval(sec)" datatype="enum" default_value="no">
<EnumValue value="no" display_value="Do Not Refresh"/>
<EnumValue value="5" display_value="5"/>
<EnumValue value="10" display_value="10"/>
<EnumValue value="15" display_value="15"/>
<EnumValue value="20" display_value="20"/>
<EnumValue value="30" display_value="30"/>
<EnumValue value="40" display_value="40"/>
<EnumValue value="50" display_value="50"/>
<EnumValue value="60" display_value="60"/>
</UserPref>
<Content type="html">
<![CDATA[
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="__UP_interval__">
<script src="http://www.google.com/js/nxsl.1.js" type="text/javascript"></script>
<style type="text/css">
#flickrimg {
margin: 10px;
font-size: 10px;
}
#flickrimg a {
padding: 0;
margin: 0 5px 5px 0;
text-decoration: none;
}
#flickrimg a:link {
color: #ff0000;
}
#flickrimg a img {
border-width:1px;
border-style: solid;
border-color: #000000;
}
#flickrimg a:hover img {
border-width:1px;
border-style: solid;
border-color: #ff0000;
}
#err_msg p {
margin: 10px;
font-size: 16px;
}
#err_msg a {
padding: 0;
margin: 0 5px 5px 0;
text-decoration: none;
}
</style>
<script type="text/javascript">
var apikey = 'd46a54682a032b1d16aa226f6a3c4eb1';
function PrintOutImg(user_id)
{
var per_page = 500;
var url = 'http://www.flickr.com/services/rest/?method=flickr.photos.search&format=json&nojsoncallback=1';
url += '&api_key=' + apikey ;
url += '&per_page=' + per_page ;
url += '&page=1';
url += '&tags=' + encodeURIComponent('__UP_tags__');
url += '&user_id=' + user_id;
_IG_FetchContent(url, function(response) {
/* random page */
var page = 1;
var data = eval('(' +response +')');
if(data.stat == 'ok')
{
var totalpages = data['photos']['pages'];
var totalphotos = data['photos']['total'];
if(totalphotos % per_page < __UP_count__)
{
totalpages = totalpages - 1;
}
if('__UP_display__' == 'random')
{
var ran_unrounded = Math.random() * totalpages;
page = Math.floor(ran_unrounded) + 1;
}
/* retrieve url and the output HTML tags */
var url = 'http://www.flickr.com/services/rest/?method=flickr.photos.search&format=json&nojsoncallback=1';
url += '&api_key=' + apikey ;
url += '&per_page=' + per_page ;
url += '&page=' + page;
url += '&tags=' + encodeURIComponent('__UP_tags__');
url += '&user_id=' + user_id;
_IG_FetchContent(url, function(response){
var size = '__UP_size__';
/* Retrieve Array for photo Tags */
var data = eval('(' + response +')');
var photos = data.photos.photo;
var size = '__UP_size__';
var count = Math.min('__UP_count__', photos.length);
var urls_1 = new Array();
var urls_2 = new Array();
var titles = new Array();
var photoindex_rec = new Array();
var countindex = 0;
var photoindex = 0;
for(countindex = 0; countindex < count; countindex++)
{
if('__UP_display__' == 'random')
{
/* random photos */
var random_stop = 1;
do
{
random_stop = 1;
photoindex = Math.floor(Math.random() * photos.length);
for(recindex = 0; recindex < photoindex_rec.length; recindex++)
{
if(photoindex_rec[recindex] == photoindex)
{
random_stop = 0;
break;
}
}
}while(random_stop == 0)
photoindex_rec[countindex] = photoindex;
}
else
{
photoindex = countindex;
}
/* Integrate to a complete URL */
urls_1[countindex] = 'http://static.flickr.com/' + photos[photoindex]['server'] + '/' + photos[photoindex]['id'] + '_' + photos[photoindex]['secret'] + '_' + size + '.jpg\n';
urls_2[countindex] = 'http://www.flickr.com/photos/' + user_id + '/' + photos[photoindex]['id'] + '\n';
titles[countindex] = photos[photoindex]['title'];
}
/* Establish HTML */
var oDIVNode = document.getElementById("flickrimg");
for(photoindex = 0; photoindex < urls_1.length; photoindex++)
{
var oANode = document.createElement("A");
oANode.setAttribute("href", urls_2[photoindex]);
oANode.setAttribute("target", "_blank");
var oImgNode = document.createElement("IMG");
oImgNode.setAttribute("src", urls_1[photoindex]);
oImgNode.setAttribute("title", titles[photoindex]);
oANode.appendChild(oImgNode);
oDIVNode.appendChild(oANode);
}
var oPNode = document.createElement("P");
var oANode = document.createElement("A");
oANode.setAttribute("href", "http://chinsonyeh.blogspot.com/2006/06/flickr-module-for-google-personalized.html");
oANode.setAttribute("target", "_blank");
var oTextNode = document.createTextNode("Gadget Blog");
oANode.appendChild(oTextNode);
oPNode.appendChild(oANode);
oDIVNode.appendChild(oPNode);
/* var oPageNode = document.createTextNode("pages : " + totalpages + " page : " + page + " total : " + totalphoto + "photos length : " + photos.length); */
/* oDIVNode.appendChild(oPageNode); */
});
}
else
{
var oDIVNode = document.getElementById("flickrimg");
oDIVNode.setAttribute("id", "err_msg");
var oPNode = document.createElement("P");
var oANode = document.createElement("A");
oANode.setAttribute("href", "http://chinsonyeh.blogspot.com/2006/06/flickr-module-for-google-personalized.html");
oANode.setAttribute("target", "_blank");
var oTextNode = document.createTextNode("Cannot retrieve photos. Please make sure your NSID is valid.");
oANode.appendChild(oTextNode);
oPNode.appendChild(oANode);
oDIVNode.appendChild(oPNode);
}
});
}
function Load()
{
if('__UP_user_method__' == 'username')
{
/* Retrieve user_id */
var url = 'http://www.flickr.com/services/rest/?method=flickr.people.findByUsername&format=json&nojsoncallback=1';
url += '&api_key=' + apikey ;
url += '&username=__UP_username__';
_IG_FetchContent(url, function(response) {
var data = eval('(' +response +')');
if(data['stat'] == 'ok') {
user_id = data['user']['nsid'] ;
PrintOutImg(user_id);
}
else
{
var oDIVNode = document.getElementById("flickrimg");
oDIVNode.setAttribute("id", "err_msg");
var oPNode = document.createElement("P");
var oANode = document.createElement("A");
oANode.setAttribute("href", "http://chinsonyeh.blogspot.com/2006/06/flickr-module-for-google-personalized.html");
oANode.setAttribute("target", "_blank");
var oTextNode = document.createTextNode("Cannot retrieve user NSID. Please make sure your username is valid and you do not hidden your profile.");
oANode.appendChild(oTextNode);
oPNode.appendChild(oANode);
oDIVNode.appendChild(oPNode);
}
});
}
else if('__UP_user_method__' == 'userid')
{
var user_id = '__UP_userid__';
PrintOutImg(user_id);
}}
</script>
</head>
<body onLoad="Load()">
<div id="flickrimg" align="center">
</div>
</body>
</html>
]]>
</Content>
</Module>