Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Slideshow
Message
Information générale
Forum:
Internet
Catégorie:
Javascript
Titre:
Divers
Thread ID:
01236789
Message ID:
01236816
Vues:
13
Very nice. Where exactly are the photo comments stored that u are displaying on the page?

>>I am looking for a way to do a slideshow based on Javascript code. I've found all kinds of examples on the WEB to show how do do this.
>>
>>However, they all want the pictures pre-defined and to exist in the same directory on the web site.
>>
>>I want to be able to point to my pictures that are stored on my FTP site. Actually, I want to be able to point to a folder of pictures and have the web page display a slideshow of all the pictures in that folder.
>>
>>How can I do this?
>
>i've done similar before by using a server script to build a javascript array of filenames found in a designated folder on the server. i.e. the server script actually creates a few lines of javascript. Then it's easy to have the javascript increment through the array.
>
>
>var photos = new Array(1);
>var currentphoto = 0;
>photos[0] = 'photos/file1.jpg';
>photos[1] = 'photos/file2.jpg';
>photos[2] = 'photos/file3.jpg';
>
>
>
>see http://www.themontrealhouse.com/tour.php
>
>this also picks up the comments displayed from the file's properties
>
>
><?php
>echo("<Script language='javascript'>");
>echo("var photos = new Array(1);");
>echo("var comments = new Array(1);");
>echo("var currentphoto = 0;");
>$dir = "d:\montrealhouse\photos";
>$i = 0;
>$oShell = new COM("shell.application");
>// Open a known directory, and proceed to read its contents
>if (is_dir($dir)) {
>   if ($dh = opendir($dir)) {
>       while (($file = readdir($dh)) !== false) {
>	   		$fext = substr(strrchr($file, "."), 1);
>			if ($fext == "jpg") {
>	       		echo "photos[".$i."] = 'photos/".$file."';";
>				$oDir = $oShell->Namespace($dir);
>				$ofile = $oDir->parsename($file);
>				$comment = $oDir->GetDetailsOf($ofile,14);
>				$comment = str_replace('"',"",$comment);
>				$comment = str_replace("'","",$comment);
>				echo("comments[".$i."] = '".$comment."';");
> 				$i=$i+1;
>   			}
>	   }
>       closedir($dh);
>   }
>}
>echo("function setPhoto(cnt) {");
>echo("var img = document.getElementById('imgPhoto');");
>echo("var txt = document.getElementById('spnComments');");
>echo("var indx = currentphoto+cnt;");
>echo("if(indx < 0 ) {indx = photos.length-1};");
>echo("if(indx > photos.length-1 ) {indx = 0};");
>echo("currentphoto = indx;");
>echo("if(document.all) {");
>echo("txt.innerText = comments[indx];");
>echo("} else {");
>echo("txt.textContent = comments[indx];}");
>echo("img.src=photos[indx];}");
>echo("</Script>");
>?>
>
>
>
>
>hth
>
>nigel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform