Topic: Multiple galleries on same html page, bug?

Hi,

Recently upgraded from the SimpleViewer 2.0.1 free version to SimpleViewerPro 2.1.13.  This could be my programming error but with the old version version this code worked:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<!--  Gallery 1 JavaScript Embed -->
<script type="text/javascript">
            var flashvars = {};
            flashvars.baseURL = "images/stonesplittergallery/";
            flashvars.galleryURL = "gallery.xml";
            var params = {};            
            params.allowfullscreen = true;
            params.allowscriptaccess = "always";
            params.bgcolor = "222222";
            swfobject.embedSWF("images/gallery/simpleviewer.swf", "flashContent1", "853", "605", "9.0.124", false, flashvars, params);
        </script>
        
        <!--  Gallery 2 JavaScript Embed -->
        <script type="text/javascript">
            var flashvars = {};
            flashvars.baseURL = "images/stonesplittergallery2/";
            flashvars.galleryURL = "gallery.xml";
            var params = {};
            params.allowfullscreen = true;
            params.allowscriptaccess = "always";
            params.bgcolor = "222222";
            swfobject.embedSWF("images/gallery/simpleviewer.swf", "flashContent2", "853", "605", "9.0.124", false, flashvars, params);
        </script>

note the var flashvars and var params.

Now when I converted to work with SimpleViewerPro 2.1.13 with the following code:

<!--START SIMPLEVIEWER EMBED.-->
<!--  Gallery 1 JavaScript Embed-->
<script type="text/javascript" src="/images/gallery/svcore/js/simpleviewer.js"></script>
<script type="text/javascript">
    var flashvars = {};
    flashvars.baseURL = "images/stonesplittergallery/";
    flashvars.galleryURL = "gallery.xml";
    var params = {};
    params.allowfullscreen = true;
    params.allowscriptaccess = "always";
    params.bgcolor = "222222";
    simpleviewer.ready(function() {
        simpleviewer.load("sv-container1", "853", "605", "222222", true, flashvars, params);
    });
</script>
<!--  Gallery 2 JavaScript Embed-->
<script type="text/javascript">
    var flashvars = {};
    flashvars.baseURL = "images/stonesplittergallery2/";
    flashvars.galleryURL = "gallery.xml";
    var params = {};
    params.allowfullscreen = true;
    params.allowscriptaccess = "always";
    params.bgcolor = "222222";
    simpleviewer.ready(function() {
        simpleviewer.load("sv-container2", "853", "605", "222222", true, flashvars, params);
    });
</script>

<div id="sv-container1"></div>
<br clear="left"/>
<br clear="left"/>
<div id="sv-container2"></div>

Then two galleries were shown but both with the contents of the second gallery.  Again note the use of var flashvars and var params.

To fix it I had to declare a unique flashvars and params for the second gallery (var flashvars2 and var params2).  Like so:

<!--START SIMPLEVIEWER EMBED.-->
<!--  Gallery 1 JavaScript Embed-->
<script type="text/javascript" src="/images/gallery/svcore/js/simpleviewer.js"></script>
<script type="text/javascript">
    var flashvars = {};
    flashvars.baseURL = "images/stonesplittergallery/";
    flashvars.galleryURL = "gallery.xml";
    var params = {};
    params.allowfullscreen = true;
    params.allowscriptaccess = "always";
    params.bgcolor = "222222";
    simpleviewer.ready(function() {
        simpleviewer.load("sv-container1", "853", "605", "222222", true, flashvars, params);
    });
</script>
<!--  Gallery 2 JavaScript Embed-->
<script type="text/javascript">
    var flashvars2 = {};
    flashvars2.baseURL = "images/stonesplittergallery2/";
    flashvars2.galleryURL = "gallery.xml";
    var params2 = {};
    params2.allowfullscreen = true;
    params2.allowscriptaccess = "always";
    params2.bgcolor = "222222";
    simpleviewer.ready(function() {
        simpleviewer.load("sv-container2", "853", "605", "222222", true, flashvars2, params2);
    });
</script>

Don't know if it's a bug since javascript isn't my thing, but it seems odd that the old one worked and the new one didn't.

Last edited by Greg9504 (2011-09-05 01:26:55)

Re: Multiple galleries on same html page, bug?

This is due to the new method used to embed SimpleViewer and each JavaScript variable on the page should be given a unique name.

Steven Speirs
SimpleViewer Support Team.