2009年4月28日 星期二

不小心修好了FGS

http://mkl-note.blogspot.com/2008/02/flickr-gmap-show.html

http://mkl-note.blogspot.com/2008/02/track-viewer.html

之前就用過flickr-gmap-show,就覺得它是我見過最完美結合track與photo的了,但是最近不知名原因爛掉,不能正常顯示地圖、track 或 照片。

於是就一直將就使用GPS Visualizer+track,可是覺得一直這樣用GPS Visualizer產page很蠢,而且有照片時就更蠢了.....,所以下定決心要修好fgs

很久沒寫javascript了,而且最近javascript有了好多library,寫法也越來越神奇....
還好這個bug很簡單,就是xml tag改名字了,換過來就好....

Index: picasa-gmap-photoset.html
===================================================================
--- picasa-gmap-photoset.html (revision 169)
+++ picasa-gmap-photoset.html (working copy)
@@ -121,8 +121,8 @@
ownerurl: function(photo) {return 'http://picasaweb.google.com/'+photo.user;},
date: function(photo) { return photo.timestamp.toDateString(); },
parse : function(photo) {
- var thumbNodes = google.feeds.getElementsByTagNameNS(photo.xmlNode, 'http://search.yahoo.com/mrss/', 'thumbnail');
- var content = google.feeds.getElementsByTagNameNS(photo.xmlNode, 'http://search.yahoo.com/mrss/', 'content');
+ var thumbNodes = photo.xmlNode.getElementsByTagName('media:thumbnail');
+ var content = photo.xmlNode.getElementsByTagName('media:content');

var iconurl = {};
iconurl.url = thumbNodes[0]?thumbNodes[0].getAttributeNode('url').firstChild.nodeValue:null;
@@ -149,7 +149,7 @@
fullurl.height = parseInt(content[0].getAttributeNode('height').firstChild.nodeValue);
}
var pageurl=photo.link;
- var timestamp=new Date(parseInt(photo.xmlNode.getElementsByTagName('timestamp')[0].firstChild.nodeValue));
+ var timestamp=new Date(parseInt(photo.xmlNode.getElementsByTagName('gphoto:timestamp')[0].firstChild.nodeValue));
return {title:photo.title,api:picasa,iconurl:iconurl,thumburl:thumburl,mediumurl:mediumurl,pageurl:pageurl,fullurl:fullurl,timestamp:timestamp};
},
callapi : function(methodname, args, obj, callback, params) {
@@ -543,9 +543,9 @@
if(rsp.error) { alert(rsp.error.message); return; }

var photos=rsp.feed.entries;
- this.pageCurr=((parseInt(rsp.xmlDocument.firstChild.getElementsByTagName('startIndex')[0].firstChild.nodeValue)-1)/PER_PAGE)+1;
- this.pageTotal=Math.ceil(parseInt(rsp.xmlDocument.firstChild.getElementsByTagName('totalResults')[0].firstChild.nodeValue)/PER_PAGE);
- var user = rsp.xmlDocument.firstChild.getElementsByTagName('user')[0].firstChild.nodeValue;
+ this.pageCurr=((parseInt(rsp.xmlDocument.firstChild.getElementsByTagName('openSearch:startIndex')[0].firstChild.nodeValue)-1)/PER_PAGE)+1;
+ this.pageTotal=Math.ceil(parseInt(rsp.xmlDocument.firstChild.getElementsByTagName('openSearch:totalResults')[0].firstChild.nodeValue)/PER_PAGE);
+ var user = rsp.xmlDocument.firstChild.getElementsByTagName('gphoto:user')[0].firstChild.nodeValue;

if(this.pageTotal<2) {
$(this.options).hide();
@@ -557,7 +557,7 @@
for (var i=0,len=photos.length; i<len; i++) {
var photo=photos[i];

- var where = photo.xmlNode.getElementsByTagName('where');
+ var where = photo.xmlNode.getElementsByTagName('georss:where');
if(!where||!where.length) { continue; }

var point = where[0].firstChild.textContent||where[0].firstChild.text;


另外我有在fgs發個issue
Issue 1: picasa-gmap-photoset.html not working anymore
http://code.google.com/p/flickr-gmap-show/issues/detail?id=1
patch applied
http://code.google.com/p/flickr-gmap-show/issues/detail?id=1#c2

url used for debug:
http://picasaweb.google.com/data/feed/api/user/mkl0301/album/090310?kind=photo
http://code.google.com/intl/zh-TW/apis/picasaweb/developers_guide_protocol.html

沒有留言: