UNPKG

4.8 kBJavaScriptView Raw
1/* nanogallery2 - v2.4.2 - 2019-03-22 - https://nanogallery2.nanostudio.org */
2/**!
3 * @preserve nanogallery2 - GOOGLE PHOTOS data provider
4 * Homepage: http://nanogallery2.nanostudio.org
5 * Sources: https://github.com/nanostudio-org/nanogallery2
6 *
7 * License: GPLv3 and commercial licence
8 *
9*/
10!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery","nanogallery2"],a):a("object"==typeof exports&&"function"==typeof require?require(["jquery","nanogallery2"]):jQuery)}(function(a){jQuery.nanogallery2.data_google2=function(a,b){function c(a,b,c){f.O.debugMode&&(console.log("Google Photos data:"),console.dir(c));var e=f.I[a].GetID();jQuery.each(c,function(a,c){if("object"==typeof c&&null!==c){var g="",h="";h="image"==b?c.description:c.title,void 0==h&&(h="");var i=c.id;if("album"==b&&(!j(h,i)||void 0==c.coverPhotoBaseUrl))return!0;var k=NGY2Item.New(f,h,g,i,e,b,""),l=0,m=0,n="";"image"==b?(n=c.baseUrl,f.O.viewerZoom||void 0==f.O.viewerZoom?n+="=h"+c.mediaMetadata.height+"-w"+c.mediaMetadata.width:window.screen.width>window.screen.height?n+="=w"+window.screen.width:n=s+"=h"+window.screen.height,k.setMediaURL(n,"img"),void 0!==c.mediaMetadata.width&&(k.imageWidth=parseInt(c.mediaMetadata.width),l=k.imageWidth),void 0!==c.mediaMetadata.height&&(k.imageHeight=parseInt(c.mediaMetadata.height),m=k.imageHeight),void 0!==c.mediaMetadata.photo&&(void 0!=c.mediaMetadata.photo.exposureTime&&(k.exif.exposure=c.mediaMetadata.photo.exposureTime),void 0!=c.mediaMetadata.photo.focalLength&&(k.exif.focallength=c.mediaMetadata.photo.focalLength),void 0!=c.mediaMetadata.photo.apertureFNumber&&(k.exif.fstop=c.mediaMetadata.photo.apertureFNumber),void 0!=c.mediaMetadata.photo.isoEquivalent&&(k.exif.iso=c.mediaMetadata.photo.isoEquivalent),void 0!=c.mediaMetadata.photo.cameraModel&&(k.exif.model=c.mediaMetadata.photo.cameraModel)),void 0!==c.mediaMetadata.video&&(void 0!=c.mediaMetadata.video.cameraModel&&(k.exif.model=c.mediaMetadata.video.cameraModel),k.downloadURL=c.baseUrl+"=dv")):k.numberItems=c.mediaItemsCount,k.thumbs=d("l1",k.thumbs,c,b,m,l),k.thumbs=d("lN",k.thumbs,c,b,m,l);var o=f.O.fnProcessData;null!==o&&("function"==typeof o?o(k,"google2",c):window[o](k,"google2",c))}}),f.I[a].contentIsLoaded=!0}function d(a,b,c,d,e,g){for(var h=["xs","sm","me","la","xl"],i=0;i<h.length;i++){if("image"==d){if("auto"==f.tn.settings.width[a][h[i]]){var j=g/e;b.height[a][h[i]]=f.tn.settings.getH(a,h[i]),b.width[a][h[i]]=f.tn.settings.getH(a,h[i])*j,b.url[a][h[i]]=c.baseUrl+"=h"+f.tn.settings.getH(a,h[i]);continue}if("auto"==f.tn.settings.height[a][h[i]]){var j=e/g;b.width[a][h[i]]=f.tn.settings.getW(a,h[i]),b.height[a][h[i]]=f.tn.settings.getW(a,h[i])*j,b.url[a][h[i]]=c.baseUrl+"=w"+f.tn.settings.getW(a,h[i]);continue}b.height[a][h[i]]=f.tn.settings.getH(a,h[i]),b.width[a][h[i]]=f.tn.settings.getW(a,h[i]),b.url[a][h[i]]=c.baseUrl+"=w"+f.tn.settings.getW(a,h[i])}if("album"==d){if("auto"==f.tn.settings.width[a][h[i]]){b.url[a][h[i]]=c.coverPhotoBaseUrl+"=h"+f.tn.settings.getH(a,h[i]);continue}if("auto"==f.tn.settings.height[a][h[i]]){b.url[a][h[i]]=c.coverPhotoBaseUrl+"=w"+f.tn.settings.getW(a,h[i]);continue}f.tn.settings.mosaic[a+"Factor"].w[h[i]];b.url[a][h[i]]=c.coverPhotoBaseUrl+"=h"+f.tn.settings.getH(a,h[i])+"-w"+f.tn.settings.getW(a,h[i])}}return b}function e(){}var f=a,g=function(a,b,d,e){var g="",j="image",l=NGY2Item.GetIdx(f,a),m="";f.galleryMaxItems.Get()>0&&(m="&max-results="+f.galleryMaxItems.Get());var n="";"undefined"!=typeof ngy2_pwa_at&&(n=ngy2_pwa_at),0==a?(g=""!=n?"https://photoslibrary.googleapis.com/v1/albums":f.O.google2URL+"?nguserid="+f.O.userID+"&alt=json&v=3&kind=album"+m+"&rnd="+(new Date).getTime(),j="album"):g=""!=n?"https://photoslibrary.googleapis.com/v1/mediaItems:search":f.O.google2URL+"?nguserid="+f.O.userID+"&ngalbumid="+a+"&alt=json&v=3&kind=photo&"+m,f.O.debugMode&&console.log("Google Photos URL: "+g),h(!0),jQuery.ajaxSetup({cache:!1}),jQuery.support.cors=!0;try{var o=setTimeout(function(){h(!1),i("Could not retrieve AJAX data...")},6e4);jQuery.getJSON(g+"&callback=?",function(g){if("error"==g.nano_status)return clearTimeout(o),h(!1),void i(f,"Could not retrieve Google data. Error: "+g.nano_message);clearTimeout(o),h(!1),c(l,j,g),k(a),null!==b&&void 0!==b&&b(d,e,null)}).fail(function(a,b,c){clearTimeout(o),h(!1);var d="";for(var e in a)d+=e+"="+a[e]+"<br>";i(f,"Could not retrieve Google data. Error: "+b+", "+c+" "+d+"<br><br>URL:"+g)})}catch(p){i(f,"Could not retrieve Google data. Error: "+p)}},h=NGY2Tools.PreloaderDisplay.bind(f),i=NGY2Tools.NanoAlert,j=(NGY2Tools.GetImageTitleFromURL.bind(f),NGY2Tools.FilterAlbumName.bind(f)),k=NGY2Tools.AlbumPostProcess.bind(f);switch(b){case"AlbumGetContent":g(arguments[2],arguments[3],arguments[4],arguments[5]);break;case"Init":e()}}});
\No newline at end of file