Skip to content

Commit 5dc25a4

Browse files
Joscha RohmannKanaye
authored andcommitted
Moved jsdebug default styles to an object.
1 parent bc129d7 commit 5dc25a4

File tree

1 file changed

+24
-46
lines changed

1 file changed

+24
-46
lines changed

lib/blocks/jsdebug.js

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ blocks.debug = {
5252
}
5353

5454
message
55-
.addSpan('Arguments mismatch:', { background: 'yellow'})
55+
.addSpan('Arguments mismatch:', defaultStyles.info)
5656
.addText(' ');
5757

5858
if (one) {
@@ -95,10 +95,10 @@ blocks.debug = {
9595
queryNotExists: debugFunc(function (query, element) {
9696
var message = blocks.debug.Message();
9797
message.beginSpan({ 'font-weight': 'bold' });
98-
message.addSpan('Warning:', { background: 'orange', padding: '0 3px' });
98+
message.addSpan('Warning:', blocks.extend({}, defaultStyles.warning, {padding: '0 3px' }));
9999

100100
message.addText(' ');
101-
message.addSpan(query.name, { background: 'red', color: 'white' });
101+
message.addSpan(query.name, defaultStyles.error);
102102
message.addSpan('(' + query.params.join(', ') + ')', { background: '#EEE' });
103103

104104
message.addText(' - data-query ');
@@ -122,14 +122,14 @@ blocks.debug = {
122122

123123
message.beginCollapsedGroup();
124124
message.beginSpan({ 'font-weight': 'bold' });
125-
message.addSpan('Critical:', { background: 'red', color: 'white' });
125+
message.addSpan('Critical:', defaultStyles.error);
126126
message.addText(' ');
127127
message.beginSpan({ background: '#EEE' });
128128
message.addText(query.name + '(');
129129
for (var i = 0; i < params.length; i++) {
130130
param = params[i];
131131
if (param == failedParameter) {
132-
message.addSpan(param, { background: 'red', color: 'white' });
132+
message.addSpan(param, defaultStyles.error);
133133
} else {
134134
message.addText(param);
135135
}
@@ -154,9 +154,9 @@ blocks.debug = {
154154
var message = new blocks.debug.Message();
155155

156156
message.beginSpan({ 'font-weight': 'bold' });
157-
message.addSpan('Critical:', { background: 'red', color: 'white' });
157+
message.addSpan('Critical:', defaultStyles.error);
158158
message.addText(' ');
159-
message.addSpan('{{' + expressionText + '}}', { background: 'red', color: 'white' });
159+
message.addSpan('{{' + expressionText + '}}', defaultStyles.error);
160160
message.addText(' - exception thrown while executing expression');
161161
message.endSpan();
162162

@@ -244,7 +244,7 @@ function addError(message, error, method, paramNames) {
244244
}
245245

246246
message.beginSpan({
247-
'background-color': '#EEE'
247+
'background': '#EEE'
248248
});
249249

250250
message.addText(method.name + '(');
@@ -258,11 +258,7 @@ function addError(message, error, method, paramNames) {
258258
}
259259
for (index = error.actual; index < error.expected; index++) {
260260
message
261-
.beginSpan({
262-
'background-color': 'red',
263-
padding: '0 5px',
264-
color: 'white'
265-
})
261+
.beginSpan(blocks.extend({}, defaultStyles.error, { padding: '0 5px'}))
266262
.addText(paramNames[index] || '?')
267263
.endSpan();
268264
if (index != error.expected - 1) {
@@ -279,11 +275,7 @@ function addError(message, error, method, paramNames) {
279275
message.addText(', ');
280276
}
281277
for (index = error.expected; index < error.actual; index++) {
282-
message.addSpan(paramNames[index], {
283-
'background-color': 'red',
284-
'text-decoration': 'line-through',
285-
color: 'white'
286-
});
278+
message.addSpan(paramNames[index], blocks.extend({}, defaultStyles.error,{'text-decoration': 'line-through'}));
287279
if (index != error.actual - 1) {
288280
message.addText(', ');
289281
}
@@ -295,10 +287,7 @@ function addError(message, error, method, paramNames) {
295287
case 'param':
296288
for (index = 0; index < paramNames.length; index++) {
297289
if (method.params[index] == error.param) {
298-
message.addSpan(paramNames[index], {
299-
'background-color': 'red',
300-
color: 'white'
301-
});
290+
message.addSpan(paramNames[index], defaultStyles.error);
302291
} else {
303292
message.addText(paramNames[index]);
304293
}
@@ -556,30 +545,6 @@ function addMethodSignature(message, method) {
556545
message.newLine();
557546
}
558547

559-
function examples(method) {
560-
var examples = method.examples;
561-
562-
if (examples) {
563-
console.groupCollapsed('%cUsage examples', 'color: blue;');
564-
565-
for (var i = 0; i < examples.length; i++) {
566-
console.log(examples[i].code);
567-
if (i != examples.length - 1) {
568-
console.log('-------------------------------');
569-
}
570-
}
571-
572-
console.groupEnd();
573-
}
574-
}
575-
576-
function params(method) {
577-
var params = method.params;
578-
for (var i = 0; i < params.length; i++) {
579-
console.log(' ' + method.params[i].name + ': ' + method.params[i].description);
580-
}
581-
}
582-
583548
function hasArgumentsParam(method) {
584549
var params = method.params;
585550
for (var i = 0; i < params.length; i++) {
@@ -828,3 +793,16 @@ var highlightjs = {
828793
color: '#e7635f'
829794
}
830795
};
796+
797+
var defaultStyles = {
798+
warning: {
799+
background: 'orange'
800+
},
801+
error: {
802+
background: 'red',
803+
color: 'white'
804+
},
805+
info: {
806+
background: 'yellow'
807+
}
808+
};

0 commit comments

Comments
 (0)