Salute a tutti, o aspetato parecchio prima di postare tale domanda, ho sto cavolo di codice preso da uno slideshow che cera automaticamente FrontPage, lo ho adatato per renderlo + comprensibile, sin qua tutto bene, ma non riesco a capire come funzionino le "funzioni" ScrollLeft e ScrollRight, che essenzialmente sono le funzioni che a me occorrono il resto lo voglio realizzare in ASP.
Essenzialmente: Vi sono una serie di miniature (la galleria scorre 4 elementi per volta) + due pulsanti per far scorrere la galleria di miniature a Sx e Dx, il codice che Vi posto per me è indecifrabile o quasi (considerate che lo creà FrontPage...), a mio avviso le miniature potrei infilarle dentro un array e farle scorrere sarebbe forse più semplice, ma come fare questo rimane un dilemma.
Mi date qualche dritta?
Code dentro body:
<td align="center" valign="middle" nowrap="">
<script language="JavaScript1.1">
<!--
if (ie4()) {
document.write("<span align='center' style='width:520;overflow:hidden' id='GalleryListCell'>");
}
if (ns6()) {
document.getElementById("LeftBtn").style.visibilit y="hidden"
}
-->
</script>
</td>
code dentro head:
leftdisabled = true
rightdisabled = true
widthLength = 520
function ie4() {
var nav = navigator.appVersion.indexOf("MSIE");
return (nav>0) && (parseInt(navigator.appVersion.substring(nav+5, nav+6)) >= 4);
}
function ns6() {
return ((navigator.appName == "Netscape") &&
(parseInt(navigator.appVersion.substring(0, 1)) >= 5))
}
function ShowImg(src, sWidth, sHeight, iIndex)
{
var el = document.images["MainImg"];
if (el) {
if(ie4()) {
el.style.visiblity = "hidden";
el.src = src.lowsrc;
el.width = sWidth;
el.height = sHeight;
var caption = document.all["Caption"].all.tags("div")
var sCaptionTxt;
var sCaptionHTML;
if (caption && caption[iIndex]) {
sCaptionTxt = caption[iIndex].innerText
sCaptionHTML = caption[iIndex].innerHTML
} else {
sCaptionTxt = "";
sCaptionHTML = "";
}
el.title = sCaptionTxt;
el.style.visiblity = "visible";
var el = document.all["CaptionCell"];
if (el) {
el.innerHTML = sCaptionHTML;
}
var el = document.all["DescCell"];
if (el) {
var sDesc = document.all["Description"].all.tags("div")
el.innerHTML = sDesc && sDesc[iIndex]?sDesc[iIndex].innerHTML:"";
}
} else {
el.src = src.lowsrc
el.style.width = sWidth
el.style.height = sHeight
caption = document.getElementById("Caption").getElementsByTa gName("div")
if (caption && caption[iIndex]) {
sCaptionTxt = caption[iIndex].innerText
sCaptionHTML = caption[iIndex].innerHTML
} else {
sCaptionTxt = ""
sCaptionHTML = ""
}
el.title = sCaptionTxt
var e = document.getElementById("CaptionCell")
if (e) {
e.innerHTML = sCaptionHTML
}
var e = document.getElementById("DescCell")
if (e) {
var sDesc = document.getElementById("Description").getElements ByTagName("div")
e.innerHTML = sDesc[iIndex]?sDesc[iIndex].innerHTML:""
}
}
}
}
function ScrollLeft() {
var el = document.all["GalleryListCell"];
if (el && ie4()) {
var coll = el.children.tags("A");
var count = 20;
if (coll) {
for (i=1;i<coll.length;i++) {
if (coll(i).style.display != "none") {
coll(i-1).style.display = "inline";
break;
}
}
for (i=0;i<coll.length;i++) {
if (coll(i).style.display != "none") {
var images = coll[i].children.tags("img");
count = count + 20 + images[0].width;
if (count > widthLength)
coll(i).style.display = "none";
}
}
if ((el.scrollWidth - 5) >= el.clientWidth) {
var btn = document.all["RightBtn"]
if (btn && rightdisabled) {
rightdisabled = false;
te = btn.src
btn.src = btn.lowsrc
btn.lowsrc = te
}
}
if (coll(0).style.display != "none") {
var btn = document.all["LeftBtn"]
if (btn && !leftdisabled) {
leftdisabled = true;
te = btn.src
btn.src = btn.lowsrc
btn.lowsrc = te
}
}
}
}
}
function ScrollRight() {
var el = document.all["GalleryListCell"];
if (el && ie4()) {
if (!rightdisabled)
{
var coll = el.children.tags("A");
if (coll) {
var state = 0;
var count = 20;
for (i=0;i<coll.length;i++) {
if (state == 0)
{
if (coll(i).style.display != "none") {
coll(i).style.display = "none";
state = 1;
}
}
else{
var images = coll[i].children.tags("img");
count = count + 20 + images[0].width;
if (count < widthLength)
coll(i).style.display = "inline";
else
coll(i).style.display = "none";
}
}
}
var btn = document.all["RightBtn"];
if (btn && coll(coll.length - 1).style.display != "none") {
rightdisabled = true
te = btn.src
btn.src = btn.lowsrc
btn.lowsrc = te
}
var btn = document.all["LeftBtn"];
if (btn && leftdisabled) {
te = btn.src
btn.src = btn.lowsrc
btn.lowsrc = te
leftdisabled = false
}
}
}
}