mirror of
https://github.com/umap-project/umap.git
synced 2025-05-06 06:21:49 +02:00
Also run login javascript when page is loaded
This commit is contained in:
parent
2d111438c2
commit
d65b9f25c1
1 changed files with 46 additions and 44 deletions
|
@ -38,53 +38,55 @@
|
|||
{% block bottom_js %}
|
||||
{{ block.super }}
|
||||
<script type="text/javascript">
|
||||
!(function () {
|
||||
const ui = new L.U.UI(document.querySelector('header'))
|
||||
const xhr = new L.U.Xhr(ui)
|
||||
const login = document.querySelector('a.login')
|
||||
if (login) {
|
||||
L.DomEvent.on(login, 'click', function (e) {
|
||||
L.DomEvent.stop(e)
|
||||
xhr.login({
|
||||
login_required: this.getAttribute('href'),
|
||||
redirect: '/',
|
||||
window.addEventListener('load', (event) => {
|
||||
!(function () {
|
||||
const ui = new L.U.UI(document.querySelector('header'))
|
||||
const xhr = new L.U.Xhr(ui)
|
||||
const login = document.querySelector('a.login')
|
||||
if (login) {
|
||||
L.DomEvent.on(login, 'click', function (e) {
|
||||
L.DomEvent.stop(e)
|
||||
xhr.login({
|
||||
login_required: this.getAttribute('href'),
|
||||
redirect: '/',
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
const logout = document.querySelector('a.logout')
|
||||
if (logout) {
|
||||
L.DomEvent.on(logout, 'click', function (e) {
|
||||
}
|
||||
const logout = document.querySelector('a.logout')
|
||||
if (logout) {
|
||||
L.DomEvent.on(logout, 'click', function (e) {
|
||||
L.DomEvent.stop(e)
|
||||
xhr.logout(this.getAttribute('href'))
|
||||
})
|
||||
}
|
||||
const getMore = function (e) {
|
||||
L.DomEvent.stop(e)
|
||||
xhr.logout(this.getAttribute('href'))
|
||||
})
|
||||
}
|
||||
const getMore = function (e) {
|
||||
L.DomEvent.stop(e)
|
||||
xhr._ajax({
|
||||
uri: this.href,
|
||||
verb: 'GET',
|
||||
callback: function (data) {
|
||||
const container = this.parentNode
|
||||
container.innerHTML = data
|
||||
Array.prototype.forEach.call(
|
||||
container.querySelectorAll('script'),
|
||||
function (item) {
|
||||
eval(item.firstChild.textContent)
|
||||
xhr._ajax({
|
||||
uri: this.href,
|
||||
verb: 'GET',
|
||||
callback: function (data) {
|
||||
const container = this.parentNode
|
||||
container.innerHTML = data
|
||||
Array.prototype.forEach.call(
|
||||
container.querySelectorAll('script'),
|
||||
function (item) {
|
||||
eval(item.firstChild.textContent)
|
||||
}
|
||||
)
|
||||
const more = document.querySelector('.more_button')
|
||||
if (more) {
|
||||
L.DomEvent.on(more, 'click', getMore, more)
|
||||
}
|
||||
)
|
||||
const more = document.querySelector('.more_button')
|
||||
if (more) {
|
||||
L.DomEvent.on(more, 'click', getMore, more)
|
||||
}
|
||||
},
|
||||
context: this,
|
||||
})
|
||||
}
|
||||
const more = document.querySelector('.more_button')
|
||||
if (more) {
|
||||
L.DomEvent.on(more, 'click', getMore, more)
|
||||
}
|
||||
})(this)
|
||||
},
|
||||
context: this,
|
||||
})
|
||||
}
|
||||
const more = document.querySelector('.more_button')
|
||||
if (more) {
|
||||
L.DomEvent.on(more, 'click', getMore, more)
|
||||
}
|
||||
})(this)
|
||||
})
|
||||
</script>
|
||||
{% endblock bottom_js %}
|
||||
{% block footer %}
|
||||
|
|
Loading…
Reference in a new issue