forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reset and execute update display and storage
- Loading branch information
Berkeley Martinez
authored and
Berkeley Martinez
committed
Nov 30, 2015
1 parent
4bdf1b2
commit 74fa49c
Showing
10 changed files
with
142 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.