Fix bad ctrl enter logic

This commit is contained in:
Berkeley Martinez
2015-11-23 17:50:09 -08:00
parent f9bdc32474
commit e8d9e31a47
4 changed files with 28 additions and 12 deletions

View File

@ -9,8 +9,7 @@ window.common = (function(global) {
// ctrl + enter or cmd + enter // ctrl + enter or cmd + enter
if ( if (
e.keyCode === 13 && e.keyCode === 13 &&
e.metaKey || (e.metaKey || e.ctrlKey)
e.ctrlKey
) { ) {
$('#complete-courseware-dialog').off('keydown', ctrlEnterClickHandler); $('#complete-courseware-dialog').off('keydown', ctrlEnterClickHandler);
if ($('#submit-challenge').length > 0) { if ($('#submit-challenge').length > 0) {

View File

@ -57,6 +57,11 @@ $(document).ready(function() {
({ err, solved, output, tests }) => { ({ err, solved, output, tests }) => {
if (err) { if (err) {
console.error(err); console.error(err);
if (common.challengeType === common.challengeTypes.HTML) {
return common.updatePreview$(`
<h1>${err}</h1>
`).subscribe(() => {});
}
return common.updateOutputDisplay('' + err); return common.updateOutputDisplay('' + err);
} }
common.updateOutputDisplay(output); common.updateOutputDisplay(output);
@ -65,7 +70,7 @@ $(document).ready(function() {
common.showCompletion(); common.showCompletion();
} }
}, },
(err) => { ({ err }) => {
console.error(err); console.error(err);
common.updateOutputDisplay('' + err); common.updateOutputDisplay('' + err);
} }
@ -76,8 +81,18 @@ $(document).ready(function() {
return Observable.fromCallback($preview.ready, $preview)() return Observable.fromCallback($preview.ready, $preview)()
.delay(500) .delay(500)
.flatMap(() => common.executeChallenge$()) .flatMap(() => common.executeChallenge$())
.catch(err => Observable.just(err))
.subscribe( .subscribe(
({ tests }) => { ({ err, tests }) => {
if (err) {
console.error(err);
if (common.challengeType === common.challengeTypes.HTML) {
return common.updatePreview$(`
<h1>${err}</h1>
`).subscribe(() => {});
}
return common.updateOutputDisplay('' + err);
}
common.displayTestResults(tests); common.displayTestResults(tests);
}, },
({ err }) => { ({ err }) => {

View File

@ -65,8 +65,7 @@ block content
function controlEnterHandler(e) { function controlEnterHandler(e) {
if ( if (
e.keyCode === 13 && e.keyCode === 13 &&
e.ctrlKey || (e.ctrlKey || e.metaKey)
e.metaKey
) { ) {
$('body').unbind('keydown'); $('body').unbind('keydown');
$('#complete-courseware-editorless-dialog').modal('show'); $('#complete-courseware-editorless-dialog').modal('show');
@ -76,8 +75,7 @@ block content
function modalControlEnterHandler(e) { function modalControlEnterHandler(e) {
if ( if (
e.keyCode === 13 && e.keyCode === 13 &&
e.ctrlKey || (e.ctrlKey || e.metaKey)
e.metaKey
) { ) {
$('#complete-courseware-editorless-dialog').unbind('keydown'); $('#complete-courseware-editorless-dialog').unbind('keydown');
$('#next-courseware-button').click(); $('#next-courseware-button').click();

View File

@ -81,8 +81,10 @@ block content
common.controlEnterHandler = function (e) { common.controlEnterHandler = function (e) {
$('body').unbind('keydown'); $('body').unbind('keydown');
if (e.metaKey && e.keyCode === 13 || if (
e.ctrlKey && e.keyCode === 13) { e.keyCode === 13 &&
(e.metaKey || e.ctrlKey)
) {
$('#complete-zipline-or-basejump-dialog').modal('show'); $('#complete-zipline-or-basejump-dialog').modal('show');
} else { } else {
$('body').bind('keydown', common.controlEnterHandler); $('body').bind('keydown', common.controlEnterHandler);
@ -91,8 +93,10 @@ block content
common.modalControlEnterHandler = function (e) { common.modalControlEnterHandler = function (e) {
$('#complete-zipline-or-basejump-dialog').unbind('keydown'); $('#complete-zipline-or-basejump-dialog').unbind('keydown');
if (e.metaKey && e.keyCode === 13 || if (
e.ctrlKey && e.keyCode === 13) { e.keyCode === 13 &&
(e.metaKey || e.ctrlKey)
) {
$('#next-courseware-button').click(); $('#next-courseware-button').click();
} else { } else {
$('#complete-zipline-or-basejump-dialog').on('keydown', common.modalControlEnterHandler); $('#complete-zipline-or-basejump-dialog').on('keydown', common.modalControlEnterHandler);