%STARTINCLUDE%
<script type="text/javascript">
<!--
%CODE{"java"}% function switchToggle(whichImage, imageSrc1, imageSrc2, imageSrc3, imageSrc4, imageSrc5, imageSrc6, imageSrc7, imageSrc8, imageSrc9) { // enables to switch by mouse click up to 9 different pictures at one place // TODO ? extend for "alt" and "title" var imageSrc1 = (imageSrc1 == null) ? "" : imageSrc1; var imageSrc2 = (imageSrc2 == null) ? "" : imageSrc2; var imageSrc3 = (imageSrc3 == null) ? "" : imageSrc3; var imageSrc4 = (imageSrc4 == null) ? "" : imageSrc4; var imageSrc5 = (imageSrc5 == null) ? "" : imageSrc5; var imageSrc6 = (imageSrc6 == null) ? "" : imageSrc6; var imageSrc7 = (imageSrc7 == null) ? "" : imageSrc7; var imageSrc8 = (imageSrc8 == null) ? "" : imageSrc8; var imageSrc9 = (imageSrc9 == null) ? "" : imageSrc9;

// create empty image array imageArray = new Array(0);

// add valid sources to Array if (imageSrc1 = "") { imageArray.push(imageSrc1); } if (imageSrc2 = "") { imageArray.push(imageSrc2); } if (imageSrc3 = "") { imageArray.push(imageSrc3); } if (imageSrc4 = "") { imageArray.push(imageSrc4); } if (imageSrc5 = "") { imageArray.push(imageSrc5); } if (imageSrc6 = "") { imageArray.push(imageSrc6); } if (imageSrc7 = "") { imageArray.push(imageSrc7); } if (imageSrc8 = "") { imageArray.push(imageSrc8); } if (imageSrc9 = "") { imageArray.push(imageSrc9); }

// array size var size = imageArray.length;

// check if there are any valid strings if (size==0) {
alert("switchToggle
no valid src defined -- nothing is changed"+ "\n\t" + imageSrc1 + "\n\t" + imageSrc2 + "\n\t" + imageSrc3 + "\n\t" + imageSrc4 + "\n\t" + imageSrc5 + "\n\t" + imageSrc6 + "\n\t" + imageSrc7 + "\n\t" + imageSrc8 + "\n\t" + imageSrc9 ); }

// compare current Image src with list of sources and take next images if found var currentImageSrc = whichImage.src; for (var imageCtr=0; imageCtr<size ; imageCtr++) { if (currentImageSrc == imageArray[imageCtr]) { whichImage.src = imageArray[(imageCtr+1)%size]; break; } } } %ENDCODE%
-->
</script>
%STOPINCLUDE%

-- PeterZumbruch - 02 Mar 2006
Topic revision: r1 - 2006-03-02, PeterZumbruch
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki Send feedback | Imprint | Privacy Policy (in German)