1 /* 2 * Parses the Protovis specifications on load, allowing the use of JavaScript 3 * 1.8 function expressions on browsers that only support JavaScript 1.6. 4 * 5 * @see pv.parse 6 */ 7 pv.listen(window, "load", function() { 8 /* 9 * Note: in Firefox any variables declared here are visible to the eval'd 10 * script below. Even worse, any global variables declared by the script 11 * could overwrite local variables here (such as the index, `i`)! To protect 12 * against this, all variables are explicitly scoped on a pv.$ object. 13 */ 14 pv.$ = {i:0, x:document.getElementsByTagName("script")}; 15 for (; pv.$.i < pv.$.x.length; pv.$.i++) { 16 pv.$.s = pv.$.x[pv.$.i]; 17 if (pv.$.s.type == "text/javascript+protovis") { 18 try { 19 window.eval(pv.parse(pv.$.s.text)); 20 } catch (e) { 21 pv.error(e); 22 } 23 } 24 } 25 delete pv.$; 26 }); 27