UNPKG

pxt-core-own

Version:

Microsoft MakeCode, also known as Programming Experience Toolkit (PXT), provides Blocks / JavaScript tools and editors

190 lines (174 loc) 6.2 kB
<!doctype html> <html lang="en" data-manifest="" data-framework="typescript"> <head> <meta charset="utf-8"> <title>simulator</title> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <style> /* fix for iOS; see https://github.com/PierBover/ios-iframe-fix */ #wrap { position: fixed; top: 0; right:0; bottom:0; left: 0; overflow-y: hidden; -webkit-overflow-scrolling: touch; } html { width: 100%; height: 100%; overflow: hidden; } body { height: 100%; } div.simframe { border: none; margin: 0 0 0.5rem 0; position: relative; background: transparent; width: 100%; display: inline-block; } div.simframe > iframe { position: absolute; left: 0; top: 0; width: 100%; height: 100%; } footer { position: absolute; bottom: 0; right: 0; left: 0; z-index: 1; font-size: 0.75rem; font-family: "Lucida Console", Monaco, monospace; color: #333; padding: 0.5em; margin: 0; background: #fff; } footer img { max-height: 1rem; vertical-align: middle; margin-left: 0.5rem; } footer a, footer a:visited { text-decoration: none; cursor: pointer; border: none; color: #333; } a.center { font-size: 3em; font-family: monospace; } </style> <style id="injected-style"> </style> </head> <body> <div id="wrap"> <div id='loading' style='font-size: 25px; font-family:monospace; margin: 20% auto; width: 200px;'> loading... </div> <div id="simulators" className="simulator"> </div> <footer id="footer" style="display:none;"> </footer> </div> <script> // This line gets patched up by the cloud var pxtConfig = null; </script> <!-- @include apptrackingweb.html --> <!-- @include apptracking.html --> <script type="text/javascript" src="/embed.js"></script> <script type="text/javascript"> (function () { var loading = document.getElementById('loading'); var id = /id(?:[:=])([^&?]+)/i.exec(window.location.href); var code = /code(?:[:=])([^&?]+)/i.exec(window.location.href); var localToken = /local_token(?:[:=])([^&?]+)/i.exec(window.location.href); var hex = !!/hex(?:[:=])1/i.exec(window.location.href); var footer = !/nofooter(?:[:=])1/i.exec(window.location.href); var debugSim = !!/debugSim(?:[:=])1/i.exec(window.location.href); var sims = document.getElementById('simulators'); var highContrast = !!/hc(?:[:=])1/i.exec(window.location.href); var light = !!/light(?:[:=])1/i.exec(window.location.href); var fullScreen = !!/fullscreen(?:[:=])1/i.exec(window.location.href); var deps = /deps(?:[:=])([^&?]+)/i.exec(window.location.href); if (!id && !code && !debugSim) { console.error("missing id or code"); loading.textContent = 'Oops, wrong arguments...'; return; } if (fullScreen) { document.getElementById("injected-style").textContent = "#simulators {\n" + " height: 100%;\n" + "}\n" + "div.simframe {\n" + " height: calc(100% - 1rem);\n" + " padding-bottom: 0 !important;\n" + "}\n"; } function initAppCache() { if (!window.applicationCache) return; if (window.applicationCache.status === window.applicationCache.UPDATEREADY) window.location.reload(); window.applicationCache.addEventListener('updateready', function () { if (window.applicationCache.status === window.applicationCache.UPDATEREADY) window.location.reload(); }); } initAppCache(); ksRunnerReady(function() { var theme = pxt.appTarget.appTheme; document.title = theme.title; if (footer) pxt.runner.initFooter(document.getElementById('footer'), id); if (hex) { console.log('compiling script to hex') pxt.runner.generateHexFileAsync(options).done(function(hex) { $(loading).remove(); var name = pxt.appTarget.id + '-' + ts.pxt.BINARY_HEX; var uri = pxt.BrowserUtils.browserDownloadBinText(hex, name) var a = document.createElement("a"); a.href = uri; a.download = name; a.appendChild(document.createTextNode("Right click to save to another location.")) sims.appendChild(a); }) } else if (!debugSim) { var options = { id: id ? id[1] : undefined, code: code ? decodeURIComponent(code[1]) : undefined, highContrast: highContrast, light: light, fullScreen: fullScreen, dependencies: deps ? decodeURIComponent(deps[1]).split(",") : undefined }; console.log('simulating script') pxt.runner.simulateAsync(sims, options).done(function() { console.log('simulator started...') $(loading).remove(); }) } else { $(loading).remove(); if (localToken) { pxt.Cloud.localToken = localToken[1]; } pxt.runner.startDebuggerAsync(sims); } }) })() </script> </body> </html>