Skip to content

Instantly share code, notes, and snippets.

@dbolella
Created October 10, 2019 20:31
Show Gist options
  • Save dbolella/a3f4a1a17272b10d80a348440d3d38b0 to your computer and use it in GitHub Desktop.
Save dbolella/a3f4a1a17272b10d80a348440d3d38b0 to your computer and use it in GitHub Desktop.
Leafs for SwiftKotlinOnline
#set("title") { Translate Kotlin }
#set("body") {
<textarea id="constantsText" rows="4" cols="50">
Please put swift code here...
</textarea>
<button onclick="post()">Click me</button>
<script>
function post() {
var method = "post"; // Set method to post by default if not specified.
var path = "/translate/"
var params = {swift: document.getElementById("constantsText").value\}
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input")
hiddenField.setAttribute("type", "hidden")
hiddenField.setAttribute("name", key)
hiddenField.setAttribute("value", params[key])
form.appendChild(hiddenField)
\}
\}
document.body.appendChild(form)
form.submit()
\}
</script>
}
#embed("base")
#set("title") { Translate Kotlin }
#set("body") {
<h1>Results:</h1>
<pre><code>#(output)</code></pre>
}
#embed("base")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment