1 (function (drupalSettings) {
3 Drupal.webprofiler.helpers = (function () {
7 var escapeRx = function escapeRegExp(string) {
8 return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
11 repl = function replaceAll(string, find, replace) {
12 if (typeof string != 'string') {
15 return string.replace(new RegExp(escapeRx(find), 'g'), replace);
18 shortLink = function (clazz) {
22 clazz = repl(clazz, '/', '\\');
23 var parts = clazz.split("\\"), result = [], size = (parts.length - 1);
25 _.each(parts, function (item, key) {
27 result.push(item.substring(0, 1));
32 return result.join("\\");
35 abbr = function (clazz) {
40 return '<abbr title="' + clazz + '">' + shortLink(clazz) + '</abbr>';
43 ideLink = function (file, line) {
50 file = file.replace(drupalSettings.webprofiler.ide_link_remote, drupalSettings.webprofiler.ide_link_local);
52 return drupalSettings.webprofiler.ide_link.replace("@file", file).replace("@line", line);
55 classLink = function (data) {
56 var link = ideLink(data['file'], data['line']), clazz = abbr(data['class']), method = data['method'], output = '';
60 output += '::' + method;
64 output = '<a href="' + link + '">' + output + '</a>';
70 printTime = function (data, unit) {
72 data = Math.round((data + 0.00001) * 100) / 100;
73 return data + ' ' + unit;
76 frm = function (obj, level) {
78 var str = '<ul class="list--unstyled list--level-' + level + ' list--flat">', prop;
79 if (typeof obj != 'object') {
84 str += '<li>' + frm(obj[prop], level + 1) + '</li>';
86 str += '<li><span class="list-item--bold">' + prop + '</span>: ' + frm(obj[prop], level + 1) + '</li>';
92 isInt = function (value) {
94 return isNaN(value) ? !1 : (x = parseFloat(value), (0 | x) === x);
100 shortLink: shortLink,
101 classLink: classLink,