Update Turbolinks, load additional assets only on request, fix JS

Signed-off-by: Sebastian Serth <Sebastian.Serth@student.hpi.de>
This commit is contained in:
Sebastian Serth
2018-09-30 11:19:38 +02:00
parent a77a006e8d
commit 15b1670511
48 changed files with 566 additions and 82 deletions

View File

@@ -0,0 +1,45 @@
CodeOceanEditorPrompt = {
prompt: '#prompt',
showPrompt: function(msg) {
var label = $('#prompt .input-group-addon');
var prompt = $(this.prompt);
label.text(msg.data || label.data('prompt'));
if (prompt.isPresent() && prompt.hasClass('hidden')) {
prompt.removeClass('hidden');
}
$('#prompt input').focus();
},
hidePrompt: function() {
var prompt = $(this.prompt);
if (prompt.isPresent() && !prompt.hasClass('hidden')) {
prompt.addClass('hidden');
}
},
initPrompt: function() {
if ($('#run').isPresent()) {
$('#run').bind('click', this.hidePrompt.bind(this));
}
if ($('#prompt').isPresent()) {
$('#prompt').on('keypress', this.handlePromptKeyPress.bind(this));
$('#prompt-submit').on('click', this.submitPromptInput.bind(this));
}
},
submitPromptInput: function() {
var input = $('#prompt-input');
var message = input.val();
this.websocket.send(JSON.stringify({cmd: 'result', 'data': message}));
this.websocket.flush();
input.val('');
this.hidePrompt();
},
handlePromptKeyPress: function(evt) {
if (evt.which === this.ENTER_KEY_CODE) {
this.submitPromptInput();
}
}
};