MediaWiki:Multibilde.js
Fra Villmark
(Forskjeller mellom versjoner)
Admin (Diskusjon | bidrag)
(Ny side: function nextSibling1(node) { var n = node; while ( n && !( n.nodeType == 1 && n.nodeName == "DIV" )) n = n.nextSibling; return n; } function nextImage(iImage)…)
(Ny side: function nextSibling1(node) { var n = node; while ( n && !( n.nodeType == 1 && n.nodeName == "DIV" )) n = n.nextSibling; return n; } function nextImage(iImage)…)
Nåværende revisjon fra 22. jul 2009 kl. 23:38
function nextSibling1(node) { var n = node; while ( n && !( n.nodeType == 1 && n.nodeName == "DIV" )) n = n.nextSibling; return n; } function nextImage(iImage) { var divs = document.getElementsByTagName( "div" ); for ( var i = 0, j = 0; i < divs.length; i++ ) { if ( hasClass( divs[i], "vekselbilde" ) ) { if ( j == iImage ) { for ( var chi = nextSibling1(divs[i].firstChild); chi; chi = nextSibling1(chi.nextSibling) ) { if ( chi.style.display == "" ) { chi.style.display = "none"; if ( nextSibling1(chi.nextSibling) ) nextSibling1(chi.nextSibling).style.display = ""; else nextSibling1(divs[i].firstChild).style.display = ""; break; } } break; } else j++; } } } function checkMultiImages() { var paragraphs = document.getElementsByTagName( "p" ); for ( var i = 0, j = 0; i < paragraphs.length; i++ ) { if ( hasClass( paragraphs[i], "vekselbilde" ) ) { var link = document.createElement( "a" ); link.setAttribute( "href", "javascript:nextImage(" + (j++) + ");" ); link.setAttribute( "title", "alternativbilde" ); link.appendChild( paragraphs[i].firstChild ); paragraphs[i].appendChild( link ); paragraphs[i].style.display = ""; } } } addOnloadHook( checkMultiImages );