Pendigard's picture
Upload folder using huggingface_hub (part 23)
bd98362 verified
Raw History Blame Contribute Delete
1.17 kB
var flight = require('flightjs');
var template = require('./templates/title.hogan');
const TYPING_DELAY = 42;
const BASE_TYPING_DELAY = 50;
function helloWorldUI() {
this.attributes({
});
this.typewriter = function(str) {
var instance = this;
var textEl = document.querySelector('[data-text]');
var arr = str.split('');
var i = 0;
textEl.innerHTML = '';
setTimeout(function() {
instance.setText(textEl, arr, 0);
}, BASE_TYPING_DELAY);
};
this.setText = function(el, arr, i) {
var instance = this;
var delay = (TYPING_DELAY * Math.random()) + BASE_TYPING_DELAY;
if (arr[i]) {
el.innerHTML += arr[i];
i++;
setTimeout(function() {
instance.setText(el, arr, i);
}, delay);
}
};
this.render = function(name) {
var titleEl = document.querySelector('[data-title]');
titleEl.innerHTML = template.render({
name: name
});
}
this.after('initialize', function() {
this.render('Hanna');
this.typewriter.call(this, 'Welcome to the Epsilon Eridani system. What would you like to do next?');
});
}
module.exports = flight.component(helloWorldUI);