X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fjs%2Fapp%2Fhelpers.js;fp=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fjs%2Fapp%2Fhelpers.js;h=caa8bdb4ead55f717a545589f0428b2b8d63ecfb;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/devel/webprofiler/js/app/helpers.js b/web/modules/contrib/devel/webprofiler/js/app/helpers.js new file mode 100644 index 000000000..caa8bdb4e --- /dev/null +++ b/web/modules/contrib/devel/webprofiler/js/app/helpers.js @@ -0,0 +1,107 @@ +(function (drupalSettings) { + + Drupal.webprofiler.helpers = (function () { + + "use strict"; + + var escapeRx = function escapeRegExp(string) { + return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); + }, + + repl = function replaceAll(string, find, replace) { + if (typeof string != 'string') { + return ''; + } + return string.replace(new RegExp(escapeRx(find), 'g'), replace); + }, + + shortLink = function (clazz) { + if (!clazz) { + return null; + } + clazz = repl(clazz, '/', '\\'); + var parts = clazz.split("\\"), result = [], size = (parts.length - 1); + + _.each(parts, function (item, key) { + if (key < size) { + result.push(item.substring(0, 1)); + } else { + result.push(item); + } + }); + return result.join("\\"); + }, + + abbr = function (clazz) { + if (!clazz) { + return null; + } + + return '' + shortLink(clazz) + ''; + }, + + ideLink = function (file, line) { + if (!file) { + return null; + } + + line = line || 0; + + file = file.replace(drupalSettings.webprofiler.ide_link_remote, drupalSettings.webprofiler.ide_link_local); + + return drupalSettings.webprofiler.ide_link.replace("@file", file).replace("@line", line); + }, + + classLink = function (data) { + var link = ideLink(data['file'], data['line']), clazz = abbr(data['class']), method = data['method'], output = ''; + + output = clazz; + if (method) { + output += '::' + method; + } + + if (link) { + output = '' + output + ''; + } + + return output; + }, + + printTime = function (data, unit) { + unit = unit || 'ms'; + data = Math.round((data + 0.00001) * 100) / 100; + return data + ' ' + unit; + }, + + frm = function (obj, level) { + level = level || 0; + var str = ''; + }, + + isInt = function (value) { + var x; + return isNaN(value) ? !1 : (x = parseFloat(value), (0 | x) === x); + }; + + return { + frm: frm, + ideLink: ideLink, + shortLink: shortLink, + classLink: classLink, + printTime: printTime + } + + })(); + +}(drupalSettings));