User:LeinardoSmith/monaco.js

// HideMe v0.1 // Elements in the class "hideme" will be affected by this code.

// Utility function from http://www.netlobo.com/javascript_getelementsbyclassname.html

document.getElementsByClassName = function(clsName){ var retVal = new Array; var elements = document.getElementsByTagName("*"); for(var i = 0;i < elements.length;i++){ if(elements[i].className.indexOf(" ") >= 0){ var classes = elements[i].className.split(" "); for(var j = 0;j < classes.length;j++){ if(classes[j] == clsName) retVal.push(elements[i]); }       }        else if(elements[i].className == clsName) retVal.push(elements[i]); }   return retVal; }

var _hidden_link_text = "hidden"; var _message_question = "You have requested hidden material on a secret Networker, Item, or other info that is a potential spoiler. Do you wish to view the info?"; var _yes_button_text = "Yes, show me the info"; var _no_button_text = "No, close this dialog"; var _message_shown = "The hidden material is shown below."; var _hidden;

function hideMeInit { _hidden = document.getElementsByClassName("hideme"); for (var i = 0; i<_hidden.length; i++) { if (_hidden[i].innerHTML === "") continue; content = '[' + _hidden_link_text + '] X' + _message_question + ' ' + _yes_button_text + '' + _no_button_text + ' X' + _message_shown + ' ' + _hidden[i].innerHTML + ' '; _hidden[i].innerHTML = content; _hidden[i].setAttribute("id","hideme" + i); } }

function hideMeOpenDialog(id,dialog) { document.getElementById("hideme" + id).childNodes[dialog + 1].style.display = "block"; }

function hideMeCloseDialog(id,dialog) { document.getElementById("hideme" + id).childNodes[dialog + 1].style.display = "none"; }

addOnloadHook(hideMeInit);