Add tabs UI to options page

This commit is contained in:
SimonBrazell 2020-04-25 18:31:27 +10:00
parent 7d1b0be167
commit 269739347f
4 changed files with 202 additions and 117 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "Privacy Redirect", "name": "Privacy Redirect",
"description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.", "description": "Redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.",
"version": "1.1.21", "version": "1.1.22",
"manifest_version": 2, "manifest_version": 2,
"background": { "background": {
"scripts": [ "scripts": [

View File

@ -11,6 +11,19 @@
<body> <body>
<div class="tab">
<button class="tablinks" id="generalTab">
General
</button>
<button class="tablinks" id="advancedTab">
Advanced
</button>
<button class="tablinks" id="whitelistTab">
Whitelist
</button>
</div>
<div id="general" class="tabcontent">
<section class="options settings_block"> <section class="options settings_block">
<div class="onoffswitch switch" aria-label="Toggle Nitter redirects"> <div class="onoffswitch switch" aria-label="Toggle Nitter redirects">
<h1>Nitter Redirects</h1> <h1>Nitter Redirects</h1>
@ -82,10 +95,12 @@
<option value="https://openstreetmap.org"> <option value="https://openstreetmap.org">
</datalist> </datalist>
</section> </section>
</div>
<div id="advanced" class="tabcontent">
<section class="options settings_block"> <section class="options settings_block">
<div class="onoffswitch switch" aria-label="Always proxy videos through Invidious"> <div class="onoffswitch switch" aria-label="Always proxy videos through Invidious">
<h1>Always proxy videos through Invidious?</h1> <h1>Always proxy videos through Invidious</h1>
<input aria-hidden="true" id="always-proxy" type="checkbox" checked>&nbsp; <input aria-hidden="true" id="always-proxy" type="checkbox" checked>&nbsp;
<label for="always-proxy" class="checkbox-label"> <label for="always-proxy" class="checkbox-label">
</label> </label>
@ -94,7 +109,7 @@
<section class="options settings_block"> <section class="options settings_block">
<div class="onoffswitch switch" aria-label="Only redirect embedded video to Invidious"> <div class="onoffswitch switch" aria-label="Only redirect embedded video to Invidious">
<h1>Only redirect embedded video to Invidious?</h1> <h1>Only redirect embedded video to Invidious</h1>
<input aria-hidden="true" id="only-embed" type="checkbox" checked>&nbsp; <input aria-hidden="true" id="only-embed" type="checkbox" checked>&nbsp;
<label for="only-embed" class="checkbox-label"> <label for="only-embed" class="checkbox-label">
</label> </label>
@ -119,6 +134,11 @@
</label> </label>
</div> </div>
</section> </section>
</div>
<div id="whitelist" class="tabcontent">
</div>
<script src="./options.js"></script> <script src="./options.js"></script>

View File

@ -1,17 +1,17 @@
'use strict'; 'use strict';
let nitterInstance = document.querySelector('#nitter-instance'); let nitterInstance = document.getElementById('nitter-instance');
let invidiousInstance = document.querySelector('#invidious-instance'); let invidiousInstance = document.getElementById('invidious-instance');
let bibliogramInstance = document.querySelector('#bibliogram-instance'); let bibliogramInstance = document.getElementById('bibliogram-instance');
let osmInstance = document.querySelector('#osm-instance'); let osmInstance = document.getElementById('osm-instance');
let disableNitter = document.querySelector('#disable-nitter'); let disableNitter = document.getElementById('disable-nitter');
let disableInvidious = document.querySelector('#disable-invidious'); let disableInvidious = document.getElementById('disable-invidious');
let disableBibliogram = document.querySelector('#disable-bibliogram'); let disableBibliogram = document.getElementById('disable-bibliogram');
let disableOsm = document.querySelector('#disable-osm'); let disableOsm = document.getElementById('disable-osm');
let alwaysProxy = document.querySelector('#always-proxy'); let alwaysProxy = document.getElementById('always-proxy');
let onlyEmbeddedVideo = document.querySelector('#only-embed'); let onlyEmbeddedVideo = document.getElementById('only-embed');
let videoQuality = document.querySelector('#video-quality'); let videoQuality = document.getElementById('video-quality');
let removeTwitterSW = document.querySelector('#remove-twitter-sw'); let removeTwitterSW = document.getElementById('remove-twitter-sw');
window.browser = window.browser || window.chrome; window.browser = window.browser || window.chrome;
@ -46,6 +46,32 @@ browser.storage.sync.get(
} }
); );
function openTab(tab, event) {
let i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName('tabcontent');
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = 'none';
}
tablinks = document.getElementsByClassName('tablinks');
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(' active', '');
}
document.getElementById(tab).style.display = 'block';
event.currentTarget.className += ' active';
}
document.getElementById('generalTab').addEventListener(
'click', openTab.bind(null, 'general')
);
document.getElementById('advancedTab').addEventListener(
'click', openTab.bind(null, 'advanced')
);
document.getElementById('whitelistTab').addEventListener(
'click', openTab.bind(null, 'whitelist')
);
document.getElementById('generalTab').click();
function debounce(func, wait, immediate) { function debounce(func, wait, immediate) {
let timeout; let timeout;
return () => { return () => {

View File

@ -2,6 +2,7 @@
--text-main: #FFF; --text-main: #FFF;
--text-secondary: #000; --text-secondary: #000;
--dark-grey: #3C4043; --dark-grey: #3C4043;
--darker-grey: #292A2D;
--white: #FFF; --white: #FFF;
--active: #FF5B56; --active: #FF5B56;
--space: 5px; --space: 5px;
@ -12,16 +13,17 @@
body { body {
color: var(--text-secondary); color: var(--text-secondary);
margin: 0; margin: 0;
background-color: var(--dark-grey); background-color: var(--darker-grey);
max-width: 400px; max-width: 400px;
margin: auto; margin: auto;
min-height: 460px;
} }
.popup { .popup {
min-width: 300px; width: 300px;
height: auto;
overflow: hidden; overflow: hidden;
background-color: var(--dark-grey);
} }
input { input {
@ -190,3 +192,40 @@ input[type="url"]:invalid {
.margin-bottom { .margin-bottom {
margin-bottom: 20px; margin-bottom: 20px;
} }
.tab {
overflow: hidden;
background-color: var(--darker-grey);
}
.tab button {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
color: var(--text-main);
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
border: solid 1px var(--dark-grey);
width: 33.333%;
font-size: 14px;
}
.tab button:hover {
background-color: var(--active);
}
.tab button.active {
background-color: var(--dark-grey);
}
.tabcontent {
padding-top: 10px;
display: none;
border: solid 1px var(--dark-grey);
background-color: var(--dark-grey);
min-height: 403px;
}