update: fixed timer
This commit is contained in:
38
index.html
38
index.html
@@ -188,6 +188,26 @@
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
dayjs.extend(dayjs_plugin_utc);
|
||||
dayjs.extend(dayjs_plugin_timezone);
|
||||
dayjs.extend(dayjs_plugin_duration);
|
||||
dayjs.extend(dayjs_plugin_relativeTime);
|
||||
|
||||
const Timer = {
|
||||
setTimestamp: (reset=false) => {
|
||||
$('#uptimeLabel').dataset.timestamp = dayjs().unix();
|
||||
if (reset) $('#uptimeLabel').dataset.timedelta = 0;
|
||||
},
|
||||
setTimedelta: () => {
|
||||
$('#uptimeLabel').dataset.timedelta = Timer.getTimedelta().asSeconds();
|
||||
},
|
||||
getTimedelta: () => {
|
||||
let timedelta = dayjs.duration(dayjs().diff(dayjs.unix($('#uptimeLabel').dataset.timestamp)));
|
||||
let sum = dayjs.duration($('#uptimeLabel').dataset.timedelta||0, 'second').add(timedelta);
|
||||
return sum;
|
||||
},
|
||||
};
|
||||
|
||||
const $ = (selectors) => {
|
||||
return document.querySelector(selectors);
|
||||
};
|
||||
@@ -245,6 +265,7 @@ $$$('#send', 'click', async (e) => {
|
||||
|
||||
Connection.send(JSON.stringify(parameters));
|
||||
Status = 'RUNNING';
|
||||
Timer.setTimestamp(true);
|
||||
|
||||
$('#send > span.text').innerHTML = 'Pause';
|
||||
$('#send > span.icon').classList.remove('hidden');
|
||||
@@ -278,7 +299,6 @@ $$$('#send', 'click', async (e) => {
|
||||
Status = 'READY';
|
||||
|
||||
$('#fileLabel').innerHTML = file.name;
|
||||
$('#uptimeLabel').dataset.seconds = 0;
|
||||
$('#send > span.text').innerHTML = 'Send';
|
||||
$('#cancel').disabled = false;
|
||||
$('#send').disabled = true;
|
||||
@@ -444,6 +464,7 @@ function main(url, parameters, locales) {
|
||||
case 'setStatus':
|
||||
switch (args[0]) {
|
||||
case 'RESUME':
|
||||
Timer.setTimestamp();
|
||||
case 'BYPASS':
|
||||
Status = 'RUNNING';
|
||||
$('#send').disabled = false;
|
||||
@@ -452,6 +473,7 @@ function main(url, parameters, locales) {
|
||||
case 'ONHOLD':
|
||||
Status = 'STANDBY';
|
||||
$('#send').disabled = false;
|
||||
Timer.setTimedelta();
|
||||
break;
|
||||
case 'FAILED':
|
||||
Status = 'STANDBY';
|
||||
@@ -491,11 +513,6 @@ function main(url, parameters, locales) {
|
||||
}
|
||||
});
|
||||
|
||||
dayjs.extend(dayjs_plugin_utc);
|
||||
dayjs.extend(dayjs_plugin_timezone);
|
||||
dayjs.extend(dayjs_plugin_duration);
|
||||
dayjs.extend(dayjs_plugin_relativeTime);
|
||||
|
||||
let clock = setInterval(() => {
|
||||
let timezone = $('#timezoneLabel').dataset.timezone;
|
||||
let city = timezone.split('/')[1];
|
||||
@@ -510,16 +527,15 @@ function main(url, parameters, locales) {
|
||||
let percentage = parseFloat((index / limit * 100).toFixed(2));
|
||||
$('#progressLabel').innerHTML = `${index} / ${limit} (${percentage} %)`;
|
||||
|
||||
let uptime = dayjs.duration($('#uptimeLabel').dataset.seconds, 'second');
|
||||
let uptime = Timer.getTimedelta();
|
||||
$('#uptimeLabel').innerHTML = uptime.format("HH:mm:ss");
|
||||
|
||||
let rate = Number($('#progressLabel').dataset.sent) / uptime.asSeconds();
|
||||
let spm = parseFloat(Number(rate*60).toFixed(2));
|
||||
|
||||
$('#remainingLabel').innerHTML = rate > 0 ? `<span>${dayjs.duration((limit - index) / rate, 'second').humanize()}</span>` : '';
|
||||
$('#remainingLabel').innerHTML += spm >= 1 ? `<span class="${spm > 8.33 ? 'rate warning' : 'rate'}">${spm} per minute</span>` : '';
|
||||
$('#uptimeLabel').innerHTML = uptime.format("HH:mm:ss");
|
||||
$('#uptimeLabel').dataset.seconds = uptime.asSeconds() + 1;
|
||||
}
|
||||
}, 1000);
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
5
main.py
5
main.py
@@ -293,6 +293,11 @@ def main(driver: WebDriver):
|
||||
recipients = data.get(parameters.get('column_address'), [])
|
||||
limit = len(recipients)
|
||||
|
||||
if not limit:
|
||||
tell('输入无效', filename, level=1)
|
||||
outbox.put(Command('setStatus', 'FINISH'))
|
||||
continue
|
||||
|
||||
names = data.get(parameters.get('column_name'), [None] * limit)
|
||||
codes = data.get(parameters.get('column_code'), [None] * limit)
|
||||
sents = data.setdefault(parameters.get('column_sent'), [None] * limit)
|
||||
|
||||
Reference in New Issue
Block a user