forked from JWHorner/KinLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteConfirmation.js
36 lines (31 loc) · 1.25 KB
/
deleteConfirmation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const params = new URLSearchParams(window.location.search);
const id = params.get('id').trim();
const name = params.get('name').trim();
const referrer = params.get('referrer').trim();
let seconds = 3;
// Version
document.getElementById('version').innerText = `v${chrome.runtime.getManifest().version_name}`;
document.getElementById('warning').innerText = `Permanently delete chat log for\r\n${name}?`;
function deleteConversation() {
chrome.tabs.query({ 'active': true, 'lastFocusedWindow': true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { type: "deleteConversation", id: id }, function (response) {
location.href = referrer;
});
});
}
// Buttons
document.getElementById('cancel').addEventListener('click', function(){
location.href = referrer;
});
document.getElementById('delete').addEventListener('click', function(){
deleteConversation();
});
document.getElementById('delete').innerText = seconds;
let timer = setInterval(function(){
document.getElementById('delete').innerText = --seconds;
if (seconds === 0) {
document.getElementById('delete').innerText = 'Confirm';
document.getElementById('delete').attributes.removeNamedItem('disabled');
clearInterval(timer);
}
}, 1000)