|
194 | 194 | ); |
195 | 195 |
|
196 | 196 | $('.navbar .clear').on('click', function () { |
197 | | - $('#debug-cards > .card').not('.working').trigger('removed.debug.card').remove(); |
| 197 | + console.time('clear'); |
| 198 | + $('#debug-cards > .card').not('.working').trigger('removed.debug.card'); |
| 199 | + console.timeEnd('clear'); |
198 | 200 | }); |
199 | 201 |
|
200 | 202 | $('#debug-cards').on('added.debug.card', function (e) { |
|
203 | 205 | }); |
204 | 206 | $('#debug-cards').on('removed.debug.card', function (e) { |
205 | 207 | // console.warn('card removed', e.target, e) |
| 208 | + var $card = $(e.target); |
206 | 209 | io.unobserve(e.target); |
207 | 210 | $cardsInViewport = $cardsInViewport.not(e.target); |
| 211 | + if ($card.hasClass('working')) { |
| 212 | + console.warn('removed working session:' + $card.prop('id')); |
| 213 | + } |
| 214 | + $card.remove(); |
208 | 215 | }); |
209 | 216 |
|
210 | 217 | $('body').on('mouseup', function (e) { |
|
220 | 227 | timeoutHandler = setTimeout(function () { |
221 | 228 | // has been long pressed (3 seconds) |
222 | 229 | // clear all (incl working) |
223 | | - $('#debug-cards > .card.working').each(function () { |
224 | | - console.warn('removed working session:' + $(this).prop('id')); |
225 | | - }); |
226 | | - $('#debug-cards > .card').trigger('removed.debug.card').remove(); |
| 230 | + $('#debug-cards > .card').trigger('removed.debug.card'); |
227 | 231 | }, 2000); |
228 | 232 | }); |
229 | 233 |
|
|
246 | 250 |
|
247 | 251 | // close btn on card-header clicked |
248 | 252 | $('body').on('click', '.btn-remove-session', function (e) { |
249 | | - var $card = $(this).closest('.card'); |
250 | | - if ($card.hasClass('working')) { |
251 | | - console.warn('removed working session:' + $card.prop('id')); |
252 | | - } |
253 | | - $card.trigger('removed.debug.card').remove(); |
| 253 | + $(this).closest('.card').trigger('removed.debug.card'); |
254 | 254 | }); |
255 | 255 |
|
256 | 256 | $(window).on('scroll', debounce(function () { |
|
582 | 582 | var html = ''; |
583 | 583 | var strClassname = ''; |
584 | 584 | if (typeof abs.cfgFlags === 'undefined') { |
585 | | - abs.cfgFlags = 0x3FFFFF; // 21 bits |
| 585 | + abs.cfgFlags = 0x3FFFFF; // 21 bits |
586 | 586 | } |
587 | 587 | strClassname = this.dumpClassname(abs); |
588 | 588 | if (abs.isMaxDepth) { |
|
1817 | 1817 | val += '<span class="maxlen">… ' + strLenDiff + ' more bytes (not logged)</span>'; |
1818 | 1818 | } |
1819 | 1819 | if (abs.brief) { |
| 1820 | + // @todo display bytes |
1820 | 1821 | return abs.contentType |
1821 | 1822 | ? '<span class="t_keyword">string</span>' + |
1822 | 1823 | '<span class="text-muted">(' + abs.contentType + ')</span><span class="t_punct colon">:</span> ' |
1823 | | - // + $this->debug->utility->getBytes($abs['strlen']) |
1824 | 1824 | : val |
1825 | 1825 | } |
1826 | 1826 | dumpOpts.postDump = function (val, dumpOpts) { |
|
2110 | 2110 |
|
2111 | 2111 | Dump.prototype.dumpArray = function (array) { |
2112 | 2112 | var html = ''; |
| 2113 | + var i; |
| 2114 | + var key; |
2113 | 2115 | var keys = array.__debug_key_order__ || Object.keys(array); |
2114 | 2116 | var length = keys.length; |
2115 | | - var key; |
2116 | | - var i; |
2117 | 2117 | var dumpOpts = $.extend({ |
2118 | 2118 | asFileTree: false, |
2119 | 2119 | expand: null, |
2120 | 2120 | isMaxDepth: false, |
2121 | 2121 | showListKeys: true |
2122 | 2122 | }, this.getDumpOpts()); |
| 2123 | + var isList = (function () { |
| 2124 | + for (i = 0; i < length; i++) { |
| 2125 | + if (parseInt(keys[i], 10) !== i) { |
| 2126 | + return false |
| 2127 | + } |
| 2128 | + } |
| 2129 | + return true |
| 2130 | + })(); |
| 2131 | + var showKeys = dumpOpts.showListKeys || !isList; |
2123 | 2132 | /* |
2124 | 2133 | console.warn('dumpArray', { |
2125 | 2134 | array: JSON.parse(JSON.stringify(array)), |
|
2146 | 2155 | '<ul class="array-inner list-unstyled">\n'; |
2147 | 2156 | for (i = 0; i < length; i++) { |
2148 | 2157 | key = keys[i]; |
2149 | | - html += '\t<li>' + |
2150 | | - '<span class="t_key' + (/^\d+$/.test(key) ? ' t_int' : '') + '">' + key + '</span>' + |
2151 | | - '<span class="t_operator">=></span>' + |
2152 | | - this.dump(array[key]) + |
2153 | | - '</li>\n'; |
| 2158 | + html += this.dumpArrayValue(key, array[key], showKeys); |
2154 | 2159 | } |
2155 | 2160 | html += '</ul>' + |
2156 | 2161 | '<span class="t_punct">)</span>'; |
2157 | 2162 | return html |
2158 | 2163 | }; |
2159 | 2164 |
|
| 2165 | + Dump.prototype.dumpArrayValue = function (key, val, withKey) { |
| 2166 | + return withKey |
| 2167 | + ? '\t<li>' + |
| 2168 | + '<span class="t_key' + (/^\d+$/.test(key) ? ' t_int' : '') + '">' + key + '</span>' + |
| 2169 | + '<span class="t_operator">=></span>' + |
| 2170 | + this.dump(val) + |
| 2171 | + '</li>\n' |
| 2172 | + : '\t' + this.dump(val, { tagName: 'li' }) + '\n' |
| 2173 | + }; |
| 2174 | + |
2160 | 2175 | Dump.prototype.dumpBool = function (val) { |
2161 | 2176 | return val ? 'true' : 'false' |
2162 | 2177 | }; |
|
2505 | 2520 | .append($groupHeader) |
2506 | 2521 | .append($groupBody); |
2507 | 2522 | nodes.push($groupBody); |
2508 | | - if ($group.is(':visible')) { |
2509 | | - $group.debugEnhance(); |
2510 | | - } |
2511 | 2523 | return $group |
2512 | 2524 | }, |
2513 | 2525 | groupCollapsed: function (logEntry, info) { |
|
2557 | 2569 | if (nodes.length > 1) { |
2558 | 2570 | nodes.pop(); |
2559 | 2571 | } |
2560 | | - if (!isSummaryRoot) { |
2561 | | - $toggle = info.$node.prev(); |
2562 | | - $group = $toggle.parent(); |
2563 | | - if ($group.hasClass('empty') && $group.hasClass('hide-if-empty')) { |
2564 | | - // console.log('remove', $group) |
2565 | | - // $toggle.remove() |
2566 | | - // info.$currentNode.remove() |
2567 | | - $group.remove(); |
2568 | | - } else if ($group.hasClass('ungroup')) { |
2569 | | - var $children = $group.find('> ul.group-body > li'); |
2570 | | - var $groupLabel = $group.find('> .group-header > .group-label'); |
2571 | | - var $li = $('<li></li>').data($group.data()); |
2572 | | - if ($children.length === 0) { |
2573 | | - $group.replaceWith( |
2574 | | - $li.html($groupLabel.html()) |
2575 | | - ); |
2576 | | - } else if ($children.length === 1 && $children.filter('.m_group').length === 0) { |
2577 | | - $group.replaceWith($children); |
2578 | | - } |
2579 | | - } else if (!$group.is(':visible')) ; else { |
2580 | | - // console.log('enhance') |
2581 | | - $group.debugEnhance(); |
| 2572 | + if (isSummaryRoot) { |
| 2573 | + return |
| 2574 | + } |
| 2575 | + $toggle = info.$node.prev(); |
| 2576 | + $group = $toggle.parent(); |
| 2577 | + if ($group.hasClass('empty') && $group.hasClass('hide-if-empty')) { |
| 2578 | + // console.log('remove', $group) |
| 2579 | + // $toggle.remove() |
| 2580 | + // info.$currentNode.remove() |
| 2581 | + $group.remove(); |
| 2582 | + } else if ($group.hasClass('ungroup')) { |
| 2583 | + var $children = $group.find('> ul.group-body > li'); |
| 2584 | + var $groupLabel = $group.find('> .group-header > .group-label'); |
| 2585 | + var $li = $('<li></li>').data($group.data()); |
| 2586 | + if ($children.length === 0) { |
| 2587 | + $group.replaceWith( |
| 2588 | + $li.html($groupLabel.html()) |
| 2589 | + ); |
| 2590 | + } else if ($children.length === 1 && $children.filter('.m_group').length === 0) { |
| 2591 | + $group.replaceWith($children); |
2582 | 2592 | } |
| 2593 | + } else if ($group.hasClass('filter-hidden') === false && $group.is(':visible')) { |
| 2594 | + // console.log('enhance') |
| 2595 | + $group.debugEnhance(); |
2583 | 2596 | } |
2584 | 2597 | }, |
2585 | 2598 | groupUncollapse: function (logEntry, info) { |
|
2967 | 2980 |
|
2968 | 2981 | function processEntry (logEntry) { |
2969 | 2982 | // console.log(JSON.parse(JSON.stringify(logEntry))); |
2970 | | - var method = logEntry.method; |
2971 | 2983 | var meta = logEntry.meta; |
2972 | | - var i; |
2973 | 2984 | var info = getNodeInfo(meta); |
2974 | 2985 | var channelsTab = info.channels.filter(function (channelInfo) { |
2975 | 2986 | return channelInfo.name === info.channelNameTop || channelInfo.name.indexOf(info.channelNameTop + '.') === 0 |
2976 | 2987 | }); |
2977 | 2988 | var $node; |
2978 | 2989 |
|
2979 | 2990 | try { |
2980 | | - if (meta.format === 'html') { |
2981 | | - if (typeof logEntry.args === 'object') { |
2982 | | - $node = $('<li />', { class: 'm_' + method }); |
2983 | | - for (i = 0; i < logEntry.args.length; i++) { |
2984 | | - $node.append(logEntry.args[i]); |
2985 | | - } |
2986 | | - } else { |
2987 | | - $node = $(logEntry.args); |
2988 | | - if (!$node.is('.m_' + method)) { |
2989 | | - $node = $('<li />', { class: 'm_' + method }).html(logEntry.args); |
2990 | | - } |
2991 | | - } |
2992 | | - } else if (methods[method]) { |
2993 | | - $node = methods[method](logEntry, info); |
2994 | | - } else { |
2995 | | - $node = methods.default(logEntry, info); |
2996 | | - } |
| 2991 | + $node = buildLogEntryNode(logEntry, info); |
2997 | 2992 | updateSidebar(logEntry, info, $node !== false); |
2998 | 2993 | if (!$node) { |
2999 | 2994 | return |
|
3029 | 3024 | $node.attr('data-found-files', meta.foundFiles ? meta.foundFiles : []); |
3030 | 3025 | } |
3031 | 3026 | $node.parent().closest('.m_group.empty').removeClass('empty').trigger('updated.debug.group'); |
3032 | | - if ($node.is(':visible:not(.filter-hidden)')) { |
| 3027 | + if ($node.hasClass('filter-hidden') === false && $node.is(':visible')) { |
3033 | 3028 | $node.debugEnhance(); |
3034 | 3029 | } |
3035 | 3030 | } catch (err) { |
|
3038 | 3033 | } |
3039 | 3034 | } |
3040 | 3035 |
|
| 3036 | + function buildLogEntryNode (logEntry, info) { |
| 3037 | + var method = logEntry.method; |
| 3038 | + var $node; |
| 3039 | + var i; |
| 3040 | + if (logEntry.meta.format === 'html') { |
| 3041 | + if (typeof logEntry.args === 'object') { |
| 3042 | + $node = $('<li />', { class: 'm_' + method }); |
| 3043 | + for (i = 0; i < logEntry.args.length; i++) { |
| 3044 | + $node.append(logEntry.args[i]); |
| 3045 | + } |
| 3046 | + return $node |
| 3047 | + } |
| 3048 | + $node = $(logEntry.args); |
| 3049 | + if (!$node.is('.m_' + method)) { |
| 3050 | + $node = $('<li />', { class: 'm_' + method }).html(logEntry.args); |
| 3051 | + } |
| 3052 | + return $node |
| 3053 | + } |
| 3054 | + if (methods[method]) { |
| 3055 | + return methods[method](logEntry, info) |
| 3056 | + } |
| 3057 | + return methods.default(logEntry, info) |
| 3058 | + } |
| 3059 | + |
3041 | 3060 | function getNodeInfo (meta) { |
3042 | 3061 | var $container = $('#' + meta.requestId); |
3043 | 3062 | var $debug; |
|
0 commit comments