Skip to content

Commit

Permalink
Simple HTML template for alert
Browse files Browse the repository at this point in the history
  • Loading branch information
tayandenga committed Sep 13, 2021
1 parent db56add commit ae45142
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 13 deletions.
86 changes: 86 additions & 0 deletions ChannelPointsSFX/alert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="1">
<style>
@import url('https://fonts.googleapis.com/css2?family=Baloo+Chettan+2:wght@400;700&display=swap');
body{
margin: 0 auto;
overflow: hidden;
text-align: center;
}
.container {
display: flex;
align-items: center;
justify-content: center;
font-size: 96px;
font-family: 'Baloo Chettan 2', Arial;
color: #fff;
}
.container img {
width: 64px;
height: 64px;
}
.animate{
animation: glitch 1s linear infinite;
font-weight: 700;
}
.animate:before,
.animate:after{
content: attr(title);
position: absolute;
left: 0;
}
.animate:before{
animation: glitchTop 1s linear infinite;
clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
-webkit-clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
}
.animate:after{
animation: glitchBotom 1.5s linear infinite;
clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
-webkit-clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
}
@keyframes glitch{
2%,64%{
transform: translate(2px,0) skew(0deg);
}
4%,60%{
transform: translate(-2px,0) skew(0deg);
}
62%{
transform: translate(0,0) skew(5deg);
}
}
@keyframes glitchTop{
2%,64%{
transform: translate(2px,-2px);
}
4%,60%{
transform: translate(-2px,2px);
}
62%{
transform: translate(13px,-1px) skew(-13deg);
}
}
@keyframes glitchBotom{
2%,64%{
transform: translate(-2px,0);
}
4%,60%{
transform: translate(-2px,0);
}
62%{
transform: translate(-22px,5px) skew(21deg);
}
}
</style>
</head>
<body>
<img src="http://img.pietrzak.biz/images/2021/09/13/uXQsP5col.gif">
<div class="container">
<div class="animate" title="|DISPLAY_NAME|">|DISPLAY_NAME|</div> &nbsp;odebrał &nbsp;<div class="animate" title="|TITLE|">|TITLE|</div> &nbsp;(<img src="https://static-cdn.jtvnw.net/channel-points-icons/60253521/8feb297d-934e-4c6a-8032-a553b4ab045b/icon-1.png"> |COST|)
</div>
</body>
</html>
39 changes: 26 additions & 13 deletions ChannelPointsSFX/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private void HandleConnections(object state)

private static async Task HandleIncomingConnections()
{
string alertSchema = File.ReadAllText("alert.html");
while (!killServer)
{
HttpListenerContext ctx = await listener.GetContextAsync();
Expand All @@ -71,23 +72,35 @@ private static async Task HandleIncomingConnections()
string headStr = "", bodyStr = "";
if (req.Url.AbsolutePath == "/")
{
headStr = "<meta http-equiv=\"refresh\" content=\"1\">";
if (File.Exists("alert.txt"))
{
bodyStr = File.ReadAllText("alert.txt");
String[] alertData = File.ReadAllLines("alert.txt");
if (alertData.Length == 3)
{
bodyStr = alertSchema.Replace("|DISPLAY_NAME|", alertData[0]).Replace("|TITLE|", alertData[1]).Replace("|COST|", alertData[2]);
}
}
else
{
headStr = "<meta http-equiv=\"refresh\" content=\"1\">";
}
}

byte[] data = Encoding.UTF8.GetBytes("<!DOCTYPE html>" +
"<html lang=\"en\">" +
"<head>" +
"<meta charset=\"utf-8\">" +
headStr +
"</head>" +
"<body>" +
bodyStr +
"</body>" +
"</html>");
byte[] data = Encoding.UTF8.GetBytes("");
if (headStr.Length > 0)
{
data = Encoding.UTF8.GetBytes("<!DOCTYPE html>" +
"<html lang=\"en\">" +
"<head>" +
"<meta charset=\"utf-8\">" +
headStr +
"</head>" +
"</html>");
}
else if (bodyStr.Length > 0)
{
data = Encoding.UTF8.GetBytes(bodyStr);
}

HttpListenerResponse resp = ctx.Response;
resp.ContentType = "text/html";
Expand Down Expand Up @@ -240,7 +253,7 @@ private void BuildAlert(string Title, string DisplayName, int RewardCost, string
}
else
{
File.WriteAllText("alert.txt", "<h1>" + Title + "</h1>\n<h2>" + DisplayName + "</h2>\n<h3>" + RewardCost + "</h3>");
File.WriteAllText("alert.txt", DisplayName + "\n" + Title + "\n" + RewardCost);
Task.Delay(500).ContinueWith((task) => {
PlaySound(Sound);
});
Expand Down

0 comments on commit ae45142

Please sign in to comment.