From aaba25eb337a5ea5e7064f9bb10fd6f08c8c3863 Mon Sep 17 00:00:00 2001 From: Kyle Paulsen Date: Sat, 6 Feb 2016 22:33:33 -0800 Subject: [PATCH] Don't let giant urls make the load content dropdown get too big. --- src/ui/devtoolstab.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ui/devtoolstab.js b/src/ui/devtoolstab.js index f244253..366c3c0 100644 --- a/src/ui/devtoolstab.js +++ b/src/ui/devtoolstab.js @@ -75,6 +75,18 @@ return prefix.charAt(0) + (maxId + 1); } + function shortenString(str, limit) { + var over = str.length - limit; + if (over > 0) { + var halfPos = str.length / 2; + var firstOffset = Math.floor(over / 2 + 2); + var secondOffset = Math.ceil(over / 2 + 3); + return str.substring(0, halfPos - firstOffset) + " ... " + + str.substring(halfPos + secondOffset); + } + return str; + } + function getTabResources(cb) { if (!window.isNormalTab) { chrome.devtools.inspectedWindow.getResources(function(resourceList) { @@ -168,7 +180,7 @@ filteredList.forEach(function(url) { var $newOpt = $("