
var template = {"url":"http://jsbin.com/iridi3/10","html" : "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=utf-8 \/>\n<title>JS Bin<\/title>\n<!--[if IE]>\n  <script src=\"http:\/\/html5shiv.googlecode.com\/svn\/trunk\/html5.js\"><\/script>\n<![endif]-->\n<style>\n  article, aside, figure, footer, header, hgroup, \n  menu, nav, section { display: block; }\n  body { background-color: #000; color: #fff; }\n<\/style>\n<\/head>\n<body>\n  <p id=\"result\"><\/p>\n<\/body>\n<\/html>","javascript":"Function.prototype.waitUntil = function (condition, interval) {\n    interval = interval || 100;\n        \n    var fn = this,\n        shell = function () {\n            var timer = setInterval(\n                function () {\n                    var check;\n                        \n                    try {\n                        check = !!(condition());\n                    } catch (e) {\n                        check = false;\n                    }\n                        \n                    if (check) {\n                        clearInterval(timer);\n                        delete timer;\n                        fn();\n                    }\n                },\n                interval\n            );\n        };\n        \n    return shell;\n};\n\n\nvar doneOne = doneTwo = false;\n\n(function () { document.getElementById('result').innerHTML = 'done one.'; }).waitUntil(function () { return !!(doneOne); })();\n(function () { document.getElementById('result').innerHTML += '<br \/>done two.'; }).waitUntil(function () { return !!(doneTwo); })();\n\nsetTimeout(function () { doneOne = true; setTimeout(function () { doneTwo = true; }, 2000); }, 2000);\n"}
