User:Josefec/common.js

function repair(tags) { for (h=0;h0) { k = j - 1; previousNode = tags[h][i].childNodes[k].nodeName.toUpperCase; previousNodeType = tags[h][i].childNodes[k].nodeType; } // type 8 is comment

value = value.replace(/([^ 	—\(\[\n\/])"/g,'$1”');    if (j>0 && previousNode!='BR' && previousNodeType!=8) { value = value.replace(/^"/,'”'); }    value = value.replace(/"/g,'“');

value = value.replace(/ 't /g,' ’t '); value = value.replace(/'([0-9]{2}[^0-9]+)/g,'’$1'); value = value.replace(/'([0-9]{2})$/g,'’$1'); for (l=0;l<2;l++) { value = value.replace(/([^ 	—\(\[\n\/])'/g,'$1’'); }    if (j>0 && previousNode!='BR' && previousNodeType!=8) { value = value.replace(/^'/,'’'); }    value = value.replace(/'/g,'‘');

value = value.replace(/\.\.\./g,'…'); value = value.replace(/[ \n]-([  \n])/g,' –$1'); value = value.replace(/([0-9]) ([0-9])/g,'$1 $2');

tags[h][i].childNodes[j].nodeValue = value; }}}}}

function repairAll { /*var startTime = new Date.getTime;*/

var all = new Array(   document.getElementsByTagName('title'),    document.getElementsByTagName('p'),    document.getElementsByTagName('h1'),    document.getElementsByTagName('h2'),    document.getElementsByTagName('h3'),    document.getElementsByTagName('h4'),    document.getElementsByTagName('h5'),    document.getElementsByTagName('h6'),    document.getElementsByTagName('li'),    document.getElementsByTagName('td'),    document.getElementsByTagName('th'),    document.getElementsByTagName('dd'),    document.getElementsByTagName('caption'),    document.getElementsByTagName('span'),    document.getElementsByTagName('a'),    document.getElementsByTagName('em'),    document.getElementsByTagName('strong'),    document.getElementsByTagName('i'),    document.getElementsByTagName('b'),    Array.filter(document.getElementsByClassName('dablink'), function(elem){return elem.nodeName.toUpperCase=='DIV';}), Array.filter(document.getElementsByClassName('thumbcaption'), function(elem){return elem.nodeName.toUpperCase=='DIV';}), Array.filter(document.getElementsByClassName('templatequote'), function(elem){return elem.nodeName.toUpperCase=='BLOCKQUOTE';}))

repair(all); /*var endTime = new Date.getTime; var time = endTime-startTime; alert(time);*/ }

function hyphen { hyphScript=document.createElement('script'); hyphScript.src='https://hyphenator.googlecode.com/svn/tags/Version 4.0.0/Hyphenator.js?bm=true&displaytogglebox=false&defaultlanguage=en&orphancontrol=2&useCSS3hyphenation=true'; hyphScript.type='text/javascript'; document.getElementsByTagName('head')[0].appendChild(hyphScript); }

repairAll; hyphen;