Created
August 25, 2011 04:12
-
-
Save danheberden/1169967 to your computer and use it in GitHub Desktop.
coffeescript jsfiddle parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var s = "script", | |
n = "\n", | |
d = document, | |
tag = d.getElementsByTagName( s ); | |
console.log( s,n,d,tag); | |
(function parseCoffee() { | |
console.log( 'running' ); | |
// check for a non-src'd script | |
var found = false; | |
for ( var i = 0; i < tag.length; i++ ) { | |
if ( !tag[i].src ) { | |
found = i; | |
console.log( 'found!', i, tag[i] ); | |
} | |
} | |
if ( found === false ) { | |
setTimeout( parseCoffee, 50 ); | |
} else { | |
var b = tag[found].innerHTML.split(n); | |
d.write('<'+s+' type="text/coffeescript">'+b.slice(2,b.length-2).join(n)+'</'+s+'>'); | |
} | |
})(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment