Skip to content

Commit

Permalink
Don't let giant urls make the load content dropdown get too big.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylepaulsen committed Feb 7, 2016
1 parent fe336c5 commit aaba25e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ui/devtoolstab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -168,7 +180,7 @@
filteredList.forEach(function(url) {
var $newOpt = $("<option>");
$newOpt.attr("value", url);
$newOpt.text(url);
$newOpt.text(shortenString(url, 250));
$loadSelect.append($newOpt);
});
$loadSelect.val("");
Expand Down

0 comments on commit aaba25e

Please sign in to comment.