31 lines
978 B
JavaScript
31 lines
978 B
JavaScript
|
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 => {
|
||
|
smsProgress.setAttribute('aria-valuenow', data.used_today);
|
||
|
smsProgress.setAttribute('aria-valuemax', data.total_free);
|
||
|
smsProgress.setAttribute('style', `width: ${data.used_today / data.total_free * 100}%`);
|
||
|
smsProgress.innerText = `Лимит: ${data.used_today} из ${data.total_free}`;
|
||
|
});
|
||
|
|
||
|
// console.log(smsProgress);
|
||
|
}
|