Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Countdown in a pop-up window(ポップアップウインドウでのカウントダウン) #69

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion confirm-address/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
"caDialogAcceptbtn": {
"message": "Senden"
},
"caCountdownSubject": {
"message": "Subject:"
},
"caCountdownTitle": {
"message": "Countdown"
"message": "Confirm-Address: Countdown"
},
"caCountdownMsg1": {
"message": "Countdown..."
Expand All @@ -58,6 +61,9 @@
"caDialogCancelbtn": {
"message": "Cancel"
},
"caCountdownNone": {
"message": "There is no mail to countdown."
},
//"setting.html": "*** L10n message ***",
"caSettingTitle": {
"message": "Confirm-Address Einstellungen"
Expand Down
8 changes: 7 additions & 1 deletion confirm-address/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@
"caDialogCancelbtn": {
"message": "Cancel"
},
"caCountdownSubject": {
"message": "Subject:"
},
"caCountdownTitle": {
"message": "Countdown"
"message": "Confirm-Address: Countdown"
},
"caCountdownMsg1": {
"message": "Countdown..."
Expand All @@ -61,6 +64,9 @@
"caCountdownSkip": {
"message": "Send"
},
"caCountdownNone": {
"message": "There is no mail to countdown."
},
//"setting.html": "*** L10n message ***",
"caSettingTitle": {
"message": "Confirm-Address settings"
Expand Down
8 changes: 7 additions & 1 deletion confirm-address/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@
"caDialogCancelbtn": {
"message": "Annuler"
},
"caCountdownSubject": {
"message": "Subject:"
},
"caCountdownTitle": {
"message": "Compte à rebours"
"message": "Confirm-Address: Compte à rebours"
},
"caCountdownMsg1": {
"message": "Compte à rebours..."
Expand All @@ -61,6 +64,9 @@
"caCountdownSkip": {
"message": "Envoyer"
},
"caCountdownNone": {
"message": "Il n'y a pas de courrier à décompter."
},
//"setting.html": "*** L10n message ***",
"caSettingTitle": {
"message": "Paramètres de Confirm-Address"
Expand Down
6 changes: 6 additions & 0 deletions confirm-address/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"caDialogCancelbtn": {
"message": "キャンセル"
},
"caCountdownSubject": {
"message": "件名:"
},
"caCountdownTitle": {
"message": "カウントダウン"
},
Expand All @@ -61,6 +64,9 @@
"caCountdownSkip": {
"message": "送信"
},
"caCountdownNone": {
"message": "カウントダウン対象のメールはありません"
},
//"setting.html": "*** L10n message ***",
"caSettingTitle": {
"message": "Confirm-Address 設定"
Expand Down
8 changes: 7 additions & 1 deletion confirm-address/_locales/pt-BR/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@
"caDialogCancelbtn": {
"message": "Cancel"
},
"caCountdownSubject": {
"message": "Subject:"
},
"caCountdownTitle": {
"message": "Contagem Regressiva"
"message": "Confirm-Address: Contagem Regressiva"
},
"caCountdownMsg1": {
"message": "Contagem Regressiva..."
Expand All @@ -61,6 +64,9 @@
"caCountdownSkip": {
"message": "Enviar"
},
"caCountdownNone": {
"message": "Não há correio a ser contado."
},
//"setting.html": "*** L10n message ***",
"caSettingTitle": {
"message": "Confirme os ajustes de endereço"
Expand Down
8 changes: 4 additions & 4 deletions confirm-address/html/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
.box_scrollbar {
overflow: auto;
width: 300px;
width: 500px;
height: 80px;
padding: 5px;
border: 1px solid #fff;
Expand All @@ -38,7 +38,7 @@
.box_title {
border: 1px solid #fff;
padding: 5px;
width: 300px;
width: 500px;
font-weight: bold;
font-size: 14px;
background-color: #777;
Expand Down Expand Up @@ -67,7 +67,7 @@
}
.box_scrollbar {
overflow: auto;
width: 300px;
width: 500px;
height: 80px;
padding: 5px;
border: 1px solid #000;
Expand All @@ -79,7 +79,7 @@
.box_title {
border: 1px solid #000;
padding: 5px;
width: 300px;
width: 500px;
font-weight: bold;
font-size: 14px;
background-color: #000;
Expand Down
5 changes: 0 additions & 5 deletions confirm-address/html/confirm-address-popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ <h3 l10n-tag="caDialogMessage" id="DialogMessage" style="display:none;"></h3>
<div id="Attachments" class="box_scrollbar">
</div>
</div>
<div id="countdownArea" style="display:none;">
<span id="countdown1" l10n-tag="caCountdownMsg1"></span>
<span id="counter"></span>&nbsp;
<span id="countdown2" l10n-tag="caCountdownMsg2"></span>
</div>
<div>
<input type="button" name="btn_send" l10n-val-tag="caDialogAcceptbtn" disabled="true">
&nbsp;
Expand Down
45 changes: 45 additions & 0 deletions confirm-address/html/countdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" media="screen" href="common.css">
<title>Confirm-Address: Countdown</title>
<style type="text/css">
</style>
<script src="../scripts/countdown.js" defer></script>
<script src="../scripts/l10n.js" defer></script>
</head>
<body>

<h1 l10n-tag="caCountdownTitle"></h1>
<p id="noitems" style="display:none" l10n-tag="caCountdownNone"></p>

<!-- Countdown Queue Item Template -->
<template id="caCDQItem">
<form>
<div id="caCD">
<div class="box_title">
<span l10n-tab="caCountdownSubject"></span>&nbsp;<span id="mailSubject"></span>
</div>

<div id="countdownMessage" class="box_scrollbar">
<p>
<span id="countdown1" l10n-tag="caCountdownMsg1"></span>
<span id="counter"></span>&nbsp;
<span id="countdown2" l10n-tag="caCountdownMsg2"></span>
</p>
<p>
<button id="btn_send_now" l10n-tag="caCountdownSkip"></button>
&nbsp;<button id="btn_abort" l10n-tag="caDialogCancelbtn"></button>
</p>
</div>
</div>
</form>
</template>

<!-- Actual countdown queue item places here -->
<div id="caCountdownQueue">

</div>
</body>
</html>
78 changes: 76 additions & 2 deletions confirm-address/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var default_prefs = {
};
var promiseMap = new Map();

var numCountdown = 0;

async function init() {
browser.composeAction.disable();
await loadPrefs();
Expand Down Expand Up @@ -48,6 +50,7 @@ browser.runtime.onMessage.addListener(async message => {
await loadPrefs();
var recipients = [];
await collectAddress(message.tabId, recipients);
var mailsubject = await getMailSubject(message.tabId);
var mailbody = await getMailBody(message.tabId);
var attachments = [];
await getAttachments(message.tabId, attachments);
Expand All @@ -56,14 +59,15 @@ browser.runtime.onMessage.addListener(async message => {
browser.runtime.sendMessage({
message: "SEND_RECIPIENTS",
recipients: recipients,
mailsubject: mailsubject,
mailbody: mailbody,
attachments: attachments,
prefs: prefs,
session: inSendSession
});
break;
case "USER_CHECKED":
let resolve = promiseMap.get(message.tabId);
var resolve = promiseMap.get(message.tabId);
if (!resolve) {
break;
}
Expand All @@ -80,7 +84,65 @@ browser.runtime.onMessage.addListener(async message => {
});
}
break;
default:
case "USER_CHECKED_WITH_COUNTDOWN":
var resolve = promiseMap.get(message.tabId);
if (!resolve) {
break;
}

if (message.confirmed) {
browser.composeAction.disable(message.tabId);
var limit = prefs["CA_COUNT_DOWN_TIME"];
if(numCountdown == 0){
var newDialog = {
type: "detached_panel",
url: "html/countdown.html",
width: 550,
height: 400
};

browser.windows.create(newDialog);
}

numCountdown++;
const ms = 333;
setTimeout(() => {
browser.runtime.sendMessage({
message: "START_COUNTDOWN",
mailsubject: message.mailsubject,
tabId: message.tabId,
countdownSec: limit
});
}, ms);
} else {
browser.composeAction.enable(message.tabId);
resolve({
cancel: true // for onBeforeSend event
});
}
break;
case "SEND_MAIL_NOW":
var resolve = promiseMap.get(message.tabId);
if (!resolve) {
break;
}
resolve({
cancel: false
});
numCountdown--;
break;
case "ABORT_SEND_MAIL":
var resolve = promiseMap.get(message.tabId);
if (!resolve) {
break;
}
browser.composeAction.enable(message.tabId);
resolve({
cancel: true
});
numCountdown--;
break;
default:
break;
}
});
Expand All @@ -96,6 +158,18 @@ async function getAttachments(tabId, attachments){
attachments.push({name: atts[item].name});
}
}

async function getMailSubject(tabId){
if (tabId == null) {
return;
}

let details = await browser.compose.getComposeDetails(tabId);
var mailsubject = details.subject;

//console.log(mailsubject);
return mailsubject;
}

async function getMailBody(tabId){
if (tabId == null) {
Expand Down
Loading