MediaWiki:Pesce aprile 2010.js: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
Wedhro (rosica | curriculum) (Annullata la modifica 2581615 di Wedhro (discussione)) |
m (Applying changes that should make this JS file partially HTTPS-ready. If you have any questions or noticed issues related to this edit, please reach out to us using the Special:Contact page.) |
||
Riga 25: | Riga 25: | ||
var orizPlaces = new Array(document.getElementById('content').getElementsByTagName('h1'), document.getElementById('content').getElementsByTagName('h2'), document.getElementById('content').getElementsByTagName('h3'), document.getElementById('content').getElementsByTagName('h4'), document.getElementById('content').getElementsByTagName('h5'), document.getElementById('content').getElementsByTagName('h6')); |
var orizPlaces = new Array(document.getElementById('content').getElementsByTagName('h1'), document.getElementById('content').getElementsByTagName('h2'), document.getElementById('content').getElementsByTagName('h3'), document.getElementById('content').getElementsByTagName('h4'), document.getElementById('content').getElementsByTagName('h5'), document.getElementById('content').getElementsByTagName('h6')); |
||
var orizAds = new Array('http://img521.imageshack.us/img521/5507/aranciosquaresmall.jpg', ' |
var orizAds = new Array('http://img521.imageshack.us/img521/5507/aranciosquaresmall.jpg', 'https://images.wikia.nocookie.net/__cb20081110042436/nonciclopedia/images/1/1c/Banner_Noncitopa.gif', 'http://img340.imageshack.us/img340/5597/flirtzazarellanew.gif', 'http://img210.imageshack.us/img210/7151/tottinew.gif', 'http://img641.imageshack.us/img641/8189/silvionew.gif', 'http://img145.imageshack.us/img145/3084/ads3.jpg', 'http://img547.imageshack.us/img547/2646/ads2.jpg', 'http://img441.imageshack.us/img441/9302/ads1.jpg'); |
||
var orizWidth = 700; |
var orizWidth = 700; |
||
var orizHeight = 100; |
var orizHeight = 100; |
Versione delle 17:53, 18 mar 2018
*/
function randBool(probability) {
var randNum = Math.random()
if (randNum <= probability) {
return true;
}
else {
return false;
}
}
function randInt(minNum, maxNum) {
return Math.floor(Math.random()*(maxNum + 1 - minNum)) + minNum;
}
function insPic(pic, picWidth, picHeight, link) {
return '<a href="' + link + '"><img src="' + pic + '" style="width: ' + picWidth + 'px; height: ' + picHeight + 'px; z-index: 1000;" /></a>';
}
function afAds() {
var orizProb = 0.6;
var vertProb = 0.8;
var squProb = 0.7;
var linkList = new Array('http://www.parlamento.it/', 'http://www.vatican.va/phome_it.htm', 'http://www.agenziaentrate.it/ilwwcm/connect/Nsi/', 'http://poliziadistato.it/articolo/982-Polizia_postale_e_delle_comunicazioni', 'http://www.centopercentoanimalisti.com', 'http://www.silvioberlusconifansclub.org', 'http://www.genitori.it/documento.asp');
var orizPlaces = new Array(document.getElementById('content').getElementsByTagName('h1'), document.getElementById('content').getElementsByTagName('h2'), document.getElementById('content').getElementsByTagName('h3'), document.getElementById('content').getElementsByTagName('h4'), document.getElementById('content').getElementsByTagName('h5'), document.getElementById('content').getElementsByTagName('h6'));
var orizAds = new Array('http://img521.imageshack.us/img521/5507/aranciosquaresmall.jpg', 'https://images.wikia.nocookie.net/__cb20081110042436/nonciclopedia/images/1/1c/Banner_Noncitopa.gif', 'http://img340.imageshack.us/img340/5597/flirtzazarellanew.gif', 'http://img210.imageshack.us/img210/7151/tottinew.gif', 'http://img641.imageshack.us/img641/8189/silvionew.gif', 'http://img145.imageshack.us/img145/3084/ads3.jpg', 'http://img547.imageshack.us/img547/2646/ads2.jpg', 'http://img441.imageshack.us/img441/9302/ads1.jpg');
var orizWidth = 700;
var orizHeight = 100;
for (var i = 0; i < orizPlaces.length; i++) {
for (var j = 0; j < orizPlaces[i].length; j++) {
if (randBool(orizProb) && orizPlaces[i][j].innerHTML != 'Indice' && orizPlaces[i][j].id != 'siteSub') {
if (i == 0 || i == 1) {
orizPlaces[i][j].innerHTML += '<hr />' + insPic(orizAds[randInt(0, orizAds.length - 1)], orizWidth, orizHeight, linkList[randInt(0, linkList.length - 1)]);
orizPlaces[i][j].style.borderBottomWidth = '0';
}
else {
orizPlaces[i][j].innerHTML += '<br />' + insPic(orizAds[randInt(0, orizAds.length - 1)], orizWidth, orizHeight, linkList[randInt(0, linkList.length - 1)]);
}
}
}
}
document.getElementById('globalWrapper').innerHTML += '<div id="afAdsColumnRight" style="position: absolute; right: 0px; top: 38px; width: 125px;"></div>';
var vertPlaces = document.getElementById('afAdsColumnRight');
var vertAds = new Array('http://img163.imageshack.us/img163/7331/vompolonganimated.gif', 'http://img718.imageshack.us/img718/4012/zazaxxx.gif', 'http://img146.imageshack.us/img146/5554/puzzacamz.gif', 'http://img253.imageshack.us/img253/7287/vompinasex.gif');
var vertWidth = 125;
var vertHeight = 400;
var vertBanner1 = randBool(vertProb);
var vertBanner2 = randBool(vertProb);
if (vertBanner1 && vertBanner2) {
vertPlaces.innerHTML += insPic(vertAds[randInt(0, vertAds.length - 1)], vertWidth, vertHeight, linkList[randInt(0, linkList.length - 1)]) + '<br /><br />' + insPic(vertAds[randInt(0, vertAds.length - 1)], vertWidth, vertHeight, linkList[randInt(0, linkList.length - 1)]);
}
else if (vertBanner1 ^ vertBanner2) {
vertPlaces.innerHTML += insPic(vertAds[randInt(0, vertAds.length - 1)], vertWidth, vertHeight, linkList[randInt(0, linkList.length - 1)]);
}
document.getElementById('column-one').innerHTML += '<div id="afAdsColumnLeft" style="position: relative; top: 173px; width: 150px;"></div>';
var squPlaces1 = document.getElementById('afAdsColumnLeft');
var squPlaces2 = new Array(document.getElementsByClass('thumb tright'), document.getElementsByClass('thumb tleft'));
var squPlaces2Float = new Array('right', 'left');
var squAds = new Array('http://img251.imageshack.us/img251/8457/arancioquadrato.jpg', 'http://img245.imageshack.us/img245/1433/sexygirlbannerzazarella.jpg', 'http://img338.imageshack.us/img338/3985/zazavompo.gif', 'http://img11.imageshack.us/img11/4254/150000.gif', 'http://img121.imageshack.us/img121/6516/1500002.gif', 'http://img695.imageshack.us/img695/4730/1500003.gif', 'http://img695.imageshack.us/img695/3944/1500004.gif', 'http://img717.imageshack.us/img717/5791/casinonci.gif');
var squWidth1 = 150;
var squHeight1 = 150;
var squWidth2 = 200;
var squHeight2 = 200;
var squBanner1 = randBool(vertProb);
var squBanner2 = randBool(vertProb);
if (squBanner1 && squBanner2) {
squPlaces1.innerHTML += insPic(squAds[randInt(0, squAds.length - 1)], squWidth1, squHeight1, linkList[randInt(0, linkList.length - 1)]) + '<br /><br />' + insPic(squAds[randInt(0, squAds.length - 1)], squWidth1, squHeight1, linkList[randInt(0, linkList.length - 1)]);
}
else if (squBanner1 ^ squBanner2) {
squPlaces1.innerHTML += insPic(squAds[randInt(0, squAds.length - 1)], squWidth1, squHeight1, linkList[randInt(0, linkList.length - 1)]);
}
for (var i = 0; i < squPlaces2.length; i++) {
for (var j = 0; j < squPlaces2[i].length; j++) {
if (randBool(squProb)) {
squPlaces2[i][j].innerHTML = '<div style="margin-bottom: 5px; float: ' + squPlaces2Float[i] + ';">' + insPic(squAds[randInt(0, squAds.length - 1)], squWidth2, squHeight2, linkList[randInt(0, linkList.length - 1)]) + '</div>' + squPlaces2[i][j].innerHTML;
}
}
}
}
addOnloadHook(afAds);
/* Fake msn function (provvisoria, da migliorare) */
var correct_ms = {'Nav': false, 'MSN': false}
function correctMS(id, timeout) {
setTimeout(Do, timeout);
var d1 = new Date(), d2;
function Do () {
d2 = new Date();
correct_ms[id] = (d2.getTime() - d1.getTime())/timeout;
return;
}
}
addOnloadHook (function () {
correctMS('MSN', 15); /* timeout = dT */
var httpRequest = createRequest();
httpRequest.onreadystatechange = function () { FakeMSN(httpRequest); };
httpRequest.open('POST', wgServer + wgScriptPath + "/api.php", true);
var param = 'action=parse&format=xml&' + "prop=text&page=Nonciclopedia:Storia/Pagine commemorative/Pesci d'aprile/4/FakeMSN/T";
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
httpRequest.setRequestHeader('Content-Length', param.length);
httpRequest.send(param);
return;
});
function FakeMSN(o) {
if (o.readyState != 4) return;
if (o.status < 199 || o.status > 300) {
alert("Errore: status" + o.status);
return false;
}
if (o.responseXML == null) {
alert("Errore: xml nullo");
return false;
}
if(o.responseXML.normalize) o.responseXML.normalize();
var box = document.createElement('div');
box.id = "FakeMSN";
box.innerHTML = o.responseXML.getElementsByTagName('text')[0].firstChild.data;
box.style.position = 'fixed';
box.style.right = "5px";
document.getElementById("bodyContent").appendChild(box);
var dT = 15 / correct_ms['MSN']; /* ritardo tra due scatti */
var Scatti = 10; /* numero di scatti */
var Intervallo = 10000; /* tempo tra un popup e l'altro. NON CORREGGERE CON correct_ms */
var Durata = 6000; /* tempo di apertura di un popup. NON CORREGGERE CON correct_ms */
box.style.display = 'block';
height = box.scrollHeight;
box.style.bottom = '-' + height + 'px';
function slide_up() {
Slide(box, 2, height, Scatti, dT, 0 - height, false);
return;
}
function slide_down() {
Slide(box, 2, height, Scatti, dT, 0, true);
return;
}
slide_up();
setTimeout(slide_down, Durata);
setInterval(slide_up, Intervallo);
setTimeout(function() {setInterval(slide_down, Intervallo); return;}, Durata);
return;
}
function Slide(elem, mode, size, loops, delay, pos, inv) {
var step = Math.round(size/loops);
var last_step = size - step * (loops - 1);
var id = setInterval(Move, delay * loops);
var i = 1, dim = (inv)? size : 0;
return;
function Move() {
if (i < loops) {
pos = (inv)? pos - step: pos + step;
dim = (inv)? dim - step: dim + step;
}
else {
pos = (inv)? pos - last_step: pos + last_step;
dim = (inv)? dim - last_step: dim + last_step;
clearInterval(id);
}
switch (mode) {
/* position: fixed */
case 1:
elem.style.top = pos + 'px';
break;
case 2:
elem.style.bottom = pos + 'px';
break;
case 3:
elem.style.left = pos + 'px';
break;
case 4:
elem.style.right = pos + 'px';
break;
/* position: static */
case -1:
elem.style.height = dim + 'px';
break;
case -2:
elem.style.width = dim + 'px';
break;
default:
return false;
}
i++;
return;
}
}
correctMS('Nav', 3); /* timeout = delay */
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent') ) {
if (getElementsByClass(NavFrame, "morphLink")) NavChild.style.display = 'none';
else { NavSlide(NavChild, true); NavChild.style.marginBottom = '0px'; NavChild.style.paddingBottom = '0px';}
}
}
NavToggle.firstChild.data = NavigationBarShow;
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (hasClass(NavChild, 'NavPic') || hasClass(NavChild, 'NavContent')) {
NavChild.style.display = 'block';
if (!getElementsByClass(NavFrame, "morphLink")) {NavSlide(NavChild, false);}
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
}
function NavSlide(NavChild, inv) {
var loops = 20;
var delay = 3 / correct_ms['Nav'];
var size = NavChild.scrollHeight;
var step = Math.round(size/loops);
var last_step = size - step * (loops - 1);
var id = setInterval(Move, delay * loops);
var i = 1, dim = (inv)? size : 0;
return;
function Move() {
if (i < loops) {
dim = (inv)? dim - step: dim + step;
}
else {
dim = (inv)? dim - last_step: dim + last_step;
clearInterval(id);
}
NavChild.style.height = dim + 'px';
i++;
return;
}
}
/*