ſ again

I had to change the code base a bit. Now you don't have to look at the ſs if you don't want to. Just click above and the ſs goes away. The change is suble to the user, but it took a lot of effort on my part to learn JavaScript tricks.


<form name="longs">
<input type="checkbox" name="check" checked onclick="longs_conversion()">
Unclick this box to turn off long s
</form>

<Script>
var match_longs = "([^f])s([a-eg-z\-])";
var unmatch_xml = '(<[^>]*)ſ([^<]*>)';
var replace_longs = "$1ſ$2";
var replace_shorts = "$1s$2";
var reg_longs = new RegExp(match_longs, "g");
var reg_unlongs = new RegExp(unmatch_xml, "g");

function longs_conversion() {
//Populate the array with all the page tags
var allPageTags=document.getElementsByTagName("*");
//Cycle through the tags using a for loop
for (i=0; i < allPageTags.length; i++) {
if (document.longs.check.checked==false) {
//Pick out the tags with our class name
if (allPageTags[i].className=="blogpost_ss") {
//Manipulate this in whatever way you want
allPageTags[i].style.display='block';
}
if (allPageTags[i].className=="blogpost_ls") {
//Manipulate this in whatever way you want
allPageTags[i].style.display='none';
}
} else {
if (allPageTags[i].className=="blogpost_ss") {
//Manipulate this in whatever way you want
allPageTags[i].style.display='none';
}
if (allPageTags[i].className=="blogpost_ls") {
//Manipulate this in whatever way you want
allPageTags[i].style.display='block';
}
}
}
}

</Script>


...

<Script>

var blogitembody = (<r><![CDATA[

<$BlogItemBody$>

]]></r>).toString();

var longs_blogitembody = blogitembody.replace(reg_longs,replace_longs).replace(reg_unlongs,replace_shorts);


document.write("<div class=\"blogpost_ls\">"+longs_blogitembody+"</div>");
document.write("<div class=\"blogpost_ss\" style=\"display:none;\">"+blogitembody+"</div>");


</Script>



0 Comments:

Post a Comment

<< Home

   Subscribe to: Posts (Atom)