-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
vote.html
249 lines (242 loc) · 13.4 KB
/
vote.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
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
<html>
<head>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Fredoka+One|Open+Sans&display=swap" rel="stylesheet">
<title>ChatBlocks Challenge Voting!</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-135113520-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-135113520-1');
</script>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<script src="https://cdn.jsdelivr.net/npm/comfytwitch@latest/web/comfytwitch.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/comfy.js/dist/comfy.min.js"></script>
<style>
html, body {
font-family: "Fredoka One", "sans-serif";
color: #ffffff;
background-color: #333;
}
a, a:hover {
color: #ffa600;
}
.translucent-purple-bg {
background-color: rgba( 100, 65, 165, 0.5 );
border-color: rgba( 100, 65, 165, 0.5 );
color: #ccc;
}
.btn-purple-outline {
background-color: #fff;
border-color: #fff;
color: #6441a5;
}
.btn-purple {
background-color: #6441a5;
border-color: #6441a5;
color: #fff;
}
.btn-primary {
background-color: #4C97FF;
border-color: #4C97FF;
}
.btn-warning {
background-color: #ffa600;
border-color: #ffa600;
}
.card {
background-color: #6441a5;
color: #fff;
}
.card-img-top {
width: 100%;
height: 25vw;
object-fit: cover;
}
.pre {
white-space: pre-wrap;
}
</style>
</head>
<body class="container">
<div id="login-group" class="py-2 float-right" hidden><button id="login" class="btn btn-purple center">Log In with <i class="fa fa-twitch"></i> Twitch</button></div><div id="profile-group" class="py-2 float-right" hidden><span><span id="username"></span> <img id="profile-image" class="rounded" src="" alt="Profile Image" height="38" width="38"></span> <button id="logout" class="btn btn-purple">Log Out</button></div>
<h1>ChatBlocks by <a href="https://www.instafluff.tv" target="_blank">Instafluff</a></h1>
<p>Vote for your favorite ChatBlocks Challenge 3.0 entry! <span class="text-info">(Until Fri Dec 18, 11:59pm Pacific Time)</span></p>
<div id="entries" class="row">
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<script>
const params = new URLSearchParams( location.search );
let submissions = [
{
"challenge": 3,
"creator": "MStewGT",
"description": `This Chat-Blocks bot implements the !pokeball command allowing a user to attempt to catch a random pokemon. It uses the https://pokeapi.co/ API to retrieve a random pokemon which then has a chance to either run away or be successfully caught.`,
"notes": `Love your channel! It's extremely welcoming and accessible to newcomers/beginners and I appreciate what you contribute to the community. Keep up the good work!`,
"screenshots": [ "1_pokeball_01.png", "1_pokeball_01.png" ],
"file": "1_pokeball.cbs"
},
{
"challenge": 3,
"creator": "sparky_pugwash",
"description": `like a bean boozle, you type !bean and get a flavour bean could be bad or good flavours`,
"notes": `I hope you like it`,
"screenshots": [ "2_bean_01.jpg" ],
"file": "2_bean.cbs"
},
{
"challenge": 3,
"creator": "vic10usx",
"description": `Command Cooldown (using Dad Jokes)`,
"notes": ``,
"screenshots": [ "3_cooldown_01.png", "3_cooldown_02.png" ],
"file": "3_cooldown.cbs"
},
{
"challenge": 3,
"creator": "Schkullie",
"description": `This is a little thing I made for my stream that puts out questions randomly every 15 minutes.
It helps to keep up the talking going and also opens up opportunities to get to know the viewers a bit more .
I did change the questions to family friendly ones for my entry, but any questions you can think of work.
It's not really a difficult chatblocks code, but I never seen something like this on a stream and thought it might be cool to share.`,
"notes": ``,
"screenshots": [ "4_questions_01.png", "4_questions_02.jpg" ],
"file": "4_questions.cbs"
},
{
"challenge": 3,
"creator": "walpolea",
"description": `twitch-a-sketch is a chat-powered drawing app. Point your OBS source to https://twitch-a-sketch.web.app/ and use the !sketch <x y x y x y>, !sketchby <x y x y x y>, !sketchclear, !sketchsize <n>, !sketchcolor <#22FFCC or web color>`,
"notes": ``,
"screenshots": [ "5_sketch_01.png" ],
"file": "5_sketch.cbs"
},
{
"challenge": 3,
"creator": "informathemusic",
"description": `Generates a username`,
"notes": `🔫(TwT {Vote Informa 2020]`,
"screenshots": [ "6_username_01.png" ],
"file": "6_username.cbs"
},
{
"challenge": 3,
"creator": "informathemusic",
"description": `Looks up for acronyms in wikipedia`,
"notes": `I've won the elections, and by a lot!`,
"screenshots": [ "7_wiki_01.png" ],
"file": "7_wiki.cbs"
},
{
"challenge": 3,
"creator": "ellenary",
"description": `A stretch timer that'll play a sound when it's time for you to take a break. You can set it to whatever interval you'd like. Every 30 mins (1800 sec), every hour (3600 sec), etc. Originally made for MaayaInsane, but it found a home on Instafluff's channel and I want to share it with the rest of the world. :)`,
"notes": ``,
"screenshots": [ "8_stretch_01.png", "8_stretch_02.png" ],
"file": "8_stretch.cbs"
},
];
(async () => {
let votes = await fetch( "https://api.instafluff.tv:9999/cbvotes/3" ).then( r => r.json() ).catch( err => {} );
votes = votes || {};
let entries = [];
submissions.forEach( ( entry, i ) => {
console.log( entry, i );
let carouselIndicators = "";
let carouselItems = "";
entry.screenshots.forEach( ( s, n ) => {
carouselIndicators += `<li data-target="#carousel_${i}" data-slide-to="${n}" ${n === 0 ? 'class="active"' : ''}></li>`;
carouselItems += `<div class="carousel-item ${n === 0 ? "active" : ""}"><img src="web/vote${entry.challenge}/${s}" class="d-block w-100 card-img-top" alt="screenshot"></div>`
});
entries.push(`
<div class="col-4 pb-4">
<div class="card">
<div id="carousel_${i}" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
${carouselIndicators}
</ol>
<div class="carousel-inner">
${carouselItems}
</div>
<a class="carousel-control-prev" href="#carousel_${i}" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel_${i}" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div class="card-body">
<h5 class="card-title">Built By: <span class="text-warning">${entry.creator}</span></h5>
<a href="web/vote${entry.challenge}/${entry.file}" target="_blank" class="btn btn-info" download>Download</a>
<button id="vote_${i}" class="btn btn-danger" onclick="sendVote(${i})">Votes (${( votes[ i ] || 0 ) + 1})</button>
<br/><br/>
<p class="card-text pre"><small>${entry.description}</small></p>
<br/><br/>
<small><i>${entry.notes}</i></small>
</div>
</div>
</div>`);
});
// Shuffle entries
for( let i = entries.length - 1; i > 0; i-- ) {
const j = Math.floor( Math.random() * ( i + 1 ) );
[ entries[ i ], entries[ j ] ] = [ entries[ j ], entries[ i ] ];
}
entries.forEach( e => {
$( "#entries" ).append( e );
});
})();
async function sendVote( id ) {
let result = await fetch( `https://api.instafluff.tv:9999/cbvote/3?twitch=${ComfyTwitch.Token}&vote=${id}` );
// console.log( "VOTE", result );
location.reload();
}
const clientId = "xrxinjwucvs83rf1b6lxq758yslj3c";
const baseUrl = window.location.origin + window.location.pathname;
ComfyTwitch.Check()
.then( async result => {
console.log( result );
if( result ) {
// Logged In
let user = await ComfyTwitch.GetUser( clientId, result.user_id );
document.getElementById( "username" ).innerText = user.display_name;
document.getElementById( "profile-image" ).src = user.profile_image_url;
document.querySelector( "#login-group" ).setAttribute( "hidden", true );
document.querySelector( "#profile-group" ).removeAttribute( "hidden" );
document.querySelector( "#logout" ).addEventListener( "click", function() {
ComfyTwitch.Logout();
window.location.reload();
});
let myVote = await fetch( `https://api.instafluff.tv:9999/cbmyvote/3?twitch=${ComfyTwitch.Token}` ).then( r => r.json() ).catch( err => {} );
console.log( myVote );
if( myVote && myVote.user ) {
$( `#vote_${myVote.vote}` ).text( $( `#vote_${myVote.vote}` ).text().replace( "Votes", "My Vote" ) );
$( `#vote_${myVote.vote}` ).removeClass( "btn-danger" );
$( `#vote_${myVote.vote}` ).addClass( "btn-secondary" );
}
}
else {
// Logged Out
document.querySelector( "#profile-group" ).setAttribute( "hidden", true );
document.querySelector( "#login-group" ).removeAttribute( "hidden" );
document.querySelector( "#login" ).addEventListener( "click", function() {
ComfyTwitch.Login( clientId, baseUrl, [ "user:read:email" ] );
});
}
});
</script>
</body>
</html>