This should do it. Put a copy of jquery-1.4.2.min.js in the same directory (jQuery is a Javascript library for keeping browser compatibility bugs at bay).
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script>
function setColorScheme(colorScheme)
{
setCookie("colorScheme", colorScheme, 30);
if(colorScheme=="whiteOnBlack")
{
$("body").css({
"background-color": "black",
"color": "white"
});
}
else if(colorScheme=="blackOnWhite")
{
$("body").css({
"background-color": "white",
"color": "black"
});
}
}
$(document).ready(function()
{
var cookie = getCookie("colorScheme");
if(cookie)
setColorScheme(cookie);
});
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
</script>
Background color: <a href="javascript:setColorScheme('blackOnWhite')">white</a> | <a href="javascript:setColorScheme('whiteOnBlack')">black</a>
This stores the color scheme in a cookie, so it's preserved when you move between chapters. The setCookie and getCookie functions came from here. Given the example, this should be pretty easy to extend for things like changing text size and margins, if you are so inclined.
This appears to work perfectly! However, it looks like the default color scheme is black on white, and I'd like it to be the other way around - what do I change to make the black background default?
Also, is there any way for changing the color scheme to bring a different set of navigation buttons in? I made some white ones (not a complete set yet) which would look much nicer than the existing ones on the white background.
In the vein of the Harry Potter and the Methods of Rationality discussion threads this is the place to discuss anything relating to Alicorn's Twilight fanfic Luminosity. The fanfic is also archived on Alicorn's own website <strike>(warning: white text on black background)</strike>.
Previous discussion is hidden so deeply within the first Methods of Rationality thread that it's difficult to find even if you already know it exists.
Similar to how Eliezer's fanfic popularizes material from his sequences Alicorn is using the insights from her Luminosity sequence.
Spoilers for the fanfic itself as well as the original novels need and should not be hidden, but spoiler protection still applies for any other works of fiction, except for Harry Potter and the Methods of Rationality chapters more than a week old so we can freely discuss similarities and differences.
EDIT: Post-ginormous-spoiler discussion should go to the second thread. (If you have any doubt on whether you have reached the spoiler in question you have not.)