function showLineNumbers() {
/************************************
* Written by Andreas Papadopoulos *
* http://akomaenablog.blogspot.com *
* akoma1blog@yahoo.com *
************************************/
var isIE = navigator.appName.indexOf('Microsoft') != -1;
var preElems = document.getElementsByTagName('pre');
if (preElems.length == 0) return;
for (var i = 0; i < preElems.length; i++) {
var pre = preElems[i];
var oldContent = pre.innerHTML;
oldContent = oldContent.replace(/ /g," ");
var strs = oldContent.split("
");
if (isIE) {
strs = oldContent.split("
");
}
oldContent = oldContent.substring(4); //remove the 1st
var newContent = "
";
newContent = "
";
for(var j=1; j < strs.length - 1; j++) {
newContent += j+".
";
}
newContent += " | | ";
newContent += oldContent;
newContent += " |
";
pre.innerHTML = newContent;
}
}
No comments:
Post a Comment