VulpesOS/gaia/apps/bookmark/js/bookmark_remover.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

39 lines
1.2 KiB
JavaScript
Executable file

'use strict';
/* global BookmarksDatabase */
/* exported BookmarkRemover */
var BookmarkRemover = {
init: function bookmarkRemover_init(data) {
var id = data.id;
BookmarksDatabase.get(id).then(function got(bookmark) {
if (!bookmark) {
data.oncancelled('bookmark does not exist');
return;
}
// Title and message
var ttl = document.getElementById('title');
var msg = document.getElementById('message');
ttl.setAttribute('data-l10n-id', 'remove-title');
ttl.setAttribute('data-l10n-args',
JSON.stringify({ name: bookmark.name }));
msg.setAttribute('data-l10n-id', 'remove-message');
msg.setAttribute('data-l10n-args',
JSON.stringify({ name: bookmark.name }));
// Action handlers
document.getElementById('cancel-action').addEventListener('click',
function onCancel() {
data.oncancelled('cancelled');
}
);
document.getElementById('remove-action').addEventListener('click',
function onConfirm(evt) {
evt.target.removeEventListener('click', onConfirm);
BookmarksDatabase.remove(id).then(data.onremoved, data.oncancelled);
}
);
}, data.oncancelled);
}
};