mirror of
https://github.com/zombieFox/nightTab.git
synced 2025-02-04 04:20:19 +01:00
[refactor] improve link string handling
This commit is contained in:
parent
40a1303bb9
commit
61416e10b3
@ -14,7 +14,7 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "icon",
|
display: "icon",
|
||||||
letter: "AS",
|
letter: "AS",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: "dice-d20",
|
name: "dice-d20",
|
||||||
prefix: "fas",
|
prefix: "fas",
|
||||||
@ -56,7 +56,7 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "letter",
|
display: "letter",
|
||||||
letter: "AZ",
|
letter: "AZ",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: "amazon",
|
name: "amazon",
|
||||||
prefix: "fab",
|
prefix: "fab",
|
||||||
@ -98,7 +98,7 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "letter",
|
display: "letter",
|
||||||
letter: "GM",
|
letter: "GM",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: "envelope",
|
name: "envelope",
|
||||||
prefix: "fas",
|
prefix: "fas",
|
||||||
@ -140,7 +140,7 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "icon",
|
display: "icon",
|
||||||
letter: "R",
|
letter: "R",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: "reddit-alien",
|
name: "reddit-alien",
|
||||||
prefix: "fab",
|
prefix: "fab",
|
||||||
@ -182,7 +182,7 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "icon",
|
display: "icon",
|
||||||
letter: "N",
|
letter: "N",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: "film",
|
name: "film",
|
||||||
prefix: "fas",
|
prefix: "fas",
|
||||||
@ -224,11 +224,11 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "letter",
|
display: "letter",
|
||||||
letter: "DR",
|
letter: "DR",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: null,
|
name: "",
|
||||||
prefix: null,
|
prefix: "",
|
||||||
label: null
|
label: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name: "Drive",
|
name: "Drive",
|
||||||
@ -275,7 +275,7 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "icon",
|
display: "icon",
|
||||||
letter: "DEV",
|
letter: "DEV",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: "code",
|
name: "code",
|
||||||
prefix: "fas",
|
prefix: "fas",
|
||||||
@ -317,7 +317,7 @@ var bookmarks = (function() {
|
|||||||
visual: {
|
visual: {
|
||||||
display: "icon",
|
display: "icon",
|
||||||
letter: "GIT",
|
letter: "GIT",
|
||||||
image: null,
|
image: "",
|
||||||
icon: {
|
icon: {
|
||||||
name: "github",
|
name: "github",
|
||||||
prefix: "fab",
|
prefix: "fab",
|
||||||
|
@ -27,7 +27,7 @@ var layout = (function() {
|
|||||||
if (helper.checkIfValidString(state.get.current().layout.title)) {
|
if (helper.checkIfValidString(state.get.current().layout.title)) {
|
||||||
title.textContent = helper.trimString(state.get.current().layout.title);
|
title.textContent = helper.trimString(state.get.current().layout.title);
|
||||||
} else {
|
} else {
|
||||||
title.textContent = "New tab";
|
title.textContent = "New Tab";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -978,16 +978,39 @@ var link = (function() {
|
|||||||
var linkDisplayImage = null;
|
var linkDisplayImage = null;
|
||||||
|
|
||||||
if (stagedLink.link.visual.display == "letter" && helper.checkIfValidString(stagedLink.link.visual.letter)) {
|
if (stagedLink.link.visual.display == "letter" && helper.checkIfValidString(stagedLink.link.visual.letter)) {
|
||||||
linkDisplayLetter = helper.node("p:" + helper.trimString(stagedLink.link.visual.letter) + "|class:link-display-letter");
|
linkDisplayLetter = helper.makeNode({
|
||||||
|
tag: "p",
|
||||||
|
text: helper.trimString(stagedLink.link.visual.letter),
|
||||||
|
attr: [{
|
||||||
|
key: "class",
|
||||||
|
value: "link-display-letter"
|
||||||
|
}]
|
||||||
|
});
|
||||||
} else if (stagedLink.link.visual.display == "icon" && helper.checkIfValidString(stagedLink.link.visual.icon.prefix) && helper.checkIfValidString(stagedLink.link.visual.icon.name)) {
|
} else if (stagedLink.link.visual.display == "icon" && helper.checkIfValidString(stagedLink.link.visual.icon.prefix) && helper.checkIfValidString(stagedLink.link.visual.icon.name)) {
|
||||||
linkDisplayIcon = helper.node("div|class:link-display-icon " + stagedLink.link.visual.icon.prefix + " fa-" + stagedLink.link.visual.icon.name);
|
linkDisplayIcon = helper.node("div|class:link-display-icon " + stagedLink.link.visual.icon.prefix + " fa-" + stagedLink.link.visual.icon.name);
|
||||||
} else if (stagedLink.link.visual.display == "image" && helper.checkIfValidString(stagedLink.link.visual.image)) {
|
} else if (stagedLink.link.visual.display == "image" && helper.checkIfValidString(stagedLink.link.visual.image)) {
|
||||||
linkDisplayImage = helper.node("div|class:link-display-image,style:--link-display-image-url: url(" + helper.trimString(stagedLink.link.visual.image) + ")");
|
linkDisplayImage = helper.makeNode({
|
||||||
|
tag: "div",
|
||||||
|
attr: [{
|
||||||
|
key: "class",
|
||||||
|
value: "link-display-image"
|
||||||
|
}, {
|
||||||
|
key: "style",
|
||||||
|
value: "--link-display-image-url: url(" + helper.trimString(stagedLink.link.visual.image) + ")"
|
||||||
|
}]
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var linkDisplayName;
|
var linkDisplayName;
|
||||||
if (helper.checkIfValidString(stagedLink.link.name)) {
|
if (helper.checkIfValidString(stagedLink.link.name)) {
|
||||||
linkDisplayName = helper.node("p:" + helper.trimString(stagedLink.link.name) + "|class:link-display-name");
|
linkDisplayName = helper.makeNode({
|
||||||
|
tag: "p",
|
||||||
|
text: helper.trimString(stagedLink.link.name),
|
||||||
|
attr: [{
|
||||||
|
key: "class",
|
||||||
|
value: "link-display-name"
|
||||||
|
}]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
linkDisplayName = helper.node("p|class:link-display-name");
|
linkDisplayName = helper.node("p|class:link-display-name");
|
||||||
};
|
};
|
||||||
@ -2089,9 +2112,9 @@ var link = (function() {
|
|||||||
stagedLink.link.url = this.value;
|
stagedLink.link.url = this.value;
|
||||||
}, false);
|
}, false);
|
||||||
displayIconFormGroupClear.addEventListener("click", function(event) {
|
displayIconFormGroupClear.addEventListener("click", function(event) {
|
||||||
stagedLink.link.visual.icon.name = null;
|
stagedLink.link.visual.icon.name = "";
|
||||||
stagedLink.link.visual.icon.prefix = null;
|
stagedLink.link.visual.icon.prefix = "";
|
||||||
stagedLink.link.visual.icon.label = null;
|
stagedLink.link.visual.icon.label = "";
|
||||||
var existingIcon = helper.e(".link-form-icon");
|
var existingIcon = helper.e(".link-form-icon");
|
||||||
if (existingIcon) {
|
if (existingIcon) {
|
||||||
existingIcon.remove();
|
existingIcon.remove();
|
||||||
@ -2527,8 +2550,6 @@ var link = (function() {
|
|||||||
stagedLink.link = JSON.parse(JSON.stringify(arrayItem));
|
stagedLink.link = JSON.parse(JSON.stringify(arrayItem));
|
||||||
stagedLink.position.origin.item = index;
|
stagedLink.position.origin.item = index;
|
||||||
stagedLink.position.destination.item = index;
|
stagedLink.position.destination.item = index;
|
||||||
stagedLink.position.group.new = null;
|
|
||||||
stagedLink.position.group.name.text = null;
|
|
||||||
if (state.get.current().search) {
|
if (state.get.current().search) {
|
||||||
if (stagedLink.link.searchMatch) {
|
if (stagedLink.link.searchMatch) {
|
||||||
group.querySelector(".group-body").appendChild(render.item.link());
|
group.querySelector(".group-body").appendChild(render.item.link());
|
||||||
|
@ -107,13 +107,26 @@ var modal = (function() {
|
|||||||
modalControls.appendChild(cancelButton);
|
modalControls.appendChild(cancelButton);
|
||||||
modalControls.appendChild(actionButton);
|
modalControls.appendChild(actionButton);
|
||||||
if (options.heading != null) {
|
if (options.heading != null) {
|
||||||
var modalHeading = helper.node("h1:" + options.heading + "|class:modal-heading,tabindex:1");
|
var modalHeading = helper.makeNode({
|
||||||
|
tag: "h1",
|
||||||
|
text: options.heading,
|
||||||
|
attr: [{
|
||||||
|
key: "class",
|
||||||
|
value: "modal-heading"
|
||||||
|
}, {
|
||||||
|
key: "tabindex",
|
||||||
|
value: 1
|
||||||
|
}]
|
||||||
|
});
|
||||||
modalBody.appendChild(modalHeading);
|
modalBody.appendChild(modalHeading);
|
||||||
};
|
};
|
||||||
if (options.content) {
|
if (options.content) {
|
||||||
if (typeof options.content == "string") {
|
if (typeof options.content == "string") {
|
||||||
var container = helper.node("div|class:container");
|
var container = helper.node("div|class:container");
|
||||||
var para = helper.node("p:" + options.content);
|
var para = helper.makeNode({
|
||||||
|
tag: "p",
|
||||||
|
text: options.content
|
||||||
|
});
|
||||||
container.appendChild(para);
|
container.appendChild(para);
|
||||||
modalBody.appendChild(container);
|
modalBody.appendChild(container);
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,12 +44,13 @@ var search = (function() {
|
|||||||
get: function() {
|
get: function() {
|
||||||
var searchInput = helper.e(".search-input");
|
var searchInput = helper.e(".search-input");
|
||||||
var string = helper.trimString(searchInput.value).toLowerCase();
|
var string = helper.trimString(searchInput.value).toLowerCase();
|
||||||
|
console.log(string);
|
||||||
if (state.get.current().search) {
|
if (state.get.current().search) {
|
||||||
bookmarks.get().forEach(function(arrayItem, index) {
|
bookmarks.get().forEach(function(arrayItem, index) {
|
||||||
arrayItem.items.forEach(function(arrayItem, index) {
|
arrayItem.items.forEach(function(arrayItem, index) {
|
||||||
arrayItem.searchMatch = false;
|
arrayItem.searchMatch = false;
|
||||||
var matchUrl = helper.checkIfValidString(arrayItem.url) && (arrayItem.url.toLowerCase().includes(string));
|
var matchUrl = helper.checkIfValidString(arrayItem.url) && arrayItem.url.toLowerCase().includes(string);
|
||||||
var matchName = helper.checkIfValidString(arrayItem.name) && (helper.trimString(arrayItem.name).toLowerCase().includes(string));
|
var matchName = helper.checkIfValidString(arrayItem.name) && helper.trimString(arrayItem.name).toLowerCase().includes(string);
|
||||||
if (matchUrl || matchName) {
|
if (matchUrl || matchName) {
|
||||||
arrayItem.searchMatch = true;
|
arrayItem.searchMatch = true;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user