rack-mini-profiler 1.0.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +115 -20
  3. data/README.md +126 -45
  4. data/lib/enable_rails_patches.rb +5 -0
  5. data/lib/html/dot.1.1.2.min.js +2 -0
  6. data/lib/html/includes.css +136 -35
  7. data/lib/html/includes.js +1400 -1009
  8. data/lib/html/includes.scss +546 -441
  9. data/lib/html/includes.tmpl +231 -148
  10. data/lib/html/pretty-print.js +810 -0
  11. data/lib/html/profile_handler.js +1 -1
  12. data/lib/html/rack-mini-profiler.css +3 -0
  13. data/lib/html/rack-mini-profiler.js +2 -0
  14. data/lib/html/share.html +0 -1
  15. data/lib/html/speedscope/LICENSE +21 -0
  16. data/lib/html/speedscope/README.md +3 -0
  17. data/lib/html/speedscope/demangle-cpp.1768f4cc.js +4 -0
  18. data/lib/html/speedscope/favicon-16x16.f74b3187.png +0 -0
  19. data/lib/html/speedscope/favicon-32x32.bc503437.png +0 -0
  20. data/lib/html/speedscope/file-format-schema.json +324 -0
  21. data/lib/html/speedscope/fonts/source-code-pro-regular.css +8 -0
  22. data/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff +0 -0
  23. data/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff2 +0 -0
  24. data/lib/html/speedscope/import.cf0fa83f.js +115 -0
  25. data/lib/html/speedscope/index.html +2 -0
  26. data/lib/html/speedscope/release.txt +3 -0
  27. data/lib/html/speedscope/reset.8c46b7a1.css +2 -0
  28. data/lib/html/speedscope/source-map.438fa06b.js +24 -0
  29. data/lib/html/speedscope/speedscope.44364064.js +200 -0
  30. data/lib/html/vendor.js +848 -0
  31. data/lib/mini_profiler/asset_version.rb +3 -2
  32. data/lib/mini_profiler/client_settings.rb +13 -5
  33. data/lib/mini_profiler/config.rb +43 -5
  34. data/lib/mini_profiler/gc_profiler.rb +1 -1
  35. data/lib/mini_profiler/profiler.rb +310 -42
  36. data/lib/mini_profiler/profiling_methods.rb +13 -8
  37. data/lib/mini_profiler/snapshots_transporter.rb +109 -0
  38. data/lib/mini_profiler/storage/abstract_store.rb +79 -1
  39. data/lib/mini_profiler/storage/file_store.rb +3 -3
  40. data/lib/mini_profiler/storage/memcache_store.rb +2 -0
  41. data/lib/mini_profiler/storage/memory_store.rb +54 -5
  42. data/lib/mini_profiler/storage/redis_store.rb +136 -2
  43. data/lib/mini_profiler/timer_struct/custom.rb +1 -0
  44. data/lib/mini_profiler/timer_struct/page.rb +60 -4
  45. data/lib/mini_profiler/timer_struct/request.rb +53 -11
  46. data/lib/mini_profiler/timer_struct/sql.rb +4 -2
  47. data/lib/mini_profiler/version.rb +1 -1
  48. data/lib/mini_profiler_rails/railtie.rb +88 -7
  49. data/lib/mini_profiler_rails/railtie_methods.rb +61 -0
  50. data/lib/patches/db/activerecord.rb +1 -12
  51. data/lib/patches/db/mongo.rb +1 -1
  52. data/lib/patches/db/moped.rb +1 -1
  53. data/lib/patches/db/mysql2.rb +4 -27
  54. data/lib/patches/db/mysql2/alias_method.rb +30 -0
  55. data/lib/patches/db/mysql2/prepend.rb +34 -0
  56. data/lib/patches/db/plucky.rb +4 -4
  57. data/lib/patches/net_patches.rb +18 -8
  58. data/lib/patches/sql_patches.rb +13 -5
  59. data/lib/prepend_mysql2_patch.rb +5 -0
  60. data/lib/prepend_net_http_patch.rb +5 -0
  61. data/lib/rack-mini-profiler.rb +1 -1
  62. data/rack-mini-profiler.gemspec +15 -6
  63. metadata +150 -31
  64. data/lib/html/jquery.1.7.1.js +0 -4
  65. data/lib/html/jquery.tmpl.js +0 -486
  66. data/lib/html/list.css +0 -9
  67. data/lib/html/list.js +0 -38
  68. data/lib/html/list.tmpl +0 -34
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rack
4
+ MINI_PROFILER_ENABLE_RAILS_PATCHES = true
5
+ end
@@ -0,0 +1,2 @@
1
+ /* Laura Doktorova https://github.com/olado/doT */
2
+ !function(){"use strict";function e(n,t,r){return("string"==typeof t?t:t.toString()).replace(n.define||a,function(e,t,o,a){return 0===t.indexOf("def.")&&(t=t.substring(4)),t in r||(":"===o?(n.defineParams&&a.replace(n.defineParams,function(e,n,o){r[t]={arg:n,text:o}}),t in r||(r[t]=a)):new Function("def","def['"+t+"']="+a)(r)),""}).replace(n.use||a,function(t,o){n.useParams&&(o=o.replace(n.useParams,function(e,n,t,o){if(r[t]&&r[t].arg&&o){var a=(t+":"+o).replace(/'|\\/g,"_");return r.__exp=r.__exp||{},r.__exp[a]=r[t].text.replace(new RegExp("(^|[^\\w$])"+r[t].arg+"([^\\w$])","g"),"$1"+o+"$2"),n+"def.__exp['"+a+"']"}}));var a=new Function("def","return "+o)(r);return a?e(n,a,r):a})}function n(e){return e.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")}var t,r={engine:"doT",version:"1.1.1",templateSettings:{evaluate:/\{\{([\s\S]+?(\}?)+)\}\}/g,interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,useParams:/(^|[^\w$])def(?:\.|\[[\'\"])([\w$\.]+)(?:[\'\"]\])?\s*\:\s*([\w$\.]+|\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,defineParams:/^\s*([\w$]+):([\s\S]+)/,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:!0,append:!0,selfcontained:!1,doNotSkipEncoded:!1},template:void 0,compile:void 0,log:!0};r.encodeHTMLSource=function(e){var n={"&":"&#38;","<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","/":"&#47;"},t=e?/[&<>"'\/]/g:/&(?!#?\w+;)|<|>|"|'|\//g;return function(e){return e?e.toString().replace(t,function(e){return n[e]||e}):""}},t=function(){return this||(0,eval)("this")}(),"undefined"!=typeof module&&module.exports?module.exports=r:"function"==typeof define&&define.amd?define(function(){return r}):t.doT=r;var o={append:{start:"'+(",end:")+'",startencode:"'+encodeHTML("},split:{start:"';out+=(",end:");out+='",startencode:"';out+=encodeHTML("}},a=/$^/;r.template=function(c,i,u){i=i||r.templateSettings;var d,s,p=i.append?o.append:o.split,l=0,f=i.use||i.define?e(i,c,u||{}):c;f=("var out='"+(i.strip?f.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""):f).replace(/'|\\/g,"\\$&").replace(i.interpolate||a,function(e,t){return p.start+n(t)+p.end}).replace(i.encode||a,function(e,t){return d=!0,p.startencode+n(t)+p.end}).replace(i.conditional||a,function(e,t,r){return t?r?"';}else if("+n(r)+"){out+='":"';}else{out+='":r?"';if("+n(r)+"){out+='":"';}out+='"}).replace(i.iterate||a,function(e,t,r,o){return t?(l+=1,s=o||"i"+l,t=n(t),"';var arr"+l+"="+t+";if(arr"+l+"){var "+r+","+s+"=-1,l"+l+"=arr"+l+".length-1;while("+s+"<l"+l+"){"+r+"=arr"+l+"["+s+"+=1];out+='"):"';} } out+='"}).replace(i.evaluate||a,function(e,t){return"';"+n(t)+"out+='"})+"';return out;").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/(\s|;|\}|^|\{)out\+='';/g,"$1").replace(/\+''/g,""),d&&(i.selfcontained||!t||t._encodeHTML||(t._encodeHTML=r.encodeHTMLSource(i.doNotSkipEncoded)),f="var encodeHTML = typeof _encodeHTML !== 'undefined' ? _encodeHTML : ("+r.encodeHTMLSource.toString()+"("+(i.doNotSkipEncoded||"")+"));"+f);try{return new Function(i.varname,f)}catch(e){throw"undefined"!=typeof console&&console.log("Could not create a template function: "+f),e}},r.compile=function(e,n){return r.template(e,null,n)}}();
@@ -1,9 +1,40 @@
1
1
  @charset "UTF-8";
2
- .profiler-result, .profiler-queries {
2
+ .mp-snapshots,
3
+ .profiler-result,
4
+ .profiler-queries {
3
5
  color: #555;
4
6
  line-height: 1;
5
7
  font-size: 12px; }
6
- .profiler-result pre, .profiler-result code, .profiler-result label, .profiler-result table, .profiler-result tbody, .profiler-result thead, .profiler-result tfoot, .profiler-result tr, .profiler-result th, .profiler-result td, .profiler-queries pre, .profiler-queries code, .profiler-queries label, .profiler-queries table, .profiler-queries tbody, .profiler-queries thead, .profiler-queries tfoot, .profiler-queries tr, .profiler-queries th, .profiler-queries td {
8
+ .mp-snapshots pre,
9
+ .mp-snapshots code,
10
+ .mp-snapshots label,
11
+ .mp-snapshots table,
12
+ .mp-snapshots tbody,
13
+ .mp-snapshots thead,
14
+ .mp-snapshots tfoot,
15
+ .mp-snapshots tr,
16
+ .mp-snapshots th,
17
+ .mp-snapshots td,
18
+ .profiler-result pre,
19
+ .profiler-result code,
20
+ .profiler-result label,
21
+ .profiler-result table,
22
+ .profiler-result tbody,
23
+ .profiler-result thead,
24
+ .profiler-result tfoot,
25
+ .profiler-result tr,
26
+ .profiler-result th,
27
+ .profiler-result td,
28
+ .profiler-queries pre,
29
+ .profiler-queries code,
30
+ .profiler-queries label,
31
+ .profiler-queries table,
32
+ .profiler-queries tbody,
33
+ .profiler-queries thead,
34
+ .profiler-queries tfoot,
35
+ .profiler-queries tr,
36
+ .profiler-queries th,
37
+ .profiler-queries td {
7
38
  margin: 0;
8
39
  padding: 0;
9
40
  border: 0;
@@ -13,21 +44,40 @@
13
44
  background-color: transparent;
14
45
  overflow: visible;
15
46
  max-height: none; }
16
- .profiler-result table, .profiler-queries table {
47
+ .mp-snapshots table,
48
+ .profiler-result table,
49
+ .profiler-queries table {
17
50
  border-collapse: collapse;
18
51
  border-spacing: 0; }
19
- .profiler-result a, .profiler-result a:hover, .profiler-queries a, .profiler-queries a:hover {
52
+ .mp-snapshots a,
53
+ .mp-snapshots a:hover,
54
+ .profiler-result a,
55
+ .profiler-result a:hover,
56
+ .profiler-queries a,
57
+ .profiler-queries a:hover {
20
58
  cursor: pointer;
21
- color: #0077CC; }
22
- .profiler-result a, .profiler-queries a {
59
+ color: #0077cc; }
60
+ .mp-snapshots a,
61
+ .profiler-result a,
62
+ .profiler-queries a {
23
63
  text-decoration: none; }
24
- .profiler-result a:hover, .profiler-queries a:hover {
64
+ .mp-snapshots a:hover,
65
+ .profiler-result a:hover,
66
+ .profiler-queries a:hover {
25
67
  text-decoration: underline; }
68
+ .mp-snapshots .custom-fields-title,
69
+ .profiler-result .custom-fields-title,
70
+ .profiler-queries .custom-fields-title {
71
+ color: #555;
72
+ font: Helvetica, Arial, sans-serif;
73
+ font-size: 14px; }
26
74
 
27
75
  .profiler-result {
28
76
  font-family: Helvetica, Arial, sans-serif; }
29
77
  .profiler-result .profiler-toggle-duration-with-children {
30
78
  float: right; }
79
+ .profiler-result .profiler-snapshots-page-link {
80
+ float: left; }
31
81
  .profiler-result table.profiler-client-timings {
32
82
  margin-top: 10px; }
33
83
  .profiler-result .profiler-label {
@@ -38,9 +88,13 @@
38
88
  color: #767676; }
39
89
  .profiler-result .profiler-trivial {
40
90
  display: none; }
41
- .profiler-result .profiler-trivial td, .profiler-result .profiler-trivial td * {
91
+ .profiler-result .profiler-trivial td,
92
+ .profiler-result .profiler-trivial td * {
42
93
  color: #767676 !important; }
43
- .profiler-result pre, .profiler-result code, .profiler-result .profiler-number, .profiler-result .profiler-unit {
94
+ .profiler-result pre,
95
+ .profiler-result code,
96
+ .profiler-result .profiler-number,
97
+ .profiler-result .profiler-unit {
44
98
  font-family: Consolas, monospace, serif; }
45
99
  .profiler-result .profiler-number {
46
100
  color: #111; }
@@ -54,7 +108,8 @@
54
108
  background-color: #fff;
55
109
  color: #767676;
56
110
  text-align: right; }
57
- .profiler-result .profiler-timings th, .profiler-result .profiler-timings td {
111
+ .profiler-result .profiler-timings th,
112
+ .profiler-result .profiler-timings td {
58
113
  white-space: nowrap; }
59
114
  .profiler-result .profiler-timings .profiler-duration-with-children {
60
115
  display: none; }
@@ -63,8 +118,9 @@
63
118
  text-align: right; }
64
119
  .profiler-result .profiler-timings .profiler-indent {
65
120
  letter-spacing: 4px; }
66
- .profiler-result .profiler-timings .profiler-queries-show .profiler-number, .profiler-result .profiler-timings .profiler-queries-show .profiler-unit {
67
- color: #0077CC; }
121
+ .profiler-result .profiler-timings .profiler-queries-show .profiler-number,
122
+ .profiler-result .profiler-timings .profiler-queries-show .profiler-unit {
123
+ color: #0077cc; }
68
124
  .profiler-result .profiler-timings .profiler-queries-duration {
69
125
  padding-left: 6px; }
70
126
  .profiler-result .profiler-timings .profiler-percent-in-sql {
@@ -89,13 +145,15 @@
89
145
  .profiler-result .profiler-queries tbody tr {
90
146
  border-bottom: 1px solid #f1f1f1; }
91
147
  .profiler-result .profiler-queries tr {
92
- background-color: #FFF; }
148
+ background-color: #fff; }
149
+ .profiler-result .profiler-queries tr.higlight-animate {
150
+ animation: highlight-in 3s; }
93
151
  .profiler-result .profiler-queries tr.slow {
94
- background-color: #FEE; }
152
+ background-color: #fee; }
95
153
  .profiler-result .profiler-queries tr.very-slow {
96
- background-color: #FDD; }
154
+ background-color: #fdd; }
97
155
  .profiler-result .profiler-queries tr.very-very-slow {
98
- background-color: #FCC; }
156
+ background-color: #fcc; }
99
157
  .profiler-result .profiler-queries pre {
100
158
  font-family: Consolas, monospace, serif;
101
159
  white-space: pre-wrap; }
@@ -110,12 +168,14 @@
110
168
  text-align: left; }
111
169
  .profiler-result .profiler-queries td:last-child {
112
170
  padding-right: 25px; }
113
- .profiler-result .profiler-queries .profiler-since-start, .profiler-result .profiler-queries .profiler-duration {
171
+ .profiler-result .profiler-queries .profiler-since-start,
172
+ .profiler-result .profiler-queries .profiler-duration {
114
173
  text-align: right; }
115
174
  .profiler-result .profiler-queries .profiler-info div {
116
175
  text-align: right;
117
176
  margin-bottom: 5px; }
118
- .profiler-result .profiler-queries .profiler-gap-info, .profiler-result .profiler-queries .profiler-gap-info td {
177
+ .profiler-result .profiler-queries .profiler-gap-info,
178
+ .profiler-result .profiler-queries .profiler-gap-info td {
119
179
  background-color: #ccc; }
120
180
  .profiler-result .profiler-queries .profiler-gap-info .profiler-unit {
121
181
  color: #777; }
@@ -147,9 +207,15 @@
147
207
  color: blue; }
148
208
  .profiler-result .profiler-queries .dec {
149
209
  color: purple; }
150
- .profiler-result .profiler-warning, .profiler-result .profiler-warning *, .profiler-result .profiler-warning .profiler-queries-show, .profiler-result .profiler-warning .profiler-queries-show .profiler-unit {
210
+ .profiler-result .profiler-warning,
211
+ .profiler-result .profiler-warning *,
212
+ .profiler-result .profiler-warning .profiler-queries-show,
213
+ .profiler-result .profiler-warning .profiler-queries-show .profiler-unit {
151
214
  color: #f00; }
152
- .profiler-result .profiler-warning:hover, .profiler-result .profiler-warning *:hover, .profiler-result .profiler-warning .profiler-queries-show:hover, .profiler-result .profiler-warning .profiler-queries-show .profiler-unit:hover {
215
+ .profiler-result .profiler-warning:hover,
216
+ .profiler-result .profiler-warning *:hover,
217
+ .profiler-result .profiler-warning .profiler-queries-show:hover,
218
+ .profiler-result .profiler-warning .profiler-queries-show .profiler-unit:hover {
153
219
  color: #f00; }
154
220
  .profiler-result .profiler-nuclear {
155
221
  color: #f00;
@@ -165,39 +231,48 @@
165
231
  top: 0px; }
166
232
  .profiler-results.profiler-top.profiler-left {
167
233
  left: 0px; }
168
- .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-results.profiler-top.profiler-left .profiler-controls {
234
+ .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-result:last-child .profiler-button,
235
+ .profiler-results.profiler-top.profiler-left .profiler-controls {
169
236
  -webkit-border-bottom-right-radius: 10px;
170
237
  -moz-border-radius-bottomright: 10px;
171
238
  border-bottom-right-radius: 10px; }
172
- .profiler-results.profiler-top.profiler-left .profiler-button, .profiler-results.profiler-top.profiler-left .profiler-controls {
239
+ .profiler-results.profiler-top.profiler-left .profiler-button,
240
+ .profiler-results.profiler-top.profiler-left .profiler-controls {
173
241
  border-right: 1px solid #888; }
174
242
  .profiler-results.profiler-top.profiler-right {
175
243
  right: 0px; }
176
- .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-result:last-child .profiler-button, .profiler-results.profiler-top.profiler-right .profiler-controls {
244
+ .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-result:last-child .profiler-button,
245
+ .profiler-results.profiler-top.profiler-right .profiler-controls {
177
246
  -webkit-border-bottom-left-radius: 10px;
178
247
  -moz-border-radius-bottomleft: 10px;
179
248
  border-bottom-left-radius: 10px; }
180
- .profiler-results.profiler-top.profiler-right .profiler-button, .profiler-results.profiler-top.profiler-right .profiler-controls {
249
+ .profiler-results.profiler-top.profiler-right .profiler-button,
250
+ .profiler-results.profiler-top.profiler-right .profiler-controls {
181
251
  border-left: 1px solid #888; }
182
252
  .profiler-results.profiler-bottom {
183
253
  bottom: 0px; }
184
254
  .profiler-results.profiler-bottom.profiler-left {
185
255
  left: 0px; }
186
- .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-result:first-child .profiler-button, .profiler-results.profiler-bottom.profiler-left .profiler-controls {
256
+ .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-result:first-child .profiler-button,
257
+ .profiler-results.profiler-bottom.profiler-left .profiler-controls {
187
258
  -webkit-border-top-right-radius: 10px;
188
259
  -moz-border-radius-topright: 10px;
189
260
  border-top-right-radius: 10px; }
190
- .profiler-results.profiler-bottom.profiler-left .profiler-button, .profiler-results.profiler-bottom.profiler-left .profiler-controls {
261
+ .profiler-results.profiler-bottom.profiler-left .profiler-button,
262
+ .profiler-results.profiler-bottom.profiler-left .profiler-controls {
191
263
  border-right: 1px solid #888; }
192
264
  .profiler-results.profiler-bottom.profiler-right {
193
265
  right: 0px; }
194
- .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-result:first-child .profiler-button, .profiler-results.profiler-bottom.profiler-right .profiler-controls {
266
+ .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-result:first-child .profiler-button,
267
+ .profiler-results.profiler-bottom.profiler-right .profiler-controls {
195
268
  -webkit-border-bottom-top-radius: 10px;
196
269
  -moz-border-radius-topleft: 10px;
197
270
  border-top-left-radius: 10px; }
198
- .profiler-results.profiler-bottom.profiler-right .profiler-button, .profiler-results.profiler-bottom.profiler-right .profiler-controls {
271
+ .profiler-results.profiler-bottom.profiler-right .profiler-button,
272
+ .profiler-results.profiler-bottom.profiler-right .profiler-controls {
199
273
  border-left: 1px solid #888; }
200
- .profiler-results .profiler-button, .profiler-results .profiler-controls {
274
+ .profiler-results .profiler-button,
275
+ .profiler-results .profiler-controls {
201
276
  display: none;
202
277
  z-index: 2147483640;
203
278
  border-bottom: 1px solid #888;
@@ -205,12 +280,17 @@
205
280
  padding: 4px 7px;
206
281
  text-align: right;
207
282
  cursor: pointer; }
208
- .profiler-results .profiler-button.profiler-button-active, .profiler-results .profiler-controls.profiler-button-active {
283
+ .profiler-results .profiler-button.profiler-button-active,
284
+ .profiler-results .profiler-controls.profiler-button-active {
209
285
  background-color: maroon; }
210
- .profiler-results .profiler-button.profiler-button-active .profiler-number, .profiler-results .profiler-button.profiler-button-active .profiler-nuclear, .profiler-results .profiler-controls.profiler-button-active .profiler-number, .profiler-results .profiler-controls.profiler-button-active .profiler-nuclear {
286
+ .profiler-results .profiler-button.profiler-button-active .profiler-number,
287
+ .profiler-results .profiler-button.profiler-button-active .profiler-nuclear,
288
+ .profiler-results .profiler-controls.profiler-button-active .profiler-number,
289
+ .profiler-results .profiler-controls.profiler-button-active .profiler-nuclear {
211
290
  color: #fff;
212
291
  font-weight: bold; }
213
- .profiler-results .profiler-button.profiler-button-active .profiler-unit, .profiler-results .profiler-controls.profiler-button-active .profiler-unit {
292
+ .profiler-results .profiler-button.profiler-button-active .profiler-unit,
293
+ .profiler-results .profiler-controls.profiler-button-active .profiler-unit {
214
294
  color: #fff;
215
295
  font-weight: normal; }
216
296
  .profiler-results .profiler-totals .profiler-reqs {
@@ -258,7 +338,8 @@
258
338
  display: none; }
259
339
  .profiler-results .profiler-popup .profiler-info .profiler-server-time {
260
340
  font-size: 95%; }
261
- .profiler-results .profiler-popup .profiler-timings th, .profiler-results .profiler-popup .profiler-timings td {
341
+ .profiler-results .profiler-popup .profiler-timings th,
342
+ .profiler-results .profiler-popup .profiler-timings td {
262
343
  padding-left: 6px;
263
344
  padding-right: 6px; }
264
345
  .profiler-results .profiler-popup .profiler-timings th {
@@ -288,7 +369,6 @@
288
369
  @media print {
289
370
  .profiler-results {
290
371
  display: none; } }
291
-
292
372
  .profiler-queries-bg {
293
373
  z-index: 2147483642;
294
374
  display: none;
@@ -313,7 +393,8 @@
313
393
  padding-right: 20px;
314
394
  font-size: 80%;
315
395
  color: #888; }
316
- .profiler-result-full .profiler-result .profiler-popup .profiler-timings td, .profiler-result-full .profiler-result .profiler-popup .profiler-timings th {
396
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings td,
397
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings th {
317
398
  padding-left: 8px;
318
399
  padding-right: 8px; }
319
400
  .profiler-result-full .profiler-result .profiler-popup .profiler-timings th {
@@ -339,3 +420,23 @@
339
420
  .profiler-result-full .profiler-result .profiler-queries .profiler-info div {
340
421
  text-align: right;
341
422
  margin-bottom: 5px; }
423
+
424
+ @keyframes highlight-in {
425
+ 0% {
426
+ background: #ffffbb; }
427
+ 100% {
428
+ background: #fff; } }
429
+
430
+ .mp-snapshots {
431
+ font-family: Helvetica, Arial, sans-serif;
432
+ font-size: 16px; }
433
+ .mp-snapshots .snapshots-table thead {
434
+ background: #6a737c;
435
+ color: #ffffff; }
436
+ .mp-snapshots .snapshots-table th, .mp-snapshots .snapshots-table td {
437
+ padding: 5px 10px;
438
+ box-sizing: border-box; }
439
+ .mp-snapshots .snapshots-table th:not(.request-group), .mp-snapshots .snapshots-table td:not(.request-group) {
440
+ text-align: center; }
441
+ .mp-snapshots .snapshots-table th {
442
+ border-right: 1px solid #ffffff; }
data/lib/html/includes.js CHANGED
@@ -1,1103 +1,1494 @@
1
1
  "use strict";
2
- var MiniProfiler = (function () {
3
- var $;
4
-
5
- var options,
6
- container,
7
- controls,
8
- fetchedIds = [],
9
- fetchingIds = [], // so we never pull down a profiler twice
10
- ajaxStartTime,
11
- totalsControl,
12
- reqs = 0,
13
- expandedResults = false,
14
- totalTime = 0,
15
- totalSqlCount = 0
16
- ;
17
-
18
- var hasLocalStorage = function (keyPrefix) {
19
- try {
20
- // attempt to save to localStorage as Safari private windows will throw an error
21
- localStorage[keyPrefix+'-test'] = '1';
22
- localStorage.removeItem(keyPrefix+'-test');
23
- return 'localStorage' in window && window['localStorage'] !== null ;
24
- } catch (e) {
25
- return false;
26
- }
27
- };
28
-
29
- var getVersionedKey = function (keyPrefix) {
30
- return keyPrefix + '-' + options.version;
31
- };
32
-
33
- var save = function (keyPrefix, value) {
34
- if (!hasLocalStorage(keyPrefix)) { return; }
35
2
 
36
- // clear old keys with this prefix, if any
37
- for (var i = 0; i < localStorage.length; i++) {
38
- if ((localStorage.key(i) || '').indexOf(keyPrefix) > -1) {
39
- localStorage.removeItem(localStorage.key(i));
40
- }
3
+ var _MiniProfiler = (function() {
4
+ var _arguments = arguments;
5
+ var options,
6
+ container,
7
+ controls,
8
+ fetchedIds = (window.MiniProfiler && window.MiniProfiler.fetchedIds) || [],
9
+ fetchingIds =
10
+ (window.MiniProfiler && window.MiniProfiler.fetchingIds) || [],
11
+ // so we never pull down a profiler twice
12
+ ajaxStartTime,
13
+ totalsControl,
14
+ reqs = 0,
15
+ expandedResults = false,
16
+ totalTime = 0,
17
+ totalSqlCount = 0;
18
+
19
+ var hasLocalStorage = function hasLocalStorage(keyPrefix) {
20
+ try {
21
+ // attempt to save to localStorage as Safari private windows will throw an error
22
+ localStorage[keyPrefix + "-test"] = "1";
23
+ localStorage.removeItem(keyPrefix + "-test");
24
+ return "localStorage" in window && window["localStorage"] !== null;
25
+ } catch (e) {
26
+ return false;
27
+ }
28
+ };
29
+
30
+ var getVersionedKey = function getVersionedKey(keyPrefix) {
31
+ return keyPrefix + "-" + options.version;
32
+ };
33
+
34
+ // polyfills as helper functions to avoid conflicts
35
+ // needed for IE11
36
+ // remove and replace with Element.closest when we drop IE11 support
37
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
38
+
39
+ var elementMatches =
40
+ Element.prototype.msMatchesSelector ||
41
+ Element.prototype.webkitMatchesSelector;
42
+
43
+ var elementClosest = function elementClosest(el, s) {
44
+ if (typeof el.closest === "function") {
45
+ return el.closest(s);
46
+ }
47
+
48
+ do {
49
+ if (typeof el.matches === "function") {
50
+ if (el.matches(s)) return el;
51
+ } else {
52
+ if (elementMatches.call(el, s)) return el;
53
+ }
54
+
55
+ el = el.parentElement || el.parentNode;
56
+ } while (el !== null && el.nodeType === 1);
57
+
58
+ return null;
59
+ };
60
+
61
+ var save = function save(keyPrefix, value) {
62
+ if (!hasLocalStorage(keyPrefix)) {
63
+ return;
64
+ } // clear old keys with this prefix, if any
65
+
66
+ for (var i = 0; i < localStorage.length; i++) {
67
+ if ((localStorage.key(i) || "").indexOf(keyPrefix) > -1) {
68
+ localStorage.removeItem(localStorage.key(i));
69
+ }
70
+ } // save under this version
71
+
72
+ localStorage[getVersionedKey(keyPrefix)] = value;
73
+ };
74
+
75
+ var load = function load(keyPrefix) {
76
+ if (!hasLocalStorage(keyPrefix)) {
77
+ return null;
78
+ }
79
+
80
+ return localStorage[getVersionedKey(keyPrefix)];
81
+ };
82
+
83
+ var getClientPerformance = function getClientPerformance() {
84
+ return window.performance === null ? null : window.performance;
85
+ };
86
+
87
+ var fetchResults = function fetchResults(ids) {
88
+ var clientPerformance, clientProbes, i, j, p, id, idx;
89
+
90
+ for (i = 0; i < ids.length; i++) {
91
+ id = ids[i];
92
+ clientPerformance = null;
93
+ clientProbes = null;
94
+
95
+ if (window.mPt) {
96
+ clientProbes = mPt.results();
97
+
98
+ for (j = 0; j < clientProbes.length; j++) {
99
+ clientProbes[j].d = clientProbes[j].d.getTime();
41
100
  }
42
101
 
43
- // save under this version
44
- localStorage[getVersionedKey(keyPrefix)] = value;
45
- };
102
+ mPt.flush();
103
+ }
46
104
 
47
- var load = function (keyPrefix) {
48
- if (!hasLocalStorage(keyPrefix)) { return null; }
105
+ if (id == options.currentId) {
106
+ clientPerformance = getClientPerformance();
49
107
 
50
- return localStorage[getVersionedKey(keyPrefix)];
51
- };
108
+ if (clientPerformance !== null) {
109
+ // ie is buggy strip out functions
110
+ var copy = {
111
+ navigation: {},
112
+ timing: clientPerformance.timing.toJSON()
113
+ };
52
114
 
53
- var fetchTemplates = function (success) {
54
- var key = 'templates',
55
- cached = load(key);
115
+ if (clientPerformance.navigation) {
116
+ copy.navigation.redirectCount =
117
+ clientPerformance.navigation.redirectCount;
118
+ }
56
119
 
57
- if (cached) {
58
- $('body').append(cached);
59
- success();
60
- }
61
- else {
62
- $.get(options.path + 'includes.tmpl?v=' + options.version, function (data) {
63
- if (data) {
64
- save(key, data);
65
- $('body').append(data);
66
- success();
67
- }
68
- }, "text");
120
+ clientPerformance = copy;
69
121
  }
70
- };
71
-
72
- var getClientPerformance = function() {
73
- return window.performance === null ? null : window.performance;
74
- };
75
-
76
- var fetchResults = function (ids) {
77
- var clientPerformance, clientProbes, i, j, p, id, idx;
78
-
79
- for (i = 0; i < ids.length; i++) {
80
- id = ids[i];
122
+ } else if (
123
+ ajaxStartTime !== null &&
124
+ clientProbes &&
125
+ clientProbes.length > 0
126
+ ) {
127
+ clientPerformance = {
128
+ timing: {
129
+ navigationStart: ajaxStartTime.getTime()
130
+ }
131
+ };
132
+ ajaxStartTime = null;
133
+ }
134
+
135
+ if (fetchedIds.indexOf(id) < 0 && fetchingIds.indexOf(id) < 0) {
136
+ idx = fetchingIds.push(id) - 1;
137
+
138
+ (function() {
139
+ var request = new XMLHttpRequest();
140
+ var url = options.path + "results";
141
+ var params = {
142
+ id: id,
143
+ clientPerformance: clientPerformance,
144
+ clientProbes: clientProbes,
145
+ popup: 1
146
+ };
147
+ var queryParam = toQueryString(params);
148
+ request.open("POST", url, true);
81
149
 
82
- clientPerformance = null;
83
- clientProbes = null;
150
+ request.onload = function() {
151
+ if (request.status >= 200 && request.status < 400) {
152
+ var json = JSON.parse(request.responseText);
153
+ fetchedIds.push(id);
84
154
 
85
- if (window.mPt) {
86
- clientProbes = mPt.results();
87
- for (j = 0; j < clientProbes.length; j++) {
88
- clientProbes[j].d = clientProbes[j].d.getTime();
89
- }
90
- mPt.flush();
155
+ if (json != "hidden" && MiniProfiler.templates) {
156
+ buttonShow(json);
157
+ }
91
158
  }
92
159
 
93
- if (id == options.currentId) {
94
-
95
- clientPerformance = getClientPerformance();
96
-
97
- if (clientPerformance !== null) {
98
- // ie is buggy strip out functions
99
- var copy = { navigation: {}, timing: {} };
100
-
101
- var timing = $.extend({}, clientPerformance.timing);
102
-
103
- for (p in timing) {
104
- if (timing.hasOwnProperty(p) && !$.isFunction(timing[p])) {
105
- copy.timing[p] = timing[p];
106
- }
107
- }
108
- if (clientPerformance.navigation) {
109
- copy.navigation.redirectCount = clientPerformance.navigation.redirectCount;
110
- }
111
- clientPerformance = copy;
112
- }
113
- } else if (ajaxStartTime !== null && clientProbes && clientProbes.length > 0) {
114
- clientPerformance = { timing: { navigationStart: ajaxStartTime.getTime() } };
115
- ajaxStartTime = null;
116
- }
160
+ fetchingIds.splice(idx, 1);
161
+ };
117
162
 
118
- if ($.inArray(id, fetchedIds) < 0 && $.inArray(id, fetchingIds) < 0) {
119
- idx = fetchingIds.push(id) - 1;
120
-
121
- $.ajax({
122
- url: options.path + 'results',
123
- data: { id: id, clientPerformance: clientPerformance, clientProbes: clientProbes, popup: 1 },
124
- dataType: 'json',
125
- global: false,
126
- type: 'POST',
127
- success: function (json) {
128
- fetchedIds.push(id);
129
- if (json != "hidden") {
130
- buttonShow(json);
131
- }
132
- },
133
- complete: function () {
134
- fetchingIds.splice(idx, 1);
135
- }
136
- });
137
- }
163
+ request.setRequestHeader("Accept", "application/json");
164
+ request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
165
+ request.setRequestHeader(
166
+ "Content-Type",
167
+ "application/x-www-form-urlencoded"
168
+ );
169
+ request.send(queryParam);
170
+ })();
171
+ }
172
+ }
173
+ };
174
+
175
+ var toQueryString = function toQueryString(data, parentKey) {
176
+ var result = [];
177
+ for (var key in data) {
178
+ var val = data[key];
179
+ var newKey = !parentKey ? key : parentKey + "[" + key + "]";
180
+ if (
181
+ typeof val === "object" &&
182
+ !Array.isArray(val) &&
183
+ val !== null &&
184
+ val !== undefined
185
+ ) {
186
+ result[result.length] = toQueryString(val, newKey);
187
+ } else {
188
+ if (Array.isArray(val)) {
189
+ val.forEach(function(v) {
190
+ result[result.length] =
191
+ encodeURIComponent(newKey + "[]") + "=" + encodeURIComponent(v);
192
+ });
193
+ } else if (val === null || val === undefined) {
194
+ result[result.length] = encodeURIComponent(newKey) + "=";
195
+ } else {
196
+ result[result.length] =
197
+ encodeURIComponent(newKey) +
198
+ "=" +
199
+ encodeURIComponent(val.toString());
138
200
  }
139
- };
140
-
141
- var renderTemplate = function (json) {
142
- return $('#profilerTemplate').tmpl(json);
143
- };
144
-
145
-
146
- var buttonShow = function (json) {
147
- var result = renderTemplate(json);
148
-
149
- totalTime += parseFloat(json.duration_milliseconds, 10);
150
- totalSqlCount += parseInt(json.sql_count);
151
- reqs++;
152
-
153
- if (!controls && reqs > 1 && options.collapseResults && !expandedResults) {
154
- if (!totalsControl) {
155
- container.find('.profiler-result').hide();
156
-
157
- totalsControl = $("<div class='profiler-result'><div class='profiler-button profiler-totals'></div></div>");
158
- totalsControl.appendTo(container);
159
- totalsControl.on('click', function(){
160
- totalsControl.parent().find('.profiler-result').show();
161
- totalsControl.hide();
162
- expandedResults = true;
163
- });
164
-
165
- totalsControl.find('.profiler-button').show();
201
+ }
202
+ }
203
+ return result
204
+ .filter(function(element) {
205
+ return element && element.length > 0;
206
+ })
207
+ .join("&");
208
+ };
209
+
210
+ var renderTemplate = function renderTemplate(json) {
211
+ var textDom = MiniProfiler.templates.profilerTemplate(json);
212
+ var tempElement = document.createElement("DIV");
213
+ tempElement.innerHTML = textDom;
214
+ return tempElement.children[0];
215
+ };
216
+
217
+ var buttonShow = function buttonShow(json) {
218
+ var result = renderTemplate(json);
219
+ totalTime += parseFloat(json.duration_milliseconds, 10);
220
+ totalSqlCount += parseInt(json.sql_count);
221
+ reqs++;
222
+
223
+ if (!controls && reqs > 1 && options.collapseResults && !expandedResults) {
224
+ if (!totalsControl) {
225
+ toArray(container.querySelectorAll(".profiler-result")).forEach(
226
+ function(el) {
227
+ return (el.style.display = "none");
166
228
  }
167
-
168
- var reqsHtml = reqs > 1 ? ("<span class='profiler-reqs'>" + reqs + "</span>") : "";
169
- var sqlHtml = options.showTotalSqlCount && totalSqlCount > 0 ? (" / <span class='profiler-number'>" + totalSqlCount + "</span> <span class='profiler-unit'>sql</span>") : "";
170
- totalsControl.find('.profiler-button').html("<span class='profiler-number'>" +
171
- totalTime.toFixed(1) + "</span> <span class='profiler-unit'>ms</span>" +
172
- sqlHtml +
173
- reqsHtml);
174
-
175
- result.hide();
176
- }
177
-
178
- if (controls)
179
- result.insertBefore(controls);
180
- else
181
- result.appendTo(container);
182
-
183
- var button = result.find('.profiler-button'),
184
- popup = result.find('.profiler-popup');
185
-
186
- // button will appear in corner with the total profiling duration - click to show details
187
- button.on('click', function () { buttonClick(button, popup); });
188
-
189
- // small duration steps and the column with aggregate durations are hidden by default; allow toggling
190
- toggleHidden(popup);
191
-
192
- // lightbox in the queries
193
- popup.find('.profiler-queries-show').on('click', function () { queriesShow($(this), result); });
194
-
195
- // limit count
196
- if (container.find('.profiler-result').length > options.maxTracesToShow)
197
- container.find('.profiler-result').first().remove();
198
- button.show();
199
- };
200
-
201
- var toggleHidden = function (popup) {
202
- var trivial = popup.find('.profiler-toggle-trivial');
203
- var childrenTime = popup.find('.profiler-toggle-duration-with-children');
204
- var trivialGaps = popup.parent().find('.profiler-toggle-trivial-gaps');
205
-
206
- var toggleIt = function (node) {
207
- var link = $(node),
208
- klass = "profiler-" + link.attr('class').substr('profiler-toggle-'.length),
209
- isHidden = link.text().indexOf('show') > -1;
210
-
211
- popup.parent().find('.' + klass).toggle(isHidden);
212
- link.text(link.text().replace(isHidden ? 'show' : 'hide', isHidden ? 'hide' : 'show'));
213
-
214
- popupPreventHorizontalScroll(popup);
215
- };
216
-
217
- childrenTime.add(trivial).add(trivialGaps).on('click', function () {
218
- toggleIt(this);
229
+ );
230
+ totalsControl = document.createElement("div");
231
+ totalsControl.setAttribute("class", "profiler-result");
232
+ totalsControl.innerHTML =
233
+ "<div class='profiler-button profiler-totals'></div>";
234
+ container.appendChild(totalsControl);
235
+ totalsControl.addEventListener("click", function() {
236
+ toArray(
237
+ totalsControl.parentNode.querySelectorAll(".profiler-result")
238
+ ).forEach(function(el) {
239
+ return (el.style.display = "block");
240
+ });
241
+ totalsControl.style.display = "none";
242
+ expandedResults = true;
219
243
  });
220
-
221
- // if option is set or all our timings are trivial, go ahead and show them
222
- if (options.showTrivial || trivial.data('show-on-load')) {
223
- toggleIt(trivial);
224
- }
225
- // if option is set, go ahead and show time with children
226
- if (options.showChildrenTime) {
227
- toggleIt(childrenTime);
228
- }
229
- };
230
-
231
- var buttonClick = function (button, popup) {
232
- // we're toggling this button/popup
233
- if (popup.is(':visible')) {
234
- popupHide(button, popup);
235
- }
236
- else {
237
- var visiblePopups = container.find('.profiler-popup:visible'),
238
- theirButtons = visiblePopups.siblings('.profiler-button');
239
-
240
- // hide any other popups
241
- popupHide(theirButtons, visiblePopups);
242
-
243
- // before showing the one we clicked
244
- popupShow(button, popup);
245
- }
246
- };
247
-
248
- var popupShow = function (button, popup) {
249
- button.addClass('profiler-button-active');
250
-
251
- popupSetDimensions(button, popup);
252
-
253
- popup.show();
254
-
255
- popupPreventHorizontalScroll(popup);
256
- };
257
-
258
- var popupSetDimensions = function (button, popup) {
259
- var px = button.position().top - 1, // position next to the button we clicked
260
- windowHeight = $(window).height(),
261
- maxHeight = windowHeight - 40; // make sure the popup doesn't extend below the fold
262
-
263
- popup
264
- .css(options.renderVerticalPosition, px)
265
- .css('max-height', maxHeight)
266
- .css(options.renderHorizontalPosition, button.outerWidth() - 3); // move left or right, based on config
267
- };
268
-
269
- var popupPreventHorizontalScroll = function (popup) {
270
- var childrenHeight = 0;
271
-
272
- popup.children().each(function () { childrenHeight += $(this).height(); });
273
-
274
- popup.css({ 'padding-right': childrenHeight > popup.height() ? 40 : 10 });
275
- };
276
-
277
- var popupHide = function (button, popup) {
278
- button.removeClass('profiler-button-active');
279
- popup.hide();
280
- };
281
-
282
- var queriesShow = function (link, result) {
283
-
284
- var px = 30,
285
- win = $(window),
286
- width = win.width() - 2 * px,
287
- height = win.height() - 2 * px,
288
- queries = result.find('.profiler-queries');
289
-
290
- // opaque background
291
- $('<div class="profiler-queries-bg"/>').appendTo('body').css({ 'height': $(document).height() }).show();
292
-
293
- // center the queries and ensure long content is scrolled
294
- queries.css(options.renderVerticalPosition, px).css({'max-height': height, 'width': width }).css(options.renderHorizontalPosition, px)
295
- .find('table').css({ 'width': width });
296
-
297
- // have to show everything before we can get a position for the first query
298
- queries.show();
299
-
300
- queriesScrollIntoView(link, queries, queries);
301
-
302
- // syntax highlighting
303
- prettyPrint();
244
+ toArray(totalsControl.querySelectorAll(".profiler-button")).forEach(
245
+ function(el) {
246
+ return (el.style.display = "block");
247
+ }
248
+ );
249
+ }
250
+
251
+ var reqsHtml =
252
+ reqs > 1 ? "<span class='profiler-reqs'>" + reqs + "</span>" : "";
253
+ var sqlHtml =
254
+ options.showTotalSqlCount && totalSqlCount > 0
255
+ ? " / <span class='profiler-number'>" +
256
+ totalSqlCount +
257
+ "</span> <span class='profiler-unit'>sql</span>"
258
+ : "";
259
+ totalsControl.querySelector(".profiler-button").innerHTML =
260
+ "<span class='profiler-number'>" +
261
+ totalTime.toFixed(1) +
262
+ "</span> <span class='profiler-unit'>ms</span>" +
263
+ sqlHtml +
264
+ reqsHtml;
265
+ result.style.display = "none";
266
+ }
267
+
268
+ if (controls) result.insertBefore(controls);
269
+ else container.appendChild(result);
270
+ var button = result.querySelector(".profiler-button"),
271
+ popup = result.querySelector(".profiler-popup"); // button will appear in corner with the total profiling duration - click to show details
272
+
273
+ button.addEventListener("click", function() {
274
+ buttonClick(button, popup);
275
+ }); // small duration steps and the column with aggregate durations are hidden by default; allow toggling
276
+
277
+ toggleHidden(popup); // lightbox in the queries
278
+
279
+ toArray(popup.querySelectorAll(".profiler-queries-show")).forEach(function(
280
+ el
281
+ ) {
282
+ el.addEventListener("click", function() {
283
+ queriesShow(this, result);
284
+ });
285
+ }); // limit count
286
+
287
+ if (
288
+ container.querySelectorAll(".profiler-result").length >
289
+ options.maxTracesToShow
290
+ ) {
291
+ var elem = container.querySelector(".profiler-result");
292
+
293
+ if (elem) {
294
+ elem.parentElement.removeChild(elem);
295
+ }
296
+ }
297
+
298
+ button.style.display = "block";
299
+ };
300
+
301
+ var toggleHidden = function toggleHidden(popup) {
302
+ var trivial = popup.querySelector(".profiler-toggle-trivial");
303
+ var childrenTime = popup.querySelector(
304
+ ".profiler-toggle-duration-with-children"
305
+ );
306
+ var trivialGaps = popup.parentNode.querySelector(
307
+ ".profiler-toggle-trivial-gaps"
308
+ );
309
+
310
+ var toggleIt = function toggleIt(node) {
311
+ var link = node,
312
+ klass =
313
+ "profiler-" +
314
+ link.getAttribute("class").substr("profiler-toggle-".length),
315
+ isHidden = link.textContent.indexOf("show") > -1;
316
+ var elements = toArray(popup.parentNode.querySelectorAll("." + klass));
317
+
318
+ if (isHidden) {
319
+ elements.forEach(function(el) {
320
+ return (el.style.display = "table-row");
321
+ });
322
+ } else {
323
+ elements.forEach(function(el) {
324
+ return (el.style.display = "none");
325
+ });
326
+ }
327
+
328
+ var text = link.textContent;
329
+ link.textContent = text.replace(
330
+ isHidden ? "show" : "hide",
331
+ isHidden ? "hide" : "show"
332
+ );
333
+ popupPreventHorizontalScroll(popup);
304
334
  };
305
335
 
306
- var queriesScrollIntoView = function (link, queries, whatToScroll) {
307
- var id = link.closest('tr').attr('data-timing-id'),
308
- cells = queries.find('tr[data-timing-id="' + id + '"]');
309
-
310
- // ensure they're in view
311
- whatToScroll.scrollTop(whatToScroll.scrollTop() + cells.first().position().top - 100);
312
-
313
- // highlight and then fade back to original bg color; do it ourselves to prevent any conflicts w/ jquery.UI or other implementations of Resig's color plugin
314
- cells.each(function () {
315
- var cell = $(this),
316
- highlightHex = '#FFFFBB',
317
- highlightRgb = getRGB(highlightHex),
318
- originalRgb = getRGB(cell.css('background-color')),
319
- getColorDiff = function (fx, i) {
320
- // adapted from John Resig's color plugin: http://plugins.jquery.com/project/color
321
- return Math.max(Math.min(parseInt((fx.pos * (originalRgb[i] - highlightRgb[i])) + highlightRgb[i], 10), 255), 0);
322
- };
323
-
324
- // we need to animate some other property to piggy-back on the step function, so I choose you, opacity!
325
- cell.css({ 'opacity': 1, 'background-color': highlightHex })
326
- .animate({ 'opacity': 1 }, { duration: 2000, step: function (now, fx) {
327
- fx.elem.style.backgroundColor = "rgb(" + [getColorDiff(fx, 0), getColorDiff(fx, 1), getColorDiff(fx, 2)].join(",") + ")";
328
- }
329
- });
336
+ [childrenTime, trivial, trivialGaps].forEach(function(el) {
337
+ if (el) {
338
+ el.addEventListener("click", function() {
339
+ toggleIt(this);
340
+ });
341
+ }
342
+ }); // if option is set or all our timings are trivial, go ahead and show them
343
+
344
+ if (
345
+ trivial &&
346
+ (options.showTrivial || trivial.getAttribute("show-on-load"))
347
+ ) {
348
+ toggleIt(trivial);
349
+ } // if option is set, go ahead and show time with children
350
+
351
+ if (childrenTime && options.showChildrenTime) {
352
+ toggleIt(childrenTime);
353
+ }
354
+ };
355
+
356
+ var toArray = function toArray(list) {
357
+ var arr = [];
358
+
359
+ if (!list) {
360
+ return arr;
361
+ }
362
+
363
+ for (var i = 0; i < list.length; i++) {
364
+ arr.push(list[i]);
365
+ }
366
+
367
+ return arr;
368
+ };
369
+
370
+ var buttonClick = function buttonClick(button, popup) {
371
+ // we're toggling this button/popup
372
+ if (popup.offsetWidth > 0 || popup.offsetHeight > 0) {
373
+ // if visible
374
+ popupHide(button, popup);
375
+ } else {
376
+ var visiblePopups = toArray(
377
+ container.querySelectorAll(".profiler-popup")
378
+ ).filter(function(el) {
379
+ return el.offsetWidth > 0 || el.offsetHeight > 0;
380
+ }); // theirButtons = visiblePopups.siblings(".profiler-button");
381
+
382
+ var theirButtons = [];
383
+ visiblePopups.forEach(function(el) {
384
+ theirButtons.push(el.parentNode.querySelector(".profiler-button"));
385
+ }); // hide any other popups
386
+
387
+ popupHide(theirButtons, visiblePopups); // before showing the one we clicked
388
+
389
+ popupShow(button, popup);
390
+ }
391
+ };
392
+
393
+ var popupShow = function popupShow(button, popup) {
394
+ button.classList.add("profiler-button-active");
395
+ popupSetDimensions(button, popup);
396
+ popup.style.display = "block";
397
+ popupPreventHorizontalScroll(popup);
398
+ };
399
+
400
+ var popupSetDimensions = function popupSetDimensions(button, popup) {
401
+ var px = button.offsetTop - 1,
402
+ // position next to the button we clicked
403
+ windowHeight = window.innerHeight,
404
+ maxHeight = windowHeight - px - 40; // make sure the popup doesn't extend below the fold
405
+
406
+ popup.style[options.renderVerticalPosition] = "".concat(px, "px");
407
+ popup.style.maxHeight = "".concat(maxHeight, "px");
408
+ popup.style[options.renderHorizontalPosition] = "".concat(
409
+ button.offsetWidth - 3,
410
+ "px"
411
+ ); // move left or right, based on config
412
+ };
413
+
414
+ var popupPreventHorizontalScroll = function popupPreventHorizontalScroll(
415
+ popup
416
+ ) {
417
+ var childrenHeight = 0;
418
+ toArray(popup.children).forEach(function(el) {
419
+ childrenHeight += el.offsetHeight;
420
+ });
421
+ popup.style.paddingRight = "".concat(
422
+ childrenHeight > popup.offsetHeight ? 40 : 10,
423
+ "px"
424
+ );
425
+ };
426
+
427
+ var popupHide = function popupHide(button, popup) {
428
+ if (button) {
429
+ if (Array.isArray(button)) {
430
+ button.forEach(function(el) {
431
+ return el.classList.remove("profiler-button-active");
432
+ });
433
+ } else {
434
+ button.classList.remove("profiler-button-active");
435
+ }
436
+ }
437
+
438
+ if (popup) {
439
+ if (Array.isArray(popup)) {
440
+ popup.forEach(function(el) {
441
+ return (el.style.display = "none");
330
442
  });
443
+ } else {
444
+ popup.style.display = "none";
445
+ }
446
+ }
447
+ };
448
+
449
+ var queriesShow = function queriesShow(link, result) {
450
+ result = result;
451
+ var px = 30,
452
+ win = window,
453
+ width = win.innerWidth - 2 * px,
454
+ height = win.innerHeight - 2 * px,
455
+ queries = result.querySelector(".profiler-queries"); // opaque background
456
+
457
+ var background = document.createElement("div");
458
+ background.classList.add("profiler-queries-bg");
459
+ document.body.appendChild(background);
460
+ background.style.height = "".concat(window.innerHeight, "px");
461
+ background.style.display = "block"; // center the queries and ensure long content is scrolled
462
+
463
+ queries.style[options.renderVerticalPosition] = "".concat(px, "px");
464
+ queries.style.maxHeight = "".concat(height, "px");
465
+ queries.style.width = "".concat(width, "px");
466
+ queries.style[options.renderHorizontalPosition] = "".concat(px, "px");
467
+ queries.querySelector("table").style.width = "".concat(width, "px"); // have to show everything before we can get a position for the first query
468
+
469
+ queries.style.display = "block";
470
+ queriesScrollIntoView(link, queries, queries); // syntax highlighting
471
+
472
+ prettyPrint();
473
+ };
474
+
475
+ var queriesScrollIntoView = function queriesScrollIntoView(
476
+ link,
477
+ queries,
478
+ whatToScroll
479
+ ) {
480
+ var id = elementClosest(link, "tr").getAttribute("data-timing-id"),
481
+ cells = toArray(
482
+ queries.querySelectorAll('tr[data-timing-id="' + id + '"]')
483
+ ); // ensure they're in view
484
+
485
+ whatToScroll.scrollTop =
486
+ (whatToScroll.scrollTop || 0) + cells[0].offsetTop - 100; // highlight and then fade back to original bg color; do it ourselves to prevent any conflicts w/ jquery.UI or other implementations of Resig's color plugin
487
+
488
+ cells.forEach(function(el) {
489
+ el.classList.add("higlight-animate");
490
+ });
491
+ setTimeout(function() {
492
+ cells.forEach(function(el) {
493
+ return el.classList.remove("higlight-animate");
494
+ });
495
+ }, 3000);
496
+ };
497
+
498
+ var onClickEvents = function onClickEvents(e) {
499
+ // this happens on every keystroke, and :visible is crazy expensive in IE <9
500
+ // and in this case, the display:none check is sufficient.
501
+ var popup = toArray(document.querySelectorAll(".profiler-popup")).filter(
502
+ function(el) {
503
+ return el.style.display === "block";
504
+ }
505
+ );
506
+
507
+ if (!popup.length) {
508
+ return;
509
+ }
510
+
511
+ popup = popup[0];
512
+ var button = popup.parentNode.querySelector(".profiler-button"),
513
+ queries = elementClosest(popup, ".profiler-result").querySelector(
514
+ ".profiler-queries"
515
+ ),
516
+ bg = document.querySelector(".profiler-queries-bg"),
517
+ isEscPress = e.type == "keyup" && e.which == 27,
518
+ hidePopup = false,
519
+ hideQueries = false;
520
+
521
+ if (bg && bg.style.display === "block") {
522
+ hideQueries =
523
+ isEscPress ||
524
+ (e.type == "click" &&
525
+ !(queries !== e.target && queries.contains(e.target)) &&
526
+ !(popup !== e.target && popup.contains(e.target)));
527
+ } else if (popup.style.display === "block") {
528
+ hidePopup =
529
+ isEscPress ||
530
+ (e.type == "click" &&
531
+ !(popup !== e.target && popup.contains(e.target)) &&
532
+ !(button !== e.target && button.contains(e.target)) &&
533
+ button != e.target);
534
+ }
535
+
536
+ if (hideQueries) {
537
+ bg.parentElement.removeChild(bg);
538
+ queries.style.display = "none";
539
+ }
540
+
541
+ if (hidePopup) {
542
+ popupHide(button, popup);
543
+ }
544
+ };
545
+
546
+ var keydownEvent = function keydownEvent() {
547
+ var results = document.querySelector(".profiler-results");
548
+
549
+ if (results.style.display === "none") {
550
+ results.style.display = "block";
551
+ } else {
552
+ results.style.display = "none";
553
+ }
554
+
555
+ sessionStorage["rack-mini-profiler-start-hidden"] =
556
+ results.style.display === "none";
557
+ };
558
+
559
+ var toggleShortcutEvent = function toggleShortcutEvent(e) {
560
+ // simplified version of https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
561
+ var shortcut = options.toggleShortcut.toLowerCase();
562
+ var modifier = "";
563
+ ["alt", "ctrl", "shift"].forEach(function(k) {
564
+ if (e[k + "Key"]) {
565
+ modifier += "".concat(k, "+");
566
+ }
567
+ });
568
+ var specialKeys = {
569
+ 8: "backspace",
570
+ 9: "tab",
571
+ 10: "return",
572
+ 13: "return",
573
+ 16: "shift",
574
+ 17: "ctrl",
575
+ 18: "alt",
576
+ 27: "esc",
577
+ 32: "space",
578
+ 59: ";",
579
+ 61: "=",
580
+ 96: "0",
581
+ 97: "1",
582
+ 98: "2",
583
+ 99: "3",
584
+ 100: "4",
585
+ 101: "5",
586
+ 102: "6",
587
+ 103: "7",
588
+ 104: "8",
589
+ 105: "9",
590
+ 106: "*",
591
+ 107: "+",
592
+ 109: "-",
593
+ 110: ".",
594
+ 173: "-",
595
+ 186: ";",
596
+ 187: "="
331
597
  };
332
-
333
- // Color Conversion functions from highlightFade
334
- // By Blair Mitchelmore
335
- // http://jquery.offput.ca/highlightFade/
336
- // Parse strings looking for color tuples [255,255,255]
337
- var getRGB = function (color) {
338
- var result;
339
-
340
- // Check if we're already dealing with an array of colors
341
- if (color && color.constructor == Array && color.length == 3) return color;
342
-
343
- // Look for rgb(num,num,num)
344
- if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
345
-
346
- // Look for rgb(num%,num%,num%)
347
- if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) return [parseFloat(result[1]) * 2.55, parseFloat(result[2]) * 2.55, parseFloat(result[3]) * 2.55];
348
-
349
- // Look for #a0b1c2
350
- if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];
351
-
352
- // Look for #fff
353
- if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];
354
-
355
- // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
356
- if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) return [0,0,0,0];
357
-
358
- return null;
598
+ var shiftNums = {
599
+ "`": "~",
600
+ "1": "!",
601
+ "2": "@",
602
+ "3": "#",
603
+ "4": "$",
604
+ "5": "%",
605
+ "6": "^",
606
+ "7": "&",
607
+ "8": "*",
608
+ "9": "(",
609
+ "0": ")",
610
+ "-": "_",
611
+ "=": "+",
612
+ ";": ": ",
613
+ "'": '"',
614
+ ",": "<",
615
+ ".": ">",
616
+ "/": "?",
617
+ "\\": "|"
359
618
  };
360
-
361
- var bindDocumentEvents = function () {
362
- $(document).on('click.mini-profiler keyup.mini-profiler', function (e) {
363
-
364
- // this happens on every keystroke, and :visible is crazy expensive in IE <9
365
- // and in this case, the display:none check is sufficient.
366
- var popup = $('.profiler-popup').filter(function () { return $(this).css("display") !== "none"; });
367
-
368
- if (!popup.length) {
369
- return;
619
+ var character = String.fromCharCode(e.which).toLowerCase();
620
+ var special = specialKeys[e.which];
621
+ var keys = [];
622
+
623
+ if (special) {
624
+ keys.push(special);
625
+ } else {
626
+ keys.push(character);
627
+ keys.push(shiftNums[character]);
628
+ }
629
+
630
+ for (var i = 0; i < keys.length; i++) {
631
+ if (modifier + keys[i] === shortcut) {
632
+ keydownEvent();
633
+ break;
634
+ }
635
+ }
636
+ };
637
+
638
+ var turbolinksSkipResultsFetch = function turbolinksSkipResultsFetch(event) {
639
+ event.data.xhr.__miniProfilerSkipResultsFetch = true;
640
+ };
641
+
642
+ var bindDocumentEvents = function bindDocumentEvents() {
643
+ document.addEventListener("click", onClickEvents);
644
+ document.addEventListener("keyup", onClickEvents);
645
+ document.addEventListener("keyup", toggleShortcutEvent);
646
+
647
+ if (typeof Turbolinks !== "undefined" && Turbolinks.supported) {
648
+ document.addEventListener("page:change", unbindDocumentEvents);
649
+ document.addEventListener("turbolinks:load", unbindDocumentEvents);
650
+ document.addEventListener(
651
+ "turbolinks:request-start",
652
+ turbolinksSkipResultsFetch
653
+ );
654
+ }
655
+ };
656
+
657
+ var unbindDocumentEvents = function unbindDocumentEvents() {
658
+ document.removeEventListener("click", onClickEvents);
659
+ document.removeEventListener("keyup", onClickEvents);
660
+ document.removeEventListener("keyup", toggleShortcutEvent);
661
+ document.removeEventListener("page:change", unbindDocumentEvents);
662
+ document.removeEventListener("turbolinks:load", unbindDocumentEvents);
663
+ document.removeEventListener(
664
+ "turbolinks:request-start",
665
+ turbolinksSkipResultsFetch
666
+ );
667
+ };
668
+
669
+ var initFullView = function initFullView() {
670
+ // profiler will be defined in the full page's head
671
+ container[0].appendChild(renderTemplate(profiler));
672
+ var popup = document.querySelector(".profiler-popup");
673
+ toggleHidden(popup);
674
+ prettyPrint(); // since queries are already shown, just highlight and scroll when clicking a "1 sql" link
675
+
676
+ toArray(popup.querySelectorAll(".profiler-queries-show")).forEach(function(
677
+ el
678
+ ) {
679
+ el.addEventListener("click", function() {
680
+ queriesScrollIntoView(
681
+ this,
682
+ document.querySelector(".profiler-queries"),
683
+ document.body
684
+ );
685
+ });
686
+ });
687
+ };
688
+
689
+ var initSnapshots = function initSnapshots(dataElement) {
690
+ var data = JSON.parse(dataElement.textContent);
691
+ var temp = document.createElement("DIV");
692
+ if (data.page === "overview") {
693
+ temp.innerHTML = MiniProfiler.templates.snapshotsGroupsList(data);
694
+ } else if (data.group_name) {
695
+ var allCustomFieldsNames = [];
696
+ data.list.forEach(function(snapshot) {
697
+ Object.keys(snapshot.custom_fields).forEach(function(k) {
698
+ if (
699
+ allCustomFieldsNames.indexOf(k) === -1 &&
700
+ options.hiddenCustomFields.indexOf(k.toLowerCase()) === -1
701
+ ) {
702
+ allCustomFieldsNames.push(k);
703
+ }
704
+ });
705
+ });
706
+ allCustomFieldsNames.sort();
707
+ temp.innerHTML = MiniProfiler.templates.snapshotsList({
708
+ data: data,
709
+ allCustomFieldsNames: allCustomFieldsNames
710
+ });
711
+ }
712
+ Array.from(temp.children).forEach(function(child) {
713
+ document.body.appendChild(child);
714
+ });
715
+ };
716
+
717
+ var initControls = function initControls(container) {
718
+ if (options.showControls) {
719
+ var _controls = document.createElement("div");
720
+
721
+ _controls.classList.add("profiler-controls");
722
+
723
+ _controls.innerHTML =
724
+ '<span class="profiler-min-max">m</span><span class="profiler-clear">c</span>';
725
+ container.appendChild(_controls);
726
+ document
727
+ .querySelector(".profiler-controls .profiler-min-max")
728
+ .addEventListener("click", function() {
729
+ return toggleClass(container, "profiler-min");
730
+ });
731
+ container.addEventListener("mouseenter", function() {
732
+ if (this.classList.contains("profiler-min")) {
733
+ this.querySelector(".profiler-min-max").style.display = "block";
734
+ }
735
+ });
736
+ container.addEventListener("mouseleave", function() {
737
+ if (this.classList.contains("profiler-min")) {
738
+ this.querySelector(".profiler-min-max").style.display = "none";
739
+ }
740
+ });
741
+ document
742
+ .querySelector(".profiler-controls .profiler-clear")
743
+ .addEventListener("click", function() {
744
+ toArray(container.querySelectorAll(".profiler-result")).forEach(
745
+ function(el) {
746
+ return el.parentElement.removeChild(el);
370
747
  }
748
+ );
749
+ });
750
+ } else {
751
+ container.classList.add("profiler-no-controls");
752
+ }
753
+ };
754
+
755
+ var toggleClass = function toggleClass(el, className) {
756
+ if (el.classList) {
757
+ el.classList.toggle(className);
758
+ } else {
759
+ var classes = el.className.split(" ");
760
+ var existingIndex = classes.indexOf(className);
761
+ if (existingIndex >= 0) classes.splice(existingIndex, 1);
762
+ else classes.push(className);
763
+ el.className = classes.join(" ");
764
+ }
765
+ };
766
+
767
+ var initPopupView = function initPopupView() {
768
+ if (options.authorized) {
769
+ // all fetched profilings will go in here
770
+ container = document.createElement("div");
771
+ container.className = "profiler-results";
772
+ document.querySelector(options.htmlContainer).appendChild(container); // MiniProfiler.RenderIncludes() sets which corner to render in - default is upper left
773
+
774
+ container.classList.add("profiler-" + options.renderHorizontalPosition);
775
+ container.classList.add("profiler-" + options.renderVerticalPosition); //initialize the controls
776
+
777
+ initControls(container);
778
+ fetchResults(options.ids);
779
+
780
+ if (options.startHidden) container.style.display = "none";
781
+ } else {
782
+ fetchResults(options.ids);
783
+ }
784
+
785
+ if (!window.MiniProfiler || !window.MiniProfiler.patchesApplied) {
786
+ var send = XMLHttpRequest.prototype.send;
787
+
788
+ XMLHttpRequest.prototype.send = function(data) {
789
+ ajaxStartTime = new Date();
790
+ this.addEventListener("load", function() {
791
+ // responseURL isn't available in IE11
792
+ if (
793
+ this.responseURL &&
794
+ this.responseURL.indexOf(window.location.origin) !== 0
795
+ ) {
796
+ return;
797
+ }
798
+ if (this.__miniProfilerSkipResultsFetch) {
799
+ return;
800
+ }
801
+ // getAllResponseHeaders isn't available in Edge.
802
+ var allHeaders = this.getAllResponseHeaders
803
+ ? this.getAllResponseHeaders()
804
+ : null;
805
+ if (
806
+ allHeaders &&
807
+ allHeaders.toLowerCase().indexOf("x-miniprofiler-ids") === -1
808
+ ) {
809
+ return;
810
+ }
811
+ // should be a string of comma-separated ids
812
+ var stringIds = this.getResponseHeader("X-MiniProfiler-Ids");
371
813
 
372
- var button = popup.siblings('.profiler-button'),
373
- queries = popup.closest('.profiler-result').find('.profiler-queries'),
374
- bg = $('.profiler-queries-bg'),
375
- isEscPress = e.type == 'keyup' && e.which == 27,
376
- hidePopup = false,
377
- hideQueries = false;
814
+ if (stringIds) {
815
+ var ids = stringIds.split(",");
816
+ fetchResults(ids);
817
+ }
818
+ });
819
+ send.call(this, data);
820
+ }; // fetch results after ASP Ajax calls
821
+
822
+ if (
823
+ typeof Sys != "undefined" &&
824
+ typeof Sys.WebForms != "undefined" &&
825
+ typeof Sys.WebForms.PageRequestManager != "undefined"
826
+ ) {
827
+ // Get the instance of PageRequestManager.
828
+ var PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
829
+ PageRequestManager.add_endRequest(function(sender, args) {
830
+ if (args) {
831
+ var response = args.get_response();
832
+
833
+ if (
834
+ response.get_responseAvailable() &&
835
+ response._xmlHttpRequest !== null
836
+ ) {
837
+ var stringIds = args
838
+ .get_response()
839
+ .getResponseHeader("X-MiniProfiler-Ids");
378
840
 
379
- if (bg.is(':visible')) {
380
- hideQueries = isEscPress || (e.type == 'click' && !$.contains(queries[0], e.target) && !$.contains(popup[0], e.target));
841
+ if (stringIds) {
842
+ var ids = stringIds.split(",");
843
+ fetchResults(ids);
844
+ }
381
845
  }
382
- else if (popup.is(':visible')) {
383
- hidePopup = isEscPress || (e.type == 'click' && !$.contains(popup[0], e.target) && !$.contains(button[0], e.target) && button[0] != e.target);
846
+ }
847
+ });
848
+ } // more Asp.Net callbacks
849
+
850
+ if (typeof WebForm_ExecuteCallback == "function") {
851
+ WebForm_ExecuteCallback = (function(callbackObject) {
852
+ // Store original function
853
+ var original = WebForm_ExecuteCallback;
854
+ return function(callbackObject) {
855
+ original(callbackObject);
856
+ var stringIds = callbackObject.xmlRequest.getResponseHeader(
857
+ "X-MiniProfiler-Ids"
858
+ );
859
+
860
+ if (stringIds) {
861
+ var ids = stringIds.split(",");
862
+ fetchResults(ids);
384
863
  }
864
+ };
865
+ })();
866
+ } // also fetch results after ExtJS requests, in case it is being used
867
+
868
+ if (
869
+ typeof Ext != "undefined" &&
870
+ typeof Ext.Ajax != "undefined" &&
871
+ typeof Ext.Ajax.on != "undefined"
872
+ ) {
873
+ // Ext.Ajax is a singleton, so we just have to attach to its 'requestcomplete' event
874
+ Ext.Ajax.on("requestcomplete", function(e, xhr, settings) {
875
+ //iframed file uploads don't have headers
876
+ if (!xhr || !xhr.getResponseHeader) {
877
+ return;
878
+ }
385
879
 
386
- if (hideQueries) {
387
- bg.remove();
388
- queries.hide();
389
- }
880
+ var stringIds = xhr.getResponseHeader("X-MiniProfiler-Ids");
390
881
 
391
- if (hidePopup) {
392
- popupHide(button, popup);
393
- }
394
- });
395
- $(document).on('keydown.mini-profiler', null, options.toggleShortcut, function(e) {
396
- $('.profiler-results').toggle();
397
- sessionStorage['rack-mini-profiler-start-hidden'] = $('.profiler-results').is(':hidden');
882
+ if (stringIds) {
883
+ var ids = stringIds.split(",");
884
+ fetchResults(ids);
885
+ }
398
886
  });
887
+ }
399
888
 
400
- if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
401
- $(document).on('page:change.mini-profiler turbolinks:load.mini-profiler', function() {
402
- unbindDocumentEvents();
403
- });
404
- }
405
- };
406
-
407
- var unbindDocumentEvents = function() {
408
- $(document).off('.mini-profiler');
409
- };
410
-
411
- var initFullView = function () {
412
-
413
- // first, get jquery tmpl, then render and bind handlers
414
- fetchTemplates(function () {
415
-
416
- // profiler will be defined in the full page's head
417
- renderTemplate(profiler).appendTo(container);
418
-
419
- var popup = $('.profiler-popup');
889
+ if (typeof MooTools != "undefined" && typeof Request != "undefined") {
890
+ Request.prototype.addEvents({
891
+ onComplete: function onComplete() {
892
+ var stringIds = this.xhr.getResponseHeader("X-MiniProfiler-Ids");
420
893
 
421
- toggleHidden(popup);
422
-
423
- prettyPrint();
424
-
425
- // since queries are already shown, just highlight and scroll when clicking a "1 sql" link
426
- popup.find('.profiler-queries-show').on('click', function () {
427
- queriesScrollIntoView($(this), $('.profiler-queries'), $(document));
428
- });
894
+ if (stringIds) {
895
+ var ids = stringIds.split(",");
896
+ fetchResults(ids);
897
+ }
898
+ }
429
899
  });
430
- };
431
-
432
- var initControls = function (container) {
433
- if (options.showControls) {
434
- controls = $('<div class="profiler-controls"><span class="profiler-min-max">m</span><span class="profiler-clear">c</span></div>').appendTo(container);
900
+ } // add support for AngularJS, which use the basic XMLHttpRequest object.
901
+
902
+ if (window.angular && typeof XMLHttpRequest != "undefined") {
903
+ var _send = XMLHttpRequest.prototype.send;
904
+
905
+ XMLHttpRequest.prototype.send = function sendReplacement(data) {
906
+ if (this.onreadystatechange) {
907
+ if (
908
+ typeof this.miniprofiler == "undefined" ||
909
+ typeof this.miniprofiler.prev_onreadystatechange == "undefined"
910
+ ) {
911
+ this.miniprofiler = {
912
+ prev_onreadystatechange: this.onreadystatechange
913
+ };
914
+
915
+ this.onreadystatechange = function onReadyStateChangeReplacement() {
916
+ if (this.readyState == 4) {
917
+ var stringIds = this.getResponseHeader("X-MiniProfiler-Ids");
918
+
919
+ if (stringIds) {
920
+ var ids = stringIds.split(",");
921
+ fetchResults(ids);
922
+ }
923
+ }
435
924
 
436
- $('.profiler-controls .profiler-min-max').on('click', function () {
437
- container.toggleClass('profiler-min');
438
- });
925
+ if (this.miniprofiler.prev_onreadystatechange !== null)
926
+ return this.miniprofiler.prev_onreadystatechange.apply(
927
+ this,
928
+ arguments
929
+ );
930
+ };
931
+ }
932
+ }
439
933
 
440
- container.hover(function () {
441
- if ($(this).hasClass('profiler-min')) {
442
- $(this).find('.profiler-min-max').show();
934
+ return _send.apply(this, arguments);
935
+ };
936
+ } // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
937
+
938
+ if (typeof window.fetch === "function") {
939
+ var __originalFetch = window.fetch;
940
+
941
+ window.fetch = function(input, init) {
942
+ var originalFetchRun = __originalFetch(input, init);
943
+
944
+ originalFetchRun.then(function(response) {
945
+ try {
946
+ // look for x-mini-profile-ids
947
+ var entries = response.headers.entries();
948
+ var _iteratorNormalCompletion = true;
949
+ var _didIteratorError = false;
950
+ var _iteratorError = undefined;
951
+
952
+ try {
953
+ for (
954
+ var _iterator = entries[Symbol.iterator](), _step;
955
+ !(_iteratorNormalCompletion = (_step = _iterator.next())
956
+ .done);
957
+ _iteratorNormalCompletion = true
958
+ ) {
959
+ var pair = _step.value;
960
+
961
+ if (
962
+ pair[0] &&
963
+ pair[0].toLowerCase() == "x-miniprofiler-ids"
964
+ ) {
965
+ var ids = pair[1].split(",");
966
+ fetchResults(ids);
967
+ }
443
968
  }
444
- },
445
- function () {
446
- if ($(this).hasClass('profiler-min')) {
447
- $(this).find('.profiler-min-max').hide();
969
+ } catch (err) {
970
+ _didIteratorError = true;
971
+ _iteratorError = err;
972
+ } finally {
973
+ try {
974
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
975
+ _iterator.return();
976
+ }
977
+ } finally {
978
+ if (_didIteratorError) {
979
+ throw _iteratorError;
980
+ }
448
981
  }
449
- });
450
-
451
- $('.profiler-controls .profiler-clear').on('click', function () {
452
- container.find('.profiler-result').remove();
453
- });
454
- }
455
- else {
456
- container.addClass('profiler-no-controls');
982
+ }
983
+ } catch (e) {
984
+ console.error(e);
985
+ }
986
+ });
987
+ return originalFetchRun;
988
+ };
989
+ }
990
+ window.MiniProfiler.patchesApplied = true;
991
+ }
992
+
993
+ bindDocumentEvents();
994
+ };
995
+
996
+ return {
997
+ fetchedIds: fetchedIds,
998
+ fetchingIds: fetchingIds,
999
+ init: function init() {
1000
+ var script = document.getElementById("mini-profiler");
1001
+ if (!script || !script.getAttribute) return;
1002
+
1003
+ this.options = options = (function() {
1004
+ var version = script.getAttribute("data-version");
1005
+ var path = script.getAttribute("data-path");
1006
+ var currentId = script.getAttribute("data-current-id");
1007
+ var ids = script.getAttribute("data-ids");
1008
+ if (ids) ids = ids.split(",");
1009
+ var horizontal_position = script.getAttribute(
1010
+ "data-horizontal-position"
1011
+ );
1012
+ var vertical_position = script.getAttribute("data-vertical-position");
1013
+ var toggleShortcut = script.getAttribute("data-toggle-shortcut");
1014
+
1015
+ if (script.getAttribute("data-max-traces")) {
1016
+ var maxTraces = parseInt(script.getAttribute("data-max-traces"), 10);
457
1017
  }
458
- };
459
1018
 
460
- var initPopupView = function () {
1019
+ var collapseResults =
1020
+ script.getAttribute("data-collapse-results") === "true";
1021
+ var trivial = script.getAttribute("data-trivial") === "true";
1022
+ var children = script.getAttribute("data-children") === "true";
1023
+ var controls = script.getAttribute("data-controls") === "true";
1024
+ var totalSqlCount =
1025
+ script.getAttribute("data-total-sql-count") === "true";
1026
+ var authorized = script.getAttribute("data-authorized") === "true";
1027
+ var startHidden =
1028
+ script.getAttribute("data-start-hidden") === "true" ||
1029
+ sessionStorage["rack-mini-profiler-start-hidden"] === "true";
1030
+ var htmlContainer = script.getAttribute("data-html-container");
1031
+ var cssUrl = script.getAttribute("data-css-url");
1032
+ var hiddenCustomFields = script
1033
+ .getAttribute("data-hidden-custom-fields")
1034
+ .toLowerCase()
1035
+ .split(",");
1036
+ return {
1037
+ ids: ids,
1038
+ path: path,
1039
+ version: version,
1040
+ renderHorizontalPosition: horizontal_position,
1041
+ renderVerticalPosition: vertical_position,
1042
+ showTrivial: trivial,
1043
+ showChildrenTime: children,
1044
+ maxTracesToShow: maxTraces,
1045
+ showControls: controls,
1046
+ showTotalSqlCount: totalSqlCount,
1047
+ currentId: currentId,
1048
+ authorized: authorized,
1049
+ toggleShortcut: toggleShortcut,
1050
+ startHidden: startHidden,
1051
+ collapseResults: collapseResults,
1052
+ htmlContainer: htmlContainer,
1053
+ cssUrl: cssUrl,
1054
+ hiddenCustomFields: hiddenCustomFields
1055
+ };
1056
+ })();
461
1057
 
462
- if (options.authorized) {
463
- // all fetched profilings will go in here
464
- container = $('<div class="profiler-results"/>').appendTo(options.htmlContainer);
1058
+ var doInit = function doInit() {
1059
+ var snapshotsElement = document.getElementById("snapshots-data");
1060
+ if (snapshotsElement != null) {
1061
+ initSnapshots(snapshotsElement);
1062
+ return;
1063
+ }
465
1064
 
466
- // MiniProfiler.RenderIncludes() sets which corner to render in - default is upper left
467
- container.addClass("profiler-" + options.renderHorizontalPosition);
468
- container.addClass("profiler-" + options.renderVerticalPosition);
1065
+ // when rendering a shared, full page, this div will exist
1066
+ container = document.querySelectorAll(".profiler-result-full");
469
1067
 
470
- //initialize the controls
471
- initControls(container);
1068
+ if (container.length) {
1069
+ if (window.location.href.indexOf("&trivial=1") > 0) {
1070
+ options.showTrivial = true;
1071
+ }
472
1072
 
473
- // we'll render results json via a jquery.tmpl - after we get the templates, we'll fetch the initial json to populate it
474
- fetchTemplates(function () {
475
- // get master page profiler results
476
- fetchResults(options.ids);
477
- });
478
- if (options.startHidden) container.hide();
1073
+ initFullView();
1074
+ } else {
1075
+ initPopupView();
479
1076
  }
480
- else {
481
- fetchResults(options.ids);
482
- }
483
-
484
- var jQueryAjaxComplete = function (e, xhr, settings) {
485
- if (xhr) {
486
- // should be an array of strings, e.g. ["008c4813-9bd7-443d-9376-9441ec4d6a8c","16ff377b-8b9c-4c20-a7b5-97cd9fa7eea7"]
487
- var stringIds = xhr.getResponseHeader('X-MiniProfiler-Ids');
488
- if (stringIds) {
489
- var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
490
- fetchResults(ids);
491
- }
1077
+ }; // this preserves debugging
1078
+
1079
+ var load = function load(s, f) {
1080
+ var sc = document.createElement("script");
1081
+ sc.async = "async";
1082
+ sc.type = "text/javascript";
1083
+ sc.src = s;
1084
+ var done = false;
1085
+
1086
+ sc.onload = sc.onreadystatechange = function(_, abort) {
1087
+ if (!sc.readyState || /loaded|complete/.test(sc.readyState)) {
1088
+ if (!abort && !done) {
1089
+ done = true;
1090
+ f();
492
1091
  }
1092
+ }
493
1093
  };
494
1094
 
495
- // fetch profile results for any ajax calls
496
- // note, this does not use $ cause we want to hook into the main jQuery
497
- if (jQuery && jQuery(document) && jQuery(document).ajaxComplete) {
498
- jQuery(document).on('ajaxComplete.mini-profiler', jQueryAjaxComplete);
1095
+ document.getElementsByTagName("head")[0].appendChild(sc);
1096
+ };
1097
+
1098
+ var wait = 0;
1099
+ var finish = false;
1100
+
1101
+ var deferInit = function deferInit() {
1102
+ if (finish) return;
1103
+
1104
+ if (
1105
+ window.performance &&
1106
+ window.performance.timing &&
1107
+ window.performance.timing.loadEventEnd === 0 &&
1108
+ wait < 10000
1109
+ ) {
1110
+ setTimeout(deferInit, 100);
1111
+ wait += 100;
1112
+ } else {
1113
+ finish = true;
1114
+ init();
499
1115
  }
1116
+ };
500
1117
 
501
- if (jQuery && jQuery(document).ajaxStart)
502
- jQuery(document).on('ajaxStart.mini-profiler', function () { ajaxStartTime = new Date(); });
503
-
504
- // fetch results after ASP Ajax calls
505
- if (typeof (Sys) != 'undefined' && typeof (Sys.WebForms) != 'undefined' && typeof (Sys.WebForms.PageRequestManager) != 'undefined') {
506
- // Get the instance of PageRequestManager.
507
- var PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
508
-
509
- PageRequestManager.add_endRequest(function (sender, args) {
510
- if (args) {
511
- var response = args.get_response();
512
- if (response.get_responseAvailable() && response._xmlHttpRequest !== null) {
513
- var stringIds = args.get_response().getResponseHeader('X-MiniProfiler-Ids');
514
- if (stringIds) {
515
- var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
516
- fetchResults(ids);
517
- }
518
- }
519
- }
520
- });
521
- }
522
-
523
- // more Asp.Net callbacks
524
- if (typeof (WebForm_ExecuteCallback) == "function") {
525
- WebForm_ExecuteCallback = (function (callbackObject) {
526
- // Store original function
527
- var original = WebForm_ExecuteCallback;
528
-
529
- return function (callbackObject) {
530
- original(callbackObject);
531
-
532
- var stringIds = callbackObject.xmlRequest.getResponseHeader('X-MiniProfiler-Ids');
533
- if (stringIds) {
534
- var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
535
- fetchResults(ids);
536
- }
537
- };
1118
+ var init = function init() {
1119
+ if (options.authorized) {
1120
+ var url = options.cssUrl;
1121
+
1122
+ if (document.createStyleSheet) {
1123
+ document.createStyleSheet(url);
1124
+ } else {
1125
+ var head = document.querySelector("head");
1126
+ var link = document.createElement("link");
1127
+ link.rel = "stylesheet";
1128
+ link.type = "text/css";
1129
+ link.href = url;
1130
+ head.appendChild(link);
1131
+ }
538
1132
 
539
- })();
1133
+ if (!MiniProfiler.loadedVendor) {
1134
+ load(options.path + "vendor.js?v=" + options.version, doInit);
1135
+ } else {
1136
+ doInit();
1137
+ }
1138
+ } else {
1139
+ doInit();
540
1140
  }
541
-
542
- // also fetch results after ExtJS requests, in case it is being used
543
- if (typeof (Ext) != 'undefined' && typeof (Ext.Ajax) != 'undefined' && typeof (Ext.Ajax.on) != 'undefined') {
544
- // Ext.Ajax is a singleton, so we just have to attach to its 'requestcomplete' event
545
- Ext.Ajax.on('requestcomplete', function (e, xhr, settings) {
546
- //iframed file uploads don't have headers
547
- if (!xhr || !xhr.getResponseHeader) {
548
- return;
549
- }
550
-
551
- var stringIds = xhr.getResponseHeader('X-MiniProfiler-Ids');
552
- if (stringIds) {
553
- var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
554
- fetchResults(ids);
555
- }
556
- });
1141
+ };
1142
+
1143
+ deferInit();
1144
+ },
1145
+ cleanUp: function cleanUp() {
1146
+ unbindDocumentEvents();
1147
+ },
1148
+ pageTransition: function pageTransition() {
1149
+ if (totalsControl) {
1150
+ if (totalsControl.parentElement) {
1151
+ totalsControl.parentElement.removeChild(totalsControl);
1152
+ }
1153
+ totalsControl = null;
1154
+ }
1155
+
1156
+ reqs = 0;
1157
+ totalTime = 0;
1158
+ expandedResults = false;
1159
+ toArray(
1160
+ document.querySelectorAll(".profiler-results .profiler-result")
1161
+ ).forEach(function(el) {
1162
+ return el.parentElement.removeChild(el);
1163
+ });
1164
+ },
1165
+ getClientTimingByName: function getClientTimingByName(clientTiming, name) {
1166
+ for (var i = 0; i < clientTiming.timings.length; i++) {
1167
+ if (clientTiming.timings[i].name == name) {
1168
+ return clientTiming.timings[i];
557
1169
  }
1170
+ }
1171
+
1172
+ return {
1173
+ Name: name,
1174
+ Duration: "",
1175
+ Start: ""
1176
+ };
1177
+ },
1178
+ renderDate: function renderDate(jsonDate) {
1179
+ // JavaScriptSerializer sends dates as /Date(1308024322065)/
1180
+ if (jsonDate) {
1181
+ return typeof jsonDate === "string"
1182
+ ? new Date(
1183
+ parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10)
1184
+ ).toUTCString()
1185
+ : jsonDate;
1186
+ }
1187
+ },
1188
+ renderIndent: function renderIndent(depth) {
1189
+ var result = "";
1190
+
1191
+ for (var i = 0; i < depth; i++) {
1192
+ result += "&nbsp;";
1193
+ }
1194
+
1195
+ return result;
1196
+ },
1197
+ renderExecuteType: function renderExecuteType(typeId) {
1198
+ // see StackExchange.Profiling.ExecuteType enum
1199
+ switch (typeId) {
1200
+ case 0:
1201
+ return "None";
1202
+
1203
+ case 1:
1204
+ return "NonQuery";
1205
+
1206
+ case 2:
1207
+ return "Scalar";
1208
+
1209
+ case 3:
1210
+ return "Reader";
1211
+ }
1212
+ },
1213
+ shareUrl: function shareUrl(id) {
1214
+ return options.path + "results?id=" + id;
1215
+ },
1216
+ flamegraphUrl: function flamegrapgUrl(id) {
1217
+ return options.path + "flamegraph?id=" + id;
1218
+ },
1219
+ moreUrl: function moreUrl(requestName) {
1220
+ var requestParts = requestName.split(" ");
1221
+ var linkSrc =
1222
+ requestParts[0] == "GET" ? requestParts[1] : window.location.href;
1223
+ var linkSuffix = linkSrc.indexOf("?") > 0 ? "&pp=help" : "?pp=help";
1224
+ return linkSrc + linkSuffix;
1225
+ },
1226
+ getClientTimings: function getClientTimings(clientTimings) {
1227
+ var list = [];
1228
+ var t;
1229
+ if (!clientTimings.timings) return [];
1230
+
1231
+ for (var i = 0; i < clientTimings.timings.length; i++) {
1232
+ t = clientTimings.timings[i];
1233
+ var trivial = t.Name != "Dom Complete" && t.Name != "Response";
1234
+ trivial = t.Duration < 2 ? trivial : false;
1235
+ list.push({
1236
+ isTrivial: trivial,
1237
+ name: t.Name,
1238
+ duration: t.Duration,
1239
+ start: t.Start
1240
+ });
1241
+ } // Use the Paint Timing API for render performance.
558
1242
 
559
- if (typeof (MooTools) != 'undefined' && typeof (Request) != 'undefined') {
560
- Request.prototype.addEvents({
561
- onComplete: function() {
562
- var stringIds = this.xhr.getResponseHeader('X-MiniProfiler-Ids');
563
- if (stringIds) {
564
- var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
565
- fetchResults(ids);
566
- }
567
- }
1243
+ if (window.performance && window.performance.getEntriesByName) {
1244
+ var firstPaint = window.performance.getEntriesByName("first-paint");
1245
+
1246
+ if (firstPaint !== undefined && firstPaint.length >= 1) {
1247
+ list.push({
1248
+ isTrivial: false,
1249
+ name: "First Paint Time",
1250
+ duration: firstPaint[0].duration,
1251
+ start: firstPaint[0].startTime
568
1252
  });
569
1253
  }
1254
+ }
1255
+
1256
+ list.sort(function(a, b) {
1257
+ return a.start - b.start;
1258
+ });
1259
+ return list;
1260
+ },
1261
+ getSqlTimings: function getSqlTimings(root) {
1262
+ var result = [],
1263
+ addToResults = function addToResults(timing) {
1264
+ if (timing.sql_timings) {
1265
+ for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
1266
+ sqlTiming = timing.sql_timings[i]; // HACK: add info about the parent Timing to each SqlTiming so UI can render
1267
+
1268
+ sqlTiming.parent_timing_name = timing.name;
1269
+
1270
+ if (sqlTiming.duration_milliseconds > 50) {
1271
+ sqlTiming.row_class = "slow";
1272
+ }
570
1273
 
571
- // add support for AngularJS, which use the basic XMLHttpRequest object.
572
- if (window.angular && typeof (XMLHttpRequest) != 'undefined') {
573
- var _send = XMLHttpRequest.prototype.send;
574
-
575
- XMLHttpRequest.prototype.send = function sendReplacement(data) {
576
- if (this.onreadystatechange) {
577
- if (typeof (this.miniprofiler) == 'undefined' || typeof (this.miniprofiler.prev_onreadystatechange) == 'undefined') {
578
- this.miniprofiler = { prev_onreadystatechange: this.onreadystatechange };
579
-
580
- this.onreadystatechange = function onReadyStateChangeReplacement() {
581
- if (this.readyState == 4) {
582
- var stringIds = this.getResponseHeader('X-MiniProfiler-Ids');
583
- if (stringIds) {
584
- var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
585
- fetchResults(ids);
586
- }
587
- }
588
-
589
- if (this.miniprofiler.prev_onreadystatechange !== null)
590
- return this.miniprofiler.prev_onreadystatechange.apply(this, arguments);
591
- };
1274
+ if (sqlTiming.duration_milliseconds > 200) {
1275
+ sqlTiming.row_class = "very-slow";
592
1276
  }
593
- }
594
1277
 
595
- return _send.apply(this, arguments);
596
- };
597
- }
1278
+ if (sqlTiming.duration_milliseconds > 400) {
1279
+ sqlTiming.row_class = "very-very-slow";
1280
+ }
598
1281
 
599
- // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
600
- if(typeof(window.fetch) === 'function' && window.fetch.__patchedByMiniProfiler === undefined) {
601
- var __originalFetch = window.fetch;
602
-
603
- window.fetch = function(input,init) {
604
- return new Promise(function(resolve,reject) {
605
- __originalFetch(input,init).then(function(response) {
606
- // look for x-mini-profile-ids
607
- var entries = response.headers.entries();
608
- for (var i = 0; i < entries.length; i++) {
609
- var pair = entries[i];
610
- if(pair[0] && (pair[0].toLowerCase() == 'x-miniprofiler-ids')) {
611
- var ids = JSON.parse(pair[1]);
612
- fetchResults(ids);
613
- }
614
- }
615
- resolve(response);
616
- }).catch(function(error) {
617
- reject(error);
618
- });
619
- });
1282
+ result.push(sqlTiming);
1283
+ }
620
1284
  }
621
- window.fetch.__patchedByMiniProfiler = true;
622
- }
623
-
624
- // some elements want to be hidden on certain doc events
625
- bindDocumentEvents();
626
- };
627
-
628
- return {
629
-
630
- init: function () {
631
- var script = document.getElementById('mini-profiler');
632
- if (!script || !script.getAttribute) return;
633
-
634
- options = (function () {
635
- var version = script.getAttribute('data-version');
636
- var path = script.getAttribute('data-path');
637
-
638
- var currentId = script.getAttribute('data-current-id');
639
-
640
- var ids = script.getAttribute('data-ids');
641
- if (ids) ids = ids.split(',');
642
-
643
- var horizontal_position = script.getAttribute('data-horizontal-position');
644
- var vertical_position = script.getAttribute('data-vertical-position');
645
-
646
- var toggleShortcut = script.getAttribute('data-toggle-shortcut');
647
-
648
- if (script.getAttribute('data-max-traces')) {
649
- var maxTraces = parseInt(script.getAttribute('data-max-traces'), 10);
650
- }
651
-
652
- var collapseResults = script.getAttribute('data-collapse-results') === 'true';
653
- var trivial = script.getAttribute('data-trivial') === 'true';
654
- var children = script.getAttribute('data-children') === 'true';
655
- var controls = script.getAttribute('data-controls') === 'true';
656
- var totalSqlCount = script.getAttribute('data-total-sql-count') === 'true';
657
- var authorized = script.getAttribute('data-authorized') === 'true';
658
- var startHidden = script.getAttribute('data-start-hidden') === 'true' || sessionStorage['rack-mini-profiler-start-hidden'] === 'true';
659
- var htmlContainer = script.getAttribute('data-html-container');
660
-
661
- return {
662
- ids: ids,
663
- path: path,
664
- version: version,
665
- renderHorizontalPosition: horizontal_position,
666
- renderVerticalPosition: vertical_position,
667
- showTrivial: trivial,
668
- showChildrenTime: children,
669
- maxTracesToShow: maxTraces,
670
- showControls: controls,
671
- showTotalSqlCount: totalSqlCount,
672
- currentId: currentId,
673
- authorized: authorized,
674
- toggleShortcut: toggleShortcut,
675
- startHidden: startHidden,
676
- collapseResults: collapseResults,
677
- htmlContainer: htmlContainer
678
- };
679
- })();
680
-
681
- var doInit = function () {
682
- // when rendering a shared, full page, this div will exist
683
- container = $('.profiler-result-full');
684
- if (container.length) {
685
- if (window.location.href.indexOf("&trivial=1") > 0) {
686
- options.showTrivial = true;
687
- }
688
- initFullView();
689
- }
690
- else {
691
- initPopupView();
692
- }
693
- };
694
-
695
- // this preserves debugging
696
- var load = function (s, f) {
697
- var sc = document.createElement("script");
698
- sc.async = "async";
699
- sc.type = "text/javascript";
700
- sc.src = s;
701
- var done = false;
702
- sc.onload = sc.onreadystatechange = function (_, abort) {
703
- if (!sc.readyState || /loaded|complete/.test(sc.readyState)) {
704
- if (!abort && !done) { done = true; f(); }
705
- }
706
- };
707
- document.getElementsByTagName('head')[0].appendChild(sc);
708
- };
709
-
710
- var wait = 0;
711
- var finish = false;
712
- var deferInit = function() {
713
- if (finish) return;
714
- if (window.performance && window.performance.timing && window.performance.timing.loadEventEnd === 0 && wait < 10000) {
715
- setTimeout(deferInit, 100);
716
- wait += 100;
717
- } else {
718
- finish = true;
719
- init();
720
- }
721
- };
722
1285
 
723
- var init = function() {
1286
+ if (timing.children) {
1287
+ for (var i = 0; i < timing.children.length; i++) {
1288
+ addToResults(timing.children[i]);
1289
+ }
1290
+ }
1291
+ }; // start adding at the root and recurse down
724
1292
 
725
- // jquery.hotkeys.js
726
- // https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
1293
+ addToResults(root);
727
1294
 
728
- if (MiniProfiler.jQuery.hotkeys === undefined) {
729
- (function(d){function h(g){if("string"===typeof g.data){var h=g.handler,j=g.data.toLowerCase().split(" ");g.handler=function(b){if(!(this!==b.target&&(/textarea|select/i.test(b.target.nodeName)||"text"===b.target.type))){var c="keypress"!==b.type&&d.hotkeys.specialKeys[b.which],e=String.fromCharCode(b.which).toLowerCase(),a="",f={};b.altKey&&"alt"!==c&&(a+="alt+");b.ctrlKey&&"ctrl"!==c&&(a+="ctrl+");b.metaKey&&(!b.ctrlKey&&"meta"!==c)&&(a+="meta+");b.shiftKey&&"shift"!==c&&(a+="shift+");c?f[a+c]=
730
- !0:(f[a+e]=!0,f[a+d.hotkeys.shiftNums[e]]=!0,"shift+"===a&&(f[d.hotkeys.shiftNums[e]]=!0));c=0;for(e=j.length;c<e;c++)if(f[j[c]])return h.apply(this,arguments)}}}}d.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",
731
- 109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};d.each(["keydown","keyup","keypress"],function(){d.event.special[this]={add:h}})})(MiniProfiler.jQuery);
732
- }
1295
+ var removeDuration = function removeDuration(list, duration) {
1296
+ var newList = [];
733
1297
 
734
- if (options.authorized) {
735
- var url = options.path + "includes.css?v=" + options.version;
736
- if (document.createStyleSheet) {
737
- document.createStyleSheet(url);
738
- } else {
739
- $('head').append($('<link rel="stylesheet" type="text/css" href="' + url + '" />'));
740
- }
741
- if (!$.tmpl) {
742
- load(options.path + 'jquery.tmpl.js?v=' + options.version, doInit);
743
- } else {
744
- doInit();
745
- }
746
- } else {
747
- doInit();
748
- }
749
-
750
- };
1298
+ for (var i = 0; i < list.length; i++) {
1299
+ var item = list[i];
751
1300
 
752
- var major, minor;
753
- if (typeof(jQuery) == 'function') {
754
- var jQueryVersion = jQuery.fn.jquery.split('.');
755
- major = parseInt(jQueryVersion[0], 10);
756
- minor = parseInt(jQueryVersion[1], 10);
1301
+ if (duration.start > item.start) {
1302
+ if (duration.start > item.finish) {
1303
+ newList.push(item);
1304
+ continue;
757
1305
  }
758
1306
 
759
-
760
- if (major === 3 || major === 2 || (major === 1 && minor >= 7)) {
761
- MiniProfiler.jQuery = $ = jQuery;
762
- $(deferInit);
763
- } else {
764
- load(options.path + "jquery.1.7.1.js?v=" + options.version, function() {
765
- MiniProfiler.jQuery = $ = jQuery.noConflict(true);
766
- $(deferInit);
767
- });
768
- }
769
- },
770
-
771
- cleanUp: function() {
772
- unbindDocumentEvents();
773
- },
774
-
775
- pageTransition: function() {
776
- if (totalsControl) {
777
- totalsControl.remove();
778
- totalsControl = null;
1307
+ newList.push({
1308
+ start: item.start,
1309
+ finish: duration.start
1310
+ });
779
1311
  }
780
- reqs = 0;
781
- totalTime = 0;
782
- expandedResults = false;
783
- $('.profiler-results .profiler-result').remove();
784
- },
785
-
786
- getClientTimingByName: function (clientTiming, name) {
787
1312
 
788
- for (var i = 0; i < clientTiming.timings.length; i++) {
789
- if (clientTiming.timings[i].name == name) {
790
- return clientTiming.timings[i];
791
- }
1313
+ if (duration.finish < item.finish) {
1314
+ if (duration.finish < item.start) {
1315
+ newList.push(item);
1316
+ continue;
792
1317
  }
793
- return { Name: name, Duration: "", Start: "" };
794
- },
795
1318
 
796
- renderDate: function (jsonDate) { // JavaScriptSerializer sends dates as /Date(1308024322065)/
797
- if (jsonDate) {
798
- return (typeof jsonDate === 'string') ? new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10)).toUTCString() : jsonDate;
799
- }
800
- },
1319
+ newList.push({
1320
+ start: duration.finish,
1321
+ finish: item.finish
1322
+ });
1323
+ }
1324
+ }
801
1325
 
802
- renderIndent: function (depth) {
803
- var result = '';
804
- for (var i = 0; i < depth; i++) {
805
- result += '&nbsp;';
806
- }
807
- return result;
808
- },
809
-
810
- renderExecuteType: function (typeId) {
811
- // see StackExchange.Profiling.ExecuteType enum
812
- switch (typeId) {
813
- case 0: return 'None';
814
- case 1: return 'NonQuery';
815
- case 2: return 'Scalar';
816
- case 3: return 'Reader';
817
- }
818
- },
819
-
820
- shareUrl: function (id) {
821
- return options.path + 'results?id=' + id;
822
- },
823
-
824
- moreUrl: function () {
825
- var loc = window.location.href;
826
- loc = loc.indexOf("?") > 0 ? loc + "&pp=help" : "?pp=help";
827
- return loc;
828
- },
829
-
830
- getClientTimings: function (clientTimings) {
831
- var list = [];
832
- var t;
833
-
834
- if (!clientTimings.timings) return [];
835
-
836
- for (var i = 0; i < clientTimings.timings.length; i++) {
837
- t = clientTimings.timings[i];
838
- var trivial = t.Name != "Dom Complete" && t.Name != "Response"
839
- trivial = t.Duration < 2 ? trivial : false;
840
- list.push(
841
- {
842
- isTrivial: trivial,
843
- name: t.Name,
844
- duration: t.Duration,
845
- start: t.Start
846
- });
847
- }
1326
+ return newList;
1327
+ };
848
1328
 
1329
+ var processTimes = function processTimes(elem, parent) {
1330
+ var duration = {
1331
+ start: elem.start_milliseconds,
1332
+ finish: elem.start_milliseconds + elem.duration_milliseconds
1333
+ };
1334
+ elem.richTiming = [duration];
1335
+
1336
+ if (parent !== null) {
1337
+ elem.parent = parent;
1338
+ elem.parent.richTiming = removeDuration(
1339
+ elem.parent.richTiming,
1340
+ duration
1341
+ );
1342
+ }
849
1343
 
850
- // Use the Paint Timing API for render performance.
851
- if (window.performance && window.performance.getEntriesByName) {
852
- var firstPaint = window.performance.getEntriesByName("first-paint");
1344
+ if (elem.children) {
1345
+ for (var i = 0; i < elem.children.length; i++) {
1346
+ processTimes(elem.children[i], elem);
1347
+ }
1348
+ }
1349
+ };
853
1350
 
854
- if(firstPaint !== undefined && firstPaint.length >= 1){
855
- list.push(
856
- {
857
- isTrivial: false,
858
- name: "First Paint Time",
859
- duration: firstPaint[0].duration,
860
- start: firstPaint[0].startTime
861
- });
862
- }
863
- }
1351
+ processTimes(root, null); // sort results by time
864
1352
 
865
- list.sort(function (a, b) { return a.start - b.start; });
866
- return list;
867
- },
868
-
869
- getSqlTimings: function (root) {
870
- var result = [],
871
- addToResults = function (timing) {
872
- if (timing.sql_timings) {
873
- for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
874
- sqlTiming = timing.sql_timings[i];
875
-
876
- // HACK: add info about the parent Timing to each SqlTiming so UI can render
877
- sqlTiming.parent_timing_name = timing.name;
878
-
879
- if(sqlTiming.duration_milliseconds > 50) {
880
- sqlTiming.row_class = "slow";
881
- }
882
-
883
- if(sqlTiming.duration_milliseconds > 200) {
884
- sqlTiming.row_class = "very-slow";
885
- }
886
-
887
- if(sqlTiming.duration_milliseconds > 400) {
888
- sqlTiming.row_class = "very-very-slow";
889
- }
890
-
891
- result.push(sqlTiming);
892
- }
893
- }
894
-
895
- if (timing.children) {
896
- for (var i = 0; i < timing.children.length; i++) {
897
- addToResults(timing.children[i]);
898
- }
899
- }
900
- };
901
-
902
- // start adding at the root and recurse down
903
- addToResults(root);
904
-
905
- var removeDuration = function(list, duration) {
906
-
907
- var newList = [];
908
- for (var i = 0; i < list.length; i++) {
909
-
910
- var item = list[i];
911
- if (duration.start > item.start) {
912
- if (duration.start > item.finish) {
913
- newList.push(item);
914
- continue;
915
- }
916
- newList.push({ start: item.start, finish: duration.start });
917
- }
918
-
919
- if (duration.finish < item.finish) {
920
- if (duration.finish < item.start) {
921
- newList.push(item);
922
- continue;
923
- }
924
- newList.push({ start: duration.finish, finish: item.finish });
925
- }
926
- }
1353
+ result.sort(function(a, b) {
1354
+ return a.start_milliseconds - b.start_milliseconds;
1355
+ });
927
1356
 
928
- return newList;
929
- };
1357
+ var determineOverlap = function determineOverlap(gap, node) {
1358
+ var overlap = 0;
930
1359
 
931
- var processTimes = function (elem, parent) {
932
- var duration = { start: elem.start_milliseconds, finish: (elem.start_milliseconds + elem.duration_milliseconds) };
933
- elem.richTiming = [duration];
934
- if (parent !== null) {
935
- elem.parent = parent;
936
- elem.parent.richTiming = removeDuration(elem.parent.richTiming, duration);
937
- }
1360
+ for (var i = 0; i < node.richTiming.length; i++) {
1361
+ var current = node.richTiming[i];
938
1362
 
939
- if (elem.children) {
940
- for (var i = 0; i < elem.children.length; i++) {
941
- processTimes(elem.children[i], elem);
942
- }
943
- }
944
- };
1363
+ if (current.start > gap.finish) {
1364
+ break;
1365
+ }
945
1366
 
946
- processTimes(root, null);
1367
+ if (current.finish < gap.start) {
1368
+ continue;
1369
+ }
947
1370
 
948
- // sort results by time
949
- result.sort(function (a, b) { return a.start_milliseconds - b.start_milliseconds; });
1371
+ overlap +=
1372
+ Math.min(gap.finish, current.finish) -
1373
+ Math.max(gap.start, current.start);
1374
+ }
950
1375
 
951
- var determineOverlap = function(gap, node) {
952
- var overlap = 0;
953
- for (var i = 0; i < node.richTiming.length; i++) {
954
- var current = node.richTiming[i];
955
- if (current.start > gap.finish) {
956
- break;
957
- }
958
- if (current.finish < gap.start) {
959
- continue;
960
- }
1376
+ return overlap;
1377
+ };
961
1378
 
962
- overlap += Math.min(gap.finish, current.finish) - Math.max(gap.start, current.start);
963
- }
964
- return overlap;
965
- };
1379
+ var determineGap = function determineGap(gap, node, match) {
1380
+ var overlap = determineOverlap(gap, node);
966
1381
 
967
- var determineGap = function (gap, node, match) {
968
- var overlap = determineOverlap(gap, node);
969
- if (match === null || overlap > match.duration) {
970
- match = { name: node.name, duration: overlap };
971
- }
972
- else if (match.name == node.name) {
973
- match.duration += overlap;
974
- }
1382
+ if (match === null || overlap > match.duration) {
1383
+ match = {
1384
+ name: node.name,
1385
+ duration: overlap
1386
+ };
1387
+ } else if (match.name == node.name) {
1388
+ match.duration += overlap;
1389
+ }
975
1390
 
976
- if (node.children) {
977
- for (var i = 0; i < node.children.length; i++) {
978
- match = determineGap(gap, node.children[i], match);
979
- }
980
- }
981
- return match;
982
- };
983
-
984
- var time = 0;
985
- var prev = null;
986
- $.each(result, function () {
987
- this.prevGap = {
988
- duration: (this.start_milliseconds - time).toFixed(2),
989
- start: time,
990
- finish: this.start_milliseconds
991
- };
992
-
993
- this.prevGap.topReason = determineGap(this.prevGap, root, null);
994
-
995
- time = this.start_milliseconds + this.duration_milliseconds;
996
- prev = this;
997
- });
1391
+ if (node.children) {
1392
+ for (var i = 0; i < node.children.length; i++) {
1393
+ match = determineGap(gap, node.children[i], match);
1394
+ }
1395
+ }
998
1396
 
1397
+ return match;
1398
+ };
999
1399
 
1000
- if (result.length > 0) {
1001
- var me = result[result.length - 1];
1002
- me.nextGap = {
1003
- duration: (root.duration_milliseconds - time).toFixed(2),
1004
- start: time,
1005
- finish: root.duration_milliseconds
1006
- };
1007
- me.nextGap.topReason = determineGap(me.nextGap, root, null);
1008
- }
1400
+ var time = 0;
1401
+ var prev = null;
1402
+ result.forEach(function(r) {
1403
+ r.prevGap = {
1404
+ duration: (r.start_milliseconds - time).toFixed(2),
1405
+ start: time,
1406
+ finish: r.start_milliseconds
1407
+ };
1408
+ r.prevGap.topReason = determineGap(r.prevGap, root, null);
1409
+ time = r.start_milliseconds + r.duration_milliseconds;
1410
+ prev = r;
1411
+ });
1412
+
1413
+ if (result.length > 0) {
1414
+ var me = result[result.length - 1];
1415
+ me.nextGap = {
1416
+ duration: (root.duration_milliseconds - time).toFixed(2),
1417
+ start: time,
1418
+ finish: root.duration_milliseconds
1419
+ };
1420
+ me.nextGap.topReason = determineGap(me.nextGap, root, null);
1421
+ }
1422
+
1423
+ return result;
1424
+ },
1425
+ getSqlTimingsCount: function getSqlTimingsCount(root) {
1426
+ var result = 0,
1427
+ countSql = function countSql(timing) {
1428
+ if (timing.sql_timings) {
1429
+ result += timing.sql_timings.length;
1430
+ }
1009
1431
 
1010
- return result;
1011
- },
1012
-
1013
- getSqlTimingsCount: function (root) {
1014
- var result = 0,
1015
- countSql = function (timing) {
1016
- if (timing.sql_timings) {
1017
- result += timing.sql_timings.length;
1018
- }
1019
-
1020
- if (timing.children) {
1021
- for (var i = 0; i < timing.children.length; i++) {
1022
- countSql(timing.children[i]);
1023
- }
1024
- }
1025
- };
1026
- countSql(root);
1027
- return result;
1028
- },
1029
-
1030
- fetchResultsExposed: function (ids) {
1031
- return fetchResults(ids);
1032
- },
1033
-
1034
- formatParameters: function (parameters) {
1035
- if (parameters != null) {
1036
- return parameters.map(function(item, index){ return "["+item[0]+", "+ item[1] +"]";}).join(', ');
1037
- }
1038
- else {
1039
- return '';
1432
+ if (timing.children) {
1433
+ for (var i = 0; i < timing.children.length; i++) {
1434
+ countSql(timing.children[i]);
1040
1435
  }
1041
- },
1042
-
1043
- formatDuration: function (duration) {
1044
- return (duration || 0).toFixed(1);
1045
- },
1436
+ }
1437
+ };
1046
1438
 
1047
- showTotalSqlCount: function () {
1048
- return options.showTotalSqlCount
1439
+ countSql(root);
1440
+ return result;
1441
+ },
1442
+ fetchResultsExposed: function fetchResultsExposed(ids) {
1443
+ return fetchResults(ids);
1444
+ },
1445
+ formatParameters: function formatParameters(parameters) {
1446
+ if (parameters != null) {
1447
+ return parameters
1448
+ .map(function(item, index) {
1449
+ return "[" + item[0] + ", " + item[1] + "]";
1450
+ })
1451
+ .join(", ");
1452
+ } else {
1453
+ return "";
1454
+ }
1455
+ },
1456
+ formatDuration: function formatDuration(duration) {
1457
+ return (duration || 0).toFixed(1);
1458
+ },
1459
+ showTotalSqlCount: function showTotalSqlCount() {
1460
+ return options.showTotalSqlCount;
1461
+ },
1462
+ timestampToRelative: function timestampToRelative(timestamp) {
1463
+ var now = Math.round(new Date().getTime() / 1000);
1464
+ timestamp = Math.round(timestamp / 1000);
1465
+ var diff = now - timestamp;
1466
+ if (diff < 60) {
1467
+ return "< 1 minute";
1468
+ }
1469
+ var buildDisplayTime = function buildDisplayTime(num, unit) {
1470
+ var res = num + " " + unit;
1471
+ if (num !== 1) {
1472
+ res += "s";
1049
1473
  }
1050
- };
1474
+ return res;
1475
+ };
1476
+ diff = Math.round(diff / 60);
1477
+ if (diff <= 60) {
1478
+ return buildDisplayTime(diff, "minute");
1479
+ }
1480
+ diff = Math.round(diff / 60);
1481
+ if (diff <= 24) {
1482
+ return buildDisplayTime(diff, "hour");
1483
+ }
1484
+ diff = Math.round(diff / 24);
1485
+ return buildDisplayTime(diff, "day");
1486
+ }
1487
+ };
1051
1488
  })();
1052
1489
 
1053
- MiniProfiler.init();
1054
-
1055
- if (typeof prettyPrint === "undefined") {
1056
-
1057
- // prettify.js
1058
- // http://code.google.com/p/google-code-prettify/
1059
-
1060
- window.PR_SHOULD_USE_CONTINUATION=true;window.PR_TAB_WIDTH=8;window.PR_normalizedHtml=window.PR=window.prettyPrintOne=window.prettyPrint=void 0;window._pr_isIE6=function(){var y=navigator&&navigator.userAgent&&navigator.userAgent.match(/\bMSIE ([678])\./);y=y?+y[1]:false;window._pr_isIE6=function(){return y};return y};
1061
- (function(){function y(b){return b.replace(L,"&amp;").replace(M,"&lt;").replace(N,"&gt;")}function H(b,f,i){switch(b.nodeType){case 1:var o=b.tagName.toLowerCase();f.push("<",o);var l=b.attributes,n=l.length;if(n){if(i){for(var r=[],j=n;--j>=0;)r[j]=l[j];r.sort(function(q,m){return q.name<m.name?-1:q.name===m.name?0:1});l=r}for(j=0;j<n;++j){r=l[j];r.specified&&f.push(" ",r.name.toLowerCase(),'="',r.value.replace(L,"&amp;").replace(M,"&lt;").replace(N,"&gt;").replace(X,"&quot;"),'"')}}f.push(">");
1062
- for(l=b.firstChild;l;l=l.nextSibling)H(l,f,i);if(b.firstChild||!/^(?:br|link|img)$/.test(o))f.push("</",o,">");break;case 3:case 4:f.push(y(b.nodeValue));break}}function O(b){function f(c){if(c.charAt(0)!=="\\")return c.charCodeAt(0);switch(c.charAt(1)){case "b":return 8;case "t":return 9;case "n":return 10;case "v":return 11;case "f":return 12;case "r":return 13;case "u":case "x":return parseInt(c.substring(2),16)||c.charCodeAt(1);case "0":case "1":case "2":case "3":case "4":case "5":case "6":case "7":return parseInt(c.substring(1),
1063
- 8);default:return c.charCodeAt(1)}}function i(c){if(c<32)return(c<16?"\\x0":"\\x")+c.toString(16);c=String.fromCharCode(c);if(c==="\\"||c==="-"||c==="["||c==="]")c="\\"+c;return c}function o(c){var d=c.substring(1,c.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));c=[];for(var a=[],k=d[0]==="^",e=k?1:0,h=d.length;e<h;++e){var g=d[e];switch(g){case "\\B":case "\\b":case "\\D":case "\\d":case "\\S":case "\\s":case "\\W":case "\\w":c.push(g);
1064
- continue}g=f(g);var s;if(e+2<h&&"-"===d[e+1]){s=f(d[e+2]);e+=2}else s=g;a.push([g,s]);if(!(s<65||g>122)){s<65||g>90||a.push([Math.max(65,g)|32,Math.min(s,90)|32]);s<97||g>122||a.push([Math.max(97,g)&-33,Math.min(s,122)&-33])}}a.sort(function(v,w){return v[0]-w[0]||w[1]-v[1]});d=[];g=[NaN,NaN];for(e=0;e<a.length;++e){h=a[e];if(h[0]<=g[1]+1)g[1]=Math.max(g[1],h[1]);else d.push(g=h)}a=["["];k&&a.push("^");a.push.apply(a,c);for(e=0;e<d.length;++e){h=d[e];a.push(i(h[0]));if(h[1]>h[0]){h[1]+1>h[0]&&a.push("-");
1065
- a.push(i(h[1]))}}a.push("]");return a.join("")}function l(c){for(var d=c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),a=d.length,k=[],e=0,h=0;e<a;++e){var g=d[e];if(g==="(")++h;else if("\\"===g.charAt(0))if((g=+g.substring(1))&&g<=h)k[g]=-1}for(e=1;e<k.length;++e)if(-1===k[e])k[e]=++n;for(h=e=0;e<a;++e){g=d[e];if(g==="("){++h;if(k[h]===undefined)d[e]="(?:"}else if("\\"===
1066
- g.charAt(0))if((g=+g.substring(1))&&g<=h)d[e]="\\"+k[h]}for(h=e=0;e<a;++e)if("^"===d[e]&&"^"!==d[e+1])d[e]="";if(c.ignoreCase&&r)for(e=0;e<a;++e){g=d[e];c=g.charAt(0);if(g.length>=2&&c==="[")d[e]=o(g);else if(c!=="\\")d[e]=g.replace(/[a-zA-Z]/g,function(s){s=s.charCodeAt(0);return"["+String.fromCharCode(s&-33,s|32)+"]"})}return d.join("")}for(var n=0,r=false,j=false,q=0,m=b.length;q<m;++q){var t=b[q];if(t.ignoreCase)j=true;else if(/[a-z]/i.test(t.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,
1067
- ""))){r=true;j=false;break}}var p=[];q=0;for(m=b.length;q<m;++q){t=b[q];if(t.global||t.multiline)throw Error(""+t);p.push("(?:"+l(t)+")")}return RegExp(p.join("|"),j?"gi":"g")}function Y(b){var f=0;return function(i){for(var o=null,l=0,n=0,r=i.length;n<r;++n)switch(i.charAt(n)){case "\t":o||(o=[]);o.push(i.substring(l,n));l=b-f%b;for(f+=l;l>=0;l-=16)o.push(" ".substring(0,l));l=n+1;break;case "\n":f=0;break;default:++f}if(!o)return i;o.push(i.substring(l));return o.join("")}}function I(b,
1068
- f,i,o){if(f){b={source:f,c:b};i(b);o.push.apply(o,b.d)}}function B(b,f){var i={},o;(function(){for(var r=b.concat(f),j=[],q={},m=0,t=r.length;m<t;++m){var p=r[m],c=p[3];if(c)for(var d=c.length;--d>=0;)i[c.charAt(d)]=p;p=p[1];c=""+p;if(!q.hasOwnProperty(c)){j.push(p);q[c]=null}}j.push(/[\0-\uffff]/);o=O(j)})();var l=f.length;function n(r){for(var j=r.c,q=[j,z],m=0,t=r.source.match(o)||[],p={},c=0,d=t.length;c<d;++c){var a=t[c],k=p[a],e=void 0,h;if(typeof k==="string")h=false;else{var g=i[a.charAt(0)];
1069
- if(g){e=a.match(g[1]);k=g[0]}else{for(h=0;h<l;++h){g=f[h];if(e=a.match(g[1])){k=g[0];break}}e||(k=z)}if((h=k.length>=5&&"lang-"===k.substring(0,5))&&!(e&&typeof e[1]==="string")){h=false;k=P}h||(p[a]=k)}g=m;m+=a.length;if(h){h=e[1];var s=a.indexOf(h),v=s+h.length;if(e[2]){v=a.length-e[2].length;s=v-h.length}k=k.substring(5);I(j+g,a.substring(0,s),n,q);I(j+g+s,h,Q(k,h),q);I(j+g+v,a.substring(v),n,q)}else q.push(j+g,k)}r.d=q}return n}function x(b){var f=[],i=[];if(b.tripleQuotedStrings)f.push([A,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
1070
- null,"'\""]);else b.multiLineStrings?f.push([A,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):f.push([A,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]);b.verbatimStrings&&i.push([A,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);if(b.hashComments)if(b.cStyleComments){f.push([C,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]);i.push([A,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,
1071
- null])}else f.push([C,/^#[^\r\n]*/,null,"#"]);if(b.cStyleComments){i.push([C,/^\/\/[^\r\n]*/,null]);i.push([C,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}b.regexLiterals&&i.push(["lang-regex",RegExp("^"+Z+"(/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/)")]);b=b.keywords.replace(/^\s+|\s+$/g,"");b.length&&i.push([R,RegExp("^(?:"+b.replace(/\s+/g,"|")+")\\b"),null]);f.push([z,/^\s+/,null," \r\n\t\u00a0"]);i.push([J,/^@[a-z_$][a-z_$@0-9]*/i,null],[S,/^@?[A-Z]+[a-z][A-Za-z_$@0-9]*/,
1072
- null],[z,/^[a-z_$][a-z_$@0-9]*/i,null],[J,/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],[E,/^.[^\s\w\.$@\'\"\`\/\#]*/,null]);return B(f,i)}function $(b){function f(D){if(D>r){if(j&&j!==q){n.push("</span>");j=null}if(!j&&q){j=q;n.push('<span class="',j,'">')}var T=y(p(i.substring(r,D))).replace(e?d:c,"$1&#160;");e=k.test(T);n.push(T.replace(a,s));r=D}}var i=b.source,o=b.g,l=b.d,n=[],r=0,j=null,q=null,m=0,t=0,p=Y(window.PR_TAB_WIDTH),c=/([\r\n ]) /g,
1073
- d=/(^| ) /gm,a=/\r\n?|\n/g,k=/[ \r\n]$/,e=true,h=window._pr_isIE6();h=h?b.b.tagName==="PRE"?h===6?"&#160;\r\n":h===7?"&#160;<br>\r":"&#160;\r":"&#160;<br />":"<br />";var g=b.b.className.match(/\blinenums\b(?::(\d+))?/),s;if(g){for(var v=[],w=0;w<10;++w)v[w]=h+'</li><li class="L'+w+'">';var F=g[1]&&g[1].length?g[1]-1:0;n.push('<ol class="linenums"><li class="L',F%10,'"');F&&n.push(' value="',F+1,'"');n.push(">");s=function(){var D=v[++F%10];return j?"</span>"+D+'<span class="'+j+'">':D}}else s=h;
1074
- for(;;)if(m<o.length?t<l.length?o[m]<=l[t]:true:false){f(o[m]);if(j){n.push("</span>");j=null}n.push(o[m+1]);m+=2}else if(t<l.length){f(l[t]);q=l[t+1];t+=2}else break;f(i.length);j&&n.push("</span>");g&&n.push("</li></ol>");b.a=n.join("")}function u(b,f){for(var i=f.length;--i>=0;){var o=f[i];if(G.hasOwnProperty(o))"console"in window&&console.warn("cannot override language handler %s",o);else G[o]=b}}function Q(b,f){b&&G.hasOwnProperty(b)||(b=/^\s*</.test(f)?"default-markup":"default-code");return G[b]}
1075
- function U(b){var f=b.f,i=b.e;b.a=f;try{var o,l=f.match(aa);f=[];var n=0,r=[];if(l)for(var j=0,q=l.length;j<q;++j){var m=l[j];if(m.length>1&&m.charAt(0)==="<"){if(!ba.test(m))if(ca.test(m)){f.push(m.substring(9,m.length-3));n+=m.length-12}else if(da.test(m)){f.push("\n");++n}else if(m.indexOf(V)>=0&&m.replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,' $1="$2$3$4"').match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/)){var t=m.match(W)[2],p=1,c;c=j+1;a:for(;c<q;++c){var d=l[c].match(W);if(d&&
1076
- d[2]===t)if(d[1]==="/"){if(--p===0)break a}else++p}if(c<q){r.push(n,l.slice(j,c+1).join(""));j=c}else r.push(n,m)}else r.push(n,m)}else{var a;p=m;var k=p.indexOf("&");if(k<0)a=p;else{for(--k;(k=p.indexOf("&#",k+1))>=0;){var e=p.indexOf(";",k);if(e>=0){var h=p.substring(k+3,e),g=10;if(h&&h.charAt(0)==="x"){h=h.substring(1);g=16}var s=parseInt(h,g);isNaN(s)||(p=p.substring(0,k)+String.fromCharCode(s)+p.substring(e+1))}}a=p.replace(ea,"<").replace(fa,">").replace(ga,"'").replace(ha,'"').replace(ia," ").replace(ja,
1077
- "&")}f.push(a);n+=a.length}}o={source:f.join(""),h:r};var v=o.source;b.source=v;b.c=0;b.g=o.h;Q(i,v)(b);$(b)}catch(w){if("console"in window)console.log(w&&w.stack?w.stack:w)}}var A="str",R="kwd",C="com",S="typ",J="lit",E="pun",z="pln",P="src",V="nocode",Z=function(){for(var b=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===",">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=",
1078
- "~","break","case","continue","delete","do","else","finally","instanceof","return","throw","try","typeof"],f="(?:^^|[+-]",i=0;i<b.length;++i)f+="|"+b[i].replace(/([^=<>:&a-z])/g,"\\$1");f+=")\\s*";return f}(),L=/&/g,M=/</g,N=/>/g,X=/\"/g,ea=/&lt;/g,fa=/&gt;/g,ga=/&apos;/g,ha=/&quot;/g,ja=/&amp;/g,ia=/&nbsp;/g,ka=/[\r\n]/g,K=null,aa=RegExp("[^<]+|<!--[\\s\\S]*?--\>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|</?[a-zA-Z](?:[^>\"']|'[^']*'|\"[^\"]*\")*>|<","g"),ba=/^<\!--/,ca=/^<!\[CDATA\[/,da=/^<br\b/i,W=/^<(\/?)([a-zA-Z][a-zA-Z0-9]*)/,
1079
- la=x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename using virtual wchar_t where break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params partial readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof debugger eval export function get null set undefined var with Infinity NaN caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END break continue do else for if return while and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None break continue do else for if return while alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END break continue do else for if return while case done elif esac eval fi function in local set then until ",
1080
- hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true}),G={};u(la,["default-code"]);u(B([],[[z,/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],[C,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[E,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup",
1081
- "htm","html","mxml","xhtml","xml","xsl"]);u(B([[z,/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[E,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],
1082
- ["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);u(B([],[["atv",/^[\s\S]+/]]),["uq.val"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename using virtual wchar_t where ",
1083
- hashComments:true,cStyleComments:true}),["c","cc","cpp","cxx","cyc","m"]);u(x({keywords:"null true false"}),["json"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params partial readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ",
1084
- hashComments:true,cStyleComments:true,verbatimStrings:true}),["cs"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ",
1085
- cStyleComments:true}),["java"]);u(x({keywords:"break continue do else for if return while case done elif esac eval fi function in local set then until ",hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);u(x({keywords:"break continue do else for if return while and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None ",hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);
1086
- u(x({keywords:"caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END ",hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);u(x({keywords:"break continue do else for if return while alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END ",hashComments:true,
1087
- multiLineStrings:true,regexLiterals:true}),["rb"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof debugger eval export function get null set undefined var with Infinity NaN ",cStyleComments:true,regexLiterals:true}),["js"]);u(B([],[[A,/^[\s\S]+/]]),
1088
- ["regex"]);window.PR_normalizedHtml=H;window.prettyPrintOne=function(b,f){var i={f:b,e:f};U(i);return i.a};window.prettyPrint=function(b){function f(){for(var t=window.PR_SHOULD_USE_CONTINUATION?j.now()+250:Infinity;q<o.length&&j.now()<t;q++){var p=o[q];if(p.className&&p.className.indexOf("prettyprint")>=0){var c=p.className.match(/\blang-(\w+)\b/);if(c)c=c[1];for(var d=false,a=p.parentNode;a;a=a.parentNode)if((a.tagName==="pre"||a.tagName==="code"||a.tagName==="xmp")&&a.className&&a.className.indexOf("prettyprint")>=
1089
- 0){d=true;break}if(!d){a=p;if(null===K){d=document.createElement("PRE");d.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));K=!/</.test(d.innerHTML)}if(K){d=a.innerHTML;if("XMP"===a.tagName)d=y(d);else{a=a;if("PRE"===a.tagName)a=true;else if(ka.test(d)){var k="";if(a.currentStyle)k=a.currentStyle.whiteSpace;else if(window.getComputedStyle)k=window.getComputedStyle(a,null).whiteSpace;a=!k||k==="pre"}else a=true;a||(d=d.replace(/(<br\s*\/?>)[\r\n]+/g,"$1").replace(/(?:[\r\n]+[ \t]*)+/g,
1090
- " "))}d=d}else{d=[];for(a=a.firstChild;a;a=a.nextSibling)H(a,d);d=d.join("")}d=d.replace(/(?:\r\n?|\n)$/,"");m={f:d,e:c,b:p};U(m);if(p=m.a){c=m.b;if("XMP"===c.tagName){d=document.createElement("PRE");for(a=0;a<c.attributes.length;++a){k=c.attributes[a];if(k.specified)if(k.name.toLowerCase()==="class")d.className=k.value;else d.setAttribute(k.name,k.value)}d.innerHTML=p;c.parentNode.replaceChild(d,c)}else c.innerHTML=p}}}}if(q<o.length)setTimeout(f,250);else b&&b()}for(var i=[document.getElementsByTagName("pre"),
1091
- document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],o=[],l=0;l<i.length;++l)for(var n=0,r=i[l].length;n<r;++n)o.push(i[l][n]);i=null;var j=Date;j.now||(j={now:function(){return(new Date).getTime()}});var q=0,m;f()};window.PR={combinePrefixPatterns:O,createSimpleLexer:B,registerLangHandler:u,sourceDecorator:x,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:C,PR_DECLARATION:"dec",PR_KEYWORD:R,PR_LITERAL:J,PR_NOCODE:V,PR_PLAIN:z,PR_PUNCTUATION:E,PR_SOURCE:P,PR_STRING:A,
1092
- PR_TAG:"tag",PR_TYPE:S}})()
1093
-
1094
- ;
1095
-
1096
- // lang-sql.js
1097
- // http://code.google.com/p/google-code-prettify/
1098
-
1099
- PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],["kwd",/^(?:ADD|ALL|ALTER|AND|ANY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|NATIONAL|NOCHECK|NONCLUSTERED|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PERCENT|PLAN|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNION|UNIQUE|UPDATE|UPDATETEXT|USE|USER|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WRITETEXT)(?=[^\w-]|$)/i,
1100
- null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^[a-z_][\w-]*/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]]),["sql"])
1101
-
1102
- ;
1490
+ if (window.MiniProfiler) {
1491
+ _MiniProfiler.patchesApplied = window.MiniProfiler.patchesApplied;
1103
1492
  }
1493
+ window.MiniProfiler = _MiniProfiler;
1494
+ _MiniProfiler.init();