add smaller version of server banner
This commit is contained in:
parent
5d53c2559b
commit
5490d6b358
@ -81,8 +81,9 @@ const plugin = {
|
||||
interactionData.interactionType = 1;
|
||||
interactionData.source = plugin.name;
|
||||
|
||||
interactionData.scriptAction = (sourceId, targetId, game, meta, token) => {
|
||||
const serverId = meta['serverId'];
|
||||
interactionData.scriptAction = (sourceId, targetId, game, meta, _) => {
|
||||
const serverId = meta.serverId;
|
||||
const isSmall = meta.size !== undefined && meta.size === 'small';
|
||||
let server;
|
||||
|
||||
let colorLeft = 'color: #f5f5f5; text-shadow: -1px 1px 8px #000000cc;';
|
||||
@ -145,17 +146,16 @@ const plugin = {
|
||||
colorRight = colorMappingOverride[gameCode]?.right || colorRight;
|
||||
|
||||
const font = 'Noto Sans Mono';
|
||||
let status = '<div class="status-online subtitle">ONLINE</div>';
|
||||
let status = isSmall ? '<div class="status small online-checkmark"></div>' : '<div class="status-online subtitle">ONLINE</div>';
|
||||
if (server.throttled) {
|
||||
status = '<div class="status-offline subtitle">OFFLINE</div>';
|
||||
status = isSmall ? '<div class="status small offline-x"></div>' : '<div class="status-offline subtitle">OFFLINE</div>';
|
||||
}
|
||||
|
||||
const displayIp = server.resolvedIpEndPoint.address.isInternal() ?
|
||||
plugin.manager.externalIPAddress :
|
||||
server.resolvedIpEndPoint.toString().split(':')[0];
|
||||
|
||||
return `<html>
|
||||
<head>
|
||||
const head = `<head>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=${font}">
|
||||
<style>
|
||||
* {
|
||||
@ -163,30 +163,64 @@ const plugin = {
|
||||
margin: 0;
|
||||
}
|
||||
.server-container {
|
||||
font-family: '${font}';
|
||||
background: url('https://raidmax.org/resources/images/banners/${gameCode}.jpg') no-repeat;
|
||||
align-items: center;
|
||||
}
|
||||
.server-container.large {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
width: calc(750px - 2rem);
|
||||
height: 120px;
|
||||
display: flex;
|
||||
font-family: '${font}';
|
||||
background: url('https://raidmax.org/resources/images/banners/${gameCode}.jpg') no-repeat;
|
||||
align-items: center;
|
||||
background-position: center center;
|
||||
}
|
||||
.contrast {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
.server-container.small {
|
||||
padding: 0.5rem;
|
||||
background-position: left center;
|
||||
}
|
||||
.game-icon {
|
||||
border-radius: 10px;
|
||||
background: url('https://raidmax.org/resources/images/icons/games/${gameCode}.jpg') no-repeat;
|
||||
background-size: contain;
|
||||
}
|
||||
.game-icon.large {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.game-info {
|
||||
.game-icon.small {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.first-line.small, .second-line.small {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.first-line.small .header {
|
||||
font-size: 10pt;
|
||||
font-weight: bold;
|
||||
margin-left: 0.5rem;
|
||||
align-self: center;
|
||||
}
|
||||
.second-line.small {
|
||||
align-self: center;
|
||||
}
|
||||
.game-info.small {
|
||||
margin-left: 0.5rem;
|
||||
font-size: 9pt;
|
||||
}
|
||||
.game-info.large {
|
||||
padding: 0 0.75em;
|
||||
}
|
||||
.game-info .header {
|
||||
font-weight: bold;
|
||||
}
|
||||
.game-info .subtitle {
|
||||
img.location-image {
|
||||
width: 20px;
|
||||
align-self: center;
|
||||
}
|
||||
.game-info.large .subtitle {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.text-weight-lighter {
|
||||
@ -208,20 +242,74 @@ const plugin = {
|
||||
margin: 0 0.5rem;
|
||||
height: 0.75rem;
|
||||
}
|
||||
h3, div {
|
||||
.status.small:after {
|
||||
position: absolute;
|
||||
width: 20px;
|
||||
height: 15px;
|
||||
text-align: center;
|
||||
border-radius: 2px;
|
||||
font-size: 8pt;
|
||||
margin-top: 0.1rem;
|
||||
margin-left: -0.5rem;
|
||||
}
|
||||
.online-checkmark:after {
|
||||
content: '\\2714';
|
||||
color: white;
|
||||
background: rgba(0, 128, 0, 0.5);
|
||||
}
|
||||
.offline-x:after {
|
||||
content: '\\2715';
|
||||
color: white;
|
||||
background: rgba(128, 0, 0, 0.5);
|
||||
}
|
||||
h3, .server-container.large div {
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
h2 {
|
||||
line-height: 2rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<title>${displayIp}:${server.listenPort}</title>
|
||||
</head>`;
|
||||
|
||||
<div class="server-container contrast" id="server">
|
||||
<div class="game-icon"
|
||||
|
||||
if (isSmall) {
|
||||
return `<html lang="en">
|
||||
${head}
|
||||
<body>
|
||||
<div class="server-container small" id="server">
|
||||
<div class="first-line small">
|
||||
<div class="game-icon small"></div>
|
||||
<div class="header" style="${colorLeft}">${server.serverName.stripColors()}</div>
|
||||
</div>
|
||||
<div class="third-line game-info small">
|
||||
${status}
|
||||
<div style="${colorLeft}; margin-left: 20px;">${displayIp}:${server.listenPort}</div>
|
||||
</div>
|
||||
<div class="second-line small">
|
||||
<img src="https://flagcdn.com/w40/${serverLocationCache[server.listenAddress]?.toLowerCase()}.png"
|
||||
alt="${serverLocationCache[server.listenAddress]}" class="location-image">
|
||||
<div class="game-info small" style="${colorLeft}">
|
||||
<span>${server.throttled ? '-' : server.clientNum}/${server.maxClients}</span>
|
||||
•
|
||||
<span>${server.map.alias}</span>
|
||||
•
|
||||
<span>${server.gametypeName}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
return `<html lang="en">
|
||||
${head}
|
||||
<body>
|
||||
<div class="server-container large" id="server">
|
||||
<div class="game-icon large"
|
||||
style="background: url('https://raidmax.org/resources/images/icons/games/${gameCode}.jpg');">
|
||||
</div>
|
||||
<div style="flex: 1; ${colorLeft}" class="game-info">
|
||||
<div style="flex: 1; ${colorLeft}" class="game-info large">
|
||||
<div class="header">${server.serverName.stripColors()}</div>
|
||||
<div class="text-weight-lighter subtitle">${displayIp}:${server.listenPort}</div>
|
||||
<div class="players-flag-section">
|
||||
@ -236,6 +324,7 @@ const plugin = {
|
||||
${status}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>`;
|
||||
};
|
||||
|
||||
@ -270,22 +359,39 @@ const plugin = {
|
||||
servers.forEach(eachServer => {
|
||||
response += `<div class="w-full w-xl-half">
|
||||
<div class="card m-10 p-20">
|
||||
<div class="font-size-16 mb-10"> <div class="badge ml-10 float-right font-size-16">${eachServer.gameCode}</div>${eachServer.serverName.stripColors()}</div>
|
||||
<div class="font-size-16 mb-10">
|
||||
<div class="badge ml-10 float-right font-size-16">${eachServer.gameCode}</div>
|
||||
${eachServer.serverName.stripColors()}
|
||||
</div>
|
||||
|
||||
<div style="overflow: hidden">
|
||||
<iframe src="/Interaction/Render/Banner?serverId=${eachServer.id}" width="750" height="120" style="border-width: 0; overflow: hidden;" class="rounded mb-5" ></iframe>
|
||||
<iframe src="/Interaction/Render/Banner?serverId=${eachServer.id}" width="750"
|
||||
height="120" style="border-width: 0; overflow: hidden;" class="rounded mb-5"
|
||||
title="${eachServer.id}"></iframe>
|
||||
</div>
|
||||
<div class="btn mb-10" onclick="$(document.getElementById('showCode${eachServer.id}')).toggleClass('d-flex')">Show Embed</div>
|
||||
<div class="code p-5" id="showCode${eachServer.id}" style="display:none;"><iframe
|
||||
<div class="code p-5 mb-10" id="showCode${eachServer.id}" style="display:none;">
|
||||
<iframe
|
||||
<br/> src="${plugin.webfrontUrl}/Interaction/Render/Banner?serverId=${eachServer.id}"
|
||||
<br/> width="750" height="120" style="border-width: 0; overflow: hidden;"><br/>
|
||||
</iframe></div>
|
||||
</div></div>`;
|
||||
<div>
|
||||
<iframe src="/Interaction/Render/Banner?serverId=${eachServer.id}&size=small" width="400"
|
||||
height="70" style="border-width: 0; overflow: hidden;" class="rounded mb-5"
|
||||
title="${eachServer.id}"></iframe>
|
||||
</div>
|
||||
<div class="btn mb-10" onclick="$(document.getElementById('showCode${eachServer.id}Small')).toggleClass('d-flex')">Show Embed</div>
|
||||
<div class="code p-5" id="showCode${eachServer.id}Small" style="display:none;">
|
||||
<iframe
|
||||
<br/> src="${plugin.webfrontUrl}/Interaction/Render/Banner?serverId=${eachServer.id}&size=small"
|
||||
<br/> width="400" height="70" style="border-width: 0; overflow: hidden;"><br/>
|
||||
</iframe></div>
|
||||
</div>
|
||||
</div>`;
|
||||
});
|
||||
});
|
||||
|
||||
response += '</div>';
|
||||
response += ''
|
||||
return response;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user