website/public/js/error.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-12-20 01:23:40 +01:00
$(function() {
runScripts(data, 0);
});
function runScripts(data, pos) {
var prompt = $('.prompt'),
script = data[pos];
if(script.clear === true) {
$('.history').html('');
2020-10-23 10:09:32 +02:00
}
2020-12-20 01:23:40 +01:00
switch(script.action) {
case 'type':
// cleanup for next execution
prompt.removeData();
$('.typed-cursor').text('');
prompt.typed({
strings: script.strings,
typeSpeed: 30,
callback: function() {
var history = $('.history').html();
history = history ? [history] : [];
history.push('$ ' + prompt.text());
if(script.output) {
history.push(script.output);
prompt.html('');
$('.history').html(history.join('<br>'));
}
// scroll to bottom of screen
$('.terminal').scrollTop($('.terminal').height());
// Run next script
pos++;
if(pos < data.length) {
setTimeout(function() {
runScripts(data, pos);
}, script.postDelay || 1000);
}
}
});
break;
case 'view':
break;
2020-10-23 10:09:32 +02:00
}
}