From 6fdaa4b3ab46012e8cccefbbc3f8911f797c3bb7 Mon Sep 17 00:00:00 2001 From: "mb.jquery.components" Date: Fri, 22 May 2015 19:26:16 +0200 Subject: [PATCH] reintroduced "loadFromSystem" method. --- demo_lookUp.html | 2 +- inc/mb.bgndGallery.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/demo_lookUp.html b/demo_lookUp.html index 26ee459..621c763 100644 --- a/demo_lookUp.html +++ b/demo_lookUp.html @@ -153,7 +153,7 @@ // If your server allow directory listing you can use: // (however this doesn't work locally on your computer) -// folderPath:"testImage/", + folderPath:"testImage/", // else: diff --git a/inc/mb.bgndGallery.js b/inc/mb.bgndGallery.js index cd2d0a8..19845e7 100644 --- a/inc/mb.bgndGallery.js +++ b/inc/mb.bgndGallery.js @@ -146,6 +146,10 @@ jQuery.browser.mobile = jQuery.browser.android || jQuery.browser.blackberry || j jQuery(containment).prepend(opt.gallery); + if(el.opt.folderPath && el.opt.images.length==0) + el.opt.images = jQuery.loadFromSystem(el.opt.folderPath) ; + + if(el.opt.shuffle) el.opt.images= jQuery.shuffle(el.opt.images); @@ -798,6 +802,36 @@ jQuery.browser.mobile = jQuery.browser.android || jQuery.browser.blackberry || j jQuery.fn.removeImages = jQuery.mbBgndGallery.removeImages; jQuery.fn.applyFilter = jQuery.mbBgndGallery.applyFilter; + jQuery.loadFromSystem=function(folderPath, type){ + + // if directory listing is enabled on the remote server. + // if you run the page locally you need to run it under a local web server (Ex: http://localhost/yourPage) + // otherwise the directory listing is unavailable. + + if(!folderPath) + return; + if(!type) + type= ["jpg","jpeg","png"]; + var arr=[]; + jQuery.ajax({ + url:folderPath, + async:false, + success:function(response){ + var tmp=jQuery(response); + var els= tmp.find("[href]"); + + els.each(function(){ + for (var i in type){ + if (jQuery(this).attr("href").indexOf(type[i])>=0) + arr.push(folderPath+jQuery(this).attr("href")); + arr = jQuery.unique(arr); + } + }); + tmp.remove(); + } + }); + return arr.length != 0 ? arr : false; + }; jQuery.fn.greyScale = function(el) { return this.each(function() {