rack-mini-profiler 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c284e06a7538c082f580dd74793d5a278e2c8fe4ac8f095e2f7db65f8162b6f0
4
- data.tar.gz: a8e39352e06175a4acba8445cb0e850430e727fa9b5b80dd3115fa2248be3e3a
3
+ metadata.gz: 5d7135086b980cb3201aab37e65fa4b1d9d192498c94976b724480d0487a2694
4
+ data.tar.gz: deb8ce345b8e7c8096297c7a3199ce218a72e7b06b47bd3708620fba6d5492a9
5
5
  SHA512:
6
- metadata.gz: b89818251b38e988b8eb8084388e9cbfc52e43e2566bf29a3897707a80bcec6ec29b990539e47f9e4139f0b3beaa8e77c871c158745fe96ea288e6cbf99f2cc9
7
- data.tar.gz: d616e5e78bd5db52f85d428d2657e90ba330373a7c5edb3f4304c23f268dbec3f1aff064d4bbebe63b7262ff90f86d99a569d826387402cff6846981f69f0dcb
6
+ metadata.gz: d389a986e89d4019afdab48aa1680d94a7bb3250886131e1887598d82a21a74583c192df2de377ed130b28052904f3938f1904e384607878d399ec8483476323
7
+ data.tar.gz: 662f669f1a7861bd55728b281d78270808bcc8d06fddc7bc795b24a58304b677e709e2bf48aa1e4624a58698b6bb873dae3675877a10c461c563a9c525f59a3c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.3 2019-28-10
4
+
5
+ - [FEATURE] precompile all templates to avoid need for unsafe-eval
6
+
3
7
  ## 1.1.2 2019-24-10
4
8
 
5
9
  - [FIX] JS payload was not working on IE11 and leading to errors
