Skip to content

Commit 7399d0a

Browse files
revert back to showing messages in the console
1 parent c9daf31 commit 7399d0a

5 files changed

Lines changed: 8 additions & 31 deletions

File tree

‎client/javascriptcom/directives/console.directive.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ angular.module('javascriptcom').directive('jsConsole', ['CSConsole', 'jsCommand'
2727
}
2828

2929
// Todo: Figure out how to make this work as a one time init
30-
var command = new jsCommand(onSuccess, onFailure, ctrl.messages);
30+
var command = new jsCommand(onSuccess, onFailure);
3131

3232
jsChallengeProgress.console = new CSConsole(el, {
3333
prompt: '> ',

‎client/javascriptcom/directives/course.directive.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ angular.module('javascriptcom').directive('jsCourse', ['_', 'jsCourseChallengeRe
1010
controller: function jsCourseDirective(jsCourseChallengeResource, jsChallengeProgress) {
1111
this.challengeProgress = jsChallengeProgress;
1212
this.challenges = jsCourseChallengeResource.query({ course: this.course });
13-
this.messages = [];
1413

1514
this.challengeProgress.setChallenges(this.challenges);
1615

‎client/javascriptcom/directives/messages.directive.js‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎client/javascriptcom/services/command.factory.js‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
angular.module('javascriptcom').factory('jsCommand', ['_', 'jsCommandFactory', 'jsChallengeProgress', function(_, jsCommandFactory, jsChallengeProgress) {
2-
return function jsCommand(successCallback, errorCallback, messages) {
2+
return function jsCommand(successCallback, errorCallback) {
33
var vm = this;
4-
vm.messages = messages;
54

6-
function setErrorMessageType(message, fallback) {
7-
message = _.isArray(message) ? message[1].content.textContent : message;
8-
9-
return message.match(/syntax error/i) ? 'error' : 'default';
10-
}
11-
12-
function formatResponse(content, vm, report, type) {
13-
vm.messages.push({ value: _.isArray(content) ? content[1].content.textContent : content, type: !type ? setErrorMessageType(content) : type })
14-
report({ content: _.isArray(content) ? content[0].content : '' });
5+
function jsReportAdapter(content) {
6+
if(_.isArray(content)) { return content; }
7+
if(_.isObject(content) && content['content']) { return [content]; }
8+
return [{ content: content }];
159
}
1610

1711
vm.handler = function parseCommand(line, report) {
@@ -20,10 +14,10 @@ angular.module('javascriptcom').factory('jsCommand', ['_', 'jsCommandFactory', '
2014
var challenge = jsChallengeProgress.activeChallenge();
2115

2216
command(challenge, line).then(function(content) {
23-
formatResponse(content, vm, report, 'success')
17+
report(jsReportAdapter(content));
2418
successCallback(challenge);
2519
}, function(content) {
26-
formatResponse(content, vm, report)
20+
report(jsReportAdapter(content));
2721
errorCallback(challenge);
2822
});
2923
}

‎public/templates/messages.html‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)