3 // @namespace http://6v8.gamboni.org/
4 // @description display directly a google map of the pool using Flyr. Works on most of the pages showing multiple photos (group pool, tag pool, search, user page, set pool)
6 // @identifier http://6v8.gamboni.org/IMG/js/flyrpool.user.js
8 // @creator Pierre Andrews (mortimer.pa@free.fr)
9 // @include http://*flickr.com/photos/*
10 // @include http://*flickr.com/groups/*
13 // --------------------------------------------------------------------
15 // This is a Greasemonkey user script.
17 // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
18 // Then restart Firefox and revisit this script.
19 // Under Tools, there will be a new menu item to "Install User Script".
20 // Accept the default configuration and install.
22 // --------------------------------------------------------------------
23 // Copyright (C) 2006 Pierre Andrews
25 // This program is free software; you can redistribute it and/or
26 // modify it under the terms of the GNU General Public License
27 // as published by the Free Software Foundation; either version 2
28 // of the License, or (at your option) any later version.
30 // This program is distributed in the hope that it will be useful,
31 // but WITHOUT ANY WARRANTY; without even the implied warranty of
32 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 // GNU General Public License for more details.
35 // The GNU General Public License is available by visiting
36 // http://www.gnu.org/copyleft/gpl.html
38 // Free Software Foundation, Inc.
39 // 51 Franklin Street, Fifth Floor
40 // Boston, MA 02110-1301
47 namespace: "http://6v8.gamboni.org/",
48 description: "Display directly a google map of the pool using Flyr.",
49 source: "http://6v8.gamboni.org/Flyr-Pool.html", // script homepage/description URL
50 identifier: "http://6v8.gamboni.org/IMG/js/flyrpool.user.js",
51 version: "0.3", // version
52 date: (new Date(2006, 05, 18)) // update date
56 var win = (unsafeWindow || window.wrappedJSObject || window);
57 var API_KEY = "e8c3239ff04c102ce2d6ed885bf99005";
59 win.FlyrPool = function() {;}
61 win.FlyrPool.prototype = {
69 checkTags: function(photoId) {
70 var url = 'http://www.flickr.com/services/rest/?method=flickr.tags.getListPhoto&api_key='
77 function onRez(result) {
79 var doc = result.responseText.replace(/<\?xml.*\?>/,'');
81 for each (tag in doc..tag) {
82 if(tag.@raw.match(/geo:(lat|long?)=/)) {
84 self.photos.push(photoId);
94 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey Flyr Pool',
95 'Accept': 'application/atom+xml,application/xml,text/xml'
100 getPhotos: function() {
101 var tagNodesSnapshot =
102 document.evaluate( "/html/body/div[@id='Main']/div[1]//a|//p[@class='Photo']/a",
103 document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
104 for(var i=0; i<tagNodesSnapshot.snapshotLength; i++)
106 var streamListNode = tagNodesSnapshot.snapshotItem(i);
107 href = streamListNode.href;
108 matches = /\/([0-9]+)\//.exec(href);
110 photoId = matches[1];
112 this.checkTags(photoId);
117 insertFlyr: function() {
120 var gmd = document.createElement("div");
121 gmd.setAttribute("style","font-size:85%; margin-bottom: 1em;clear: right;");
124 var xpath = document.evaluate("//div[@class='HoldPhotos']",
127 XPathResult.ANY_UNORDERED_NODE_TYPE,
130 goodStuffs = xpath.singleNodeValue;
133 goodStuffs.insertBefore(gmd,goodStuffs.firstChild);
135 //When we see the calendar
136 var xpath = document.evaluate("//table[@class='SurfsUp']",
139 XPathResult.ANY_UNORDERED_NODE_TYPE,
142 goodStuffs = xpath.singleNodeValue;
143 if(goodStuffs) goodStuffs.parentNode.insertBefore(gmd,goodStuffs.nextSibling);
147 xpath = document.evaluate("//div[@class='StreamView']",
150 XPathResult.ANY_UNORDERED_NODE_TYPE,
153 goodStuffs = xpath.singleNodeValue;
155 goodStuffs = goodStuffs.parentNode.parentNode.parentNode.insertBefore(document.createElement('tr'),goodStuffs.parentNode.parentNode);
156 goodStuffs = goodStuffs.appendChild(document.createElement('td'));
157 goodStuffs.setAttribute('colspan',2);
158 goodStuffs.appendChild(gmd);
161 goodStuffs = document.getElementById('setThumbs');
162 if(goodStuffs) goodStuffs.insertBefore(gmd,goodStuffs.firstChild);
172 //highly inspired by greasemap
173 function insertFlyrMap() {
174 var f = document.createElement('iframe');
175 var close = document.createElement("a");
176 close.innerHTML = " Close";
178 close.addEventListener('click',function() {
180 gmd.removeChild(close);
182 gmd.appendChild(close);
184 f.setAttribute('width', '812');
185 f.setAttribute('height', '420');
186 f.setAttribute('src', mapurl);
190 var mapurl = 'http://flyr.whatfettle.com/maps?ids='
191 + encodeURIComponent(this.photos.join(','));
192 gmd.innerHTML = this.photos.length+" geotagged photos have been found. <a target=\"_blank\" href=\""+mapurl+"\">Open in new window</a>,";
193 var direct = document.createElement("a");
194 direct.setAttribute("style","font-weight:bold;");
195 direct.innerHTML = " Display Here";
197 direct.addEventListener('click',function() {
200 gmd.appendChild(direct);
204 waitForResults: function() {
206 if(this.cnt >= this.photoCnt) {
207 if(this.geotag) this.insertFlyr();
210 if(this.cntTries>0) setTimeout(function() {self.waitForResults();},1000);
217 // update automatically (http://userscripts.org/scripts/show/2296)
219 window.addEventListener("load", function () {
221 win.UserScriptUpdates.requestAutomaticUpdates(SCRIPT);
223 var fltags = new win.FlyrPool();
225 fltags.waitForResults();