Skip to content

Commit

Permalink
Open in tab button next to list, false positive badges fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayquaza01 committed Jul 24, 2018
1 parent 5b3c360 commit 5880ee9
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 50 deletions.
4 changes: 4 additions & 0 deletions extension/notes.css
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,7 @@ select {
flex: 0 1 20px;
overflow-y: hidden;
}

.bold {
font-weight: bold;
}
38 changes: 27 additions & 11 deletions extension/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,32 @@ async function deleteNote() {

async function loadCustomNote(e) {
var tabs = await browser.tabs.query({active: true, currentWindow: true});
console.log(e.target.innerText)
if (e.target.innerText !== back.innerText && e.target.className !== "mdi mdi-delete") {
back.dataset[tabs[0].id] = e.target.innerText;
} else {
delete back.dataset[tabs[0].id];
loadSiteNotes();
if (e.target.className === "name") {
if (e.target.innerText !== back.innerText) {
back.dataset[tabs[0].id] = e.target.innerText;
} else if (e.target.innerText === back.innerText) {
delete back.dataset[tabs[0].id];
loadSiteNotes();
}
}
if (e.target.innerText === "General Notes") {
loadGeneralNotes();
} else if (e.target.className === "mdi mdi-delete") {
}
switch (e.target.className) {
case "mdi mdi-delete":
confirmDelete.style.width = "100%";
siteName.innerText = e.target.dataset.deleteSite;
return;
} else if (e.target.className === "name") {
siteNoteSetup(e.target.innerText);
} else {
case "mdi mdi-open-in-new":
browser.tabs.create({
active: true,
url: "https://" + e.target.dataset.open
});
break;
case "name":
siteNoteSetup(back.dataset[tabs[0].id]);
break;
default:
return;
}
closeList();
Expand Down Expand Up @@ -210,10 +220,16 @@ function addNoteToList(site) {
name.innerText = site;
name.title = site;
name.className = "name";
cont.append(name);
if (site.indexOf("about:") === -1) {
var open = document.createElement("span");
open.dataset.open = site;
open.className = "mdi mdi-open-in-new";
cont.append(open);
}
var del = document.createElement("span");
del.dataset.deleteSite = site;
del.className = "mdi mdi-delete";
cont.append(name);
cont.append(del);
noteList.append(cont);
}
Expand Down
76 changes: 37 additions & 39 deletions extension/setup.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
function setOpts() {
browser.storage.local.get().then((res) => {
res.options = res.hasOwnProperty("options") ? res.options : {};
res.options.theme = res.options.hasOwnProperty("theme") ? res.options.theme : "light";
res.options.background_color = res.options.hasOwnProperty("background_color") ? res.options.background_color : "ffffff";
res.options.font_color = res.options.hasOwnProperty("font_color") ? res.options.font_color : "000000";
res.options.background_color_dark = res.options.hasOwnProperty("background_color_dark") ? res.options.background_color_dark : "000000";
res.options.font_color_dark = res.options.hasOwnProperty("font_color_dark") ? res.options.font_color_dark : "ffffff";
res.options.width = res.options.hasOwnProperty("width") ? res.options.width : 400;
res.options.height = res.options.hasOwnProperty("height") ? res.options.height : 300;
res.options.font_family = res.options.hasOwnProperty("font_family") ? res.options.font_family : "default";
res.options.font_size = res.options.hasOwnProperty("font_size") ? res.options.font_size : 16;
res.options.font_css = res.options.hasOwnProperty("font_css") ? res.options.font_css : "";
res.options.default_display = res.options.hasOwnProperty("default_display") ? res.options.default_display : "general_notes";
if (res.options.default_display === "site_notes") {
res.options.default_display = res.options.per_site;
}
// res.options.per_site = res.options.hasOwnProperty("per_site") ? res.options.per_site : "domain";
res.options.private_browsing = res.options.hasOwnProperty("private_browsing") ? res.options.private_browsing : false;
res.options.subdomains_mode = res.options.hasOwnProperty("subdomains_mode") ? res.options.subdomains_mode : "blacklist";
res.options.subdomains = res.options.hasOwnProperty("subdomains") ? res.options.subdomains : [];
res.options.notification_badge = res.options.hasOwnProperty("notification_badge") ? res.options.notification_badge : "disabled";
res.options.notification_badge_color = res.options.hasOwnProperty("notification_badge_color") ? res.options.notification_badge_color : "d90000";
res.options.bullet_types = res.options.hasOwnProperty("bullet_types") ? res.options.bullet_types : ["*", "-", "+"];
res.options.get_params = res.options.hasOwnProperty("get_params") ? res.options.get_params : ["q", "v"];
res.options.tabnos = res.options.hasOwnProperty("tabnos") ? res.options.tabnos : 1;
res.options.padding = res.options.hasOwnProperty("padding") ? res.options.padding : 5;
res.site_notes = res.hasOwnProperty("site_notes") ? res.site_notes : {};
if (!Array.isArray(res.general_notes)) {
res.general_notes = [res.general_notes];
}
for (var site in res.site_notes) {
if (!Array.isArray(res.site_notes[site])) {
res.site_notes[site] = [res.site_notes[site]];
}
async function setOpts() {
var res = await browser.storage.local.get();
res.options = res.hasOwnProperty("options") ? res.options : {};
res.options.theme = res.options.hasOwnProperty("theme") ? res.options.theme : "light";
res.options.background_color = res.options.hasOwnProperty("background_color") ? res.options.background_color : "ffffff";
res.options.font_color = res.options.hasOwnProperty("font_color") ? res.options.font_color : "000000";
res.options.background_color_dark = res.options.hasOwnProperty("background_color_dark") ? res.options.background_color_dark : "000000";
res.options.font_color_dark = res.options.hasOwnProperty("font_color_dark") ? res.options.font_color_dark : "ffffff";
res.options.width = res.options.hasOwnProperty("width") ? res.options.width : 400;
res.options.height = res.options.hasOwnProperty("height") ? res.options.height : 300;
res.options.font_family = res.options.hasOwnProperty("font_family") ? res.options.font_family : "default";
res.options.font_size = res.options.hasOwnProperty("font_size") ? res.options.font_size : 16;
res.options.font_css = res.options.hasOwnProperty("font_css") ? res.options.font_css : "";
res.options.default_display = res.options.hasOwnProperty("default_display") ? res.options.default_display : "general_notes";
if (res.options.default_display === "site_notes") {
res.options.default_display = res.options.per_site;
}
// res.options.per_site = res.options.hasOwnProperty("per_site") ? res.options.per_site : "domain";
res.options.private_browsing = res.options.hasOwnProperty("private_browsing") ? res.options.private_browsing : false;
res.options.subdomains_mode = res.options.hasOwnProperty("subdomains_mode") ? res.options.subdomains_mode : "blacklist";
res.options.subdomains = res.options.hasOwnProperty("subdomains") ? res.options.subdomains : [];
res.options.notification_badge = res.options.hasOwnProperty("notification_badge") ? res.options.notification_badge : "disabled";
res.options.notification_badge_color = res.options.hasOwnProperty("notification_badge_color") ? res.options.notification_badge_color : "d90000";
res.options.bullet_types = res.options.hasOwnProperty("bullet_types") ? res.options.bullet_types : ["*", "-", "+"];
res.options.get_params = res.options.hasOwnProperty("get_params") ? res.options.get_params : ["q", "v"];
res.options.tabnos = res.options.hasOwnProperty("tabnos") ? res.options.tabnos : 1;
res.options.padding = res.options.hasOwnProperty("padding") ? res.options.padding : 5;
res.site_notes = res.hasOwnProperty("site_notes") ? res.site_notes : {};
if (!Array.isArray(res.general_notes)) {
res.general_notes = [res.general_notes];
}
for (var site in res.site_notes) {
if (!Array.isArray(res.site_notes[site])) {
res.site_notes[site] = [res.site_notes[site]];
}
browser.storage.local.set(res);
});
}
browser.storage.local.set(res);
}

function escapeRegex(regex) {
Expand All @@ -55,7 +54,7 @@ function bulletCounter(bulletTypes, note) {
}

function setBadge(bullet_types, notification_badge, notes, tabId) {
if (notes !== "") {
if (notes !== null && notes !== "") {
if (notification_badge.indexOf("enabled") > -1) {
browser.browserAction.setBadgeText({text: "!", tabId: tabId});
}
Expand All @@ -79,7 +78,6 @@ async function setBadgeSite(tab) {
setBadgeGeneral(tab);
} else if (!tab.incognito || (res.options.private_browsing && tab.incognito)) {
if (res.site_notes.hasOwnProperty(site)) {
console.log(res.site_notes[site][0])
setBadge(res.options.bullet_types, res.options.notification_badge, res.site_notes[site][0], tab.id);
} else {
browser.browserAction.setBadgeText({text: "", tabId: tab.id});
Expand Down

0 comments on commit 5880ee9

Please sign in to comment.