feat: Consolidate intro scripts
- Change script source from ui to intro - Test variants with classes - Move active scripts parts to index - Remove old ui script
This commit is contained in:
parent
8937b36a1e
commit
6cfe5b21e1
2 changed files with 170 additions and 87 deletions
|
|
@ -56,5 +56,69 @@ tags:
|
|||
|
||||
{%- block script %}
|
||||
{{ super() }}
|
||||
<script src="{{ pageBase }}js/ui.js"></script>
|
||||
<script src="{{ pageBase }}js/_intro.js"></script>
|
||||
<script>
|
||||
{# let intro = new Intro('Intro');
|
||||
intro.init(); #}
|
||||
|
||||
{# const ui = new UI();
|
||||
ui.init()
|
||||
.then(() => ui.showIntro())
|
||||
.then(() => ui.showHint())
|
||||
.then(() => ui.showIdle())
|
||||
.catch((error) => console.error(error)); #}
|
||||
|
||||
let introDelay = 6;
|
||||
let hintDelay = 1;
|
||||
let isAgree = false;
|
||||
|
||||
const steps = {
|
||||
agreement: {
|
||||
element: document.getElementById('agreement'),
|
||||
msgIn: 'Agreement shown.',
|
||||
msgOut: 'Agreement accepted.',
|
||||
msgNo: 'No agreement today.'
|
||||
}
|
||||
};
|
||||
const intro = document.getElementById('intro');
|
||||
const agreement = steps.agreement.element;
|
||||
const hint = {
|
||||
element: document.getElementById('hint'),
|
||||
delay: hintDelay * 1000,
|
||||
show() {
|
||||
if (typeof this.timeoutId === 'number') {
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
this.element.classList.remove('di_none');
|
||||
|
||||
this.timeoutId = setTimeout(
|
||||
() => {
|
||||
this.dismiss();
|
||||
},
|
||||
this.delay
|
||||
);
|
||||
},
|
||||
dismiss() {
|
||||
this.element.classList.add('di_none');
|
||||
this.timeoutId = undefined;
|
||||
},
|
||||
cancel() {
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
};
|
||||
const loader = document.getElementById('loader');
|
||||
|
||||
init()
|
||||
.then(loadCore)
|
||||
.then(showIntro)
|
||||
.catch(er => console.error(er))
|
||||
.then(showAgreement)
|
||||
.then(showIdle)
|
||||
.catch(er => console.error(er))
|
||||
.finally(() => {
|
||||
console.debug('Init end.', isAgree);
|
||||
// location = 'demo/examples/ui/new.html';
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue