Last active
October 3, 2015 05:48
-
-
Save tadruj/2402835 to your computer and use it in GitHub Desktop.
Meteor pair-programming App
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
This app is used for pair programming JavaScript. I have the console open on Chrome so when I click Run or do the CMD+ENTER, the script that is inside textarea executes. | |
BUG: | |
If I have 2 windows open I can type on W1 and see the changes published on W2, but when I start to type on W2, the changes won't get dispatched to W1. |
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
#code { | |
width: 1000px; | |
height: 400px; | |
font-family: "Courier"; | |
font-size: 20px; | |
} |
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
<head> | |
<title>jSinTi Sandbox2</title> | |
</head> | |
<body> | |
<h1>jS<sub>in</sub>Ti Sandbox</h1> | |
{{> sandbox}} | |
</body> | |
<template name="sandbox"> | |
<div id="sandbox" class="sandbox"> | |
<textarea id="code">{{code}}</textarea> | |
<div> | |
<input id="run" type="button" value="Run" /> ⌘⏎ | |
</div> | |
</div> | |
</template> |
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
Code = new Meteor.Collection('code'); | |
if (Meteor.is_client) { | |
Meteor.subscribe('code'); | |
Template.sandbox.code = function () { | |
kode = Code.findOne(); | |
return kode !== undefined ? kode.code_text : ''; | |
}; | |
Template.sandbox.events = { | |
'keydown #code' : function (e) { | |
if(e.keyCode == 13 && e.metaKey) { | |
eval($("#code").val()); | |
e.preventDefault(); | |
e.stopPropagation(); | |
return false; | |
} | |
}, | |
'keyup #code' : function () { | |
Code.remove({}); | |
Code.insert({ code_text: $("#code").val() }); | |
}, | |
'click #run' : function () { | |
eval($("#code").val()); | |
} | |
}; | |
} | |
if (Meteor.is_server) { | |
Meteor.publish('code'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment