User:Ahecht/Scripts/ReadingMode.js

if (typeof(readingBG) === "undefined") {var readingBG = "#f6f6f6";}

function toggleReadingMode(buttonElement) { var contentStyle = document.getElementById("content").style; if (contentStyle.backgroundColor == readingBG) { contentStyle.backgroundColor = ""; buttonElement.alt= "Reading Mode"; buttonElement.title= "Change to Reading Mode"; } else { contentStyle.backgroundColor = readingBG; readingBG = contentStyle.backgroundColor; //handle IE color format change buttonElement.alt = "Normal Mode"; buttonElement.title= "Change to Normal Mode"; } }

$(document).ready(function {	var rb=document.createElement("input");	rb.type="image";	rb.src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Eye_Icon.svg/20px-Eye_Icon.svg.png";	rb.alt="Reading Mode";	rb.title="Change to Reading Mode";	rb.setAttribute( "onClick", "toggleReadingMode(this)" );	var h=document.getElementById('firstHeading');	h.insertBefore(rb,h.firstChild); });