randomizing question

Special forum to share and discuss skins for Pano2VR and Object2VR
Post Reply
Carel
Posts: 178
Joined: Tue Sep 12, 2006 5:59 am
Location: Pasadena, CA USA
Contact:

I would like to have the index page pick a random swf from an array. Currently the index page picks a random html from an array, but that means that visitors will not bookmark or copy the index page url, but one of the randomly selected htmls. I found a bunch of javascripts to load a random image, but I have no luck making that work with the pano2vr generated script that loads the pano. Does anyone have a js script handy for this?

Here is what I tried:

Code: Select all

<body>
		<script type="text/javascript">
		<!--
		// please keep these lines on when you copy the source
		// made by: Nicolas - http://www.javascript-page.com

		var currentdate = 0
		var core = 0

		function StringArray (n) {
		  this.length = n;
  		for (var i =1; i <= n; i++) {
    		this[i] = ' '

 		 }
		}

		image = new StringArray(4)
		image[0] = '0.swf'
		image[1] = '1.swf'
		image[2] = '2.swf'
		image[3] = '3.swf'

		var ran = 60/image.length

		function ranimage() {
		  currentdate = new Date()
		  core = currentdate.getSeconds()
 		 core = Math.floor(core/ran)
		    return(image[core])
		}

//-->
</script>
		<script type="text/javascript">
<!--
			if ((window.p2q_Version) && (window.p2q_Version>=2.0)) {
				// Check to see if the version meets the requirements for playback
				var flashvars="";
			p2q_EmbedFlash('" +ranimage()+ "','100%','100%','allowFullScreen','true','bgcolor','1E1E1E','FlashVars',flashvars);
				
				if (!DetectFlashVer(9,0,0)) {
					document.write('<p class="warning">This content requires Adobe Flash Player Version 9 or higher. '
								 + '<a href="http://www.adobe.com/go/getflash/">Get Flash<\/a><\/p>');
				}
			} else {
				document.writeln('<p class="warning">p2q_embed_object.js is not included or it is too old! Please copy this file into your html directory.<\/p>');
			}
//-->
		</script>
		<noscript>
			<p class="warning">Please enable Javascript!</p>
		</noscript>
		<p align="center">
	</body>
</html>
The problem is that the image that is chosen by the randomizer does not get passed on to the p2q_EmbedFlash line.

Carel Struycken
http://www.sphericalpanoramas.com
User avatar
Hopki
Gnome
Posts: 13037
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Hi
Here is my test Here

My test will display 5 panos at random.

The way you can get this working is as follows:
Place all your panos in their own html pages. Then make your index html page with an iframe then use the code below to make the random page selector.


To make your index page, use this html code

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>This is the index page</title>
</head>

<body>

<p align="center">
<iframe name="I1" src="test.htm" width="800" height="600" border="0" frameborder="0">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe></p>

</body>

</html>


Please note that scr=”test.html” is the name of the html page that will go in the iframe.

Test.html

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test</title>


<!--
// == This Script Free To Use Providing This Notice Remains == //
// == This Script Has Been Found In The http://www.DesignerWiz.com Javascript Public Archive Library == //
// == NOTICE: Though This Material May Have Been In A Public Depository, Certain Author Copyright Restrictions May Apply == //
--><script language="JavaScript" type="text/javascript">
<!-- Begin
var howMany = 4; // max number of items listed below
var page = new Array(howMany+1);
page[0]="GP1/GP1.html";
page[1]="GP2/GP2.html";
page[2]="GP3/GP3.html";
page[3]="GP4/GP4.html";
page[4]="GP5/GP5.html";
function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->
</script>




</head>

<body>

</body>

</html>



Change the pages you will be using, replace GP1/GP1.html and the rest.
It is important that you also set the line:
var howMany = 4; // max number of items listed below

The number 4 lets you display 5 panos, 0 to 4.


Hope the helps

Hopki :)
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
Carel
Posts: 178
Joined: Tue Sep 12, 2006 5:59 am
Location: Pasadena, CA USA
Contact:

Great, Thanks. It is working and online at: www.sphericalpanoramas.com

Carel Struycken
Post Reply