-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
281 lines (256 loc) · 7.27 KB
/
index.html
File metadata and controls
281 lines (256 loc) · 7.27 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cards test</title>
<style type="text/css">
div.card {
border: 2px solid #333333;
border-radius: 5px 5px 5px 5px;
padding: 0.28em;
background: #F0F0F0;
background: -moz-linear-gradient(top, #ffffff 0%, #e5e5e5 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5));
}
.shadow {
box-shadow: 5px 5px 5px;
}
div.card {
font-size: 32px;
float: left;
margin: 18px;
}
div.card > div {
border: 1px solid;
width: 3.75em;
height: 5em;
border-radius: 3px;
position: relative;
}
div.card.red > div {
color: #FF0000;
}
div.card.ace > div > div {
font-size: 300%;
left: 0.325em;
top: 0.250em;
}
div.card.ace > div > div.index {
font-size: 0.45em;
}
div.card .index {
font-size: 0.45em;
font-weight: bold;
text-align: center;
position: absolute;
left: 0.25em;
top: 0.25em;
}
div.card .spotA1 { position: absolute; left: 0.60em; top: 0.5em; }
div.card .spotA2 { position: absolute; left: 0.60em; top: 1.5em; }
div.card .spotA3 { position: absolute; left: 0.60em; top: 2.0em; }
div.card .spotA4 { position: absolute; left: 0.60em; top: 2.5em; }
div.card .spotA5 { position: absolute; left: 0.60em; top: 3.5em; }
div.card .spotB1 { position: absolute; left: 1.55em; top: 0.5em; }
div.card .spotB2 { position: absolute; left: 1.55em; top: 1.0em; }
div.card .spotB3 { position: absolute; left: 1.55em; top: 2.0em; }
div.card .spotB4 { position: absolute; left: 1.55em; top: 3.0em; }
div.card .spotB5 { position: absolute; left: 1.55em; top: 3.5em; }
div.card .spotC1 { position: absolute; left: 2.50em; top: 0.5em; }
div.card .spotC2 { position: absolute; left: 2.50em; top: 1.5em; }
div.card .spotC3 { position: absolute; left: 2.50em; top: 2.0em; }
div.card .spotC4 { position: absolute; left: 2.50em; top: 2.5em; }
div.card .spotC5 { position: absolute; left: 2.50em; top: 3.5em; }
/*
* Animations
*/
div.card {
position: absolute;
-moz-transition: all 3s ease-out;
-moz-transform-origin: 1.875em 2.5em;
}
div.card.dealt {
-moz-transform: rotate(720deg) translate(200px, 300px) scale(0.5, 0.5);
-webkit-transform: rotate(180deg);
-o-transform: rotate(720deg);
-ms-transform: rotate(720deg);
transform: rotate(720deg);
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
var drawCard = function(container, value, suit) {
var buffer = [];
var cardClass = 'card'
var suitVal;
if(suit == 0) {
suitVal = '♠';
} else if(suit == 1) {
suitVal = '♥';
cardClass = cardClass + ' red';
} else if(suit == 2) {
suitVal = '♣';
} else {
suitVal = '♦';
cardClass = cardClass + ' red';
}
if(value == 1) {
cardClass = cardClass + ' ace';
}
buffer.push('<div class="');
buffer.push(cardClass);
buffer.push('"><div>');
//Index
buffer.push('<div class="index">');
switch(value) {
case 1:
buffer.push('A');
break;
case 11:
buffer.push('J');
break;
case 12:
buffer.push('Q');
break;
case 13:
buffer.push('K');
break;
default:
buffer.push(value);
}
buffer.push('<br />');
buffer.push(suitVal);
buffer.push('</div>');
//Draw suit pips
if (value < 11) {
buffer.push('<div class="spot');
var delimeter = '">' + suitVal + '</div><div class="spot'
buffer.push(cardSlots[value - 1].join(delimeter));
buffer.push('">');
buffer.push(suitVal);
buffer.push('</div>');
}
buffer.push('</div></div>');
if (container != null) {
var containerEl = document.getElementById(container);
if (containerEl) {
containerEl.innerHTML = buffer.join('');
}
} else {
return buffer.join('');
}
};
var cardSlots = [
['B3'],
['B1','B5'],
['B1','B3','B5'],
['A1','A5','C1','C5'],
['A1','A5','B3','C1','C5'],
['A1','A3','A5','C1','C3','C5'],
['A1','A3','A5','B2','C1','C3','C5'],
['A1','A3','A5','B2','B4','C1','C3','C5'],
['A1','A2','A4','A5','B3','C1','C2','C4','C5'],
['A1','A2','A4','A5','B2','B4','C1','C2','C4','C5']
];
</script>
</head>
<body style="background: none repeat scroll 0 0 #00CC44;">
<h1>Card Shop</h1>
<div id="card1cont" onclick="$('#card1cont .card').toggleClass('dealt')">
<a href="#" onclick="cycleCardsDemo(); return false;">Demo 1</a>
</div>
<div id="demo2" style="left: 500px; position: absolute;">
<a href="#" onclick="deckDemo(); return false;">Demo 2</a>
</div>
<br />
<!--<div>
<div class="card ace">
<div>
<div class="index">A<br />♠</div>
<div class="spotB3">♠</div>
</div>
</div>
<div class="card ace red">
<div>
<div class="index">A<br />♥</div>
<div class="spotB3">♥</div>
</div>
</div>
<div class="card ace">
<div>
<div class="index">A<br />♣</div>
<div class="spotB3">♣</div>
</div>
</div>
<div class="card ace red">
<div>
<div class="index">A<br />♦</div>
<div class="spotB3">♦</div>
</div>
</div>
<div class="card red">
<div>
<div class="index">5<br />♥</div>
<div class="spotA1">♥</div>
<div class="spotA5">♥</div>
<div class="spotB3">♥</div>
<div class="spotC1">♥</div>
<div class="spotC5">♥</div>
</div>
</div>
</div>-->
<script type="text/javascript">
/*
* Demo 1
*/
var curCardVal = 1;
var curCardSuit = 0;
var incDemoCard = function() {
curCardVal = curCardVal % 13 +1;
curCardSuit = ++curCardSuit % 4;
drawCard('card1cont', curCardVal, curCardSuit);
};
var cycleCardsDemo = function(){
incDemoCard();
window.setInterval(incDemoCard, 700);
};
/*
* Demo 2
*/
var deckDemo = function() {
var deck = [];
for(var i = 0; i < 52; i++) {
var v = (i % 13) + 1;
var s = (i / 13) | 0; //cast to int with bitwise OR
console.log(i +": "+v+"-"+s);
deck.push({val: v, suit: s});
}
//linear shuffle
for(var i = 51; i >= 0; i--) {
var swapInd = Math.floor(Math.random()*(i+1));
var temp = deck[i];
deck[i] = deck[swapInd];
deck[swapInd]=temp;
}
//draw deck
var cardsBuffer = [];
for(var i = 0; i < 52; i++) {
cardsBuffer.push('<div ');
// cardsBuffer.push('style="z-index: ');
// cardsBuffer.push(i);
// cardsBuffer.push('"');
cardsBuffer.push('>');
cardsBuffer.push(drawCard(null, deck[i].val, deck[i].suit));
cardsBuffer.push("</div>");
}
var deckDock = document.getElementById('demo2');
if(deckDock) {
deckDock.innerHTML = cardsBuffer.join('');
}
$('#demo2 .card').click(function () {
$(this).toggleClass('dealt');
});
};
</script>
</body>
</html>