Ero sivun ”Käyttäjä:Erkkimon/monobook.js” versioiden välillä

ApoWikistä
p (uutta kokeilua, aivan ihmeellistä, ettei toimi)
p (Erkkimon siirsi sivun Käyttäjä:Tom Himanen/monobook.js uudelle nimelle Käyttäjä:Erkkimon/monobook.js luomatta ohjausta: Siirretty automaattisesti tunnukselta ”Tom Himanen” tunnukselle ”Erkkimon”)
 
(3 välissä olevaa versiota samalta käyttäjältä ei näytetä)
Rivi 1: Rivi 1:
function showFootnote(evnt) {
function showFootnote(evnt) {
    var e = window.event ? window.event : evnt;
var e = window.event ? window.event : evnt;
    var obj = window.event ? window.event.srcElement : evnt.target;
var obj = window.event ? window.event.srcElement : evnt.target;
 
    // Is this link a ref tag
// Is this link a ref tag
    if(obj.tagName != "A") return;
if(obj.tagName != "A") return;
    if(!obj.hash) return;
if(!obj.hash) return;
    if(obj.hash.substr(0,11) != "#cite_note-") return;
        if(obj.hash.substr(0,11) != "#_note-") return;
    if(obj.parentNode.className != "reference") return;
if(obj.parentNode.className != "reference") return;
 
    // Is there's a footnote to display?
 
    // Someone may have forgotten the <references/> tag
    var footnote_id = obj.hash.substr(1);
// Is there's a footnote to display?
    if(!document.getElementById(footnote_id)) return;
// Someone may have forgotten the <references/> tag
var footnote_id = obj.hash.substr(1);
    // Good, hide the popup, if it isn't already
if(!document.getElementById(footnote_id)) return;
    footnote.style.display = "none";
 
// Good, hide the popup, if it isn't already
    // Decide where to put the popup
footnote.style.display = "none";
    var window_width = document.body.clientWidth;
    var horizontal_position = e.clientX;
// Decide where to put the popup
    var vertical_position = e.clientY;
var window_width = document.body.clientWidth;
    var horizontal_scroll, vertical_scroll;
var horizontal_position = e.clientX;
var vertical_position = e.clientY;
    if (document.all) {
var horizontal_scroll, vertical_scroll;
        var dObj = typeof document.documentElement.scrollLeft == 'undefined' ?
 
            document.body : document.documentElement;
if (document.all) {
        horizontal_scroll = dObj.scrollLeft;
var dObj = typeof document.documentElement.scrollLeft == 'undefined' ?
        vertical_scroll = dObj.scrollTop;
document.body : document.documentElement;
    } else {
horizontal_scroll = dObj.scrollLeft;
        horizontal_scroll = window.pageXOffset;
vertical_scroll = dObj.scrollTop;
        vertical_scroll = window.pageYOffset;
} else {
    }
horizontal_scroll = window.pageXOffset;
vertical_scroll = window.pageYOffset;
    footnote.style.top = (vertical_scroll + vertical_position - 13) + "px";
}
 
    if(horizontal_position > (window_width / 2)) {
footnote.style.top = (vertical_scroll + vertical_position - 13) + "px";
        footnote.style.right = (horizontal_scroll + window_width - horizontal_position - 13) + "px";
 
        footnote.style.left = "";
if(horizontal_position > (window_width / 2)) {
    } else {
footnote.style.right = (horizontal_scroll + window_width - horizontal_position - 13) + "px";
        footnote.style.right = "";
footnote.style.left = "";
        footnote.style.left = (horizontal_position - 13) + "px";
} else {
    }
footnote.style.right = "";
footnote.style.left = (horizontal_position - 13) + "px";
    // Fetch the footnote text and remove the unnecessary back link(s)
}
    // This is a little messy as there's no containing tags
    var fn_text = document.getElementById(footnote_id).innerHTML;
// Fetch the footnote text and remove the unnecessary back link(s)
    fn_text = fn_text.replace(/^.*<a[^>]*href="#cite_ref-.*?<\/a> */i, ""); // "
// This is a little messy as there's no containing tags
var fn_text = document.getElementById(footnote_id).innerHTML;
    // Insert the footnote text
fn_text = fn_text.replace(/^.*<a[^>]*href="#cite_ref-.*?<\/a> */i, ""); // "
    footnote.innerHTML = fn_text;
// Insert the footnote text
    //Make the popup visible
footnote.innerHTML = fn_text;
    footnote.style.display = "";
 
//Make the popup visible
footnote.style.display = "";
}
}
 
function hideFootnote(evnt) {
function hideFootnote(evnt) {
    var obj = window.event ? window.event.srcElement : evnt.target;
var obj = window.event ? window.event.srcElement : evnt.target;
    // No point in going on if popup is already hidden
// No point in going on if popup is already hidden
    if(footnote.style.display == "none") return;
if(footnote.style.display == "none") return;
    // Search the tree to see where the curser is
// Search the tree to see where the curser is
    var depth = 0; // no need to search too much
var depth = 0; // no need to search too much
    while(obj && obj.parentNode) {  
while(obj && obj.parentNode) {
        if(obj.id == "footnote" || obj.id.substr(0, 9) == "cite_ref-") { return; }
if(obj.id == "footnote" || obj.id.substr(0, 9) == "cite_ref-") { return; }
        if(depth > 3) break;
if(depth > 3) break;
        obj = obj.parentNode;
obj = obj.parentNode;
        depth++;
depth++;
    }
}
    footnote.style.display = "none";
footnote.style.display = "none";
}
}
 
// Set up the float element
// Set up the float element
var footnote = document.createElement("DIV");
var footnote = document.createElement("DIV");
Rivi 85: Rivi 87:
footnote.style.padding = "5px";
footnote.style.padding = "5px";
footnote.style.fontSize = "10pt";
footnote.style.fontSize = "10pt";
 
addOnloadHook( function () { document.body.appendChild(footnote) } );
addOnloadHook( function () { document.body.appendChild(footnote) } );
 
// Add events
// Add events
addHandler(document, "mouseover", showFootnote);
addHandler(document, "mouseover", showFootnote);
addHandler(document, "mousemove", hideFootnote);
addHandler(document, "mousemove", hideFootnote);

Nykyinen versio 8. joulukuuta 2014 kello 22.08

function showFootnote(evnt) {
	var e = window.event ? window.event : evnt;
	var obj = window.event ? window.event.srcElement : evnt.target;

	// Is this link a ref tag
	if(obj.tagName != "A") return;
	if(!obj.hash) return;
        if(obj.hash.substr(0,11) != "#_note-") return;
	if(obj.parentNode.className != "reference") return;


	
	// Is there's a footnote to display?
	// Someone may have forgotten the <references/> tag
	var footnote_id = obj.hash.substr(1);
	if(!document.getElementById(footnote_id)) return;

	// Good, hide the popup, if it isn't already
	footnote.style.display = "none";
	
	// Decide where to put the popup
	var window_width = document.body.clientWidth;
	var horizontal_position = e.clientX;
	var vertical_position = e.clientY;
	var horizontal_scroll, vertical_scroll;

	if (document.all) {
		var dObj = typeof document.documentElement.scrollLeft == 'undefined' ?
			document.body : document.documentElement;
		horizontal_scroll = dObj.scrollLeft;
		vertical_scroll = dObj.scrollTop;
	} else {
		horizontal_scroll = window.pageXOffset;
		vertical_scroll = window.pageYOffset;
	}

	footnote.style.top = (vertical_scroll + vertical_position - 13) + "px";

	if(horizontal_position > (window_width / 2)) {
		footnote.style.right = (horizontal_scroll + window_width - horizontal_position - 13) + "px";
		footnote.style.left = "";
	} else {
		footnote.style.right = "";
		footnote.style.left = (horizontal_position - 13) + "px";
	}
	
	// Fetch the footnote text and remove the unnecessary back link(s)
	// This is a little messy as there's no containing tags
	var fn_text = document.getElementById(footnote_id).innerHTML;
	fn_text = fn_text.replace(/^.*<a[^>]*href="#cite_ref-.*?<\/a> */i, ""); // "
	
	// Insert the footnote text
	footnote.innerHTML = fn_text;

	//Make the popup visible
	footnote.style.display = "";
}

function hideFootnote(evnt) {
	var obj = window.event ? window.event.srcElement : evnt.target;
	
	// No point in going on if popup is already hidden
	if(footnote.style.display == "none") return;
	
	// Search the tree to see where the curser is
	var depth = 0; // no need to search too much
	while(obj && obj.parentNode) {	
		if(obj.id == "footnote" || obj.id.substr(0, 9) == "cite_ref-") { return; }
		if(depth > 3) break;
		obj = obj.parentNode;
		depth++;
	}
	
	footnote.style.display = "none";
}

// Set up the float element
var footnote = document.createElement("DIV");
footnote.id = "footnote";
footnote.style.display = "none";
footnote.style.position = "absolute";
footnote.style.zIndex = 500;
footnote.style.border = "1px solid black";
footnote.style.backgroundColor = "lightyellow";
footnote.style.maxWidth = "450px";
footnote.style.textAlign = "justify";
footnote.style.padding = "5px";
footnote.style.fontSize = "10pt";

addOnloadHook( function () { document.body.appendChild(footnote) } );

// Add events
addHandler(document, "mouseover", showFootnote);
addHandler(document, "mousemove", hideFootnote);