-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchef.html
222 lines (203 loc) · 7.77 KB
/
chef.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
crossorigin="anonymous"></script>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<title>Schätz-App</title>
</head>
<body>
<div class="container">
<h1 class="display-3">Schätz-App
<span id="roomCode"></span>
</h1>
</div>
<div class="container">
<div class="clearfix">
<button class="btn btn-success float-left" id="show">Karten anzeigen
<span id="counter">0</span> von
<span id="users">-1</span>
</button>
<button class="btn btn-warning float-right text-light" id="reset">Neu schätzen</button>
</div>
</div>
<!--<div id="iframe"></div>-->
<div class="container">
<div class="row mt-3" id="card-container">
</div>
</div>
<div class="container">
<div class="row mt-3" id="card-container-stacked">
<div class="col-md-4">
<div class="stack mb-4" id="stack-Legendary">
</div>
</div>
<div class="col-md-4">
<div class="stack" id="stack-World-Class"></div>
</div>
<div class="col-md-4">
<div class="stack" id="stack-Pro"></div>
</div>
<div class="col-md-4">
<div class="stack" id="stack-Semi-Pro"></div>
</div>
<div class="col-md-4">
<div class="stack" id="stack-Amateur"></div>
</div>
<div class="col-md-4">
<div class="stack" id="stack-Training"></div>
</div>
</div>
</div>
</div>
<script>
$(function () {
$.fn.extend({
animateCss: function (animationName, callback) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
this.addClass('animated ' + animationName).one(animationEnd, function () {
$(this).removeClass('animated ' + animationName);
if (callback) {
callback($(this));
}
});
return this;
}
});
$.fn.animateTo = function (appendTo, destination, duration, easing, complete) {
if (appendTo !== 'appendTo' &&
appendTo !== 'prependTo' &&
appendTo !== 'insertBefore' &&
appendTo !== 'insertAfter') return $(this);
var target = $(this).clone(true).css('visibility', 'hidden')[appendTo](destination);
$(this).css({
'position': 'relative',
'top': '0px',
'left': '0px'
})
$(this).animate({
'top': (target.offset().top - $(this).offset().top) + 'px',
'left': (target.offset().left - $(this).offset().left) + 'px'
}, duration, easing, function () {
target.replaceWith($(this));
$(this).css({
'position': 'static',
'top': '',
'left': ''
});
if ($.isFunction(complete)) complete.call($(this));
});
}
$.fn.animateAppendTo = function (sel, speed, callback) {
var $this = this,
newEle = $this.clone(true).appendTo(sel),
newPos = newEle.position();
newEle.hide();
$this.css('position', 'absolute').animate(newPos, speed, function () {
newEle.show();
$this.remove();
if (callback) {
callback($(this));
}
})
};
var socket = io();
var sizes = ['Training', 'Amateur', 'Semi-Pro', 'Pro', 'World-Class', 'Legendary'];
socket.emit('set sizes', sizes);
var roomCode = prompt("enter a room code", "12345");
if (roomCode) {
$('#roomCode').html("Room-Code: " + roomCode);
socket.emit('room', roomCode);
socket.emit('chef connected', roomCode);
}
socket.on('user connected', function (msg) {
$('#users').html(parseInt($('#users').html()) + 1);
})
socket.on('card draw', function (msg) {
numCards = $('#card-container').children().length;
$('#counter').html(parseInt($('#counter').html()) + 1);
$('#card-container').append(cardHtml(numCards, msg));
});
drawNew();
/*$('#url').on("keypress", function (event) {
if (event.which == 13 && !event.shiftKey) {
$('#iframe').html('<iframe width="500px" height="500px" src="">');
}
});*/
$('#reset').click(function () {
$('#counter').html(0);
$('.card-container-card').animateCss('bounceOutLeft', function (element) {
$(element).closest('.card-container-card-container').remove();
drawNew();
});
socket.emit('card reset');
});
$('#show').click(function () {
$('.card-container-card').toggleClass('hover');
$('.stack').addClass('show');
var stackSizes = [];
$('.card-container-card').each(function (i, item) {
if (stackSizes[$(this).data('value')] == undefined) {
stackSizes[$(this).data('value')] = 0
}
$(this).detach().appendTo('#stack-' + $(this).data('value'));
/*$(this).animateAppendTo('#stack-' + $(this).data('value'), 1000, function () {*/
$(this).css("position", "absolute");
if (stackSizes[$(this).data('value')] % 2 == 0) {
$(this).css("left", '25px');
} else {
$(this).css("left", '105px');
}
$(this).css("top", `${stackSizes[$(this).data('value')] * 30}px`);
$(this).css("width", 250 - stackSizes[$(this).data('value')] * 2 + "px");
$(this).css("z-index", 100 - stackSizes[$(this).data('value')]);
$(this).css("transform", `rotate(${$(this).data("rotation")}deg)`);
stackSizes[$(this).data('value')]++;
/*});*/
});
})
function drawNew() {
$('#card-container').empty();
$('.stack').empty();
};
function cardHtml(numCards, msg) {
return `
<div class="col-md-4 col-sm-6 animated bounceInDown card-container-card-container">
<div class="card-container-card manual-flip" style="animation-delay: ${numCards * 0.3}s; transition-delay: ${numCards * 0.1}s;" data-value="${msg.card_value}" data-rotation="${Math.random() * 5 - 2.5}">
<div class="card" style="transition-delay: ${numCards * 0.3}s;">
<div class="front">
<div class="header">
<h5 class="motto">"Die Spannung steigt!!!"</h5>
</div>
</div>
<!-- end front panel -->
<div class="back">
<div class="user">
<img class="img-circle" src="${msg.url}" />
</div>
<div class="content">
<div class="main">
<h3 class="name">${msg.card_value}</h3>
<p class="profession">${msg.name}</p>
</div>
</div>
</div>
<!-- end back panel -->
</div>
<!-- end card -->
</div>
<!-- end card-container -->
</div>`
}
});
</script>
</body>
</html>