Permlink Replies: 46 - Pages: 4 [ 1 2 3 4 | Next ] - Last Post: 9 Jul 20, 10:55 Last Post By: RobM Threads: [ Previous | Next ]
RobM

Posts: 4,178
Registered: 4-Aug-2006
Random Slide Show and Album Image Count
Posted: 6 May 07, 23:31
  Click to reply to this thread Reply
I have created a JAlbum tool (inspired by PowerBase's Randomizer) that generates a javascript file which enables a random slide show to be run. It lists all of the jpg and gif file types in the slides directories of an album. To use it on any skin a new html page is required to act as a container for the slide show. Albums will also need to link to the new page in order for it to be used. Included in the zip file is a read me file showing what needs to be done to incorporate the slide show and how to modify it to include original image files if required.
alan927

Posts: 17
Registered: 18-Jun-2005
Re: Random Slide Show and Album Image Count
Posted: 13 Jul 07, 02:05   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
This looks interesting; I'll try it out this weekend. You obviously know more Java than jimberry and I combined. ;) Yes, it took 2 of us to write the original Randomizer.bsh, which hasn't been touched since PowerBase 1.0.
RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 14 Jul 07, 22:19   in response to: alan927 in response to: alan927
  Click to reply to this thread Reply
Thanks for the complement, but I'm affraid I just muddle through as best I can!
I usually know what I want to do and then look in a Java or Javascript reference book for a way to do it as I am self taught (and now trying to learn the JAlbum engine stuff too).

I'd be interested in knowing how you get on and if you end up using it or not.

Rob
alan927

Posts: 17
Registered: 18-Jun-2005
Re: Random Slide Show and Album Image Count
Posted: 15 Jul 07, 01:09   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
So far I can't get the .bsh to run; it returns the following error after processing the first file.

java.lang.StringIndexOutOfBoundsException: String index out of range: -1

So my randomImage.js looks like this:
var imagePath = new Array()
 
var thumbnailPage = new Array()
 
imagePath[0]="slides\1800s Pyramid.jpg";

At first I thought it was choking on albumfiles.txt, but I renamed it to zalbumfiles.txt and it still errored out after the first file. The next photo alphabetically is "Bird by the Ocean.jpg" and there's nothing in the JAlbum System Console, probably because of the try/catch. I'm not sure what's causing the error.
RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 15 Jul 07, 23:03   in response to: alan927 in response to: alan927
  Click to reply to this thread Reply
I've just tried it on JAlbum 7.2 and it fails with a java.io.FileNotFoundException (it seems to delete the top level res directory contents when it is run)
It works OK in version 7.1 (provided the javascripts directory exists in the res directory)

Can you confirm that you are running it from the External Tools Menu and what version of JAlbum you are using?

I'll have to ave a look and see whats going wrong, I'm affraid that it may take me a few days before I reply again but I will get back to you. I just hope I can understand what I've written!

Rob
jimberry

Posts: 493
Registered: 30-Aug-2004
Re: Random Slide Show and Album Image Count
Posted: 16 Jul 07, 00:26   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
(it seems to delete the
top level res directory contents when it is run)
It works OK in version 7.1 (provided the javascripts
directory exists in the res directory)

Is this the bug with the new(7.2) feature "Clear the output directory when using MakeAlbum - All" ?

That can be fixed in a checkbox in Tools>Preferences, or by using "Make Album - Changes".
RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 16 Jul 07, 21:33   in response to: jimberry in response to: jimberry
  Click to reply to this thread Reply
Yes, it does seem to be as doing the Make album first stops the files from being deleted.
I had only just downloaded the 7.2 version and had't yet checked the preference settings.

Thanks
Rob
RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 16 Jul 07, 21:38   in response to: alan927 in response to: alan927
  Click to reply to this thread Reply
Alan,

The error is the result of the code I used to get the path to the thumbnail index pages.
I have rewritten the offending line of code and added a bit more documentation.
In essence I was looking for the sub-string "/slides" when I should have looked for "slides" (for images at the root level directory)
So the code
if (imagePath.toString().toLowerCase().indexOf("/slides") != -1) {
thumbnailPath = imagePath.substring(0, imagePath.toString().toLowerCase().indexOf("/slides")) + "/" + engine.getIndexPageName() + engine.getPageExtension() + "\"";

should be
if (imagePath.toString().toLowerCase().indexOf("slides") != -1) {
thumbnailPath = imagePath.substring(0, imagePath.toString().toLowerCase().indexOf("slides")) + engine.getIndexPageName() + engine.getPageExtension() + "\"";

I've tried various JAlbum configurations and they all now seem to work.
Can you give the new code (attached) a try and let me know how you get on?

Rob
alan927

Posts: 17
Registered: 18-Jun-2005
Re: Random Slide Show and Album Image Count
Posted: 20 Jul 07, 22:33   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
I've got it to the point where it's flipping every 6 seconds, but it's not displaying photos. I think it's the backslashes (\) in the path.
var imagePath = new Array()
 
var thumbnailPage = new Array()
 
imagePath[0]="\slides\1800s Pyramid.jpg";
 
thumbnailPage[0]="\index.html";
 
imagePath[1]="\slides\Angry Clouds.jpg";
 
thumbnailPage[1]="\index.html";
 
imagePath[2]="\slides\Bird by the Ocean.jpg";
 
thumbnailPage[2]="\index.html";
 
imagePath[3]="\slides\Coit Tower.jpg";
 
thumbnailPage[3]="\index.html";

They should all be forward slashes (/). It appears that Javascript is using the backslashes as escape characters instead of path delimiters.

On the actual html page, it shows this (it's most noticable on files starting with a number):
Image: slides800s Pyramid.jpg

While it should show this:
Image: slides/1800s Pyramid.jpg

See how it's treating \1 as ESC-1 (00000001) instead of the character 1?
RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 22 Jul 07, 00:56   in response to: alan927 in response to: alan927
  Click to reply to this thread Reply
Alan, I think this time I've got it right!
The attached is the updated file. I've tried it with a folder of images and a sub-folder of images, that is: folder test contains 4 images and a folder called other, which contains 2 images.
JAlbum was set to link to originals via scaled images and the Random Slide Show tool was set to include originals and slides images.

The output file is:
var imagePath = new Array()
var thumbnailPage = new Array()
imagePath[0]="1800s Pyramid.jpg";
Originals_thumbnailPage[0]="index.html";
imagePath[1]="Angry Clouds_copy.jpg";
Originals_thumbnailPage[1]="index.html";
imagePath[2]="Bird by the Ocean.jpg";
Originals_thumbnailPage[2]="index.html";
imagePath[3]="Coit Tower.jpg";
Originals_thumbnailPage[3]="index.html";
imagePath[4]="other/other 1.jpg";
NotSlides_thumbnailPage[4]="other/index.html";
imagePath[5]="other/other 2.jpg";
NotSlides_thumbnailPage[5]="other/index.html";
imagePath[6]="other/slides/other 1.jpg";
thumbnailPage[6]="other/index.html";
imagePath[7]="other/slides/other 2.jpg";
thumbnailPage[7]="other/index.html";
imagePath[8]="slides/1800s Pyramid.jpg";
thumbnailPage[8]="index.html";
imagePath[9]="slides/Angry Clouds_copy.jpg";
thumbnailPage[9]="index.html";
imagePath[10]="slides/Bird by the Ocean.jpg";
thumbnailPage[10]="index.html";
imagePath[11]="slides/Coit Tower.jpg";
thumbnailPage[11]="index.html";

ImageCount = 12;

var randomImage = Math.floor(Math.random() * (ImageCount - 1)) ; // The random image number;

slideshowContent = '<a href= "' + thumbnailPage[randomImage] + '"><img src="' + imagePath[randomImage] + '" /><br />Click on the image to go to its (home) thumbnails page</a><br />Image: ' + imagePath[randomImage];

function getNext() {;
window.location = "random_slide_show.html";
};

Sorry for the problems to date, let me know if this works on your system or not.

Sorry, I left in some debug code - working on it too late at night!
See next entry from me for the corrected file


Message was edited by: RobM

RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 22 Jul 07, 15:34   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
The attached is the updated file. I've tried it with a folder of images and a sub-folder of images, that is: folder test contains 4 images and a folder called other, which contains 2 images.
JAlbum was set to link to originals via scaled images and the Random Slide Show tool was set to include originals and slides images
(See the lines of code below:
// delete "if (f.toString().toLowerCase().indexOf("slides") != -1)" leaving just the "else" and "{" to include original images
else {
).

The output file is:
var imagePath = new Array()
var thumbnailPage = new Array()
imagePath[0]="1800s Pyramid.jpg";
thumbnailPage[0]="index.html";
imagePath[1]="Angry Clouds_copy.jpg";
thumbnailPage[1]="index.html";
imagePath[2]="Bird by the Ocean.jpg";
thumbnailPage[2]="index.html";
imagePath[3]="Coit Tower.jpg";
thumbnailPage[3]="index.html";
imagePath[4]="other/other 1.jpg";
thumbnailPage[4]="other/index.html";
imagePath[5]="other/other 2.jpg";
thumbnailPage[5]="other/index.html";
imagePath[6]="other/slides/other 1.jpg";
thumbnailPage[6]="other/index.html";
imagePath[7]="other/slides/other 2.jpg";
thumbnailPage[7]="other/index.html";
imagePath[8]="slides/1800s Pyramid.jpg";
thumbnailPage[8]="index.html";
imagePath[9]="slides/Angry Clouds_copy.jpg";
thumbnailPage[9]="index.html";
imagePath[10]="slides/Bird by the Ocean.jpg";
thumbnailPage[10]="index.html";
imagePath[11]="slides/Coit Tower.jpg";
thumbnailPage[11]="index.html";

ImageCount = 12;

var randomImage = Math.floor(Math.random() * (ImageCount - 1)) ; // The random image number;

slideshowContent = '<a href= "' + thumbnailPage[randomImage] + '"><img src="' + imagePath[randomImage] + '" /><br />Click on the image to go to its (home) thumbnails page</a><br />Image: ' + imagePath[randomImage];

function getNext() {;
window.location = "random_slide_show.html";
};

Rob
philby

Posts: 5
Registered: 8-Aug-2007
Re: Random Slide Show and Album Image Count
Posted: 22 Aug 07, 15:26   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
hi all
i like this tool very cool

i have it working on www.bfphoto.co.uk had to play about with the .js it generated a little as i am using it from a diffrent location

what i am trying to do now is to have it load mutiple random images in the left frame

i tried repeating the
<script type="text/javascript">
<!--
document.write(slideshowContent);
document.close();
//-->
</script>
in the html file but end up with 2 copys of the same image

so i have tried doing the below

var randomImage = Math.floor(Math.random() * (ImageCount - 1)) ; // The random image number;
var randomImage2 = Math.floor(Math.random() * (ImageCount - 1)) ; // The random image number;
var randomImage3 = Math.floor(Math.random() * (ImageCount - 1)) ; // The random image number;

slideshowContent = '<a href= "' + thumbnailPage[randomImage] + '"target=mainFrame><img src="' + imagePath[randomImage] + '" />
</a>
Image: ' + imagePath[randomImage];

slideshowContent = '<a href= "' + thumbnailPage[randomImage2] + '"target=mainFrame><img src="' + imagePath[randomImage2] + '" />
</a>
Image: ' + imagePath[randomImage2];

slideshowContent = '<a href= "' + thumbnailPage[randomImage3] + '"target=mainFrame><img src="' + imagePath[randomImage3] + '" />
</a>
Image: ' + imagePath[randomImage3];

in the .js file
but still no joy

ok so as you can tell java is not my thing
any recomendations?

philby

Posts: 5
Registered: 8-Aug-2007
Re: Random Slide Show and Album Image Count
Posted: 22 Aug 07, 15:44   in response to: philby in response to: philby
  Click to reply to this thread Reply
i mannaged to figure it out

i now have

var randomImage = Math.floor(Math.random() * (ImageCount - 1)) ; // The random image number;
var randomImage2 = Math.floor(Math.random() * (ImageCount - 1)) ; // The random image number;

slideshowContent = '<a href= "' + thumbnailPage[randomImage] + '"target=mainFrame><img src="' + imagePath[randomImage] + '" />
</a>
Image: ' + imagePath[randomImage];

slideshowContent2 = '<a href= "' + thumbnailPage[randomImage2] + '"target=mainFrame><img src="' + imagePath[randomImage2] + '" />
</a>
Image: ' + imagePath[randomImage2];

i had forgotten to incriment slideshowcontent
in js and html

RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 22 Aug 07, 18:16   in response to: philby in response to: philby
  Click to reply to this thread Reply
I'm glad you like the slide show tool and that you managed to get it working as you wanted it.
I've looked at your site, very nice pictures.
Although unlikely, you may get the same image twice in the left frame. If it becomes a problem you could try generating subsequent images a random number from the previous one, rather than a random image from the total. Or better, but harder, is to note which image(s) have been used and if the same one is chosen then select another before refreshing the screen.

I will try to update the file so that extra unique random images are an option - unless you beat me to it and would like to send me your code.

RobM
RobM

Posts: 4,178
Registered: 4-Aug-2006
Re: Random Slide Show and Album Image Count
Posted: 22 Aug 07, 22:03   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Attachment Picture 8.jpg (144.1 KB)
Phil,
Whilst looking at your site I noticed that sometimes an image is not being displayed.
There seems to be a common thread in that all the missing images I have seen are from
bfphoto.co.uk/gallery/Phill/Rae/thumbs/gallery/
Example images from this directory are Rae05.jpg and Rae11.jpg.

Also, the favicon.ico file is shown as missing.
See attached image for a screen grab.

RobM
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums