//****************************************************************************** function filosofo_je_javascript_addEvent(obj, evType, fn){ // from http://www.sitepoint.com/article/structural-markup-javascript //****************************************************************************** if (obj.addEventListener){ obj.addEventListener(evType, fn, false); //false to make sure it happens during event bubbling, not capturing. see http://www.quirksmode.org/js/events_order.html and http://www.quirksmode.org/js/events_advanced.html return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } //****************************************************************************** function filosofo_je_javascript_extractBlockquoteCitations() { // lightly adapted from http://www.sitepoint.com/article/structural-markup-javascript //****************************************************************************** var quotes = document.getElementsByTagName('blockquote'); for (var i = 0; i < quotes.length; i++) { if (quotes[i].getAttribute('cite')) { var cite = quotes[i].getAttribute('cite'); if (cite != '') { var a = document.createElement('a'); a.setAttribute('href', cite); a.setAttribute('title', cite); a.appendChild(document.createTextNode('Source')); var p = document.createElement('p'); p.className = 'blockquotesource'; p.appendChild(a); quotes[i].appendChild(p); } } } } filosofo_je_javascript_addEvent(window, 'load', filosofo_je_javascript_extractBlockquoteCitations); //****************************************************************************** function filosofo_je_javascript_extractImageTitles() { //****************************************************************************** var images = document.getElementsByTagName('img'); for (var i = 0; i < images.length; i++) { if (images[i].getAttribute('title')) { var title = images[i].getAttribute('title'); if (title != '') { var parent = images[i].parentNode; var idname = images[i].getAttribute('id'); var span = document.createElement('span'); span.className = images[i].className; if (images[i].getAttribute('style')) { span.setAttribute('style', images[i].getAttribute('style')); } span.setAttribute('id',idname); span.setAttribute('style','text-align: center'); var pic = document.createElement('img'); var imgattribs = new Array('hspace','ismap','longdesc','usemap','vspace','width','height','src','alt'); for (counter = 0;counter < imgattribs.length;counter++) { if (images[i].getAttribute(imgattribs[counter])) { pic.setAttribute(imgattribs[counter],images[i].getAttribute(imgattribs[counter])); } } pic.setAttribute('title', title); pic.setAttribute('style',''); var p = document.createElement('p'); p.appendChild(document.createTextNode('' + title)); p.className = ''; span.appendChild(pic); span.appendChild(p); parent.replaceChild(span,images[i]); } } } } filosofo_je_javascript_addEvent(window, 'load', filosofo_je_javascript_extractImageTitles);