fixes
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
let serverUrl = '';
|
||||
|
||||
browser.storage.sync.get('serverUrl').then(r => {
|
||||
if (r.serverUrl) serverUrl = r.serverUrl.replace(/\/+$/, '');
|
||||
});
|
||||
function norm(v) {
|
||||
return (v || '').replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
async function getServerUrl() {
|
||||
const r = await browser.storage.sync.get('serverUrl');
|
||||
serverUrl = norm(r.serverUrl);
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
browser.storage.onChanged.addListener(changes => {
|
||||
if (changes.serverUrl) {
|
||||
serverUrl = changes.serverUrl.newValue.replace(/\/+$/, '');
|
||||
serverUrl = norm(changes.serverUrl.newValue);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,10 +28,18 @@ browser.runtime.onMessage.addListener((msg, sender) => {
|
||||
});
|
||||
|
||||
async function request(path, opts) {
|
||||
if (!serverUrl) throw new Error('Server URL not configured');
|
||||
const base = await getServerUrl();
|
||||
if (!base) {
|
||||
throw new Error('Server URL not set — open snotes and click "Capture" → "Apply to Extension", or set it in Options');
|
||||
}
|
||||
opts = opts || {};
|
||||
opts.credentials = 'include';
|
||||
const res = await fetch(serverUrl + path, opts);
|
||||
let res;
|
||||
try {
|
||||
res = await fetch(base + path, opts);
|
||||
} catch (e) {
|
||||
throw new Error('Cannot reach ' + base + ' (' + e.message + ')');
|
||||
}
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}));
|
||||
throw new Error(err.detail || 'HTTP ' + res.status);
|
||||
|
||||
@@ -114,12 +114,19 @@
|
||||
browser.runtime.openOptionsPage();
|
||||
});
|
||||
|
||||
function updateIndicator() {
|
||||
var el = document.getElementById('server-indicator');
|
||||
var display = serverUrl ? serverUrl.replace(/^https?:\/\//, '') : 'Set server URL…';
|
||||
el.textContent = display;
|
||||
el.title = serverUrl || '';
|
||||
}
|
||||
|
||||
browser.storage.sync.get('serverUrl').then(function (r) {
|
||||
serverUrl = (r.serverUrl || '').replace(/\/+$/, '');
|
||||
if (!serverUrl) showStatus('Set the server URL in Options', false);
|
||||
updateIndicator();
|
||||
loadUsers();
|
||||
});
|
||||
|
||||
loadUsers();
|
||||
captureContext();
|
||||
noteEl.focus();
|
||||
})();
|
||||
|
||||
@@ -327,6 +327,10 @@ body {
|
||||
.tools-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
|
||||
.tools-row .muted { min-height: 1.2em; }
|
||||
|
||||
.tools-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
|
||||
.tools-head h1 { margin: 0; }
|
||||
.tools-logo { height: 40px; width: auto; }
|
||||
|
||||
.login-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -254,7 +254,10 @@ function showTools() {
|
||||
const qsApply = el("button", { class: "btn", text: "Apply to Extension" });
|
||||
|
||||
const card = el("div", { class: "help-card" }, [
|
||||
el("h1", { text: "Quick capture" }),
|
||||
el("div", { class: "tools-head" }, [
|
||||
el("img", { src: "/static/snotes-logo.png", class: "tools-logo", alt: "quickSnote" }),
|
||||
el("h1", { text: "Quick capture" }),
|
||||
]),
|
||||
el("p", { html: 'The <b>quickSnote</b> browser extension lets you jot a note from any page. It prefills the note with the text you\'ve selected, and a <b>Page</b> button inserts the current page\'s title and link.' }),
|
||||
|
||||
el("h2", { text: "Firefox" }),
|
||||
|
||||
Reference in New Issue
Block a user