Skip to content

Instantly share code, notes, and snippets.

@mrf345
Last active November 29, 2018 16:43
Show Gist options
  • Save mrf345/2df7b3f3e1fa62afd1cd7079c60c6512 to your computer and use it in GitHub Desktop.
Save mrf345/2df7b3f3e1fa62afd1cd7079c60c6512 to your computer and use it in GitHub Desktop.
{% macro beloadingNotifier(version, beload=True, firefox="firefox", release="new release") %}
<!--
Simple macro to load beloading for fading and browser_notifier for
firefox confirmation and new release confirmation
-->
<script src="{{ url_for('static', filename='beloading.js') }}"></script>
<script src="{{ url_for('static', filename='browserNotifier.js') }}"></script>
<script type='text/javascript'>
$(document).ready(function () {
/*
$('.navbar-inverse').addClass('hide')
var toLoadNotify = function () {
browserNotifier({
storeVal: 'browserNotifier',
text: "{{ firefox }}",
validator: function () {
return new Promise(function (resolve, reject) {
if (navigator.userAgent.indexOf('Firefox') === -1) {
return resolve(true)
} else return reject(false)
})
}}, function () {
browserNotifier({
text: "{{ release }}",
iconLink: 'https://fqms.github.io/#download',
iconClass: 'fa fa-download',
storeVal: 'verNotifier',
validator: function () {
return new Promise(function (resolve, reject) {
fetch('https://fqms.github.io/js/releases.js').then(function () {
$.getScript('https://fqms.github.io/js/releases.js')
.done(function () {
['Windows', 'Linux', 'Mac'].forEach(function (os) {
if (window.navigator.userAgent.indexOf(os) !== -1) {
if (releases[os] !== '{{ version }}') resolve(true)
else reject(false)
}
if (os === 'Mac') reject(false)
})
})
.fail(function () {
return reject(false)
})
}).catch(function () { return reject(false) })
})
}
}, function () {
$('.navbar-inverse').removeClass('hide')
})
})
} */
{% if beload %}
beloading({
background: 'rgba(0,0,0,1)',
text: ' ',
icon: ' '
}, callback=function () {
setTimeout(toLoadNotify, 1500)
})
{% else %}
if (window.location.href.split('/').slice(-1)[0] !== 'manage' && window.location.href.split('/').slice(-1)[0] !== 'customize') toLoadNotify()
{% endif %}
})
</script>
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment