룰랫 추가

This commit is contained in:
김민서 2024-01-29 16:02:16 +09:00
parent 8aba2c4429
commit c9000b20fe
2 changed files with 126 additions and 21 deletions

18
.gitignore vendored
View File

@ -2,20 +2,6 @@
# Created by https://www.toptal.com/developers/gitignore/api/unity
# Edit at https://www.toptal.com/developers/gitignore?templates=unity
### Unity ###
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
/Client/[Ll]ibrary/
/Client/[Tt]emp/
/Client/[Oo]bj/
/Client/[Bb]uild/
/Client/[Ll]ogs/
/Client/[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/Client/[Mm]emoryCaptures/
# Recordings can get excessive in size
/Client/[Rr]ecordings/
@ -26,6 +12,7 @@
# Visual Studio cache directory
.vs
Server/bin
Server/obj
# Visual Code directory
.vscode/
@ -47,6 +34,3 @@ ExportedObj/
*.mdb
*.opendb
*.VC.db
# Builds
bin

View File

@ -5,16 +5,137 @@ var app = builder.Build();
//웹서버 초기화
ProtocolProcessor.Init();
//ProtocolProcessor.Init();
//깃 웹훅 초기화
GItWebhook.Init();
//GItWebhook.Init();
//http용 데이터
app.MapPost("/", ProtocolProcessor.Process);
//app.MapPost("/", ProtocolProcessor.Process);
//git 접근용 웹훅
app.MapPost("/git", GItWebhook.Process);
//app.MapPost("/git", GItWebhook.Process);
//app.MapPost("/update", GItWebhook.Process);
app.MapGet("/spin", async context =>
{
await context.Response.WriteAsync(@"
<!DOCTYPE html>
<html>
<head>
<title>Roulette</title>
<style>
#container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
.input-area {
margin-bottom: 10px;
}
#roulette {
width: 200px;
height: 200px;
border-radius: 50%;
background-color: red;
color: white;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
margin-top: 20px;
transition: opacity 0.5s ease-in-out;
cursor: pointer;
}
</style>
</head>
<body>
<div id='container'>
<h1>Spin the Roulette!</h1>
<form id='configForm'>
<label for='inputNumber'>Enter the number of texts:</label>
<input type='number' id='inputNumber' name='inputNumber' min='1'>
<button type='button' onclick='configureRoulette()'>Configure</button>
</form>
<div id='inputAreas' style='display: none;'></div>
<div id='roulette' style='display: none;' onclick='spinRoulette()'>Click to Spin!</div>
<form id='spinForm' method='post' action='/spin/random' style='display: none;'>
<input type='hidden' name='selectedText' id='selectedTextInput'>
</form>
</div>
<script>
function configureRoulette() {
const inputNumber = document.getElementById('inputNumber').value;
const inputAreas = document.getElementById('inputAreas');
inputAreas.innerHTML = '';
for (let i = 0; i < inputNumber; i++) {
const inputArea = document.createElement('div');
inputArea.classList.add('input-area');
inputArea.innerHTML = `
<label for='text${i}'>Enter text ${i + 1}:</label>
<input type='text' id='text${i}' name='text${i}'>
`;
inputAreas.appendChild(inputArea);
}
document.getElementById('configForm').style.display = 'none';
document.getElementById('inputAreas').style.display = 'block';
document.getElementById('roulette').style.display = 'flex';
document.getElementById('spinForm').style.display = 'flex';
}
let spinning = false;
function spinRoulette() {
if (!spinning) {
spinning = true;
const texts = document.querySelectorAll('input[type=text]');
const candidates = [];
texts.forEach(text => {
if (text.value.trim() !== '') {
candidates.push(text.value.trim());
}
});
if (candidates.length > 0) {
let counter = 0;
const intervals = [10, 50, 100, 300, 750];
let timeout = 0;
intervals.forEach((interval, index) => {
setTimeout(() => {
const intervalId = setInterval(() => {
document.getElementById('roulette').innerText = candidates[counter % candidates.length];
counter++;
}, interval);
setTimeout(() => {
clearInterval(intervalId);
if (index === intervals.length - 1) {
const selectedText = candidates[Math.floor(Math.random() * candidates.length)];
document.getElementById('roulette').innerText = selectedText;
document.getElementById('selectedTextInput').value = selectedText;
spinning = false;
}
}, 2000); // 2 seconds
}, timeout);
timeout += 2000; // 2 seconds
});
} else {
alert('Please enter at least one text.');
}
}
}
</script>
</body>
</html>
");
});
app.MapPost("/spin/random", async context =>
{
var selectedText = context.Request.Form["selectedText"];
await context.Response.WriteAsync($"The roulette landed on: {selectedText}!");
});
app.Run(Statics.URL);