1; (function ($, pubsub, tab, render, toastr) { 2 'use strict'; 3 4 if (!toastr) { 5 pubsub.subscribe('action.panel.showed.toastr', function (args) { 6 render.engine.insert(args.panel, 'Toastr is not available on this screen. Plugin disabled.'); 7 }); 8 return; 9 } 10 11 var preexistingToasts = []; 12 var rendered = false; 13 var toastrPanel; 14 var headerRow = [ 15 'Id', 16 'Type', 17 'State', 18 'Message', 19 'Start', 20 'End', 21 'LifeTime', 22 'This Toast\'s Options', 23 'All Toastr Options' 24 ]; 25 26 toastr.subscribe(receiveToasts); 27 28 function receiveToasts(args) { 29 var data = args; 30 !rendered ? preexistingToasts.push(data) : write(data); 31 } 32 33 function elapsedMs(start, end) { 34 return end && start ? end.getTime() - start.getTime() + ' ms' : ''; 35 } 36 37 function formatDateTime(date) { 38 var sep = ':'; 39 return !!(date && date.getMonth) ? date.getFullYear().toString() + sep + 40 padDigits(date.getMonth() + 1) + sep + 41 padDigits(date.getDate()) + sep + 42 padDigits(date.getHours()) + sep + 43 padDigits(date.getMinutes()) + sep + 44 padDigits(date.getSeconds()) + sep + 45 padDigits(date.getMilliseconds(), '0', 3) : ''; 46 47 function padDigits(val, pad, count) { 48 var value = val.toString ? val.toString() : val; 49 count = count || 2; 50 var padding = Array(count + 1).join(pad || '0'); 51 return (padding + (value)).slice(-count); 52 } 53 } 54 55 function write(data) { 56 if (data.length) { 57 for (var i = 0; i < data.length; i++) { 58 write(data[i]); 59 } 60 return; 61 } 62 63 var startTime = formatDateTime(data.startTime); 64 var endTime = formatDateTime(data.endTime); 65 var lifetime = elapsedMs(data.startTime, data.endTime); 66 67 // Must match sequence of headers 68 var pivotedData = [ 69 data.toastId, 70 data.map.type, 71 data.state, 72 data.map.message, 73 startTime, 74 endTime, 75 lifetime, 76 data.map, 77 data.options, 78 getStateStyle(data) 79 ]; 80 render.engine.prepend(toastrPanel, [headerRow, pivotedData]); 81 } 82 83 function getStateStyle(data) { 84 return data.state === 'visible' ? 'info' : ''; 85 } 86 87 pubsub.subscribe('action.panel.rendered.toastr', function (args) { 88 toastrPanel = args.panel; 89 rendered = true; 90 render.engine.insert(toastrPanel, [headerRow]); 91 if (preexistingToasts.length) { 92 for (var i = 0; i < preexistingToasts.length; i++) { 93 write(preexistingToasts[i]); 94 } 95 } 96 }); 97 98 var config = { 99 key: 'toastr', 100 payload: { 101 name: 'toastr', 102 version: '0.2.0', 103 isPermanent: true, 104 data: 'Loading glimpse.toastr ...' 105 }, 106 metadata: { 107 //documentationUri: "http://jpapa.me/c7toastr" 108 } 109 }; 110 111 tab.register(config); 112 113})(jQueryGlimpse, glimpse.pubsub, glimpse.tab, glimpse.render, window.toastr);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.