Sie sind nicht angemeldet.

  • »ronaldtichelaar« ist der Autor dieses Themas

Beiträge: 27

Wohnort: the Netherlands

Beruf: Apple Consultant & Engineer

  • Nachricht senden

1

Mittwoch, 5. November 2008, 21:07

random pano on pageload

Hi,

I'm working on a new design for my website and want a random pano on the top of my site, this is what i have so far...

http://www.ronaldtichelaar.nl/toppano/


After searching forums for to days and experimenting with java i give up. So my question is as follows...

I want the pano in the frame to change after a pageload by loading a random xml or jpg file. Can this be done in javascript, AS3 or another programming language? What is the best way?

Best,
Ronald Tichelaar

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »ronaldtichelaar« (5. November 2008, 21:46)


2

Mittwoch, 5. November 2008, 21:43

Hi,

great site!
but you shouldn't use the name "banner" for the directory,
my add-blocker (Adblock Plus, Firefox) blocked it

changing the pano randomly every refresh can be done very easily with javascript (one line of code),

for example - let's assume you have 4 panos, named:
top1.xml
top2.xml
top3.xml
top4.xml

to choose one of them randomly: (code for your site)

Quellcode

1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">

    var random_xml =  "top" + (1+Math.ceil(Math.random()*3)) + ".xml";

    swfobject.embedSWF("./krpano.swf", "krpano1", "1024", "249", "9.0.28", 
                       "swfobject21/expressInstall.swf",
                       {pano:random_xml}, 
                       {allowfullscreen:false, bgcolor:"#000000"}, 
                       {id:'krpano1', name:'krpano1'});
</script>


best,
Klaus

  • »ronaldtichelaar« ist der Autor dieses Themas

Beiträge: 27

Wohnort: the Netherlands

Beruf: Apple Consultant & Engineer

  • Nachricht senden

3

Mittwoch, 5. November 2008, 21:48

Thanks Klaus! I've changed the directory to toppano, hope this is better... :rolleyes: Also changed it in the post. I will try your hint ASAP.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »ronaldtichelaar« (6. November 2008, 00:35)


  • »ronaldtichelaar« ist der Autor dieses Themas

Beiträge: 27

Wohnort: the Netherlands

Beruf: Apple Consultant & Engineer

  • Nachricht senden

4

Mittwoch, 5. November 2008, 23:12

OK, I'm finished and it is working. I've modified your script to pick 20 xml files and modified the random formula.


for 4 xml files...

Quellcode

1
    var random_xml =  "top" + (1+Math.ceil(Math.random()*3)) + ".xml";

This way it seemed like it would never pick 1.xml so I changed it to...

Quellcode

1
 var random_xml = "top" + (Math.ceil(Math.random()*4)) + ".xml";

After some reloads this looked better. Could this modification cause other problems?


Thanks again.
Ronald

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »ronaldtichelaar« (6. November 2008, 00:37)


5

Donnerstag, 6. November 2008, 17:45

you're right,

sorry, I mixed up "ceil" (rounding up) and "floor" (rounding down)

so you can use:

Quellcode

1
var random_xml =  "top" + (1+Math.floor(Math.random()*3)) + ".xml";

or:

Quellcode

1
var random_xml =  "top" + (Math.ceil(Math.random()*4)) + ".xml";


BTW - absolutely great panos!

regards,
Klaus

Yomas

Fortgeschrittener

Beiträge: 190

Wohnort: Anglet, France

  • Nachricht senden

6

Dienstag, 25. Oktober 2011, 12:12

Random pano with if iphone / if android / if flash

Hi guys !
I'm upping this thread cause I try to do something similar, but with the creatpanoviewer isdevice method.
For now on I did a php script using the php rand but I have troubles in the iPhone, it's loading both iPhone and Android tour within the same page.
Maybe there'll be another way doing this ?
Here's my code :

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php

// Creates 3 tables for each tour version

$iphone = array ('iphone.xml', 'iphone1.xml', 'iphone2.xml', 'iphone3.xml');
$random1 = $iphone[rand(0, 3)];

$android = array ('android.xml', 'android1.xml', 'android2.xml', 'android3.xml');
$random2 = $android[rand(0, 3)];

$flash = array ('flash_tour.xml','flash_tour1.xml','flash_tour2.xml','flash_tour3.xml');
$random3 = $flash[rand(0, 3)];

?>
<!DOCTYPE html>
<html lang="fr">
<head>
<script src="js/tour.js"></script>
</head>
<body>

	<div style="width:100%; height:400px; z-index:100; background-color:none;" data-role="none" id="pano"> 
		<noscript> 
				<b>Attention:</b> <br/> 
				<br/> 
				Javascript is not activated. <br/> 
				<br/> 
				Please activate it to see the virtual tour <br/> 
		</noscript> 
				<script type="text/javascript">
						var viewer = createPanoViewer({swf:"tour.swf", id:"krpanoSWFObject", target:"pano"});
						//viewer.useHTML5("always");
						if( viewer.isDevice("iPhone|iPod|iPad") )
						{
							viewer.addVariable("xml", "<?php echo $random1; ?>"); <!-- Returns a random xml from the variable $iphone -->
							viewer.addVariable("showErrors", "false");  
							viewer.embed();
						}
						if( viewer.isDevice("Android") )
						{
							viewer.addVariable("xml", "<?php echo $random2; ?>"); <!-- Returns a random xml from the variable $android -->
							viewer.addVariable("showErrors", "false");  
							viewer.embed();
						}
						else
						{
							viewer.addVariable("xml", "<?php echo $random3; ?>"); <!-- Returns a random xml from the variable $flash -->
							viewer.addVariable("showErrors", "false");  
							viewer.embed();
						}
                </script>

	</div> <!-- end of krpanoDIV -->
 
</body> 
</html>


Thanks in advance and hoping this could help some of you ^^
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Yomas

Fortgeschrittener

Beiträge: 190

Wohnort: Anglet, France

  • Nachricht senden

7

Dienstag, 25. Oktober 2011, 15:23

[SOLVED]

Hi again ^^
I've changed the PHP script and by the way I messed up in the loading script, the following resolves it :

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// Création des tableaux pour le random
$iphone = array ('iphone.xml', 'iphone1.xml', 'iphone2.xml', 'iphone3.xml');
$android = array ('android.xml', 'android1.xml', 'android2.xml', 'android3.xml');
$flash = array ('flash_tour.xml','flash_tour1.xml','flash_tour2.xml','flash_tour3.xml');
?>
<!DOCTYPE html>
<html lang="fr">
<head>
</head>
<body>

	<div style="width:100%; height:400px; z-index:100; background-color:none;" data-role="none" id="pano"> 
		<noscript> 
				<b>Attention:</b> <br/> 
				<br/> 
				Javascript is not activated. <br/> 
				<br/> 
				Please activate it to see the virtual tour <br/> 
		</noscript> 
    <script src="js/tour.js"></script>
				<script type="text/javascript">
						var viewer = createPanoViewer({swf:"tour.swf", id:"krpanoSWFObject", target:"pano"});
						//viewer.useHTML5("always");
						if( viewer.isDevice("iPhone|iPod|iPad") )
						{
							viewer.addVariable("xml", "<?php echo $iphone[array_rand($iphone)]; ?>");
							viewer.addVariable("showErrors", "false");  
							viewer.embed();
						}
						else if( viewer.isDevice("Android") ) <!-- Here I'd forgot the else if I was using else -->
						{
							viewer.addVariable("xml", "<?php echo $android[array_rand($android)]; ?>");
							viewer.addVariable("showErrors", "false");  
							viewer.embed();
						}
						else
						{
							viewer.addVariable("xml", "<?php echo $flash[array_rand($flash)]; ?>");
							viewer.addVariable("showErrors", "false");  
							viewer.embed();
						}
                </script>

	</div> <!-- end of krpanoDIV -->
 
</body> 
</html>


Cheers !!
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Ähnliche Themen