Show tab number on tab title.

Don't show lines value if tab contents is a file.
This commit is contained in:
j433866 2019-03-22 15:55:35 +00:00
parent 9b86ed7c45
commit fbe1e2c2cc
1 changed files with 14 additions and 14 deletions

View File

@ -418,7 +418,7 @@ class InputWaiter {
this.manager.output.closeFile(); this.manager.output.closeFile();
// this.manager.highlighter.removeHighlights(); // this.manager.highlighter.removeHighlights();
const inputNum = this.getActiveTab(); 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("input-text").value = "";
document.getElementById("output-text").value = ""; document.getElementById("output-text").value = "";
document.getElementById("input-info").innerHTML = ""; document.getElementById("input-info").innerHTML = "";
@ -452,7 +452,7 @@ class InputWaiter {
const newTabContent = document.createElement("div"); const newTabContent = document.createElement("div");
newTabContent.classList.add("input-tab-content"); newTabContent.classList.add("input-tab-content");
newTabContent.innerText = "New Tab"; newTabContent.innerText = `${newTabNum}: New Tab`;
const newTabCloseBtn = document.createElement("button"); const newTabCloseBtn = document.createElement("button");
newTabCloseBtn.className = "btn btn-primary bmd-btn-icon btn-close-tab"; newTabCloseBtn.className = "btn btn-primary bmd-btn-icon btn-close-tab";
@ -503,7 +503,7 @@ class InputWaiter {
delete this.fileBuffers[tabNum]; delete this.fileBuffers[tabNum];
this.inputs[tabNum] = ""; this.inputs[tabNum] = "";
document.getElementById("input-text").value = ""; document.getElementById("input-text").value = "";
tabLiItem.firstElementChild.innerText = "New Tab"; tabLiItem.firstElementChild.innerText = `${tabNum}: New Tab`;
} }
if (tabList.children.length === 1) { if (tabList.children.length === 1) {
document.getElementById("input-tabs").style.display = "none"; document.getElementById("input-tabs").style.display = "none";
@ -546,7 +546,7 @@ class InputWaiter {
if (this.fileBuffers[newTabNum]) { if (this.fileBuffers[newTabNum]) {
const fileObj = this.fileBuffers[newTabNum]; const fileObj = this.fileBuffers[newTabNum];
this.setInputInfo(fileObj.size, 1); this.setInputInfo(fileObj.size, null);
this.setFileInfo(fileObj); this.setFileInfo(fileObj);
this.displayFilePreview(); this.displayFilePreview();
} else { } else {
@ -581,17 +581,17 @@ class InputWaiter {
* @param {string|File} input * @param {string|File} input
*/ */
displayTabInfo(input) { displayTabInfo(input) {
const activeTabs = document.getElementsByClassName("active-input-tab"); const tabNum = this.getActiveTab();
if (activeTabs.length > 0) { const activeTab = document.getElementById(`input-tab-${tabNum}`);
const activeTabContent = activeTabs.item(0).getElementsByClassName("input-tab-content")[0]; const activeTabContent = activeTab.firstElementChild;
if (input instanceof File) { if (input instanceof File) {
activeTabContent.innerText = input.name; activeTabContent.innerText = input.name;
} else {
if (input.length > 0) {
const inputText = input.slice(0, 100).split(/[\r\n]/)[0];
activeTabContent.innerText = `${tabNum}: ${inputText}`;
} else { } else {
if (input.length > 0) { activeTabContent.innerText = `${tabNum}: New Tab`;
activeTabContent.innerText = input.slice(0, 100).split(/[\r\n]/)[0];
} else {
activeTabContent.innerText = "New Tab";
}
} }
} }