User:Grandiosarceus/Render Google Charts.js

/* renderGoogleCharts - By w:User:Ciencia Al Poder "Jesús Martínez Novo" Replaces links to google charts with images of the chart The title and alternate text of the image will be the text of the link If the link is placed inside a element with class="nochart", the link won't be touched function renderGoogleCharts{ if (!document.getElementById('bodyContent')) return; var as = document.getElementById('bodyContent').getElementsByTagName('a'); for (var i = as.length-1; i>=0; i--){ if (as[i].href.indexOf('http://chart.apis.google.com/chart?') == 0){ if ((' '+as[i].parentNode.className+' ').indexOf(' nochart ') == -1){ var img = document.createElement('img'); img.src = as[i].href; var content = as[i].textContent || as[i].innerHTML || 'This is a chart' img.alt = content; img.title = content; as[i].parentNode.replaceChild(img, as[i]); } } } } addOnloadHook(renderGoogleCharts);