Skip to content

Commit 6b42853

Browse files
committed
don't append responseCode multiple times
handle TYPE_STRING_FORM abstraction handle phpDoc @Package tag table - trueAs & falseAs
1 parent ddb04a8 commit 6b42853

8 files changed

Lines changed: 139 additions & 97 deletions

File tree

src/js/main.js

Lines changed: 69 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
}
389389

390390
Table.prototype.build = function (rows, meta, onBuildRow, info) {
391-
// console.warn('Table.build', meta, classname)
391+
// console.warn('Table.build', JSON.parse(JSON.stringify(meta)))
392392
var metaDefault = {
393393
attribs: {
394394
class: [
@@ -427,10 +427,8 @@
427427
var length;
428428
var i2;
429429
var length2;
430-
var parsed;
431430
var rowKeys = rows.__debug_key_order__ || Object.keys(rows);
432431
var rowKey;
433-
var key;
434432
var row;
435433
var rowInfo;
436434
var $tbody = $table.find('> tbody');
@@ -459,46 +457,57 @@
459457
if (typeof rowKey === 'string' && rowKey.match(/^\d+$/) && Number.isSafeInteger(rowKey)) {
460458
rowKey = parseInt(rowKey, 10);
461459
}
462-
parsed = this.dump.parseTag(this.dump.dump(rowKey, {
463-
requestInfo: info,
464-
}));
465-
$tr = $$1('<tr></tr>', rowInfo.attribs || {})
466-
.append(
467-
$$1('<th scope="row" class="t_key text-right"></th>')
468-
.addClass(/^\d+$/.test(rowKey) ? 't_int' : parsed.attribs.class.join(' '))
469-
.html(parsed.innerhtml)
470-
);
471-
472-
if (tableInfo.haveObjRow) {
473-
$tr.append(
474-
rowInfo.class
475-
? $$1(this.dump.markupIdentifier(rowInfo.class, 'classname', 'td'))
476-
.attr('title', rowInfo.summary)
477-
: '<td class="t_undefined"></td>'
478-
);
479-
}
480-
for (i2 = 0, length2 = tableInfo.columns.length; i2 < length2; i2++) {
481-
key = tableInfo.columns[i2].key;
482-
/*
483-
parsed = this.dump.parseTag(this.dump.dump(row[key], true))
484-
parsed.attribs.class = parsed.attribs.class.join(' ')
485-
$tr.append(
486-
$('<td />').html(parsed.innerhtml).attr(parsed.attribs)
487-
)
488-
*/
489-
$tr.append(this.dump.dump(row[key], {
490-
requestInfo: info,
491-
tagName: 'td'
492-
}));
493-
}
494460

461+
$tr = this.buildRow(row, rowInfo, rowKey, tableInfo);
495462
for (i2 = 0, length2 = onBuildRow.length; i2 < length2; i2++) {
496463
$tr = onBuildRow[i2]($tr, row, rowInfo, rowKey);
497464
}
498465
$tbody.append($tr);
499466
}
500467
};
501468

469+
Table.prototype.buildRow = function (row, rowInfo, rowKey, tableInfo) {
470+
var i;
471+
var length;
472+
var colInfo;
473+
var key;
474+
var parsed = this.dump.parseTag(this.dump.dump(rowKey, {
475+
requestInfo: rowInfo.requestInfo,
476+
}));
477+
var td;
478+
var $tr = $$1('<tr></tr>', rowInfo.attribs || {})
479+
.append(
480+
$$1('<th scope="row" class="t_key text-right"></th>')
481+
.addClass(/^\d+$/.test(rowKey) ? 't_int' : parsed.attribs.class.join(' '))
482+
.html(parsed.innerhtml)
483+
);
484+
485+
if (tableInfo.haveObjRow) {
486+
$tr.append(
487+
rowInfo.class
488+
? $$1(this.dump.markupIdentifier(rowInfo.class, 'classname', 'td'))
489+
.attr('title', rowInfo.summary)
490+
: '<td class="t_undefined"></td>'
491+
);
492+
}
493+
for (i = 0, length = tableInfo.columns.length; i < length; i++) {
494+
colInfo = tableInfo.columns[i];
495+
key = colInfo.key;
496+
td = this.dump.dump(row[key], {
497+
attribs: colInfo.attribs || {},
498+
requestInfo: rowInfo.requestInfo,
499+
tagName: 'td',
500+
});
501+
if (row[key] === true && colInfo.trueAs !== null) {
502+
td = td.replace('>true<', '>' + colInfo.trueAs + '<');
503+
} else if (row[key] === false && colInfo.falseAs !== null) {
504+
td = td.replace('>false<', '>' + colInfo.falseAs + '<');
505+
}
506+
$tr.append(td);
507+
}
508+
return $tr
509+
};
510+
502511
/*
503512
Add totals (tfoot)
504513
*/
@@ -514,8 +523,14 @@
514523
colHasTotal = typeof info.total !== 'undefined';
515524
haveTotal = haveTotal || colHasTotal;
516525
if (colHasTotal) {
517-
info.total = parseFloat(info.total.toFixed(6), 10);
518-
cells.push(this.dump.dump(info.total, { tagName: 'td' }));
526+
if (!isNaN(parseFloat(info.total)) && isFinite(info.total)) {
527+
// isNumeric
528+
info.total = parseFloat(info.total.toFixed(6), 10);
529+
}
530+
cells.push(this.dump.dump(info.total, {
531+
attribs: info.attribs,
532+
tagName: 'td',
533+
}));
519534
continue
520535
}
521536
cells.push('<td></td>');
@@ -4372,6 +4387,11 @@
43724387
var tagEntries;
43734388
for (tagName in abs.phpDoc) {
43744389
tagEntries = abs.phpDoc[tagName];
4390+
if (tagName === 'package') {
4391+
tagEntries.tagName = tagName;
4392+
html += this.dumpTag(tagEntries);
4393+
continue
4394+
}
43754395
if (!Array.isArray(tagEntries)) {
43764396
continue
43774397
}
@@ -4721,12 +4741,6 @@
47214741
var strClassName = '';
47224742
var dumpOpts = this.dumper.getDumpOpts();
47234743
try {
4724-
if (this.dumper.getRequestInfo().$container.data('meta') === undefined) {
4725-
console.warn('meta is undefined!!!', {
4726-
requestInfo: this.dumper.getRequestInfo(),
4727-
data: this.dumper.getRequestInfo().$container.data(),
4728-
});
4729-
}
47304744
abs.debugVersion = this.dumper.getRequestInfo().$container.data('meta').debugVersion;
47314745
if (typeof abs.cfgFlags === 'undefined') {
47324746
abs.cfgFlags = 0x1FFFFFF & ~this.BRIEF;
@@ -5269,14 +5283,15 @@
52695283
function tabValuesFinish (vals, abs, dumper) {
52705284
switch (abs.typeMore) {
52715285
case 'base64':
5272-
// vals.labelDecoded = 'decoded'
52735286
vals.labelRaw = 'base64';
52745287
if (abs.strlen) {
52755288
vals.valRaw += '<span class="maxlen">&hellip; ' + (abs.strlen - abs.value.length) + ' more bytes (not logged)</span>';
52765289
}
52775290
break
5291+
case 'form':
5292+
vals.labelRaw = 'form';
5293+
break
52785294
case 'json':
5279-
// vals.labelDecoded = 'decoded'
52805295
vals.labelRaw = 'json';
52815296
if (abs.prettified || abs.strlen) {
52825297
abs.typeMore = null; // unset typeMore to prevent loop
@@ -5859,7 +5874,7 @@
58595874
};
58605875

58615876
DumpString.prototype.isEncoded = function (val) {
5862-
return ['base64', 'json', 'serialized'].indexOf(val.typeMore) > -1
5877+
return ['base64', 'form', 'json', 'serialized'].indexOf(val.typeMore) > -1
58635878
};
58645879

58655880
/**
@@ -5954,7 +5969,7 @@
59545969
type: null,
59555970
typeMore: null,
59565971
visualWhiteSpace: true
5957-
}, opts || {});
5972+
}, JSON.parse(JSON.stringify(opts || {})));
59585973
var tagName;
59595974
var type; // = this.getType(val)
59605975
var method; // = 'dump' + type[0].ucfirst()
@@ -5963,7 +5978,9 @@
59635978
dumpOpts.type = type[0];
59645979
dumpOpts.typeMore = type[1];
59655980
}
5966-
if (typeof dumpOpts.attribs.class === 'string') {
5981+
if (typeof dumpOpts.attribs.class === 'undefined') {
5982+
dumpOpts.attribs.class = [];
5983+
} else if (typeof dumpOpts.attribs.class === 'string') {
59675984
dumpOpts.attribs.class = [dumpOpts.attribs.class];
59685985
}
59695986
dumpOptStack.push(dumpOpts);
@@ -6481,7 +6498,8 @@
64816498
$container.find('.card-header .fa-spinner').remove();
64826499
$container.find('.debug > .fa-spinner').remove();
64836500
if (responseCode && responseCode + '' !== '200') {
6484-
$container.find('.card-title').append(' <span class="label label-default" title="Response Code">' + responseCode + '</span>');
6501+
$container.find('.card-title .response-code').remove();
6502+
$container.find('.card-title').append(' <span class="label label-default response-code" title="Response Code">' + responseCode + '</span>');
64856503
if (responseCode.toString().match(/^5/)) {
64866504
$container.addClass('bg-danger');
64876505
}
@@ -6929,15 +6947,15 @@
69296947
}
69306948

69316949
function markupFilePath(filePath, commonPrefix, docRoot) {
6932-
var fileParts = parseFilePath(filePath, commonPrefix, docRoot);
6950+
var fileParts = parseFilePath(filePath || '', commonPrefix, docRoot);
69336951
return (fileParts.docRoot ? '<span class="file-docroot">DOCUMENT_ROOT</span>' : '')
69346952
+ (fileParts.relPathCommon ? '<span class="file-basepath">' + dump.dump(fileParts.relPathCommon, {tagName:null}) + '</span>' : '')
69356953
+ (fileParts.relPath ? '<span class="file-relpath">' + dump.dump(fileParts.relPath, {tagName:null}) + '</span>' : '')
69366954
+ '<span class="file-basename">' + dump.dump(fileParts.baseName, {tagName:null}) + '</span>'
69376955
}
69386956

69396957
function parseFilePath (filePath, commonPrefix, docRoot) {
6940-
var baseName = filePath.match(/[^\/]+$/)[0];
6958+
var baseName = (filePath.match(/[^\/]+$/) || [''])[0];
69416959
var containsDocRoot = filePath.indexOf(docRoot) === 0;
69426960
var basePath = '';
69436961
var relPath = filePath.slice(0, 0 - baseName.length);

src/js/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js_src/Logger/Dump.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Dump.prototype.dump = function (val, opts) {
6666
type: null,
6767
typeMore: null,
6868
visualWhiteSpace: true
69-
}, opts || {})
69+
}, JSON.parse(JSON.stringify(opts || {})))
7070
var tagName
7171
var type // = this.getType(val)
7272
var method // = 'dump' + type[0].ucfirst()
@@ -75,7 +75,9 @@ Dump.prototype.dump = function (val, opts) {
7575
dumpOpts.type = type[0]
7676
dumpOpts.typeMore = type[1]
7777
}
78-
if (typeof dumpOpts.attribs.class === 'string') {
78+
if (typeof dumpOpts.attribs.class === 'undefined') {
79+
dumpOpts.attribs.class = []
80+
} else if (typeof dumpOpts.attribs.class === 'string') {
7981
dumpOpts.attribs.class = [dumpOpts.attribs.class]
8082
}
8183
dumpOptStack.push(dumpOpts)

src/js_src/Logger/DumpString.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ DumpString.prototype.helper = function (val) {
113113
}
114114

115115
DumpString.prototype.isEncoded = function (val) {
116-
return ['base64', 'json', 'serialized'].indexOf(val.typeMore) > -1
116+
return ['base64', 'form', 'json', 'serialized'].indexOf(val.typeMore) > -1
117117
}
118118

119119
/**

src/js_src/Logger/DumpStringEncoded.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ function tabValues (abs, dumper) {
7272
function tabValuesFinish (vals, abs, dumper) {
7373
switch (abs.typeMore) {
7474
case 'base64':
75-
// vals.labelDecoded = 'decoded'
7675
vals.labelRaw = 'base64'
7776
if (abs.strlen) {
7877
vals.valRaw += '<span class="maxlen">&hellip; ' + (abs.strlen - abs.value.length) + ' more bytes (not logged)</span>'
7978
}
8079
break
80+
case 'form':
81+
vals.labelRaw = 'form'
82+
break
8183
case 'json':
82-
// vals.labelDecoded = 'decoded'
8384
vals.labelRaw = 'json'
8485
if (abs.prettified || abs.strlen) {
8586
abs.typeMore = null // unset typeMore to prevent loop

0 commit comments

Comments
 (0)