Merge branch 'develop' into main
continuous-integration/drone/push Build is passing Details

Added checkbox to enable/disable archiving to popup.
This commit is contained in:
tastytea 2019-06-15 01:57:55 +02:00
commit 861232ab38
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
5 changed files with 38 additions and 20 deletions

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "remwharead",
"version": "0.3.1",
"version": "0.4.0",
"description": "Integrates remwharead into your Browser.",
"homepage_url": "https://schlomp.space/tastytea/remwharead",

View File

@ -9,7 +9,7 @@ function save_options(e)
function restore_options()
{
var item = browser.storage.sync.get('archive');
const item = browser.storage.sync.get('archive');
item.then((res) =>
{
if (res.archive === false)
@ -24,10 +24,10 @@ function info_commands(commands)
commands.forEach(
function(command)
{
var element = document.querySelector("#shortcuts");
var para = document.createElement("p");
const element = document.querySelector("#shortcuts");
const para = document.createElement("p");
var text = document.createElement("strong");
const text = document.createElement("strong");
text.appendChild(document.createTextNode(command.shortcut + ": "));
para.appendChild(text);
para.appendChild(document.createTextNode(command.description));
@ -39,5 +39,5 @@ function info_commands(commands)
document.addEventListener('DOMContentLoaded', restore_options);
document.querySelector("#archive").addEventListener("change", save_options);
var get_commands = browser.commands.getAll();
const get_commands = browser.commands.getAll();
get_commands.then(info_commands);

View File

@ -7,8 +7,14 @@
<!-- I did not use a form here because I want to display status and
error messages inside the popup. -->
<label for="txttags">Tags, comma separated:</label>
<input type="text" id="txttags" autofocus>
<input type="button" id="btnadd" value="Add URI">
<input type="text" id="txttags" autofocus/>
<div>
<label>
<input type="checkbox" id="chkarchive" value="archive" checked/>
Archive
</label>
<input type="button" id="btnadd" value="Add URI" style="float:right;"/>
</div>
<em id="msgstatus"></em>
<strong id="msgerror"></strong>

View File

@ -1,15 +1,21 @@
var taburl = "";
var archive = "";
let taburl = "";
const txttags = document.getElementById("txttags");
const chkarchive = document.getElementById("chkarchive");
const btnadd = document.getElementById("btnadd");
const msgstatus = document.getElementById("msgstatus");
const msgerror = document.getElementById("msgerror");
function set_taburl(tabs) // Set taburl to URL of current tab.
{
let tab = tabs[0];
const tab = tabs[0];
taburl = tab.url;
}
function get_tags() // get tags from text input.
{
let tags = txttags.value;
const tags = txttags.value;
if (tags != "")
{
return "-t '" + tags + "' ";
@ -19,12 +25,12 @@ function get_tags() // get tags from text input.
function read_options()
{
var item = browser.storage.sync.get('archive');
const item = browser.storage.sync.get('archive');
item.then((res) =>
{
if (res.archive === false)
{
archive = "--no-archive ";
chkarchive.checked = false;
}
});
}
@ -55,14 +61,20 @@ function launch(args) // Launch wrapper and send tags + URL to stdin.
msgstatus.textContent = "Launching remwharead…";
msgerror.textContent = "";
console.log("Sending: " + args + " to remwharead");
var sending = browser.runtime.sendNativeMessage("remwharead", args);
const sending = browser.runtime.sendNativeMessage("remwharead", args);
sending.then(onResponse, onError);
}
function add()
{
var arguments = get_tags() + archive + taburl;
launch(arguments);
let archive = "";
if (chkarchive.checked === false)
{
archive = "--no-archive ";
}
const args = get_tags() + archive + taburl;
console.log(args);
launch(args);
}
read_options();
@ -70,7 +82,7 @@ read_options();
// Call set_taburl() with current tab.
browser.tabs.query({currentWindow: true, active: true}).then(set_taburl);
btnadd.addEventListener("click", launch);
btnadd.addEventListener("click", add);
txttags.addEventListener( // Call launch() if enter is hit in text input.
"keyup", event =>
@ -79,6 +91,6 @@ txttags.addEventListener( // Call launch() if enter is hit in text input.
{
return;
}
launch();
add();
event.preventDefault();
});

View File

@ -64,7 +64,7 @@ const html_extract URI::get()
return
{
extract_title(answer),
extract_description(answer),
strip_html(extract_description(answer)),
strip_html(answer)
};
}