|
373 | 373 | this.dump = dump; |
374 | 374 | } |
375 | 375 |
|
376 | | - Table.prototype.build = function (rows, meta, onBuildRow) { |
| 376 | + Table.prototype.build = function (rows, meta, onBuildRow, info) { |
377 | 377 | // console.warn('Table.build', meta, classname) |
378 | | - meta = $$1.extend({ |
| 378 | + var metaDefault = { |
379 | 379 | attribs: { |
380 | 380 | class: [ |
381 | 381 | 'table-bordered', |
|
384 | 384 | ] |
385 | 385 | }, |
386 | 386 | caption: '', |
387 | | - tableInfo: {} |
388 | | - }, meta); |
| 387 | + tableInfo: { |
| 388 | + columns: [], |
| 389 | + haveObjRow: false, |
| 390 | + rows: [], |
| 391 | + } |
| 392 | + }; |
| 393 | + meta.tableInfo = $$1.extend(metaDefault.tableInfo, meta.tableInfo); |
| 394 | + meta = $$1.extend(metaDefault, meta); |
389 | 395 | if (meta.caption === null) { |
390 | 396 | meta.caption = ''; |
391 | 397 | } |
392 | 398 | $table = $$1('<table>' + |
393 | | - '<caption>' + meta.caption.escapeHtml() + '</caption>' + |
| 399 | + (meta.caption.length ? '<caption>' + meta.caption.escapeHtml() + '</caption>' : '')+ |
394 | 400 | '<thead><tr><th> </th></tr></thead>' + |
395 | 401 | '<tbody></tbody>' + |
396 | 402 | '</table>' |
397 | 403 | ) |
398 | 404 | .addClass(meta.attribs.class.join(' ')); |
399 | 405 | this.buildHeader(meta.tableInfo); |
400 | | - this.buildBody(rows, meta.tableInfo, onBuildRow); |
| 406 | + this.buildBody(rows, meta.tableInfo, onBuildRow, info); |
401 | 407 | this.buildFooter(meta.tableInfo); |
402 | 408 | return $table |
403 | 409 | }; |
404 | 410 |
|
405 | | - Table.prototype.buildBody = function (rows, tableInfo, onBuildRow) { |
| 411 | + Table.prototype.buildBody = function (rows, tableInfo, onBuildRow, info) { |
406 | 412 | var i; |
407 | 413 | var length; |
408 | 414 | var i2; |
|
430 | 436 | if (typeof rowKey === 'string' && rowKey.match(/^\d+$/) && Number.isSafeInteger(rowKey)) { |
431 | 437 | rowKey = parseInt(rowKey, 10); |
432 | 438 | } |
433 | | - parsed = this.dump.parseTag(this.dump.dump(rowKey)); |
| 439 | + parsed = this.dump.parseTag(this.dump.dump(rowKey, { |
| 440 | + requestInfo: info, |
| 441 | + })); |
434 | 442 | $tr = $$1('<tr></tr>', rowInfo.attribs || {}) |
435 | 443 | .append( |
436 | 444 | $$1('<th scope="row" class="t_key text-right"></th>') |
|
455 | 463 | $('<td />').html(parsed.innerhtml).attr(parsed.attribs) |
456 | 464 | ) |
457 | 465 | */ |
458 | | - $tr.append(this.dump.dump(row[key], { tagName: 'td' })); |
| 466 | + $tr.append(this.dump.dump(row[key], { |
| 467 | + requestInfo: info, |
| 468 | + tagName: 'td' |
| 469 | + })); |
459 | 470 | } |
460 | 471 | if (onBuildRow) { |
461 | 472 | $tr = onBuildRow($tr, row, rowInfo, rowKey); |
|
2975 | 2986 |
|
2976 | 2987 | Cases.prototype.dumpInner = function (name, info, cfg) { |
2977 | 2988 | var title = cfg.phpDocOutput |
2978 | | - ? info.desc |
| 2989 | + ? info.phpDoc.summary || info.desc || null |
2979 | 2990 | : null; |
2980 | 2991 | var $element = $$1('<div></div>') |
2981 | 2992 | .html('<span class="t_identifier">' + name + '</span>' + |
|
2986 | 2997 | ) |
2987 | 2998 | ); |
2988 | 2999 | if (title && title.length) { |
| 3000 | + title = this.valDumper.dumpPhpDocStr(title); |
2989 | 3001 | $element.find('.t_identifier').attr('title', title); |
2990 | 3002 | } |
2991 | 3003 | return $element[0].innerHTML |
|
3474 | 3486 | property: true, |
3475 | 3487 | setHook: info.hooks.indexOf('set') > -1 |
3476 | 3488 | }; |
3477 | | - $element.addClass(info.visibility).removeClass('debug'); |
3478 | | - $$1.each(classes, function (classname, useClass) { |
| 3489 | + var visibility = typeof info.visibility === 'object' |
| 3490 | + ? info.visibility.join(' ') |
| 3491 | + : info.visibility; |
| 3492 | + $element.addClass(visibility).removeClass('debug'); |
| 3493 | + $$1.each(classes, function (className, useClass) { |
3479 | 3494 | if (useClass) { |
3480 | | - $element.addClass(classname); |
| 3495 | + $element.addClass(className); |
3481 | 3496 | } |
3482 | 3497 | }); |
3483 | 3498 | sectionPrototype.addAttribs($element, info, cfg); |
|
3520 | 3535 | modifiers.push('static'); |
3521 | 3536 | } |
3522 | 3537 | $$1.each(modifiers, function (i, modifier) { |
3523 | | - html += '<span class="t_modifier_' + modifier + '">' + modifier + '</span> '; |
| 3538 | + var cssClass = 't_modifier_' + modifier; |
| 3539 | + modifier = modifier.replace('-set', '(set)'); |
| 3540 | + html += '<span class="' + cssClass + '">' + modifier + '</span> '; |
3524 | 3541 | }); |
3525 | 3542 | return html |
3526 | 3543 | }; |
|
5049 | 5066 | }; |
5050 | 5067 |
|
5051 | 5068 | Dump.prototype.dumpConst = function (abs) { |
5052 | | - var dumpOpts = this.getDumpOpts(); |
5053 | | - dumpOpts.attribs.title = abs.value !== this.UNDEFINED |
5054 | | - ? 'value: ' + this.dump(abs.value) |
5055 | | - : null; |
5056 | | - return this.markupIdentifier(abs.name, 'const') |
| 5069 | + return this.dumpIdentifier({ |
| 5070 | + backedValue: abs.value, |
| 5071 | + type: 'identifier', |
| 5072 | + typeMore: 'const', |
| 5073 | + value: abs.name, |
| 5074 | + }) |
5057 | 5075 | }; |
5058 | 5076 |
|
5059 | 5077 | Dump.prototype.dumpFloat = function (val, abs) { |
|
5067 | 5085 | return val |
5068 | 5086 | }; |
5069 | 5087 |
|
| 5088 | + Dump.prototype.dumpIdentifier = function (abs) { |
| 5089 | + var dumpOpts = this.getDumpOpts(); |
| 5090 | + dumpOpts.attribs.title = [undefined, this.UNDEFINED].indexOf(abs.backedValue) < 0 |
| 5091 | + ? 'value: ' + this.dump(abs.backedValue) |
| 5092 | + : null; |
| 5093 | + return this.markupIdentifier(abs.value, abs.typeMore) |
| 5094 | + }; |
| 5095 | + |
5070 | 5096 | Dump.prototype.dumpInt = function (val, abs) { |
5071 | 5097 | return this.dumpFloat(val, abs) |
5072 | 5098 | }; |
|
5228 | 5254 | } |
5229 | 5255 | if (parts.identifier) { |
5230 | 5256 | parts.identifier = this.dumpPhpDocStr(parts.identifier); |
5231 | | - parts.identifier = '<span class="t_identifier">' + parts.identifier + '</span>'; |
| 5257 | + parts.identifier = '<span class="t_name">' + parts.identifier + '</span>'; |
5232 | 5258 | } |
5233 | 5259 | return [parts.className, parts.identifier].filter(function (val) { |
5234 | 5260 | return val !== '' |
|
5254 | 5280 | }; |
5255 | 5281 |
|
5256 | 5282 | var dump = new Dump(); |
| 5283 | + var subRegex = new RegExp('%' + |
| 5284 | + '(?:' + |
| 5285 | + '[coO]|' + // c: css, o: obj with max info, O: obj w generic info |
| 5286 | + '[+-]?' + // sign specifier |
| 5287 | + '(?:[ 0]|\'.)?' + // padding specifier |
| 5288 | + '-?' + // alignment specifier |
| 5289 | + '\\d*' + // width specifier |
| 5290 | + '(?:\\.\\d+)?' + // precision specifier |
| 5291 | + '[difs]' + |
| 5292 | + ')', 'g'); |
5257 | 5293 | var table = new Table(dump); |
5258 | 5294 |
|
5259 | 5295 | var methods = { |
5260 | 5296 | alert: function (logEntry, info) { |
5261 | | - var message; |
5262 | | - var level = logEntry.meta.level || logEntry.meta.class; |
5263 | | - var dismissible = logEntry.meta.dismissible; |
5264 | 5297 | var $node = $$1('<div class="m_alert"></div>') |
5265 | | - .addClass('alert-' + level) |
| 5298 | + .addClass('alert-' + (logEntry.meta.level || logEntry.meta.class)) |
5266 | 5299 | // .html(message) |
5267 | 5300 | .attr('data-channel', logEntry.meta.channel); // using attr so can use [data-channel="xxx"] selector |
5268 | | - if (logEntry.args.length > 1) { |
5269 | | - processSubstitutions(logEntry); |
5270 | | - } |
5271 | | - message = logEntry.args[0]; |
5272 | | - $node.html(message); |
| 5301 | + var dismissible = logEntry.meta.dismissible; |
| 5302 | + var html = logEntry.args.length > 1 |
| 5303 | + ? buildEntryNode(logEntry, info).html() |
| 5304 | + : dump.dump(logEntry.args[0], { |
| 5305 | + sanitize: logEntry.meta.sanitizeFirst, |
| 5306 | + tagName: null, // don't wrap value span |
| 5307 | + visualWhiteSpace: false, |
| 5308 | + }); |
| 5309 | + $node.html(html); |
5273 | 5310 | if (dismissible) { |
5274 | 5311 | $node.prepend('<button type="button" class="close" data-dismiss="alert" aria-label="Close">' + |
5275 | 5312 | '<span aria-hidden="true">×</span>' + |
|
5558 | 5595 | logEntry.meta, |
5559 | 5596 | logEntry.meta.inclContext |
5560 | 5597 | ? tableAddContextRow |
5561 | | - : null |
| 5598 | + : null, |
| 5599 | + info |
5562 | 5600 | ); |
5563 | 5601 | return $$1('<li>', { class: 'm_' + logEntry.method }).append($table) |
5564 | 5602 | }, |
|
5583 | 5621 | update card header to emphasize error |
5584 | 5622 | */ |
5585 | 5623 | if (meta.errorCat) { |
5586 | | - // console.warn('errorCat', meta.errorCat) |
5587 | 5624 | attribs.class += ' error-' + meta.errorCat; |
5588 | 5625 | if (!meta.isSuppressed) { |
5589 | 5626 | if (method === 'error') { |
|
5599 | 5636 | if (meta.uncollapse !== undefined) { |
5600 | 5637 | attribs['data-uncollapse'] = JSON.stringify(meta.uncollapse); |
5601 | 5638 | } |
5602 | | - if (['assert', 'error', 'info', 'log', 'warn'].indexOf(method) > -1 && logEntry.args.length > 1) { |
5603 | | - /* |
5604 | | - update tab |
5605 | | - */ |
5606 | | - if (method === 'error') { |
5607 | | - getTab(info).addClass('has-error'); |
5608 | | - } else if (method === 'warn') { |
5609 | | - getTab(info).addClass('has-warn'); |
5610 | | - } else if (method === 'assert') { |
5611 | | - getTab(info).addClass('has-assert'); |
5612 | | - } |
5613 | | - processSubstitutions(logEntry); |
| 5639 | + /* |
| 5640 | + if (['assert', 'error', 'info', 'log', 'warn'].indexOf(method) > -1 && logEntry.args.length > 1)) { |
| 5641 | + } |
| 5642 | + */ |
| 5643 | + /* |
| 5644 | + update tab |
| 5645 | + */ |
| 5646 | + if (method === 'error') { |
| 5647 | + getTab(info).addClass('has-error'); |
| 5648 | + } else if (method === 'warn') { |
| 5649 | + getTab(info).addClass('has-warn'); |
| 5650 | + } else if (method === 'assert') { |
| 5651 | + getTab(info).addClass('has-assert'); |
5614 | 5652 | } |
5615 | 5653 | $node = buildEntryNode(logEntry, info); |
5616 | 5654 | $node.attr(attribs); |
|
5724 | 5762 | var glueAfterFirst = true; |
5725 | 5763 | var args = logEntry.args; |
5726 | 5764 | var numArgs = args.length; |
5727 | | - var meta = $$1.extend({ |
| 5765 | + var typeInfo; |
| 5766 | + var typeMore; |
| 5767 | + logEntry.meta = $$1.extend({ |
5728 | 5768 | sanitize: true, |
5729 | 5769 | sanitizeFirst: null |
5730 | 5770 | }, logEntry.meta); |
5731 | | - var typeInfo; |
5732 | | - var typeMore; |
5733 | | - if (meta.sanitizeFirst === null) { |
5734 | | - meta.sanitizeFirst = meta.sanitize; |
| 5771 | + if (logEntry.meta.sanitizeFirst === null) { |
| 5772 | + logEntry.meta.sanitizeFirst = logEntry.meta.sanitize; |
| 5773 | + } |
| 5774 | + // console.warn('buildEntryNode', JSON.parse(JSON.stringify(logEntry))) |
| 5775 | + if (numArgs > 1) { |
| 5776 | + processSubstitutions(logEntry); |
| 5777 | + args = logEntry.args; |
| 5778 | + numArgs = args.length; |
5735 | 5779 | } |
5736 | 5780 | if (typeof args[0] === 'string') { |
5737 | 5781 | if (args[0].match(/[=:]\s*$/)) { |
|
5751 | 5795 | addQuotes: i !== 0 || typeMore === 'numeric', |
5752 | 5796 | requestInfo: requestInfo, |
5753 | 5797 | sanitize: i === 0 |
5754 | | - ? meta.sanitizeFirst |
5755 | | - : meta.sanitize, |
| 5798 | + ? logEntry.meta.sanitizeFirst |
| 5799 | + : logEntry.meta.sanitize, |
5756 | 5800 | type: typeInfo[0], |
5757 | 5801 | typeMore: typeInfo[1] || null, |
5758 | 5802 | visualWhiteSpace: i !== 0 |
|
5785 | 5829 | var label = logEntry.args.shift(); |
5786 | 5830 | label = logEntry.meta.isFuncName |
5787 | 5831 | ? dump.markupIdentifier(label, 'function') |
5788 | | - : dump.dump(label).replace(new RegExp('^<span class="t_string">(.+)</span>$', 's'), '$1'); |
| 5832 | + : dump.dump(label, { |
| 5833 | + requestInfo: requestInfo |
| 5834 | + }).replace(new RegExp('^<span class="t_string">(.+)</span>$', 's'), '$1'); |
5789 | 5835 | for (i = 0; i < logEntry.args.length; i++) { |
5790 | 5836 | logEntry.args[i] = dump.dump(logEntry.args[i], { |
5791 | 5837 | requestInfo: requestInfo, |
|
5811 | 5857 | return $header |
5812 | 5858 | } |
5813 | 5859 |
|
| 5860 | + function containsSubstitutions(logEntry) |
| 5861 | + { |
| 5862 | + if (logEntry.args.length < 2 || typeof logEntry.args[0] !== 'string') { |
| 5863 | + return false |
| 5864 | + } |
| 5865 | + return logEntry.args[0].match(subRegex) !== null |
| 5866 | + } |
| 5867 | + |
| 5868 | + |
5814 | 5869 | /** |
5815 | 5870 | * @param logEntry |
5816 | 5871 | * |
5817 | 5872 | * @return void |
5818 | 5873 | */ |
5819 | 5874 | function processSubstitutions (logEntry, opts) { |
5820 | | - var subRegex = '%' + |
5821 | | - '(?:' + |
5822 | | - '[coO]|' + // c: css, o: obj with max info, O: obj w generic info |
5823 | | - '[+-]?' + // sign specifier |
5824 | | - '(?:[ 0]|\'.)?' + // padding specifier |
5825 | | - '-?' + // alignment specifier |
5826 | | - '\\d*' + // width specifier |
5827 | | - '(?:\\.\\d+)?' + // precision specifier |
5828 | | - '[difs]' + |
5829 | | - ')'; |
5830 | 5875 | var args = logEntry.args; |
5831 | 5876 | var argLen = args.length; |
5832 | | - var hasSubs = false; |
5833 | 5877 | var index = 0; |
5834 | 5878 | var typeCounts = { |
5835 | 5879 | c: 0 |
5836 | 5880 | }; |
5837 | | - if (typeof args[0] !== 'string' || argLen < 2) { |
| 5881 | + if (containsSubstitutions(logEntry) === false) { |
5838 | 5882 | return |
5839 | 5883 | } |
5840 | | - subRegex = new RegExp(subRegex, 'g'); |
| 5884 | + args[0] = dump.dump(args[0], { |
| 5885 | + sanitize: logEntry.meta.sanitizeFirst, |
| 5886 | + tagName: null |
| 5887 | + }); |
5841 | 5888 | args[0] = args[0].replace(subRegex, function (match) { |
5842 | 5889 | var replacement = match; |
5843 | 5890 | var type = match.substr(-1); |
|
5867 | 5914 | delete args[index]; // sets to undefined |
5868 | 5915 | return replacement |
5869 | 5916 | }); |
5870 | | - // using reduce to perform an array_sum |
5871 | | - hasSubs = Object.values(typeCounts).reduce(function (acc, val) { return acc + val }, 0) > 0; |
5872 | | - if (hasSubs) { |
5873 | | - if (typeCounts.c) { |
5874 | | - args[0] += '</span>'; |
5875 | | - } |
5876 | | - logEntry.args = args.filter(function (val) { |
5877 | | - return val !== undefined |
5878 | | - }); |
5879 | | - logEntry.meta.sanitizeFirst = false; |
| 5917 | + if (typeCounts.c) { |
| 5918 | + args[0] += '</span>'; |
5880 | 5919 | } |
| 5920 | + logEntry.args = args.filter(function (val) { |
| 5921 | + return val !== undefined |
| 5922 | + }); |
| 5923 | + logEntry.meta.sanitizeFirst = false; |
5881 | 5924 | } |
5882 | 5925 |
|
5883 | 5926 | /** |
|
0 commit comments