From fbe1e2c2cc1b44045426111e0316574bd05e1cce Mon Sep 17 00:00:00 2001 From: j433866 Date: Fri, 22 Mar 2019 15:55:35 +0000 Subject: [PATCH] Show tab number on tab title. Don't show lines value if tab contents is a file. --- src/web/InputWaiter.mjs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/web/InputWaiter.mjs b/src/web/InputWaiter.mjs index 2e4ec0f3..1ca3531e 100755 --- a/src/web/InputWaiter.mjs +++ b/src/web/InputWaiter.mjs @@ -418,7 +418,7 @@ class InputWaiter { this.manager.output.closeFile(); // this.manager.highlighter.removeHighlights(); const inputNum = this.getActiveTab(); - document.getElementById(`input-tab-${inputNum}`).firstElementChild.innerText = "New Tab"; + document.getElementById(`input-tab-${inputNum}`).firstElementChild.innerText = `${inputNum}: New Tab`; document.getElementById("input-text").value = ""; document.getElementById("output-text").value = ""; document.getElementById("input-info").innerHTML = ""; @@ -452,7 +452,7 @@ class InputWaiter { const newTabContent = document.createElement("div"); newTabContent.classList.add("input-tab-content"); - newTabContent.innerText = "New Tab"; + newTabContent.innerText = `${newTabNum}: New Tab`; const newTabCloseBtn = document.createElement("button"); newTabCloseBtn.className = "btn btn-primary bmd-btn-icon btn-close-tab"; @@ -503,7 +503,7 @@ class InputWaiter { delete this.fileBuffers[tabNum]; this.inputs[tabNum] = ""; document.getElementById("input-text").value = ""; - tabLiItem.firstElementChild.innerText = "New Tab"; + tabLiItem.firstElementChild.innerText = `${tabNum}: New Tab`; } if (tabList.children.length === 1) { document.getElementById("input-tabs").style.display = "none"; @@ -546,7 +546,7 @@ class InputWaiter { if (this.fileBuffers[newTabNum]) { const fileObj = this.fileBuffers[newTabNum]; - this.setInputInfo(fileObj.size, 1); + this.setInputInfo(fileObj.size, null); this.setFileInfo(fileObj); this.displayFilePreview(); } else { @@ -581,17 +581,17 @@ class InputWaiter { * @param {string|File} input */ displayTabInfo(input) { - const activeTabs = document.getElementsByClassName("active-input-tab"); - if (activeTabs.length > 0) { - const activeTabContent = activeTabs.item(0).getElementsByClassName("input-tab-content")[0]; - if (input instanceof File) { - activeTabContent.innerText = input.name; + const tabNum = this.getActiveTab(); + const activeTab = document.getElementById(`input-tab-${tabNum}`); + const activeTabContent = activeTab.firstElementChild; + if (input instanceof File) { + activeTabContent.innerText = input.name; + } else { + if (input.length > 0) { + const inputText = input.slice(0, 100).split(/[\r\n]/)[0]; + activeTabContent.innerText = `${tabNum}: ${inputText}`; } else { - if (input.length > 0) { - activeTabContent.innerText = input.slice(0, 100).split(/[\r\n]/)[0]; - } else { - activeTabContent.innerText = "New Tab"; - } + activeTabContent.innerText = `${tabNum}: New Tab`; } }