...

View Full Version : Pic Gallery -doesnt work under IE



swmikolaj21
02-19-2007, 11:02 PM
I don't know much about JS and I must have messed something up with the code I have while updating the website. It does'nt work under IE, it is fine in FF.

Please save my ***, I have to fix this and I have no time to learn.

Here is a code:
PHP file:

<?php
if (isset($_GET["id"]))
$id = $_GET["id"];
else
$id = '1401';
$langID = "pl";
if (isset($_GET["lang"])) {
$langID = $_GET["lang"];
if ($langID != "pl" && $langID != "en" && $langID != "de")
$langID = "pl";
}
$slajdy = "Slajdy";
if ($langID == "de" || $langID == "en")
$slajdy = "Slideshow";
$powrot = "Powrót";
switch ($langID) {
case "en": $powrot = "Return"; break;
case "de": $powrot = "Zurück"; break;
}
$sek = "sek.";
if ($langID == "en")
$sek = "sec.";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
<meta http-equiv="Creation-date" content="2006-04-20T22:09:46Z">
<meta http-equiv="Content-Language" content="pl">
<link rel="stylesheet" href="galeria.css" type="text/css">
<script type="text/javascript" src="page.js"></script>
<script type="text/javascript" src="galeria.js"></script>
<script type="text/javascript">
<!--
function DocumentInit() {
GallerySetLanguage("<?php echo $langID ?>");
GalleryInit();
if (history.length == 0)
document.getElementById("panel_powrot").disabled = true;
}

function SetLang(lang) {
window.location.href = "galeria.php?lang=" + lang + "&id=" + GalleryImageID();
return false;
}
//-->
</script>
</head>

<body>
<div id="midwrap">
<div id="pagetop"></div>
<div id="menu"><ul>
<?php
switch ($langID) {
case "en":
?>

<?php break;
case "de":
?>

<?php break;
default:
?>

<?php } ?>
<li id="flagi">
<a id="polski" href="galeria.php?id=<?echo $id ?>&lang=pl" onClick='return SetLang("pl")'></a>
<a id="deutsch" href="galeria.php?id=<?echo $id ?>&lang=de" onClick='return SetLang("de")'></a>
<a id="english" href="galeria.php?id=<?echo $id ?>&lang=en" onClick='return SetLang("en")'></a>
</li>
</ul></div>
<div id="content_wrap">
<input id="guzik_lewy" type="button" value="Ť" class="guzik" onClick="GalleryPrev()">
<input id="guzik_prawy" type="button" value="ť" class="guzik" onClick="GalleryNext()">
<img id="CurrentImage" src="img/full/foto<?php echo $id ?>.jpg" alt="Lata Yachts">
<div id="panel">
<input id="panel_lewo" type="button" value="Ť" class="guzik" onClick="GalleryPrev()">
<input id="panel_slajdy" type="button" value="<?php echo $slajdy ?>" class="guzik" onClick="GalleryRunSlideshow()">
<select id="panel_czas" onChange="GallerySetInterval()">
<option value="3">3 <?php echo $sek ?></option>
<option value="5" selected>5 <?php echo $sek ?></option>
<option value="7">7 <?php echo $sek ?></option>
<option value="10">10 <?php echo $sek ?></option>
<option value="15">15 <?php echo $sek ?></option>
</select>
<input id="panel_powrot" type="button" value="<?php echo $powrot ?>" class="guzik" onClick="history.back()">
<input id="panel_prawo" type="button" value="ť" class="guzik" onClick="GalleryNext()">
</div>
</div>

</div>
</body>
</html>


And JS:



var gallery1 = [
"img/full/foto1472.jpg",
"img/full/foto1401.jpg",
"img/full/foto1.jpg",
"img/full/foto3164.jpg",
"img/full/foto1477.jpg",
"img/full/foto1548.jpg",
"img/full/foto2363.jpg",
"img/full/foto1439.jpg",
"img/full/foto1583.jpg",
"img/full/foto1567.jpg",
"img/full/foto1532.jpg",
"img/full/foto1577.jpg",
"img/full/foto1533.jpg"
];
var gallery2 = ["img/full/foto10.jpg"];
var gallery3 = [
"img/full/foto31.jpg",
"img/full/foto32.jpg",
"img/full/foto33.jpg",
"img/full/foto34.jpg",
"img/full/foto2397.jpg",
"img/full/foto0701.jpg",
"img/full/foto0702.jpg",
"img/full/foto0703.jpg",
"img/full/foto0704.jpg",
"img/full/foto0705.jpg",
"img/full/foto0706.jpg",
"img/full/foto0707.jpg",
"img/full/foto0708.jpg",
"img/full/foto0709.jpg",
"img/full/foto0710.jpg",
"img/full/foto0711.jpg",
"img/full/foto0712.jpg",
"img/full/foto0713.jpg",
"img/full/foto0714.jpg",
"img/full/foto0715.jpg",
];
var gallery4 = [
"img/full/foto21.jpg",
"img/full/foto22.jpg",
"img/full/foto23.jpg",
"img/full/foto24.jpg",
"img/full/foto25.jpg",
"img/full/foto26.jpg",
"img/full/foto27.jpg",
"img/full/foto28.jpg",
];
var gallery5 = [
"img/full/foto0162.jpg",
"img/full/foto0163.jpg",
"img/full/foto0166.jpg",
"img/full/foto0314.jpg",
"img/full/foto0308.jpg",
"img/full/foto0296.jpg",
"img/full/foto0314.jpg",
"img/full/foto0421.jpg",
"img/full/foto0422.jpg",
"img/full/foto0423.jpg",
"img/full/foto0424.jpg",
"img/full/foto0425.jpg",
"img/full/foto0426.jpg",
"img/full/foto0427.jpg",
];
var galleries = [gallery1, gallery2, gallery3, gallery4, gallery5];
var gallery = null;
var galleryIdx = null;
var slideInterval = null;
var langID = "pl";

function GalleryImageID() {
if (galleryIdx == null)
return "1472";
var img = gallery[galleryIdx];
if (typeof img == "object")
img = img.src;
return img.replace(/^.*/img/full/foto(.+).jpg$/, "$1");
}

function GalleryInit() {
var curImg = document.getElementById("CurrentImage");
var curName = curImg.src;

curName = curName.substr(curName.lastIndexOf("/") + 1);
for (var j = 0; j < galleries.length && galleryIdx == null; ++j) {
gallery = galleries[j];
for (var i = 0; i < gallery.length; ++i)
if (gallery[i].indexOf(curName) >= 0) {
galleryIdx = i;
gallery[i] = new Image();
gallery[i].src = curImg.src;
break;
}
}
if (gallery.length == 1) {
document.getElementById("guzik_lewy").disabled = true;
document.getElementById("guzik_prawy").disabled = true;
document.getElementById("panel_lewo").disabled = true;
document.getElementById("panel_slajdy").disabled = true;
document.getElementById("panel_czas").disabled = true;
document.getElementById("panel_prawo").disabled = true;
}
GalleryPreload();
}

function GalleryNext() {
if (galleryIdx != null) {
var i = galleryIdx + 1;
if (i >= gallery.length)
i = 0;
GallerySelect(i);
}
}

function GalleryPreload() {
if (galleryIdx != null) {
var lastIdx = gallery.length - 1;
var i = galleryIdx == lastIdx? 0 : galleryIdx + 1;
var img = new Image();

img.onload = GallerySetPreload;
if (typeof gallery[i] == "string") {
img.src = gallery[i];
gallery[i] = img;
}
else {
i = galleryIdx == 0? lastIdx : galleryIdx - 1;
if (typeof gallery[i] == "string") {
img.src = gallery[i];
gallery[i] = img;
}
else {
var stopIdx = i;
i = galleryIdx + 2;
if (i > lastIdx)
i -= lastIdx + 1;
for (; i != stopIdx; i = i >= lastIdx? 0 : i + 1)
if (typeof gallery[i] == "string") {
img.src = gallery[i];
gallery[i] = img;
break;
}
}
}
}
}

function GalleryPrev() {
if (galleryIdx != null) {
var i = (galleryIdx == 0? gallery.length : galleryIdx) - 1;
GallerySelect(i);
}
}

function GalleryRunSlideshow() {
if (slideInterval == null) {
var msecs = parseInt(document.getElementById("panel_czas").value) * 1000;
slideInterval = window.setInterval("GalleryNext()", msecs);
document.getElementById("panel_slajdy").value = "Stop";
}
else
GalleryStopSlideshow();
}

function GallerySelect(idx) {
var img = document.getElementById("CurrentImage");
if (typeof gallery[idx] == "object")
img.src = gallery[idx].src;
else {
var newImg = new Image();
img.src = newImg.src = gallery[idx];
gallery[idx] = newImg;
}
galleryIdx = idx;
}

function GallerySetInterval() {
if (slideInterval != null) {
GalleryStopSlideshow();
GalleryRunSlideshow();
}
}

function GallerySetLanguage(lang) {
if (lang == "pl" || lang == "en" || lang == "de")
langID = lang;
}

function GallerySetPreload() {
window.setTimeout("GalleryPreload()", 100);
}

function GalleryStopSlideshow() {
if (slideInterval != null) {
window.clearTimeout(slideInterval);
slideInterval = null;
document.getElementById("panel_slajdy").value =
langID == "pl"? "Slajdy" : "Slideshow";
}
}


Thank very much for any peace of advice

Regards
Maciek

nikkiH
02-20-2007, 10:16 PM
Hard to test, got a live link?

First thing I notice is an array ending in a comma. IE might get peeved about that.

"img/full/foto0715.jpg",

That was the last item in that list, so should not have a comma.

swmikolaj21
02-21-2007, 12:06 AM
here is a link: http://www.latayachts.pl/galeria.php?id=34

Thanks for the comma's advice!

Regards

MikeFoster
02-21-2007, 02:32 PM
Wow, awesome yachts!

nikkiH
02-21-2007, 02:51 PM
Seems to be working now; was it the comma?

swmikolaj21
02-21-2007, 06:11 PM
Yes, it was... Thank a lot!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum