Skip to content

Commit

Permalink
add option to open feeds in new tabs or not (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
aureliendavid committed Dec 4, 2020
1 parent c910cf1 commit 8a6ccab
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"manifest_version": 2,
"name": "RSSPreview",
"version": "3.14",
"version": "3.15",
"author": "Aurelien David",
"homepage_url": "https://github.com/aureliendavid/rsspreview",

Expand Down
31 changes: 27 additions & 4 deletions popup/popup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@

var options = {
newTab: true,
};

function onOptions(opts) {
options = opts;
}

function onError(error) {
console.log(`Error on get options: ${error}`);
}

browser.storage.sync.get(options).then(onOptions, onError);

document.addEventListener("DOMContentLoaded", function(event) {


Expand All @@ -24,16 +39,24 @@ document.addEventListener("DOMContentLoaded", function(event) {

document.querySelectorAll(".panel-list-item").forEach( (elem) => {

function onUpdated(tab) {
}

function onError(error) {
}

elem.addEventListener('click', (event) => {

let url = elem.getAttribute("data-href");
if (url)
browser.tabs.create({url: url});

if (url) {
if (options.newTab)
browser.tabs.create({url: url});
else
browser.tabs.update({url: url}).then(onUpdated, onError);
}

});

});

});

3 changes: 2 additions & 1 deletion rsspreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
fullPreview: false,
doAuthor: false,
enableCss: false,
customCss: null
customCss: null,
newTab: true
};

let xml_parser = new XMLSerializer();
Expand Down
2 changes: 2 additions & 0 deletions settings/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

<label class="setting browser-style"><input type="checkbox" id="doDetect" class="validate" > Enable feed detection</label>
<hr />
<label class="setting browser-style"><input type="checkbox" id="newTab" class="validate" > Open feed in new tab</label>
<hr />
<label class="setting browser-style"><input type="checkbox" id="preventPreview" class="validate" > Display raw xml instead of preview page</label>
<hr />
<label class="setting browser-style"><input type="checkbox" id="fullPreview" class="validate" > Display full articles even when summaries are present</label>
Expand Down
8 changes: 5 additions & 3 deletions settings/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ function saveOptions(e) {
doAuthor: document.querySelector("#doAuthor").checked,
orangeIcon: document.querySelector("#orangeIcon").checked,
enableCss: document.querySelector("#enableCss").checked,
customCss: document.querySelector("#customCss").value
customCss: document.querySelector("#customCss").value,
newTab: document.querySelector("#newTab").checked
});
}


function restoreOptions() {


function onResult(result) {
document.querySelector("#doThumb").checked = result.doThumb;
document.querySelector("#doMaxWidth").checked = result.doMaxWidth;
Expand All @@ -31,6 +31,7 @@ function restoreOptions() {
document.querySelector("#orangeIcon").checked = result.orangeIcon;
document.querySelector("#enableCss").checked = result.enableCss;
document.querySelector("#customCss").value = result.customCss;
document.querySelector("#newTab").checked = result.newTab;
}

function onError(error) {
Expand All @@ -47,7 +48,8 @@ function restoreOptions() {
doAuthor: false,
orangeIcon: false,
enableCss: false,
customCss: null
customCss: null,
newTab: true
});
getting.then(onResult, onError);

Expand Down

0 comments on commit 8a6ccab

Please sign in to comment.