-
Notifications
You must be signed in to change notification settings - Fork 326
Feature/scastie front page #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,33 +234,52 @@ $(document).ready(function() { | |
|
||
// Scala in the browser | ||
$(document).ready(function() { | ||
if ($("#scastie-textarea").length) { | ||
var editor = CodeMirror.fromTextArea(document.getElementById("scastie-textarea"), { | ||
lineNumbers: true, | ||
matchBrackets: true, | ||
theme: "monokai", | ||
mode: "text/x-scala", | ||
autoRefresh: true, | ||
fixedGutter: false | ||
}); | ||
editor.setSize("100%", ($("#scastie-code-container").height())); | ||
|
||
var codeSnippet = "List(\"Hello\", \"World\").mkString(\"\", \", \", \"!\")"; | ||
editor.getDoc().setValue(codeSnippet); | ||
editor.refresh(); | ||
|
||
$('.btn-run').click(function() { | ||
// TODO: Code to connect to the scastie server would be here, what follows is just a simulation for the UI elements: | ||
$('.btn-run').addClass("inactive"); | ||
$('.btn-run i').removeClass("fa fa-play").addClass("fa fa-spinner fa-spin"); | ||
setTimeout(function() { | ||
var currentCodeSnippet = editor.getDoc().getValue(); | ||
console.log("Current code snippet: " + currentCodeSnippet); | ||
$('.btn-run').removeClass("inactive"); | ||
$('.btn-run i').removeClass("fa-spinner fa-spin").addClass("fa fa-play"); | ||
}, 2000); | ||
}) | ||
if ($("#scastie-textarea").length) { | ||
var editor = | ||
CodeMirror.fromTextArea( | ||
document.getElementById("scastie-textarea"), | ||
{ | ||
// lineNumbers: false, | ||
matchBrackets: true, | ||
theme: "monokai", | ||
mode: "text/x-scala", | ||
autoRefresh: true, | ||
fixedGutter: false, | ||
extraKeys: { | ||
'Ctrl-Enter': 'run', | ||
'Cmd-Enter': 'run' | ||
} | ||
} | ||
); | ||
|
||
editor.setSize("100%", ($("#scastie-code-container").height())); | ||
|
||
var codeSnippet = "List(\"Hello\", \"World\").mkString(\"\", \", \", \"!\")"; | ||
editor.getDoc().setValue(codeSnippet); | ||
editor.refresh(); | ||
|
||
function run(){ | ||
console.log("run"); | ||
// var scastieBaseUrl = "https://scastie.scala-lang.org"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm redeploying scastie, I will force push with the url pointing on the prod server. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, cool. Let me know when it's up, we can test to make sure it's all good, and then we fix this. |
||
var scastieBaseUrl = "http://localhost:9000"; | ||
|
||
$.ajax( | ||
{ | ||
type: "POST", | ||
url: scastieBaseUrl + '/scala-lang', | ||
data: editor.getDoc().getValue(), | ||
success: function(url) { | ||
window.open(scastieBaseUrl + "/" + url); | ||
}, | ||
// otherwise it's considered a popup | ||
async: false | ||
} | ||
) | ||
} | ||
|
||
$('.btn-run').click(run); | ||
CodeMirror.commands.run = run; | ||
} | ||
}); | ||
|
||
// OS detection | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken