From 61dba108860530bcf6a865ca7a8b861402540161 Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Sat, 29 Feb 2020 06:53:18 -0700 Subject: [PATCH] Truncate long URLs in saved recordings page, fixes #62 --- toolkit/content/aboutWebReplay.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/toolkit/content/aboutWebReplay.js b/toolkit/content/aboutWebReplay.js index 52539c7fe667f..6b9171e586b20 100644 --- a/toolkit/content/aboutWebReplay.js +++ b/toolkit/content/aboutWebReplay.js @@ -24,6 +24,16 @@ function formatDuration(duration) { return `${(duration / MsPerSecond) | 0} seconds`; } +// Maximum number of characters to print for titles and URLs. +const MaxStringLength = 50; + +function formatString(string) { + if (string.length > MaxStringLength) { + return string.substring(0, MaxStringLength - 3) + "..."; + } + return string; +} + // See also DevToolsStartup.jsm function getRecordingsPath() { let dir = Services.dirsvc.get("UAppData", Ci.nsIFile); @@ -65,8 +75,8 @@ async function showRecordings() { for (const { uuid, url, title, date, duration } of gRecordings) { const recordingUrl = `https://view.webreplay.io/${uuid}`; const newRow = document.importNode(template.content, true); - newRow.querySelector(".recording-title").innerText = title; - newRow.querySelector(".recording-url").innerText = url; + newRow.querySelector(".recording-title").innerText = formatString(title); + newRow.querySelector(".recording-url").innerText = formatString(url); newRow.querySelector(".recording-start").innerText = formatTime(date); newRow.querySelector(".recording-duration").innerText = formatDuration(duration); newRow.querySelector(".recording").href = recordingUrl;