Reset and execute update display and storage
This commit is contained in:
@@ -1,21 +1,72 @@
|
||||
$(document).ready(function() {
|
||||
var common = window.common;
|
||||
const common = window.common;
|
||||
const { Observable } = window.Rx;
|
||||
const { challengeName, challengeType, challengeTypes } = common;
|
||||
|
||||
common.init.forEach(function(init) {
|
||||
init($);
|
||||
});
|
||||
|
||||
|
||||
common.resetBtn$
|
||||
.doOnNext(() => {
|
||||
common.editor.setValue(common.replaceSafeTags(common.seed));
|
||||
})
|
||||
.flatMap(() => {
|
||||
return common.executeChallenge$();
|
||||
})
|
||||
.subscribe(
|
||||
({ output, original }) => {
|
||||
common.codeStorage.updateStorage(challengeName, original);
|
||||
common.updateOutputDisplay('' + output);
|
||||
},
|
||||
({ err }) => {
|
||||
common.updateOutputDisplay('' + err);
|
||||
}
|
||||
);
|
||||
|
||||
common.submitBtn$
|
||||
.flatMap(() => {
|
||||
return common.executeChallenge$();
|
||||
})
|
||||
.subscribe(
|
||||
({ output, original, userTests }) => {
|
||||
common.updateOutputDisplay(output);
|
||||
common.codeStorage.updateStorage(challengeName, original);
|
||||
}
|
||||
);
|
||||
|
||||
var $preview = $('#preview');
|
||||
if (typeof $preview.html() !== 'undefined') {
|
||||
if ($preview.html()) {
|
||||
$preview.load(function() {
|
||||
common.executeChallenge(true);
|
||||
common.executeChallenge()
|
||||
.subscribe(
|
||||
({ output = '' }) => {
|
||||
common.updateOutputDisplay(output);
|
||||
},
|
||||
({ err }) => {
|
||||
common.updateOutputDisplay('' + err);
|
||||
}
|
||||
);
|
||||
});
|
||||
} else if (
|
||||
common.challengeType !== '2' &&
|
||||
common.challengeType !== '3' &&
|
||||
common.challengeType !== '4' &&
|
||||
common.challengeType !== '7'
|
||||
challengeType !== '2' &&
|
||||
challengeType !== '3' &&
|
||||
challengeType !== '4' &&
|
||||
challengeType !== '7'
|
||||
) {
|
||||
common.executeChallenge(true);
|
||||
common.executeChallenge$()
|
||||
.subscribe(
|
||||
({ original }) => {
|
||||
// common.updateOutputDisplay('' + output);
|
||||
common.codeStorage.updateStorage(challengeName, original);
|
||||
},
|
||||
({ err }) => {
|
||||
if (err.stack) {
|
||||
console.error(err);
|
||||
}
|
||||
common.updateOutputDisplay('' + err);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user