mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-14 09:32:22 +00:00
Deploying to gh-pages from @ f1d945babb 🚀
This commit is contained in:
parent
386bf143b5
commit
c3a2275430
5 changed files with 272 additions and 701 deletions
|
|
@ -3,11 +3,13 @@ const backend = "149.56.132.163";
|
|||
function playgroundInit(elt) {
|
||||
var mySockets = {};
|
||||
var frames = {};
|
||||
var lastScript = "";
|
||||
|
||||
function sendSocketCommand(wat) {
|
||||
if (wat.cmd == "connect") {
|
||||
socket = new WebSocket(wat.address);
|
||||
socket.onopen = function (event) {
|
||||
socket.send(lastScript);
|
||||
app.ports.receiveSocketMsg.send({
|
||||
name: wat.name,
|
||||
msg: "data",
|
||||
|
|
@ -42,7 +44,9 @@ function playgroundInit(elt) {
|
|||
socket.onclose = connectionFailedHandler;
|
||||
mySockets[wat.name] = socket;
|
||||
} else if (wat.cmd == "send") {
|
||||
mySockets[wat.name].send(wat.content);
|
||||
if( mySockets[wat.name].readyState === mySockets[wat.name].OPEN ) {
|
||||
mySockets[wat.name].send(wat.content);
|
||||
}
|
||||
} else if (wat.cmd == "close") {
|
||||
mySockets[wat.name].close();
|
||||
delete mySockets[wat.name];
|
||||
|
|
@ -73,7 +77,26 @@ function playgroundInit(elt) {
|
|||
app.ports.receiveControlMsg.send('seek-10');
|
||||
},
|
||||
newCode: function(code) {
|
||||
lastScript = code;
|
||||
app.ports.receiveEditorMsg.send(code);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function renderSnippets(elt, myCodeMirror) {
|
||||
for(var i=0;i<snippets.length;i++) {
|
||||
const div = document.createElement("div");
|
||||
const title = document.createElement("span");
|
||||
const img = document.createElement("img");
|
||||
const code = snippets[i].code;
|
||||
title.innerHTML = snippets[i].title;
|
||||
img.src = snippets[i].url;
|
||||
div.appendChild(title)
|
||||
div.appendChild(img)
|
||||
div.onclick = function () {
|
||||
myCodeMirror.setValue(code);
|
||||
document.querySelector('#examples-modal').classList.remove('is-active');
|
||||
};
|
||||
elt.appendChild(div)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue