-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.cshtml
139 lines (118 loc) · 4.66 KB
/
default.cshtml
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
@using System.Configuration
<!DOCTYPE html>
<html lang="en">
<head>
<title>Prize Draw - DDD Perth</title>
<link rel="shortcut icon" type="image/x-icon" href="https://dddperth.com/static/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charSet="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossOrigin="anonymous" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossOrigin="anonymous" />
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" />
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Montserrat:700" />
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Overpass+Mono:700" />
<link rel="stylesheet" href="https://dddperth.com/_next/static/style.css" />
</head>
<body>
<style>
#people {
margin-left: 20px;
height: 80px;
background-color: #efefef;
padding: 5px 30px 5px 10px;
overflow: hidden;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
text-align: center;
}
#people li {
font-size: 50px;
overflow: hidden;
height: 80px;
margin-bottom: 30px;
}
#people li:before {
display: none;
}
#spin {
float: right;
}
.sub {
font-size: 0.8em;
margin-top: 50px;
}
.cover {
color: transparent;
}
.whitelogo {
background-color: #FFFFFF;
text-align: center;
}
.whitelogo img {
width: 200px;
}
</style>
<div class="container">
<h2>Prize Draw!</h2>
<p>And the winner is...</p>
<ul id="people" class="cover"></ul>
<button class="btn btn-secondary" id="spin">Spin!</button>
<div style="clear:both;"></div>
<p><small>Based on @@YiJiang's awesome <a href="http://jsfiddle.net/yijiang/AYPpF/24/">Wheel of Blame</a> which
uses the <a href="http://gsgd.co.uk/sandbox/jquery/easing/">jquery easing</a> plugin by gsgd.</small>
</p>
</div>
<div class="whitelogo">
<img src="logo.png" alt="DDD Perth" />
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>
<script type="text/javascript">
var ul = $('#people');
spinBtn = $('#spin');
var iterations = 2;
var candidates = [];
function spin() {
$('#people').removeClass("cover");
spinBtn.attr('disabled', true).text('Hang on!');
var li = $('#people li');
var count = li.length / iterations;
if (candidates.length === 0) {
for (var i = 0; i < count; i++) {
var thisPos = -(li.first().outerHeight(true) * (i + count * (iterations - 1))) - 5;
candidates.push(thisPos)
}
}
var randomIndex = Math.floor(Math.random() * candidates.length);
var newPos = candidates.splice(randomIndex, 1)[0];
li.first().animate({ marginTop: newPos }, 3000, 'easeOutCubic', function () {
spinBtn.attr('disabled', false).text('Spin Again!');
});
}
// retrieve
(function () {
$.ajax({
url: '@ConfigurationManager.AppSettings["PrizeDrawApiUrl"]',
success: function (data) {
var newlis = data.reduce(function (c, d) {
return c + "<li>" + $('<div/>').text(d).html() + "</li>";
}, '');
for (var i = 0; i < iterations; i++) {
$(newlis).clone().appendTo(ul);
}
spinBtn.click(function () {
$('#people li').first().css('margin-top', 0);
spin();
return false;
});
}
});
})();
</script>
</body>
</html>