-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathconsole.js
52 lines (43 loc) · 941 Bytes
/
console.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* An output console
* @param {$} $element
*/
function Console($element) {
this.$element = $element;
this.$output = this.$element.find('.output-container span');
}
/**
* @param {String} text
*/
Console.prototype.setOutput = function(text) {
this.$output
.html(text)
.removeClass('error');
};
/**
* @param {Object} error
* @param {Number} error.line
* @param {String} error.message
*/
Console.prototype.setError = function(error) {
var errorMsg;
if (error.line && error.message) {
// Show the error message
errorMsg = 'Line ' + error.line + ': ';
}
errorMsg += error.message;
this.setOutput(errorMsg);
this.$output.addClass('error');
};
/**
* @param {Boolean} state
*/
Console.prototype.toggleSpinner = function(state) {
var $spinner = this.$element.find('.spinner');
if (state) {
$spinner.fadeIn('fast');
} else {
$spinner.fadeOut('fast');
}
};
module.exports = Console;