Fixed hostbanner not showing for dynamic host banners

This commit is contained in:
WolverinDEV 2019-02-21 20:13:02 +01:00
parent 583ac36a30
commit 1b9b1cd5e4
3 changed files with 21 additions and 17 deletions

View file

@ -2246,16 +2246,7 @@
<div style="
background:center no-repeat url(
{{:property_virtualserver_hostbanner_gfx_url}}
{{if property_virtualserver_hostbanner_gfx_interval > 0}}
{{*
date = Math.floor(Date.now() / 1000);
if (data.property_virtualserver_hostbanner_gfx_interval <= 60)
data.property_virtualserver_hostbanner_gfx_interval = 60;
date = Math.floor(date / data.property_virtualserver_hostbanner_gfx_interval) * data.property_virtualserver_hostbanner_gfx_interval;
}}
?ts={{*:date}}
{{/if}}
{{:property_virtualserver_hostbanner_gfx_url}}{{:cache_tag}}
);
background-position: center;

View file

@ -12,8 +12,6 @@
client_away Value: '0'
client_away_message Value: ''
*/
import openBanList = Modals.openBanList;
import spawnConnectModal = Modals.spawnConnectModal;
class ControlBar {
private _muteInput: boolean;
@ -303,7 +301,7 @@ class ControlBar {
if(!this.handle.serverConnection) return;
if(this.handle.permissions.neededPermission(PermissionType.B_CLIENT_BAN_LIST).granted(1)) {
openBanList(this.handle);
Modals.openBanList(this.handle);
} else {
createErrorModal(tr("You dont have the permission"), tr("You dont have the permission to view the ban list")).open();
sound.play(Sound.ERROR_INSUFFICIENT_PERMISSIONS);

View file

@ -159,12 +159,27 @@ class Hostbanner {
for(let key in server.properties)
properties["property_" + key] = server.properties[key];
if(server.properties.virtualserver_hostbanner_gfx_interval > 0) {
const update_interval = Math.min(server.properties.virtualserver_hostbanner_gfx_interval, 60);
const update_timestamp = (Math.floor((Date.now() / 1000) / update_interval) * update_interval).toString();
try {
const url = new URL(server.properties.virtualserver_hostbanner_gfx_url);
if(url.search.length == 0)
properties["cache_tag"] = "?_ts=" + update_timestamp;
else
properties["cache_tag"] = "&_ts=" + update_timestamp;
} finally {
properties["cache_tag"] = "&_ts=" + update_timestamp;
}
this.updater = setTimeout(() => this.update(), update_interval * 1000);
} else {
properties["cache_tag"] = "";
}
const rendered = $("#tmpl_selected_hostbanner").renderTag(properties);
console.debug(tr("Hostbanner has been loaded"));
if(server.properties.virtualserver_hostbanner_gfx_interval > 0)
this.updater = setTimeout(() => this.update(), Math.min(server.properties.virtualserver_hostbanner_gfx_interval, 60) * 1000);
return Promise.resolve(rendered);
/*
const image = rendered.find("img");