Improve error notification for conkeror
This commit is contained in:
parent
2ddf0ce51c
commit
2c6d18f5f1
1 changed files with 13 additions and 11 deletions
24
js/clark.js
24
js/clark.js
|
@ -41,10 +41,10 @@ define_browser_object_class(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add URL to clark, ask for a title (provide TITLE as a
|
||||||
|
// default), description and any number of tags.
|
||||||
function clark_add_url(I, url, title)
|
function clark_add_url(I, url, title)
|
||||||
{ // Add URL to clark, ask for a title (provide TITLE as a
|
{ let url_string = load_spec_uri_string(load_spec(url));
|
||||||
// default), description and any number of tags.
|
|
||||||
let url_string = load_spec_uri_string(load_spec(url));
|
|
||||||
let title = yield I.minibuffer.read($prompt="name (required): ",
|
let title = yield I.minibuffer.read($prompt="name (required): ",
|
||||||
$initial_value=title);
|
$initial_value=title);
|
||||||
let description = yield I.minibuffer.read(
|
let description = yield I.minibuffer.read(
|
||||||
|
@ -58,7 +58,9 @@ function clark_add_url(I, url, title)
|
||||||
+ tags.split(',').map(function (str)
|
+ tags.split(',').map(function (str)
|
||||||
{ return str.trim(); }).join("' '")
|
{ return str.trim(); }).join("' '")
|
||||||
+ "'";
|
+ "'";
|
||||||
yield clark_shell_command(command);
|
let result = yield clark_shell_command(command);
|
||||||
|
|
||||||
|
yield co_return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clark_add(I) {
|
function clark_add(I) {
|
||||||
|
@ -66,7 +68,7 @@ function clark_add(I) {
|
||||||
let result = yield clark_add_url(I, I.buffer.top_frame,
|
let result = yield clark_add_url(I, I.buffer.top_frame,
|
||||||
I.buffer.title);
|
I.buffer.title);
|
||||||
|
|
||||||
if (!result)
|
if (result === "")
|
||||||
I.window.minibuffer.message('Added to clark');
|
I.window.minibuffer.message('Added to clark');
|
||||||
else
|
else
|
||||||
I.window.minibuffer.message('Couldn\'t add to clark');
|
I.window.minibuffer.message('Couldn\'t add to clark');
|
||||||
|
@ -81,7 +83,7 @@ function clark_add_link(I) {
|
||||||
let result = yield clark_add_url(I, encodeURIComponent(bo),
|
let result = yield clark_add_url(I, encodeURIComponent(bo),
|
||||||
bo.textContent);
|
bo.textContent);
|
||||||
|
|
||||||
if (!result)
|
if (result === "")
|
||||||
I.window.minibuffer.message('Added to clark');
|
I.window.minibuffer.message('Added to clark');
|
||||||
else
|
else
|
||||||
I.window.minibuffer.message('Couldn\'t add to clark');
|
I.window.minibuffer.message('Couldn\'t add to clark');
|
||||||
|
@ -188,7 +190,7 @@ function clark_edit(I) {
|
||||||
|
|
||||||
var result = yield clark_shell_command(command);
|
var result = yield clark_shell_command(command);
|
||||||
|
|
||||||
if (result)
|
if (result === "")
|
||||||
I.window.minibuffer.message("CLark done");
|
I.window.minibuffer.message("CLark done");
|
||||||
else
|
else
|
||||||
I.window.minibuffer.message("Error during CLark operation.");
|
I.window.minibuffer.message("Error during CLark operation.");
|
||||||
|
@ -234,7 +236,7 @@ function clark_remove(I) {
|
||||||
let command = clark_program + ' remove "' + url_string + '"';
|
let command = clark_program + ' remove "' + url_string + '"';
|
||||||
let result = yield clark_shell_command(command);
|
let result = yield clark_shell_command(command);
|
||||||
|
|
||||||
if (result)
|
if (result === "")
|
||||||
I.window.minibuffer.message("CLark done");
|
I.window.minibuffer.message("CLark done");
|
||||||
else
|
else
|
||||||
I.window.minibuffer.message("Error during CLark operation.");
|
I.window.minibuffer.message("Error during CLark operation.");
|
||||||
|
@ -256,7 +258,7 @@ function clark_set_tags(I) {
|
||||||
).join(" ");
|
).join(" ");
|
||||||
let result = yield clark_shell_command(command);
|
let result = yield clark_shell_command(command);
|
||||||
|
|
||||||
if (result)
|
if (result === "")
|
||||||
I.window.minibuffer.message("CLark done");
|
I.window.minibuffer.message("CLark done");
|
||||||
else
|
else
|
||||||
I.window.minibuffer.message("Error during CLark operation.");
|
I.window.minibuffer.message("Error during CLark operation.");
|
||||||
|
@ -283,7 +285,7 @@ interactive("clark-random", "Open a random bookmark", clark_random);
|
||||||
function clark_shell_command(command)
|
function clark_shell_command(command)
|
||||||
{
|
{
|
||||||
let data = "", error = "";
|
let data = "", error = "";
|
||||||
yield shell_command(
|
let res = yield shell_command(
|
||||||
command,
|
command,
|
||||||
$fds = [{ output: async_binary_string_writer("") },
|
$fds = [{ output: async_binary_string_writer("") },
|
||||||
{ input: async_binary_reader(
|
{ input: async_binary_reader(
|
||||||
|
@ -294,7 +296,7 @@ function clark_shell_command(command)
|
||||||
)}]
|
)}]
|
||||||
);
|
);
|
||||||
|
|
||||||
yield co_return(error == "" && data);
|
yield co_return(res == 0 && error == "" && data);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_keymap("clark_keymap");
|
define_keymap("clark_keymap");
|
||||||
|
|
Loading…
Reference in a new issue