ometa-script-tag.js 859 B

123456789101112131415161718192021
  1. function translateCode(s) {
  2. var translationError = function(m, i) { alert("Translation error - please tell Alex about this!"); throw fail },
  3. tree = BSOMetaJSParser.matchAll(s, "topLevel", undefined, function(m, i) {
  4. throw objectThatDelegatesTo(fail, {errorPos: i}) })
  5. return BSOMetaJSTranslator.match(tree, "trans", undefined, translationError)
  6. }
  7. origOnload = window.onload
  8. window.onload = function() {
  9. var scripts = document.getElementsByTagName("script")
  10. for (var idx = 0; idx < scripts.length; idx++) {
  11. var script = scripts[idx]
  12. if (script.type === "text/x-ometa-js")
  13. eval(translateCode(script.innerHTML))
  14. }
  15. if (typeof origOnload === "string")
  16. eval(origOnload)
  17. else if (typeof origOnload === "function")
  18. origOnload()
  19. }