Skip to content

Commit

Permalink
Unify JS simicolon
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed Sep 16, 2024
1 parent b0b5f85 commit b5f836e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion moments/blueprints/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def resend_confirmation_email():

token = generate_token(user=current_user, operation=Operations.CONFIRM)
send_confirmation_email(user=current_user, token=token)
flash('New email sent, check your inbox.', 'info')
flash('New email sent, please check your inbox.', 'info')
return redirect(url_for('main.index'))


Expand Down
62 changes: 30 additions & 32 deletions moments/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ document.addEventListener('DOMContentLoaded', () => {
}

function toast(message, category) {
const toastElem = document.getElementById('mainToast')
const toast = bootstrap.Toast.getOrCreateInstance(toastElem)
toastElem.querySelector('.toast-body').textContent = message
const toastElem = document.getElementById('mainToast');
const toast = bootstrap.Toast.getOrCreateInstance(toastElem);
toastElem.querySelector('.toast-body').textContent = message;

if (category === 'error') {
toastElem.classList.replace('text-bg-secondary', 'text-bg-danger')
toastElem.classList.replace('text-bg-secondary', 'text-bg-danger');
} else {
toastElem.classList.replace('text-bg-danger', 'text-bg-secondary')
toastElem.classList.replace('text-bg-danger', 'text-bg-secondary');
}
toast.show()
toast.show();
}

function showProfilePopover(event) {
Expand All @@ -36,7 +36,7 @@ document.addEventListener('DOMContentLoaded', () => {
content: data,
html: true,
sanitize: false,
trigger: 'manual'
trigger: 'manual',
});
popover.setContent({
'.popover-body': data
Expand All @@ -48,9 +48,7 @@ document.addEventListener('DOMContentLoaded', () => {
}, 200);
});
})
.catch(error => {
handleFetchError(error);
});
.catch(handleFetchError);
}, 500);
}

Expand Down Expand Up @@ -120,7 +118,7 @@ document.addEventListener('DOMContentLoaded', () => {
fetch(elem.dataset.href, {
method: 'POST',
headers: {
'X-CSRFToken': csrfToken
'X-CSRFToken': csrfToken,
}
})
.then(response => response.json())
Expand All @@ -139,7 +137,7 @@ document.addEventListener('DOMContentLoaded', () => {
fetch(elem.dataset.href, {
method: 'POST',
headers: {
'X-CSRFToken': csrfToken
'X-CSRFToken': csrfToken,
}
})
.then(response => response.json())
Expand All @@ -161,7 +159,7 @@ document.addEventListener('DOMContentLoaded', () => {
fetch(elem.dataset.href, {
method: 'POST',
headers: {
'X-CSRFToken': csrfToken
'X-CSRFToken': csrfToken,
}
})
.then(response => response.json())
Expand All @@ -183,7 +181,7 @@ document.addEventListener('DOMContentLoaded', () => {
fetch(elem.dataset.href, {
method: 'POST',
headers: {
'X-CSRFToken': csrfToken
'X-CSRFToken': csrfToken,
}
})
.then(response => response.json())
Expand All @@ -202,26 +200,26 @@ document.addEventListener('DOMContentLoaded', () => {

function renderAllDatetime() {
// render normal time
const elements = document.querySelectorAll('.dayjs')
const elements = document.querySelectorAll('.dayjs');
elements.forEach(elem => {
const date = dayjs.utc(elem.innerHTML)
const format = elem.dataset.format ?? 'LL'
elem.innerHTML = date.local().format(format)
})
const date = dayjs.utc(elem.innerHTML);
const format = elem.dataset.format ?? 'LL';
elem.innerHTML = date.local().format(format);
});
// render from now time
const fromNowElements = document.querySelectorAll('.dayjs-from-now')
const fromNowElements = document.querySelectorAll('.dayjs-from-now');
fromNowElements.forEach(elem => {
const date = dayjs.utc(elem.innerHTML)
elem.innerHTML = date.local().fromNow()
})
const date = dayjs.utc(elem.innerHTML);
elem.innerHTML = date.local().fromNow();
});
// render tooltip time
const toolTipElements = document.querySelectorAll('.dayjs-tooltip')
const toolTipElements = document.querySelectorAll('.dayjs-tooltip');
toolTipElements.forEach(elem => {
const date = dayjs.utc(elem.dataset.timestamp)
const format = elem.dataset.format ?? 'LLL'
elem.dataset.bsTitle = date.local().format(format)
const tooltip = new bootstrap.Tooltip(elem)
})
const date = dayjs.utc(elem.dataset.timestamp);
const format = elem.dataset.format ?? 'LLL';
elem.dataset.bsTitle = date.local().format(format);
const tooltip = new bootstrap.Tooltip(elem);
});
}

document.addEventListener('click', event => {
Expand Down Expand Up @@ -290,10 +288,10 @@ document.addEventListener('DOMContentLoaded', () => {
setInterval(updateNotificationsCount, 30000);
}

const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
const tooltipList = tooltipTriggerList.map(tooltipTriggerElem => {
return new bootstrap.Tooltip(tooltipTriggerElem)
return new bootstrap.Tooltip(tooltipTriggerElem);
});

renderAllDatetime()
renderAllDatetime();
});
4 changes: 2 additions & 2 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_register_account(self):
follow_redirects=True,
)
data = response.get_data(as_text=True)
self.assertIn('Confirm email sent, check your inbox.', data)
self.assertIn('Confirmation email sent, please check your inbox.', data)

def test_confirm_account(self):
user = User.query.filter_by(email='[email protected]').first()
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_reset_password(self):
follow_redirects=True,
)
data = response.get_data(as_text=True)
self.assertIn('Password reset email sent, check your inbox.', data)
self.assertIn('Password reset email sent, please check your inbox.', data)
user = User.query.filter_by(email='[email protected]').first()
self.assertTrue(user.validate_password('123'))

Expand Down

0 comments on commit b5f836e

Please sign in to comment.