157 lines
4.7 KiB
HTML
157 lines
4.7 KiB
HTML
|
<!doctype html>
|
||
|
<html lang="en" data-manifest="" data-framework="typescript">
|
||
|
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<title>simulator</title>
|
||
|
<style>
|
||
|
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%;
|
||
|
padding-bottom: 81.96%;
|
||
|
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>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<div id='loading' style='font-size: 25px; font-family:monospace; margin: 20% auto; width: 200px;'>
|
||
|
loading...
|
||
|
</div>
|
||
|
<div id="simulators">
|
||
|
</div>
|
||
|
<footer id="footer" style="display:none;">
|
||
|
</footer>
|
||
|
|
||
|
<script>
|
||
|
// This line gets patched up by the cloud
|
||
|
var pxtConfig = {
|
||
|
"relprefix": "/pxt-calliope/",
|
||
|
"workerjs": "/pxt-calliope/worker.js",
|
||
|
"tdworkerjs": "/pxt-calliope/tdworker.js",
|
||
|
"monacoworkerjs": "/pxt-calliope/monacoworker.js",
|
||
|
"pxtVersion": "1.0.20",
|
||
|
"pxtRelId": "",
|
||
|
"pxtCdnUrl": "/pxt-calliope/",
|
||
|
"targetVersion": "0.0.0",
|
||
|
"targetRelId": "",
|
||
|
"targetCdnUrl": "/pxt-calliope/",
|
||
|
"targetUrl": "",
|
||
|
"simUrl": "/pxt-calliope/simulator.html",
|
||
|
"partsUrl": "/pxt-calliope/siminstructions.html",
|
||
|
"runUrl": "/pxt-calliope/run.html",
|
||
|
"docsUrl": "/pxt-calliope/docs.html",
|
||
|
"isStatic": true
|
||
|
};
|
||
|
</script>
|
||
|
<!-- @include apptracking.html -->
|
||
|
<script type="text/javascript" src="/pxt-calliope/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');
|
||
|
|
||
|
if (!id && !code && !debugSim) {
|
||
|
console.error("missing id or code");
|
||
|
loading.innerText = 'Oops, wrong arguments...';
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
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 };
|
||
|
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>
|