Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions js-demo/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var PROMPT = "> " ;
var log_output = PROMPT;
var ERR_OUTPUT = "Warnings: "
var err_output = ERR_OUTPUT;

function reset_log_output (){ log_output = PROMPT;}
function reset_error_output(){ err_output = ERR_OUTPUT;}
function get_log_output(){
Expand All @@ -55,7 +55,7 @@ function get_log_output(){
function get_error_output(){
var old = err_output;
reset_error_output();
return old;
return old;
}
var compile_code ;
var evalButton = document.getElementById('option-eval');
Expand All @@ -65,9 +65,10 @@ function shouldEval(){
return evalButton.checked;
}
function onEvalButtonChange(){
console.log('change');
if(!shouldEval()){
outputMirror.setValue(PROMPT);
} else {
onEditChanges();
}
}
evalButton.addEventListener('change', onEvalButtonChange);
Expand All @@ -92,7 +93,7 @@ var exports = window;

function redirect() { log_output = log_output + Array.prototype.slice.apply(arguments).join(' ') + "\n"};

function redirect_err() {
function redirect_err() {
err_output = err_output + Array.prototype.slice.apply(arguments).join(' ') + "\n"
};

Expand Down Expand Up @@ -167,7 +168,7 @@ function clickHandler(e) {



function onEditChanges(cm, change) {
function onEditChanges(cm, change) {
if(typeof compile_code === 'undefined'){
console.log('init....');
compile_code = ocaml.compile;
Expand All @@ -177,7 +178,7 @@ function onEditChanges(cm, change) {
errorMirror.setValue(get_error_output());
console.error = original_err;
console.log(raw);
var rsp = JSON.parse(raw); // can we save this from parsing?
var rsp = JSON.parse(raw); // can we save this from parsing?
if (rsp.js_code !== undefined) {
jsCode1Mirror.setValue(rsp.js_code);
// eval
Expand All @@ -188,7 +189,7 @@ function onEditChanges(cm, change) {
jsCode1Mirror.setValue(rsp.js_error_msg);

}

}
myCode1Mirror.on("changes", onEditChanges);

Expand All @@ -205,7 +206,7 @@ function changeEvalButton(bool) {
//creates a gist from OCaml code
$('#share').click(function (e) {
var state = $(this).button('loading');
var request =
var request =
{
"description": "BuckleScript Gist",
"public": true,
Expand Down Expand Up @@ -239,9 +240,9 @@ var copy = new Clipboard('#copyButton');
copy.on('success', function(e) {
e.clearSelection();
$('#copyGlyph').attr('class', 'glyphicon glyphicon-ok');
});
});

//reset clipboard icon when modal is closed
$('#shareModal').on('hidden.bs.modal', function (e) {
$('#copyGlyph').attr('class', 'glyphicon glyphicon-copy');
});
});