1
0
mirror of https://github.com/aureliendavid/rsspreview.git synced 2025-08-22 19:28:39 +00:00

add option to display raw xml instead of preview (#29)

This commit is contained in:
Aurelien David 2019-02-14 21:44:15 +01:00
parent 55f8d983c8
commit fe1fc2ea3a
4 changed files with 44 additions and 40 deletions

View File

@ -51,6 +51,10 @@ code {
white-space: inherit;
}
img {
height: auto;
}
#feedBody {
border: 1px solid THreeDShadow;
padding: 3em;

View File

@ -11,6 +11,15 @@
window.hasRun = true;
// defaults
var options = {
doThumb: false,
doMaxWidth: true,
valMaxWidth: "900px",
doDetect: false,
preventPreview: false
};
let xml_parser = new XMLSerializer();
let html_parser = new DOMParser();
@ -204,8 +213,6 @@
function applysettings() {
function onResult(options) {
document.querySelectorAll('.mediaThumb').forEach((elem) => {
elem.style.display = options.doThumb ? "block" : "none";
});
@ -216,21 +223,6 @@
elem.style["max-width"] = options.valMaxWidth;
});
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.sync.get({
doThumb: false,
doMaxWidth: true,
valMaxWidth: "900px"
});
getting.then(onResult, onError);
}
function makepreviewhtml() {
@ -307,26 +299,30 @@
});
}
function onOptions(opts) {
options = opts;
let feedRoot = detect();
if (feedRoot) main(feedRoot);
else {
if (feedRoot && !options.preventPreview) {
main(feedRoot);
}
else if (options.doDetect) {
function onResult(options) {
if (options.doDetect)
findFeeds();
}
}
function onError(error) {
console.log(`Error: ${error}`);
}
let getting = browser.storage.sync.get({
doDetect: false
});
getting.then(onResult, onError);
console.log(`Error on get options: ${error}`);
}
let getting = browser.storage.sync.get(options);
getting.then(onOptions, onError);
function findFeeds() {

View File

@ -13,9 +13,10 @@
<input type="checkbox" id="doMaxWidth" class="validate" > Set max-width for images at
<input type="text" id="valMaxWidth" class="validate" >
</label>
<hr />
<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="preventPreview" class="validate" > Display raw xml instead of preview page</label>
<script src="options.js"></script>
</body>

View File

@ -6,7 +6,8 @@ function saveOptions(e) {
doThumb: document.querySelector("#doThumb").checked,
doMaxWidth: document.querySelector("#doMaxWidth").checked,
valMaxWidth: document.querySelector("#valMaxWidth").value,
doDetect: document.querySelector("#doDetect").checked
doDetect: document.querySelector("#doDetect").checked,
preventPreview: document.querySelector("#preventPreview").checked
});
}
@ -19,6 +20,7 @@ function restoreOptions() {
document.querySelector("#doMaxWidth").checked = result.doMaxWidth;
document.querySelector("#valMaxWidth").value = result.valMaxWidth;
document.querySelector("#doDetect").checked = result.doDetect;
document.querySelector("#preventPreview").checked = result.preventPreview;
}
function onError(error) {
@ -29,7 +31,8 @@ function restoreOptions() {
doThumb: false,
doMaxWidth: true,
valMaxWidth: "900px",
doDetect: false
doDetect: false,
preventPreview: false
});
getting.then(onResult, onError);