[html] <div id="prizemanager"><button id="showCommonPrizes">Показать коды простых призов</button>
<button id="showRarePrizes">Показать коды редких призов</button>
<button id="showUniquePrizes">Показать коды уникальных призов</button>
<div id="output"></div>
<input type="text" id="codesInput" placeholder="Введите коды через запятую">
<button id="generatePrizes">Выдать призы</button></div>
<script>// структура данных для кодов и призов
const commonPrizesData = [
{ codes: ['126', '127', '128'], prizeElement: "300 монет" },
{ codes: ['001', '002', '003'], prizeElement: "200 монет" }
];
const rarePrizesData = [
{ codes: ['321', '322', '333'], prizeElement: "3000 монет" },
{ codes: ['212', '211', '210'], prizeElement: "2000 монет" }
];
const uniquePrizesData = [
{ codes: ['144', '145', '146'], prizeElement: "плашка" },
{ codes: ['555', '444', '222'], prizeElement: "иконка" }
];
// Отображение информации о кодах призов
document.getElementById('showCommonPrizes').addEventListener('click', function() {
const allCodes = commonPrizesData.flatMap(prize => prize.codes);
document.getElementById('output').innerText = '[' + allCodes.map(code => `'${code}'`).join(', ') + ']';
});
document.getElementById('showRarePrizes').addEventListener('click', function() {
const allCodes = rarePrizesData.flatMap(prize => prize.codes);
document.getElementById('output').innerText = '[' + allCodes.map(code => `'${code}'`).join(', ') + ']';
});
document.getElementById('showUniquePrizes').addEventListener('click', function() {
const allCodes = uniquePrizesData.flatMap(prize => prize.codes);
document.getElementById('output').innerText = '[' + allCodes.map(code => `'${code}'`).join(', ') + ']';
});
// Выдача призов по набору кодов
document.getElementById('generatePrizes').addEventListener('click', function() {
const inputCodes = document.getElementById('codesInput').value.split(',').map(code => code.trim());
let matchingPrizes = [];
inputCodes.forEach(inputCode => {
[commonPrizesData, rarePrizesData, uniquePrizesData].forEach(category => {
category.forEach(prize => {
if (prize.codes.includes(inputCode)) {
matchingPrizes.push(prize.prizeElement);
}
});
});
});
document.getElementById('output').innerText = matchingPrizes.join(', ');
});
</script>
<style>div#prizemanager {
width: 608px;
margin: 0 auto;
padding: 20px;
background-color: rgb(180 180 180 / 78%);
border: 1px double #77777757;
position: relative;
box-shadow: 0px 0px 6px -2px #00000040;
}
div#prizemanager button {
background-color: var(--authorbg);
color: var(--color-accent);
padding: 3px 6px 4px 6px !important;
border: 1px solid var(--color-accent)!important;
border-radius: 4px;
font-size: 12px;
margin: 5px!important;
}
div#output {
border: 1px solid #0706091c!important;
outline: 1px solid #ffffff3d;
background: #fffffe24!important;
box-shadow: 0px 0px 6px -5px var(--color-accent), 0px 0px 19px -10px inset hsl(0deg 0% 54.96% / 39%);
width: auto;
height: 27px;
margin: 13px;
padding: 7px;
}
input#codesInput {
width: 300px;
}</style>[/html]