X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=www%2Fplugins%2Fgalleria.ssp.js;fp=www%2Fplugins%2Fgalleria.ssp.js;h=267012c889ab48aef71b8ae690bb95a64a4b1d94;hb=6468e8c20ecbb8ca9601058bc17b0d18d178e171;hp=0000000000000000000000000000000000000000;hpb=2dbf4d0209064d7c481ae33df8a2e0fa2b5a4982;p=scribo diff --git a/www/plugins/galleria.ssp.js b/www/plugins/galleria.ssp.js new file mode 100644 index 0000000..267012c --- /dev/null +++ b/www/plugins/galleria.ssp.js @@ -0,0 +1,93 @@ +/*! + * Galleria SlideShowPro Plugin v 1.1 + * http://galleria.aino.se + * + * Copyright 2010, Aino + * Licensed under the MIT license. + */ + +(function() { + +var G = window.Galleria; +if (typeof G == 'undefined') { + return; +} + +var S = G.SSP = function(url) { + var query = "select * from xml where url='" + url + "' limit 1"; + var encodedQuery = encodeURIComponent(query.toLowerCase()); + var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodedQuery + '&format=json&callback=?'; + var scope = this; + + if (url.substr(0,7) == 'http://') { + var a = document.createElement('a'); + a.href = url; + this.domain = a.protocol+'//'+a.hostname; + this.path = url.substring(0,(url.lastIndexOf("/")) + 1); + } + + $.getJSON(yql, function(data) { + scope.data = data; + }); + +} + +S.prototype = { + data: null, + domain: '', + path:'', + getAlbum: function(index, callback) { + this.ready(function() { + var data = this.parseData(index); + callback.call(this, data); + }); + return this; + }, + getAbsoluteUrl: function(path) { + if (path.substr(0,7) != 'http://') { + if (path.substr(0,1) != '/') { + path = this.path + path; + } else { + path = this.domain + path; + } + } + return path; + }, + parseData: function(index) { + var albums = this.data.query.results.gallery.album; + var album = albums[index] || albums; + var path = album.lgPath || ''; + var thumbPath = album.tnPath || path; + + var arr = []; + var scope = this; + + G.prototype.loop(album.img, function(img) { + var obj = { + image: scope.getAbsoluteUrl(path+img.src), + thumb: scope.getAbsoluteUrl(thumbPath+img.src), + title: img.title + }; + if (img.caption) { + obj.description = img.caption + } + if (img.link) { + obj.link = img.link; + } + arr.push(obj); + }); + return arr; + }, + ready: function(callback) { + var scope = this; + G.prototype.wait(function() { + return !!scope.data; + }, function() { + callback.call(scope); + }, function() { + G.raise('YQL not available.') + }, 10000); + } +} + +})(); \ No newline at end of file