Files
2021-12-03 01:05:09 +00:00

73 lines
2.2 KiB
JavaScript

window.addEventListener('message', function (event) {
switch(event.data.action) {
case 'shortnotif':
DoShortHudText(event.data);
break;
case 'notif':
DoHudText(event.data);
break;
case 'longnotif':
DoLongHudText(event.data);
break;
default:
DoCustomHudText(event.data);
break;
}
});
function DoShortHudText(data) {
var $notification = $('.notification.template').clone();
$notification.removeClass('template');
$notification.addClass(data.type);
$notification.html(data.text);
$notification.fadeIn();
$('.notif-container').append($notification);
setTimeout(function() {
$.when($notification.fadeOut()).done(function() {
$notification.remove()
});
}, 1000);
}
function DoHudText(data) {
var $notification = $('.notification.template').clone();
$notification.removeClass('template');
$notification.addClass(data.type);
$notification.html(data.text);
$notification.fadeIn();
$('.notif-container').append($notification);
setTimeout(function() {
$.when($notification.fadeOut()).done(function() {
$notification.remove()
});
}, 7500);
}
function DoLongHudText(data) {
var $notification = $('.notification.template').clone();
$notification.removeClass('template');
$notification.addClass(data.type);
$notification.html(data.text);
$notification.fadeIn();
$('.notif-container').append($notification);
setTimeout(function() {
$.when($notification.fadeOut()).done(function() {
$notification.remove()
});
}, 5000);
}
function DoCustomHudText(data) {
var $notification = $('.notification.template').clone();
$notification.removeClass('template');
$notification.addClass(data.type);
$notification.html(data.text);
$notification.fadeIn();
$('.notif-container').append($notification);
setTimeout(function() {
$.when($notification.fadeOut()).done(function() {
$notification.remove()
});
}, data.length === undefined ? data.length : 2500);
}