data/lib/html/includes.js CHANGED
@@ -93,35 +93,6 @@ var MiniProfiler = (function() {
93
93
  MiniProfiler.templates = templates;
94
94
  };
95
95
 
96
- var fetchTemplates = function fetchTemplates(success) {
97
- var key = "templates",
98
- cached = load(key);
99
-
100
- if (cached) {
101
- compileTemplates(cached);
102
- success();
103
- } else {
104
- var request = new XMLHttpRequest();
105
- var url = options.path + "includes.tmpl?v=" + options.version;
106
- request.open("GET", url, true);
107
-
108
- request.onload = function() {
109
- if (request.status >= 200 && request.status < 400) {
110
- var data = request.response;
111
-
112
- if (data) {
113
- save(key, data);
114
- compileTemplates(data);
115
- success();
116
- }
117
- }
118
- };
119
-
120
- request.setRequestHeader("Content-Type", "text/plain");
121
- request.send();
122
- }
123
- };
124
-
125
96
  var getClientPerformance = function getClientPerformance() {
126
97
  return window.performance === null ? null : window.performance;
127
98
  };
@@ -683,25 +654,22 @@ var MiniProfiler = (function() {
683
654
  };
684
655
 
685
656
  var initFullView = function initFullView() {
686
- // first, get jquery tmpl, then render and bind handlers
687
- fetchTemplates(function() {
688
- // profiler will be defined in the full page's head
689
- container[0].appendChild(renderTemplate(profiler));
690
- var popup = document.querySelector(".profiler-popup");
691
- toggleHidden(popup);
692
- prettyPrint(); // since queries are already shown, just highlight and scroll when clicking a "1 sql" link
693
-
694
- toArray(popup.querySelectorAll(".profiler-queries-show")).forEach(
695
- function(el) {
696
- el.addEventListener("click", function() {
697
- queriesScrollIntoView(
698
- this,
699
- document.querySelector(".profiler-queries"),
700
- document.body
701
- );
702
- });
703
- }
704
- );
657
+ // profiler will be defined in the full page's head
658
+ container[0].appendChild(renderTemplate(profiler));
659
+ var popup = document.querySelector(".profiler-popup");
660
+ toggleHidden(popup);
661
+ prettyPrint(); // since queries are already shown, just highlight and scroll when clicking a "1 sql" link
662
+
663
+ toArray(popup.querySelectorAll(".profiler-queries-show")).forEach(function(
664
+ el
665
+ ) {
666
+ el.addEventListener("click", function() {
667
+ queriesScrollIntoView(
668
+ this,
669
+ document.querySelector(".profiler-queries"),
670
+ document.body
671
+ );
672
+ });
705
673
  });
706
674
  };
707
675
 
@@ -765,12 +733,9 @@ var MiniProfiler = (function() {
765
733
  container.classList.add("profiler-" + options.renderHorizontalPosition);
766
734
  container.classList.add("profiler-" + options.renderVerticalPosition); //initialize the controls
767
735
 
768
- initControls(container); // we'll render results json via a jquery.tmpl - after we get the templates, we'll fetch the initial json to populate it
736
+ initControls(container);
737
+ fetchResults(options.ids);
769
738
 
770
- fetchTemplates(function() {
771
- // get master page profiler results
772
- fetchResults(options.ids);
773
- });
774
739
  if (options.startHidden) container.style.display = "none";
775
740
  } else {
776
741
  fetchResults(options.ids);
@@ -1087,11 +1052,8 @@ var MiniProfiler = (function() {
1087
1052
  head.appendChild(link);
1088
1053
  }
1089
1054
 
1090
- if (!window.doT) {
1091
- load(
1092
- options.path + "dot.1.1.2.min.js?v=" + options.version,
1093
- doInit
1094
- );
1055
+ if (!MiniProfiler.loadedVendor) {
1056
+ load(options.path + "vendor.js?v=" + options.version, doInit);
1095
1057
  } else {
1096
1058
  doInit();
1097
1059
  }
@@ -1418,814 +1380,3 @@ var MiniProfiler = (function() {
1418
1380
  })();
1419
1381
 
1420
1382
  MiniProfiler.init();
1421
-
1422
- if (typeof prettyPrint === "undefined") {
1423
- // prettify.js
1424
- // http://code.google.com/p/google-code-prettify/
1425
- // prettier-ignore
1426
- window.PR_SHOULD_USE_CONTINUATION = true;
1427
- window.PR_TAB_WIDTH = 8;
1428
- window.PR_normalizedHtml = window.PR = window.prettyPrintOne = window.prettyPrint = void 0;
1429
-
1430
- window._pr_isIE6 = function() {
1431
- var y =
1432
- navigator &&
1433
- navigator.userAgent &&
1434
- navigator.userAgent.match(/\bMSIE ([678])\./);
1435
- y = y ? +y[1] : false;
1436
-
1437
- window._pr_isIE6 = function() {
1438
- return y;
1439
- };
1440
-
1441
- return y;
1442
- };
1443
-
1444
- (function () {
1445
- function y(b) {
1446
- return b.replace(L, "&amp;").replace(M, "&lt;").replace(N, "&gt;");
1447
- }
1448
-
1449
- function H(b, f, i) {
1450
- switch (b.nodeType) {
1451
- case 1:
1452
- var o = b.tagName.toLowerCase();
1453
- f.push("<", o);
1454
- var l = b.attributes,
1455
- n = l.length;
1456
-
1457
- if (n) {
1458
- if (i) {
1459
- for (var r = [], j = n; --j >= 0;) {
1460
- r[j] = l[j];
1461
- }
1462
-
1463
- r.sort(function (q, m) {
1464
- return q.name < m.name ? -1 : q.name === m.name ? 0 : 1;
1465
- });
1466
- l = r;
1467
- }
1468
-
1469
- for (j = 0; j < n; ++j) {
1470
- r = l[j];
1471
- r.specified && f.push(" ", r.name.toLowerCase(), '="', r.value.replace(L, "&amp;").replace(M, "&lt;").replace(N, "&gt;").replace(X, "&quot;"), '"');
1472
- }
1473
- }
1474
-
1475
- f.push(">");
1476
-
1477
- for (l = b.firstChild; l; l = l.nextSibling) {
1478
- H(l, f, i);
1479
- }
1480
-
1481
- if (b.firstChild || !/^(?:br|link|img)$/.test(o)) f.push("</", o, ">");
1482
- break;
1483
-
1484
- case 3:
1485
- case 4:
1486
- f.push(y(b.nodeValue));
1487
- break;
1488
- }
1489
- }
1490
-
1491
- function O(b) {
1492
- function f(c) {
1493
- if (c.charAt(0) !== "\\") return c.charCodeAt(0);
1494
-
1495
- switch (c.charAt(1)) {
1496
- case "b":
1497
- return 8;
1498
-
1499
- case "t":
1500
- return 9;
1501
-
1502
- case "n":
1503
- return 10;
1504
-
1505
- case "v":
1506
- return 11;
1507
-
1508
- case "f":
1509
- return 12;
1510
-
1511
- case "r":
1512
- return 13;
1513
-
1514
- case "u":
1515
- case "x":
1516
- return parseInt(c.substring(2), 16) || c.charCodeAt(1);
1517
-
1518
- case "0":
1519
- case "1":
1520
- case "2":
1521
- case "3":
1522
- case "4":
1523
- case "5":
1524
- case "6":
1525
- case "7":
1526
- return parseInt(c.substring(1), 8);
1527
-
1528
- default:
1529
- return c.charCodeAt(1);
1530
- }
1531
- }
1532
-
1533
- function i(c) {
1534
- if (c < 32) return (c < 16 ? "\\x0" : "\\x") + c.toString(16);
1535
- c = String.fromCharCode(c);
1536
- if (c === "\\" || c === "-" || c === "[" || c === "]") c = "\\" + c;
1537
- return c;
1538
- }
1539
-
1540
- function o(c) {
1541
- 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"));
1542
- c = [];
1543
-
1544
- for (var a = [], k = d[0] === "^", e = k ? 1 : 0, h = d.length; e < h; ++e) {
1545
- var g = d[e];
1546
-
1547
- switch (g) {
1548
- case "\\B":
1549
- case "\\b":
1550
- case "\\D":
1551
- case "\\d":
1552
- case "\\S":
1553
- case "\\s":
1554
- case "\\W":
1555
- case "\\w":
1556
- c.push(g);
1557
- continue;
1558
- }
1559
-
1560
- g = f(g);
1561
- var s;
1562
-
1563
- if (e + 2 < h && "-" === d[e + 1]) {
1564
- s = f(d[e + 2]);
1565
- e += 2;
1566
- } else s = g;
1567
-
1568
- a.push([g, s]);
1569
-
1570
- if (!(s < 65 || g > 122)) {
1571
- s < 65 || g > 90 || a.push([Math.max(65, g) | 32, Math.min(s, 90) | 32]);
1572
- s < 97 || g > 122 || a.push([Math.max(97, g) & -33, Math.min(s, 122) & -33]);
1573
- }
1574
- }
1575
-
1576
- a.sort(function (v, w) {
1577
- return v[0] - w[0] || w[1] - v[1];
1578
- });
1579
- d = [];
1580
- g = [NaN, NaN];
1581
-
1582
- for (e = 0; e < a.length; ++e) {
1583
- h = a[e];
1584
- if (h[0] <= g[1] + 1) g[1] = Math.max(g[1], h[1]);else d.push(g = h);
1585
- }
1586
-
1587
- a = ["["];
1588
- k && a.push("^");
1589
- a.push.apply(a, c);
1590
-
1591
- for (e = 0; e < d.length; ++e) {
1592
- h = d[e];
1593
- a.push(i(h[0]));
1594
-
1595
- if (h[1] > h[0]) {
1596
- h[1] + 1 > h[0] && a.push("-");
1597
- a.push(i(h[1]));
1598
- }
1599
- }
1600
-
1601
- a.push("]");
1602
- return a.join("");
1603
- }
1604
-
1605
- function l(c) {
1606
- 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) {
1607
- var g = d[e];
1608
- if (g === "(") ++h;else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) k[g] = -1;
1609
- }
1610
-
1611
- for (e = 1; e < k.length; ++e) {
1612
- if (-1 === k[e]) k[e] = ++n;
1613
- }
1614
-
1615
- for (h = e = 0; e < a; ++e) {
1616
- g = d[e];
1617
-
1618
- if (g === "(") {
1619
- ++h;
1620
- if (k[h] === undefined) d[e] = "(?:";
1621
- } else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) d[e] = "\\" + k[h];
1622
- }
1623
-
1624
- for (h = e = 0; e < a; ++e) {
1625
- if ("^" === d[e] && "^" !== d[e + 1]) d[e] = "";
1626
- }
1627
-
1628
- if (c.ignoreCase && r) for (e = 0; e < a; ++e) {
1629
- g = d[e];
1630
- c = g.charAt(0);
1631
- if (g.length >= 2 && c === "[") d[e] = o(g);else if (c !== "\\") d[e] = g.replace(/[a-zA-Z]/g, function (s) {
1632
- s = s.charCodeAt(0);
1633
- return "[" + String.fromCharCode(s & -33, s | 32) + "]";
1634
- });
1635
- }
1636
- return d.join("");
1637
- }
1638
-
1639
- for (var n = 0, r = false, j = false, q = 0, m = b.length; q < m; ++q) {
1640
- var t = b[q];
1641
- 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, ""))) {
1642
- r = true;
1643
- j = false;
1644
- break;
1645
- }
1646
- }
1647
-
1648
- var p = [];
1649
- q = 0;
1650
-
1651
- for (m = b.length; q < m; ++q) {
1652
- t = b[q];
1653
- if (t.global || t.multiline) throw Error("" + t);
1654
- p.push("(?:" + l(t) + ")");
1655
- }
1656
-
1657
- return RegExp(p.join("|"), j ? "gi" : "g");
1658
- }
1659
-
1660
- function Y(b) {
1661
- var f = 0;
1662
- return function (i) {
1663
- for (var o = null, l = 0, n = 0, r = i.length; n < r; ++n) {
1664
- switch (i.charAt(n)) {
1665
- case "\t":
1666
- o || (o = []);
1667
- o.push(i.substring(l, n));
1668
- l = b - f % b;
1669
-
1670
- for (f += l; l >= 0; l -= 16) {
1671
- o.push(" ".substring(0, l));
1672
- }
1673
-
1674
- l = n + 1;
1675
- break;
1676
-
1677
- case "\n":
1678
- f = 0;
1679
- break;
1680
-
1681
- default:
1682
- ++f;
1683
- }
1684
- }
1685
-
1686
- if (!o) return i;
1687
- o.push(i.substring(l));
1688
- return o.join("");
1689
- };
1690
- }
1691
-
1692
- function I(b, f, i, o) {
1693
- if (f) {
1694
- b = {
1695
- source: f,
1696
- c: b
1697
- };
1698
- i(b);
1699
- o.push.apply(o, b.d);
1700
- }
1701
- }
1702
-
1703
- function B(b, f) {
1704
- var i = {},
1705
- o;
1706
-
1707
- (function () {
1708
- for (var r = b.concat(f), j = [], q = {}, m = 0, t = r.length; m < t; ++m) {
1709
- var p = r[m],
1710
- c = p[3];
1711
- if (c) for (var d = c.length; --d >= 0;) {
1712
- i[c.charAt(d)] = p;
1713
- }
1714
- p = p[1];
1715
- c = "" + p;
1716
-
1717
- if (!q.hasOwnProperty(c)) {
1718
- j.push(p);
1719
- q[c] = null;
1720
- }
1721
- }
1722
-
1723
- j.push(/[\0-\uffff]/);
1724
- o = O(j);
1725
- })();
1726
-
1727
- var l = f.length;
1728
-
1729
- function n(r) {
1730
- for (var j = r.c, q = [j, z], m = 0, t = r.source.match(o) || [], p = {}, c = 0, d = t.length; c < d; ++c) {
1731
- var a = t[c],
1732
- k = p[a],
1733
- e = void 0,
1734
- h;
1735
- if (typeof k === "string") h = false;else {
1736
- var g = i[a.charAt(0)];
1737
-
1738
- if (g) {
1739
- e = a.match(g[1]);
1740
- k = g[0];
1741
- } else {
1742
- for (h = 0; h < l; ++h) {
1743
- g = f[h];
1744
-
1745
- if (e = a.match(g[1])) {
1746
- k = g[0];
1747
- break;
1748
- }
1749
- }
1750
-
1751
- e || (k = z);
1752
- }
1753
-
1754
- if ((h = k.length >= 5 && "lang-" === k.substring(0, 5)) && !(e && typeof e[1] === "string")) {
1755
- h = false;
1756
- k = P;
1757
- }
1758
-
1759
- h || (p[a] = k);
1760
- }
1761
- g = m;
1762
- m += a.length;
1763
-
1764
- if (h) {
1765
- h = e[1];
1766
- var s = a.indexOf(h),
1767
- v = s + h.length;
1768
-
1769
- if (e[2]) {
1770
- v = a.length - e[2].length;
1771
- s = v - h.length;
1772
- }
1773
-
1774
- k = k.substring(5);
1775
- I(j + g, a.substring(0, s), n, q);
1776
- I(j + g + s, h, Q(k, h), q);
1777
- I(j + g + v, a.substring(v), n, q);
1778
- } else q.push(j + g, k);
1779
- }
1780
-
1781
- r.d = q;
1782
- }
1783
-
1784
- return n;
1785
- }
1786
-
1787
- function x(b) {
1788
- var f = [],
1789
- i = [];
1790
- if (b.tripleQuotedStrings) f.push([A, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/, null, "'\""]);else b.multiLineStrings ? f.push([A, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/, null, "'\"`"]) : f.push([A, /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/, null, "\"'"]);
1791
- b.verbatimStrings && i.push([A, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]);
1792
- if (b.hashComments) if (b.cStyleComments) {
1793
- f.push([C, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/, null, "#"]);
1794
- i.push([A, /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/, null]);
1795
- } else f.push([C, /^#[^\r\n]*/, null, "#"]);
1796
-
1797
- if (b.cStyleComments) {
1798
- i.push([C, /^\/\/[^\r\n]*/, null]);
1799
- i.push([C, /^\/\*[\s\S]*?(?:\*\/|$)/, null]);
1800
- }
1801
-
1802
- b.regexLiterals && i.push(["lang-regex", RegExp("^" + Z + "(/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/)")]);
1803
- b = b.keywords.replace(/^\s+|\s+$/g, "");
1804
- b.length && i.push([R, RegExp("^(?:" + b.replace(/\s+/g, "|") + ")\\b"), null]);
1805
- f.push([z, /^\s+/, null, " \r\n\t\xA0"]);
1806
- i.push([J, /^@[a-z_$][a-z_$@0-9]*/i, null], [S, /^@?[A-Z]+[a-z][A-Za-z_$@0-9]*/, 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]);
1807
- return B(f, i);
1808
- }
1809
-
1810
- function $(b) {
1811
- function f(D) {
1812
- if (D > r) {
1813
- if (j && j !== q) {
1814
- n.push("</span>");
1815
- j = null;
1816
- }
1817
-
1818
- if (!j && q) {
1819
- j = q;
1820
- n.push('<span class="', j, '">');
1821
- }
1822
-
1823
- var T = y(p(i.substring(r, D))).replace(e ? d : c, "$1&#160;");
1824
- e = k.test(T);
1825
- n.push(T.replace(a, s));
1826
- r = D;
1827
- }
1828
- }
1829
-
1830
- var i = b.source,
1831
- o = b.g,
1832
- l = b.d,
1833
- n = [],
1834
- r = 0,
1835
- j = null,
1836
- q = null,
1837
- m = 0,
1838
- t = 0,
1839
- p = Y(window.PR_TAB_WIDTH),
1840
- c = /([\r\n ]) /g,
1841
- d = /(^| ) /gm,
1842
- a = /\r\n?|\n/g,
1843
- k = /[ \r\n]$/,
1844
- e = true,
1845
- h = window._pr_isIE6();
1846
-
1847
- h = h ? b.b.tagName === "PRE" ? h === 6 ? "&#160;\r\n" : h === 7 ? "&#160;<br>\r" : "&#160;\r" : "&#160;<br />" : "<br />";
1848
- var g = b.b.className.match(/\blinenums\b(?::(\d+))?/),
1849
- s;
1850
-
1851
- if (g) {
1852
- for (var v = [], w = 0; w < 10; ++w) {
1853
- v[w] = h + '</li><li class="L' + w + '">';
1854
- }
1855
-
1856
- var F = g[1] && g[1].length ? g[1] - 1 : 0;
1857
- n.push('<ol class="linenums"><li class="L', F % 10, '"');
1858
- F && n.push(' value="', F + 1, '"');
1859
- n.push(">");
1860
-
1861
- s = function s() {
1862
- var D = v[++F % 10];
1863
- return j ? "</span>" + D + '<span class="' + j + '">' : D;
1864
- };
1865
- } else s = h;
1866
-
1867
- for (;;) {
1868
- if (m < o.length ? t < l.length ? o[m] <= l[t] : true : false) {
1869
- f(o[m]);
1870
-
1871
- if (j) {
1872
- n.push("</span>");
1873
- j = null;
1874
- }
1875
-
1876
- n.push(o[m + 1]);
1877
- m += 2;
1878
- } else if (t < l.length) {
1879
- f(l[t]);
1880
- q = l[t + 1];
1881
- t += 2;
1882
- } else break;
1883
- }
1884
-
1885
- f(i.length);
1886
- j && n.push("</span>");
1887
- g && n.push("</li></ol>");
1888
- b.a = n.join("");
1889
- }
1890
-
1891
- function u(b, f) {
1892
- for (var i = f.length; --i >= 0;) {
1893
- var o = f[i];
1894
- if (G.hasOwnProperty(o)) "console" in window && console.warn("cannot override language handler %s", o);else G[o] = b;
1895
- }
1896
- }
1897
-
1898
- function Q(b, f) {
1899
- b && G.hasOwnProperty(b) || (b = /^\s*</.test(f) ? "default-markup" : "default-code");
1900
- return G[b];
1901
- }
1902
-
1903
- function U(b) {
1904
- var f = b.f,
1905
- i = b.e;
1906
- b.a = f;
1907
-
1908
- try {
1909
- var o,
1910
- l = f.match(aa);
1911
- f = [];
1912
- var n = 0,
1913
- r = [];
1914
- if (l) for (var j = 0, q = l.length; j < q; ++j) {
1915
- var m = l[j];
1916
-
1917
- if (m.length > 1 && m.charAt(0) === "<") {
1918
- if (!ba.test(m)) if (ca.test(m)) {
1919
- f.push(m.substring(9, m.length - 3));
1920
- n += m.length - 12;
1921
- } else if (da.test(m)) {
1922
- f.push("\n");
1923
- ++n;
1924
- } 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/)) {
1925
- var t = m.match(W)[2],
1926
- p = 1,
1927
- c;
1928
- c = j + 1;
1929
-
1930
- a: for (; c < q; ++c) {
1931
- var d = l[c].match(W);
1932
- if (d && d[2] === t) if (d[1] === "/") {
1933
- if (--p === 0) break a;
1934
- } else ++p;
1935
- }
1936
-
1937
- if (c < q) {
1938
- r.push(n, l.slice(j, c + 1).join(""));
1939
- j = c;
1940
- } else r.push(n, m);
1941
- } else r.push(n, m);
1942
- } else {
1943
- var a;
1944
- p = m;
1945
- var k = p.indexOf("&");
1946
- if (k < 0) a = p;else {
1947
- for (--k; (k = p.indexOf("&#", k + 1)) >= 0;) {
1948
- var e = p.indexOf(";", k);
1949
-
1950
- if (e >= 0) {
1951
- var h = p.substring(k + 3, e),
1952
- g = 10;
1953
-
1954
- if (h && h.charAt(0) === "x") {
1955
- h = h.substring(1);
1956
- g = 16;
1957
- }
1958
-
1959
- var s = parseInt(h, g);
1960
- isNaN(s) || (p = p.substring(0, k) + String.fromCharCode(s) + p.substring(e + 1));
1961
- }
1962
- }
1963
-
1964
- a = p.replace(ea, "<").replace(fa, ">").replace(ga, "'").replace(ha, '"').replace(ia, " ").replace(ja, "&");
1965
- }
1966
- f.push(a);
1967
- n += a.length;
1968
- }
1969
- }
1970
- o = {
1971
- source: f.join(""),
1972
- h: r
1973
- };
1974
- var v = o.source;
1975
- b.source = v;
1976
- b.c = 0;
1977
- b.g = o.h;
1978
- Q(i, v)(b);
1979
- $(b);
1980
- } catch (w) {
1981
- if ("console" in window) console.log(w && w.stack ? w.stack : w);
1982
- }
1983
- }
1984
-
1985
- var A = "str",
1986
- R = "kwd",
1987
- C = "com",
1988
- S = "typ",
1989
- J = "lit",
1990
- E = "pun",
1991
- z = "pln",
1992
- P = "src",
1993
- V = "nocode",
1994
- Z = function () {
1995
- for (var b = ["!", "!=", "!==", "#", "%", "%=", "&", "&&", "&&=", "&=", "(", "*", "*=", "+=", ",", "-=", "->", "/", "/=", ":", "::", ";", "<", "<<", "<<=", "<=", "=", "==", "===", ">", ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[", "^", "^=", "^^", "^^=", "{", "|", "|=", "||", "||=", "~", "break", "case", "continue", "delete", "do", "else", "finally", "instanceof", "return", "throw", "try", "typeof"], f = "(?:^^|[+-]", i = 0; i < b.length; ++i) {
1996
- f += "|" + b[i].replace(/([^=<>:&a-z])/g, "\\$1");
1997
- }
1998
-
1999
- f += ")\\s*";
2000
- return f;
2001
- }(),
2002
- L = /&/g,
2003
- M = /</g,
2004
- N = />/g,
2005
- X = /\"/g,
2006
- ea = /&lt;/g,
2007
- fa = /&gt;/g,
2008
- ga = /&apos;/g,
2009
- ha = /&quot;/g,
2010
- ja = /&amp;/g,
2011
- ia = /&nbsp;/g,
2012
- ka = /[\r\n]/g,
2013
- K = null,
2014
- aa = RegExp("[^<]+|<!--[\\s\\S]*?-->|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|</?[a-zA-Z](?:[^>\"']|'[^']*'|\"[^\"]*\")*>|<", "g"),
2015
- ba = /^<\!--/,
2016
- ca = /^<!\[CDATA\[/,
2017
- da = /^<br\b/i,
2018
- W = /^<(\/?)([a-zA-Z][a-zA-Z0-9]*)/,
2019
- la = x({
2020
- 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 ",
2021
- hashComments: true,
2022
- cStyleComments: true,
2023
- multiLineStrings: true,
2024
- regexLiterals: true
2025
- }),
2026
- G = {};
2027
-
2028
- u(la, ["default-code"]);
2029
- 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", "htm", "html", "mxml", "xhtml", "xml", "xsl"]);
2030
- 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], ["lang-css", /^style\s*=\s*([^\"\'>\s]+)/i]]), ["in.tag"]);
2031
- u(B([], [["atv", /^[\s\S]+/]]), ["uq.val"]);
2032
- u(x({
2033
- 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 ",
2034
- hashComments: true,
2035
- cStyleComments: true
2036
- }), ["c", "cc", "cpp", "cxx", "cyc", "m"]);
2037
- u(x({
2038
- keywords: "null true false"
2039
- }), ["json"]);
2040
- u(x({
2041
- 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 ",
2042
- hashComments: true,
2043
- cStyleComments: true,
2044
- verbatimStrings: true
2045
- }), ["cs"]);
2046
- u(x({
2047
- 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 ",
2048
- cStyleComments: true
2049
- }), ["java"]);
2050
- u(x({
2051
- keywords: "break continue do else for if return while case done elif esac eval fi function in local set then until ",
2052
- hashComments: true,
2053
- multiLineStrings: true
2054
- }), ["bsh", "csh", "sh"]);
2055
- u(x({
2056
- 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 ",
2057
- hashComments: true,
2058
- multiLineStrings: true,
2059
- tripleQuotedStrings: true
2060
- }), ["cv", "py"]);
2061
- u(x({
2062
- 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 ",
2063
- hashComments: true,
2064
- multiLineStrings: true,
2065
- regexLiterals: true
2066
- }), ["perl", "pl", "pm"]);
2067
- u(x({
2068
- 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 ",
2069
- hashComments: true,
2070
- multiLineStrings: true,
2071
- regexLiterals: true
2072
- }), ["rb"]);
2073
- u(x({
2074
- 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 ",
2075
- cStyleComments: true,
2076
- regexLiterals: true
2077
- }), ["js"]);
2078
- u(B([], [[A, /^[\s\S]+/]]), ["regex"]);
2079
- window.PR_normalizedHtml = H;
2080
-
2081
- window.prettyPrintOne = function (b, f) {
2082
- var i = {
2083
- f: b,
2084
- e: f
2085
- };
2086
- U(i);
2087
- return i.a;
2088
- };
2089
-
2090
- window.prettyPrint = function (b) {
2091
- function f() {
2092
- for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
2093
- var p = o[q];
2094
-
2095
- if (p.className && p.className.indexOf("prettyprint") >= 0) {
2096
- var c = p.className.match(/\blang-(\w+)\b/);
2097
- if (c) c = c[1];
2098
-
2099
- for (var d = false, a = p.parentNode; a; a = a.parentNode) {
2100
- if ((a.tagName === "pre" || a.tagName === "code" || a.tagName === "xmp") && a.className && a.className.indexOf("prettyprint") >= 0) {
2101
- d = true;
2102
- break;
2103
- }
2104
- }
2105
-
2106
- if (!d) {
2107
- a = p;
2108
-
2109
- if (null === K) {
2110
- d = document.createElement("PRE");
2111
- d.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
2112
- K = !/</.test(d.innerHTML);
2113
- }
2114
-
2115
- if (K) {
2116
- d = a.innerHTML;
2117
- if ("XMP" === a.tagName) d = y(d);else {
2118
- a = a;
2119
- if ("PRE" === a.tagName) a = true;else if (ka.test(d)) {
2120
- var k = "";
2121
- if (a.currentStyle) k = a.currentStyle.whiteSpace;else if (window.getComputedStyle) k = window.getComputedStyle(a, null).whiteSpace;
2122
- a = !k || k === "pre";
2123
- } else a = true;
2124
- a || (d = d.replace(/(<br\s*\/?>)[\r\n]+/g, "$1").replace(/(?:[\r\n]+[ \t]*)+/g, " "));
2125
- }
2126
- d = d;
2127
- } else {
2128
- d = [];
2129
-
2130
- for (a = a.firstChild; a; a = a.nextSibling) {
2131
- H(a, d);
2132
- }
2133
-
2134
- d = d.join("");
2135
- }
2136
-
2137
- d = d.replace(/(?:\r\n?|\n)$/, "");
2138
- m = {
2139
- f: d,
2140
- e: c,
2141
- b: p
2142
- };
2143
- U(m);
2144
-
2145
- if (p = m.a) {
2146
- c = m.b;
2147
-
2148
- if ("XMP" === c.tagName) {
2149
- d = document.createElement("PRE");
2150
-
2151
- for (a = 0; a < c.attributes.length; ++a) {
2152
- k = c.attributes[a];
2153
- if (k.specified) if (k.name.toLowerCase() === "class") d.className = k.value;else d.setAttribute(k.name, k.value);
2154
- }
2155
-
2156
- d.innerHTML = p;
2157
- c.parentNode.replaceChild(d, c);
2158
- } else c.innerHTML = p;
2159
- }
2160
- }
2161
- }
2162
- }
2163
-
2164
- if (q < o.length) setTimeout(f, 250);else b && b();
2165
- }
2166
-
2167
- for (var i = [document.getElementsByTagName("pre"), document.getElementsByTagName("code"), document.getElementsByTagName("xmp")], o = [], l = 0; l < i.length; ++l) {
2168
- for (var n = 0, r = i[l].length; n < r; ++n) {
2169
- o.push(i[l][n]);
2170
- }
2171
- }
2172
-
2173
- i = null;
2174
- var j = Date;
2175
- j.now || (j = {
2176
- now: function now() {
2177
- return new Date().getTime();
2178
- }
2179
- });
2180
- var q = 0,
2181
- m;
2182
- f();
2183
- };
2184
-
2185
- window.PR = {
2186
- combinePrefixPatterns: O,
2187
- createSimpleLexer: B,
2188
- registerLangHandler: u,
2189
- sourceDecorator: x,
2190
- PR_ATTRIB_NAME: "atn",
2191
- PR_ATTRIB_VALUE: "atv",
2192
- PR_COMMENT: C,
2193
- PR_DECLARATION: "dec",
2194
- PR_KEYWORD: R,
2195
- PR_LITERAL: J,
2196
- PR_NOCODE: V,
2197
- PR_PLAIN: z,
2198
- PR_PUNCTUATION: E,
2199
- PR_SOURCE: P,
2200
- PR_STRING: A,
2201
- PR_TAG: "tag",
2202
- PR_TYPE: S
2203
- };
2204
- })(); // prettier-ignore
2205
- // lang-sql.js
2206
- // http://code.google.com/p/google-code-prettify/
2207
-
2208
- PR.registerLangHandler(
2209
- PR.createSimpleLexer(
2210
- [
2211
- ["pln", /^[\t\n\r \xA0]+/, null, "\t\n\r \xA0"],
2212
- ["str", /^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/, null, "\"'"]
2213
- ],
2214
- [
2215
- ["com", /^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],
2216
- [
2217
- "kwd",
2218
- /^(?: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,
2219
- null
2220
- ],
2221
- [
2222
- "lit",
2223
- /^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i
2224
- ],
2225
- ["pln", /^[a-z_][\w-]*/i],
2226
- ["pun", /^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]
2227
- ]
2228
- ),
2229
- ["sql"]
2230
- );
2231
- }