-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
366 lines (247 loc) · 11.2 KB
/
script.js
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
// BTCPay Server
if(!window.btcpay){
var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script');
script.src='https://btcpay989117.lndyn.com/modal/btcpay.js';
script.type = 'text/javascript';
head.append(script);}function onBTCPayFormSubmit(event){
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if(this.status == 200 && this.responseText){
var response = JSON.parse(this.responseText);
window.btcpay.showInvoice(response.invoiceId);
}
}
};
xhttp.open("POST", event.target.getAttribute('action'), true);
xhttp.send(new FormData( event.target ));
}
$( document ).ready(function() {
$("#hero-cta").click(function() {
$('html, body').animate({
scrollTop: $("#producership-options ").offset().top
}, 1000);
});
$("#back-to-scenes").click(function() {
$('html, body').animate({
scrollTop: $("#scenes").offset().top
}, 1000);
});
$(".popup-toggle").click(function() {
$("#"+$(this).attr("data-target")).fadeIn(300);
});
$(".popup-overlay").click(function(event) {
e = event || window.event;
if (e.target == this) {
$("#"+$(this).attr("data-target")).fadeOut(300);
}
});
$(".popup-close").click(function() {
$(".popup-overlay").fadeOut(300);
$('iframe').attr('src', $('iframe').attr('src'));
});
$(document).on('keyup', function(e) {
if (e.key == "Escape") {
$(".popup-overlay").fadeOut(300);
$('iframe').attr('src', $('iframe').attr('src'));
};
});
//load scenes from google docs
var totalScenes = 9;
// Hack to force reloading of content from google sheets
setTimeout(function(){
getScenesData(totalScenes);
getProducerData();
getTeamtData(totalScenes);
}, 500);
$(".btcpay-form").each(function( index, element ) {
var jsonForm = new Object();
var type = $(element).find('.input-checkoutDesc').val();
$(element).find('.btcpay-input').keyup(function() {
// limit, for validation
// {"p":"Contributor","n":"wdhgt735344eew","t":"rwfrw66uiolou3746467456fwwed","g":"546646665644664654"}
$(element).find('.input-checkoutDesc').val( type + ':' + $(element).find('.input-name').val());
jsonForm.p = type;
jsonForm.n = $(element).find('.input-name').val();
jsonForm.t = $(element).find('.input-twitterHandle').val();
jsonForm.g = $(element).find('.input-githubUsername').val();
console.log(JSON.stringify(jsonForm));
$(element).find('.input-orderId').val(JSON.stringify(jsonForm));
});
});
// Form label animations
$('input').focus(function(){
$(this).parents('.form-group').addClass('focused');
});
$('input').blur(function(){
var inputValue = $(this).val();
if ( inputValue == "" ) {
$(this).removeClass('filled');
$(this).parents('.form-group').removeClass('focused');
} else {
$(this).addClass('filled');
}
})
});
function getScenesData(totalScenes){
var sceneData = [];
var shots = [];
var tableDeader = "<thead><tr> <th class='table-col-section'><h4>Theme</h4></th> <th class='table-col-board'><h4>Board</h4></th> <th class='table-col-vo'><h4>Voice</h4></th> <th class='table-col-visual'><h4>Shot</h4></th> </tr></thead>"
//and in your call will listen for the custom deferred's done
for (i = 1; i <= totalScenes; i++) {
getScriptData(i).then(function(returndata){
sceneData.push(returndata);
//if all loaded
if(sceneData.length == totalScenes){
//sort after all loaded
sceneData.sort(compare);
//iterate all scenes
$.each(sceneData, function( key, scene ) {
//print title nav
$( "<h4/>", { "id": "scene-select-"+scene.sort, "class": "scene-select inactive", html: scene.title }).appendTo( "#scenes-nav" );
shots.push(tableDeader);
shots.push("<tbody>");
$.each( scene.shots, function( key, shot ) {
//console.log(shot);
shots.push( "<tr id='sheet"+scene.sort+" row-" + key + "' class='row-content'> ");
var rowContent = '';
shot.gsx$section.$t == '' ? rowContent = ' empty' : rowContent = '';
shots.push( "<td class='table-col-section"+rowContent+"'><h4>" + shot.gsx$section.$t.replace(/\n/g,"<br>") + "</h4></td>");
shot.gsx$board.$t == '' ? rowContent = ' empty' : rowContent = '';
shots.push( "<td class='table-col-board"+rowContent+"'>");
if(shot.gsx$board.$t != ""){
shots.push( "<div class='image-holder'><img src=" + shot.gsx$board.$t + " /></div>");
}
shots.push( "</td>");
shot.gsx$vo.$t == '' ? rowContent = ' empty' : rowContent = '';
shots.push( "<td class='table-col-vo"+rowContent+"'>" + shot.gsx$vo.$t.replace(/\n/g,"<br>") + "</td>");
shot.gsx$visual.$t == '' ? rowContent = ' empty' : rowContent = '';
shots.push( "<td class='table-col-visual grey"+rowContent+"'>" + shot.gsx$visual.$t.replace(/\n/g,"<br>") + "</td>");
shots.push( "</tr>");
});
shots.push("</tbody>");
//Print shots table
$( "<table/>", { "id": "scene-select-"+scene.sort+"-table" , "class": "scene", html: shots.join( "" ) }).appendTo( "#scenes-data" );
shots = [];
});
$('.scene-select').click(function() {
var t = $(this).attr('id');
if($(this).hasClass('inactive')){ //this is the start of our condition
$('.scene-select').addClass('inactive');
$(this).removeClass('inactive');
$('.scene').hide();
$('#'+ t + '-table').fadeIn('slow');
}
for (i = 1; i <= totalScenes; i++) {
$('#scenes-diagrams').removeClass('diagram-scene-select-'+i);
}
$('#scenes-diagrams').addClass('diagram-'+t);
});
$('.scene').hide();
$('#scene-select-1-table').fadeIn('slow');
$('#scene-select-1').removeClass('inactive');
}
});
}
}
function getTeamtData(totalScenes){
var teamData = {};
var markupTeam = '';
var department;
return $.getJSON("https://spreadsheets.google.com/feeds/list/1JTdEbmcEsAtAz1-FyO9LyxF-FsBwEJ-9MCthfWktfv8/"+(totalScenes+2)+"/public/values?alt=json").then(function(data){
$.each(data.feed.entry, function (key, teamMember) {
if(teamMember.gsx$department.$t !== ""){
department = teamMember.gsx$department.$t;
teamData[department] = {'departmentName': department, 'departmentCompensation': teamMember.gsx$departmentcompensation.$t, 'team': [] };
}
teamData[department].team.push({
'name': teamMember.gsx$individual.$t.replace(/\n/g,"<br>"),
'individualCompensation': teamMember.gsx$individualcompensation.$t,
'url': teamMember.gsx$url.$t
})
});
$.each(teamData, function(key, item){
$.each(item.team, function(key, teamMember){
if(teamMember.url != ""){
markupTeam += '<a href="'+teamMember.url+'" target="_blank">' + teamMember.name + '</a> <span class="compensation">' + teamMember.individualCompensation + '%</span><br>';
}else{
markupTeam += teamMember.name + ' <span class="compensation">' + teamMember.individualCompensation + '%</span><br>';
}
});
$('#team-data').append('<tr><td class="team-position"><span class="compensation">'+item.departmentCompensation+'%</span> '+item.departmentName+' </td><td class="team-person">'+markupTeam+'</td></tr>');
markupTeam = "";
});
});
};
/*
gsx$individualcompensation
gsx$departmentcompensation
gsx$individual
gsx$url
*/
function getScriptData(i){
return $.getJSON("https://spreadsheets.google.com/feeds/list/1JTdEbmcEsAtAz1-FyO9LyxF-FsBwEJ-9MCthfWktfv8/"+(i+1)+"/public/values?alt=json").then(function(data){
return {
sort:i,
title:data.feed.title.$t,
shots:data.feed.entry
}
});
};
function getProducerData(){
var amoutTotal = 0;
$.getJSON("https://pvxg.net/BTCpaySponsor/").then(function(data){
$.each(data, function (key, producer) {
//console.log(JSON.parse(producer.metadata.orderId));
//console.log(producer.metadata.itemDesc.startsWith("Contributor:"));
var targetContainer = "";
var jsonObject;
var amount = '<div class="amount">' + producer.amount + ' <span class="grey">' + producer.currency + '</span></div>';
var currentAmount = parseFloat(producer.amount);
if(producer.metadata.itemDesc !== undefined && producer.metadata.itemDesc !== null){
if(producer.metadata.itemDesc.startsWith("Contributor:")){
targetContainer = "#contributors-inner";
jsonObject = JSON.parse(producer.metadata.orderId);
//console.log(jsonObject.n);
$( "<div/>", { "class": "producer-name", html: '<b>' + jsonObject.n + '</b>' + amount }).appendTo(targetContainer);
amoutTotal = (currentAmount) + amoutTotal;
} else if(producer.metadata.itemDesc.startsWith("Sponsor:")){
targetContainer = "#sponsors-inner";
jsonObject = JSON.parse(producer.metadata.orderId);
$( "<div/>", { "class": "producer-name", html: '<h2>' + jsonObject.n + '</h2>' + amount }).appendTo(targetContainer);
amoutTotal = (currentAmount) + amoutTotal;
} else if(producer.metadata.itemDesc.startsWith("Producer:")){
targetContainer = "#producers-inner";
//Adding logos to major contributors
if(producer.metadata.itemDesc.startsWith("Producer:ACME")){
$( "<div/>", { "class": "producer-name", html: '<img class="producer-logo" src="assets/logos/example.png">' + amount }).appendTo(targetContainer);
}
if(producer.metadata.itemDesc.startsWith("Producer:Widgets")){
$( "<div/>", { "class": "producer-name", html: '<img class="producer-logo" src="https://theme4press.com/wp-content/uploads/2015/11/featured-large-adding-widgets.jpg">' + amount }).appendTo(targetContainer);
}
amoutTotal = (currentAmount) + amoutTotal;
}
}
//reset target
targetContainer = "";
});
var finalProgress = (amoutTotal / 3)*100
if( finalProgress < 3 ){
finalProgress = '30px';
$('.meter').addClass('short');
}else{
$('.meter').addClass('long');
finalProgress = finalProgress+'%';
}
$(".amount-value-progress").text(amoutTotal.toFixed(8));
$( "#meter-progress-bar" ).animate({ width: finalProgress}, 200, function() { });
});
};
function compare( a, b ) {
if ( a.sort < b.sort ){
return -1;
}
if ( a.sort > b.sort ){
return 1;
}
return 0;
}