2022-09-03 22:34:26 +03:00
|
|
|
window.onload = function () {
|
|
|
|
let dataToday = document.getElementById('data-today');
|
|
|
|
|
|
|
|
// Set current date
|
|
|
|
let today = new Date().toLocaleDateString('en-US', {
|
|
|
|
// 'weekday': 'long',
|
|
|
|
'year': 'numeric',
|
|
|
|
'month': 'long',
|
|
|
|
'day': 'numeric'
|
|
|
|
});
|
|
|
|
dataToday.innerText = today.replace('/', ' ');
|
|
|
|
|
|
|
|
let smsruUpdateButton = document.getElementById('button-smsru-update');
|
|
|
|
smsruUpdateButton.onclick = smsruUpdateMessages;
|
|
|
|
}
|
|
|
|
|
|
|
|
function smsruUpdateMessages() {
|
|
|
|
let smsProgress = document.getElementById('data-smsru-progress');
|
|
|
|
|
|
|
|
fetch('/api/v1.0/smsru_status')
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2022-09-13 22:40:21 +03:00
|
|
|
if (data.used_today === null) data.used_today = 0;
|
|
|
|
|
2022-09-03 22:34:26 +03:00
|
|
|
smsProgress.setAttribute('aria-valuenow', data.used_today);
|
|
|
|
smsProgress.setAttribute('aria-valuemax', data.total_free);
|
2022-09-13 22:40:21 +03:00
|
|
|
if (data.used_today > 0) {
|
|
|
|
smsProgress.setAttribute('style', `width: ${data.total_free / data.used_today}%`);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
smsProgress.setAttribute('style', `width: 100%`);
|
|
|
|
}
|
2022-09-03 22:34:26 +03:00
|
|
|
smsProgress.innerText = `Лимит: ${data.used_today} из ${data.total_free}`;
|
|
|
|
});
|
|
|
|
}
|