ed
This commit is contained in:
parent
8110c00382
commit
05b2063db3
17 changed files with 1553 additions and 1 deletions
147
resources/[freizeit]/rubellose/html/css/style.css
Normal file
147
resources/[freizeit]/rubellose/html/css/style.css
Normal file
|
@ -0,0 +1,147 @@
|
|||
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@900&display=swap');
|
||||
body {
|
||||
display: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.disable-select {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#card {
|
||||
background: linear-gradient(to right bottom, #138d75, #239c83, #30ab92, #3cbaa1, #48c9b0);
|
||||
background-size: 400% 400%;
|
||||
width: 350px;
|
||||
height: 500px;
|
||||
animation: spin 10s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
5% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
10% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
#background {
|
||||
width: 326px;
|
||||
height: 476px;
|
||||
margin: 12px;
|
||||
position: absolute;
|
||||
background: #2E4053;
|
||||
background-image: url(../img/fivem-background.png);
|
||||
filter: blur(1.5px);
|
||||
background-size: cover;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#content {
|
||||
width: 326px;
|
||||
height: 476px;
|
||||
margin: 12px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#title {
|
||||
position: relative;
|
||||
display: block;
|
||||
z-index: 2;
|
||||
letter-spacing: 1px;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-size: 55px;
|
||||
color: #48c9b0;
|
||||
text-shadow: -1px 5px #ffffff;
|
||||
text-align: right;
|
||||
margin-right: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#second-title {
|
||||
position: relative;
|
||||
display: block;
|
||||
z-index: 2;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-size: 55px;
|
||||
letter-spacing: 2px;
|
||||
color: #ffffff;
|
||||
text-shadow: -1px 5px #3cbaa1;
|
||||
text-align: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#game-border {
|
||||
position: relative;
|
||||
display: flex;
|
||||
z-index: 2;
|
||||
background: linear-gradient(to right bottom, #138d75, #239c83, #30ab92, #3cbaa1, #48c9b0);
|
||||
background-size: 400% 400%;
|
||||
margin-left: 28px;
|
||||
margin-top: 15px;
|
||||
width: 270px;
|
||||
height: 250px;
|
||||
animation: spin2 5s linear infinite;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
@keyframes spin2 {
|
||||
0% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
5% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
10% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
#game {
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
margin: 12px;
|
||||
width: 248px;
|
||||
height: 226px;
|
||||
background-color: #2E4053;
|
||||
}
|
||||
|
||||
#game p {
|
||||
text-align: center;
|
||||
top: 50%;
|
||||
margin-top: 30px;
|
||||
font-family: fantasy;
|
||||
font-size: 40px;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#canvas {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
BIN
resources/[freizeit]/rubellose/html/img/fivem-background.png
Normal file
BIN
resources/[freizeit]/rubellose/html/img/fivem-background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 452 KiB |
BIN
resources/[freizeit]/rubellose/html/img/scratch-here.jpg
Normal file
BIN
resources/[freizeit]/rubellose/html/img/scratch-here.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 94 KiB |
BIN
resources/[freizeit]/rubellose/html/img/scratch.png
Normal file
BIN
resources/[freizeit]/rubellose/html/img/scratch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
38
resources/[freizeit]/rubellose/html/index.html
Normal file
38
resources/[freizeit]/rubellose/html/index.html
Normal file
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Scatch Card by xDreamLand aka Ruwbix</title>
|
||||
<link href="./css/style.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container" class="disable-select">
|
||||
<div id="card">
|
||||
<div id="background"></div>
|
||||
<div id="content">
|
||||
<div id="title">SCRATCH</div>
|
||||
<div id="second-title">& WIN!</div>
|
||||
<div id="game-border">
|
||||
<div id="game">
|
||||
<p id="price"></p>
|
||||
<p class="hidden" id="key-hidden"></p>
|
||||
<p class="hidden" id="price-hidden"></p>
|
||||
<p class="hidden" id="amount-hidden"></p>
|
||||
<p class="hidden" id="price-type-hidden"></p>
|
||||
<canvas id="canvas" width="248" height="226"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="js/card.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
153
resources/[freizeit]/rubellose/html/js/card.js
Normal file
153
resources/[freizeit]/rubellose/html/js/card.js
Normal file
|
@ -0,0 +1,153 @@
|
|||
var debugMode = false;
|
||||
var resourceName, toFillInPercentage, win_message, lose_message, currency, key, price, price_type, price_label, formattedPrice;
|
||||
|
||||
$(function() {
|
||||
window.addEventListener('message', function(event) {
|
||||
if (event.data.type === "openScratch") {
|
||||
$('body').fadeIn(500);
|
||||
debugMode = event.data.debug;
|
||||
resourceName = event.data.resourceName;
|
||||
toFillInPercentage = event.data.scratchAmount;
|
||||
win_message = event.data.win_message;
|
||||
lose_message = event.data.lose_message;
|
||||
currency = event.data.currency;
|
||||
key = event.data.key;
|
||||
price = event.data.price;
|
||||
amount = event.data.amount;
|
||||
price_type = event.data.price_type;
|
||||
price_label = event.data.price_label;
|
||||
document.getElementById('key-hidden').innerHTML = key;
|
||||
document.getElementById('price-hidden').innerHTML = price;
|
||||
document.getElementById('amount-hidden').innerHTML = amount;
|
||||
document.getElementById('price-type-hidden').innerHTML = price_type;
|
||||
if(price_type == 'money') {
|
||||
formattedPrice = currency + ' ' + Number.parseFloat(price).toFixed(0); // Want decimals? Change 0 -> n of decimals
|
||||
price > 0 ? document.getElementById('price').innerHTML = "<span style='color:#2ECC71'>" + win_message + "</span><br><br><span style='font-size:50px;'>" + formattedPrice + '</span>' : document.getElementById('price').innerHTML = "<span style='color:#B2BABB;text-transform:uppercase;'>" + lose_message + "</span><br><br><span style='font-size:60px;'>" + currency + " 0</span>";
|
||||
} else {
|
||||
document.getElementById('price').innerHTML = "<span style='color:#2ECC71'>" + win_message + "</span><br><span style='font-size:20px;color:#7F8C8D'>" + amount + "x</span><br><span style='font-size:40px;'>" + price_label + '</span>'
|
||||
}
|
||||
} else if (event.data.type === "closeScratch") {
|
||||
$('body').fadeOut(500);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var isDrawing, lastPoint;
|
||||
var canvas = document.getElementById('canvas'),
|
||||
ctx = canvas.getContext('2d'),
|
||||
canvasWidth = canvas.width,
|
||||
canvasHeight= canvas.height,
|
||||
image = new Image(),
|
||||
imageSrc = 'img/scratch-here.jpg',
|
||||
brush = new Image();
|
||||
image.src = imageSrc;
|
||||
|
||||
image.onload = function() {
|
||||
ctx.drawImage(
|
||||
image,
|
||||
canvas.width / 2 - image.width / 2,
|
||||
canvas.height / 2 - image.height / 2
|
||||
);
|
||||
};
|
||||
|
||||
brush.src = 'img/scratch.png';
|
||||
canvas.addEventListener('mousedown', handleMouseDown, false);
|
||||
canvas.addEventListener('touchstart', handleMouseDown, false);
|
||||
canvas.addEventListener('mousemove', handleMouseMove, false);
|
||||
canvas.addEventListener('touchmove', handleMouseMove, false);
|
||||
canvas.addEventListener('mouseup', handleMouseUp, false);
|
||||
canvas.addEventListener('touchend', handleMouseUp, false);
|
||||
|
||||
function distanceBetween(point1, point2) {
|
||||
return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
|
||||
}
|
||||
|
||||
function angleBetween(point1, point2) {
|
||||
return Math.atan2(point2.x - point1.x, point2.y - point1.y);
|
||||
}
|
||||
|
||||
function getFilledInPixels(stride) {
|
||||
if (!stride || stride < 1) { stride = 1; }
|
||||
var pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight),
|
||||
pdata = pixels.data,
|
||||
l = pdata.length,
|
||||
total = (l / stride),
|
||||
count = 0;
|
||||
for (var i = count = 0; i < l; i += stride) {
|
||||
if (parseInt(pdata[i]) === 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return Math.round((count / total) * 100);
|
||||
}
|
||||
|
||||
function getMouse(e, canvas) {
|
||||
var offsetX = 0,
|
||||
offsetY = 0,
|
||||
mx, my;
|
||||
if (canvas.offsetParent !== undefined) {
|
||||
do {
|
||||
offsetX += canvas.offsetLeft;
|
||||
offsetY += canvas.offsetTop;
|
||||
} while ((canvas = canvas.offsetParent));
|
||||
}
|
||||
mx = (e.pageX || e.touches[0].clientX) - offsetX;
|
||||
my = (e.pageY || e.touches[0].clientY) - offsetY;
|
||||
return { x: mx, y: my };
|
||||
}
|
||||
|
||||
function handlePercentage(filledInPixels) {
|
||||
filledInPixels = filledInPixels || 0;
|
||||
debugMode == true ? console.log(filledInPixels + '%') : '';
|
||||
if (filledInPixels > toFillInPercentage) {
|
||||
try { canvas.parentNode.removeChild(canvas); } catch (err) {}
|
||||
var keyHtml = document.getElementById('key-hidden').innerHTML,
|
||||
priceHtml = document.getElementById('price-hidden').innerHTML,
|
||||
amountHtml = document.getElementById('amount-hidden').innerHTML,
|
||||
typeHtml = document.getElementById('price-type-hidden').innerHTML;
|
||||
$.post('https://' + resourceName + '/deposit', JSON.stringify({
|
||||
key: keyHtml,
|
||||
price: priceHtml,
|
||||
amount: amountHtml,
|
||||
type: typeHtml
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
function handleMouseDown(e) {
|
||||
isDrawing = true;
|
||||
lastPoint = getMouse(e, canvas);
|
||||
}
|
||||
|
||||
function handleMouseMove(e) {
|
||||
if (!isDrawing) { return; }
|
||||
e.preventDefault();
|
||||
var currentPoint = getMouse(e, canvas),
|
||||
dist = distanceBetween(lastPoint, currentPoint),
|
||||
angle = angleBetween(lastPoint, currentPoint),
|
||||
x, y;
|
||||
for (var i = 0; i < dist; i++) {
|
||||
x = lastPoint.x + (Math.sin(angle) * i) - 25;
|
||||
y = lastPoint.y + (Math.cos(angle) * i) - 25;
|
||||
ctx.globalCompositeOperation = 'destination-out';
|
||||
ctx.drawImage(brush, x, y);
|
||||
}
|
||||
lastPoint = currentPoint;
|
||||
handlePercentage(getFilledInPixels(32));
|
||||
}
|
||||
|
||||
function handleMouseUp(e) {
|
||||
isDrawing = false;
|
||||
}
|
||||
|
||||
$(document).on('keyup', function(data) {
|
||||
if (data.which == 27) {
|
||||
$.post('https://' + resourceName + '/nuiCloseCard',JSON.stringify({
|
||||
key: key,
|
||||
price: price,
|
||||
amount: amount,
|
||||
type: price_type
|
||||
}));
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue