Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nicnacnic authored May 25, 2021
1 parent 6603f99 commit 3eeb351
Show file tree
Hide file tree
Showing 58 changed files with 938 additions and 1,150 deletions.
501 changes: 146 additions & 355 deletions configschema.json

Large diffs are not rendered by default.

181 changes: 181 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
const fetch = require("node-fetch");
let oengusURL;

module.exports = function(nodecg) {

// Declare replicants.
const targetData = nodecg.Replicant('targetData', '');
const pollData = nodecg.Replicant('pollData', '');
const rewardData = nodecg.Replicant('rewardData', '');
const campaignData = nodecg.Replicant('campaignData', '');
const donationTotal = nodecg.Replicant('donationTotal', 0)

campaignData.value = { currentAmount: 0, targetAmount: 0 }

// Pull data from Tiltify/Oengus
if (nodecg.bundleConfig.donation.useTiltify) {
fetch(`https://tiltify.com/api/v3/campaigns/${nodecg.bundleConfig.donation.tiltifyCampaignID}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${nodecg.bundleConfig.donation.tiltifyAuthToken}`
},
dataType: 'json',
}).then(response => response.json())
.then(data => {
if (data.status === (403 || 500))
nodecg.log.error("There was an issue retriving your Tiltify campaign information. Make sure your campaign ID and auth token are correct!")
else {
nodecg.log.info(`Connected to campaign ID ${nodecg.bundleConfig.donation.tiltifyCampaignID}!`)
getTiltifyData()
setInterval(() => {
getTiltifyData()
}, nodecg.bundleConfig.donation.refreshTime)
}
});
}
else if (nodecg.bundleConfig.donation.useOengus) {
if (nodecg.bundleConfig.donation.oengusUseSandbox)
oengusURL = `https://sandbox.oengus.io/api/marathons/${nodecg.bundleConfig.donation.oengusMarathon}`;
else
oengusURL = `https://oengus.io/api/marathons/${nodecg.bundleConfig.donation.oengusMarathon}`;
fetch(oengusURL, {
method: 'GET',
dataType: 'json',
}).then(response => response.json())
.then(data => {
if (data.status === (403 || 500))
nodecg.log.error("There was an issue retriving your Oengus marathon information. Make sure your marathon short name is correct!")
else {
nodecg.log.info(`Connected to marathon ${nodecg.bundleConfig.donation.oengusMarathon}!`)
if (nodecg.bundleConfig.donation.oengusUseSandbox)
nodecg.log.warn("You are using a Oengus sandbox marathon! To disable, set oengusUseSandbox to false.");
getOengusData();
setInterval(() => {
getOengusData()
}, nodecg.bundleConfig.donation.refreshTime)
}
})
}

function getTiltifyData() {
fetch(`https://tiltify.com/api/v3/campaigns/${nodecg.bundleConfig.donation.tiltifyCampaignID}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${nodecg.bundleConfig.donation.tiltifyAuthToken}`
},
dataType: 'json',
}).then(response => response.json())
.then(data => {
campaignData.value = { name: data.data.name, url: data.data.url, description: data.data.description, currentAmount: data.data.amountRaised, targetAmount: data.data.fundraiserGoalAmount }
donationTotal.value = data.data.amountRaised;

// Get targets.
fetch(`https://tiltify.com/api/v3/campaigns/${nodecg.bundleConfig.donation.tiltifyCampaignID}/challenges`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${nodecg.bundleConfig.donation.tiltifyAuthToken}`
},
dataType: 'json',
}).then(response => response.json())
.then(targets => {
let targetArray = [];
if (targets.data !== '') {
targets.data.forEach(element => {
if ((element.endsAt > new Date().getTime() || element.endsAt === 0) && element.totalAmountRaised < element.amount && element.active) {
if (element.endsAt === 0)
element.endsAt = 9999999999999;
targetArray.push({ name: element.name, currentAmount: element.amount, targetAmount: element.totalAmountRaised, endsAt: element.endsAt, id: element.id })
}
})
targetArray.sort((a, b) => a.endsAt - b.endsAt);
targetData.value = { dataLength: targetArray.length, data: targetArray };
}
});

// Get polls.
fetch(`https://tiltify.com/api/v3/campaigns/${nodecg.bundleConfig.donation.tiltifyCampaignID}/polls`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${nodecg.bundleConfig.donation.tiltifyAuthToken}`
},
dataType: 'json',
}).then(response => response.json())
.then(polls => {
let pollArray = [];
if (polls.data !== '') {
polls.data.forEach(element => {
if (element.active) {
let pollOptionArray = [];
element.options.forEach(pollOption => {
pollOptionArray.push({ name: pollOption.name, currentAmount: pollOption.totalAmountRaised })
})
pollOptionArray.sort((a, b) => b.currentAmount - a.currentAmount);
pollArray.push({ name: element.name, options: pollOptionArray, id: element.id })
}
})
pollData.value = { dataLength: pollArray.length, data: pollArray };
}
});

// Get rewards.
fetch(`https://tiltify.com/api/v3/campaigns/${nodecg.bundleConfig.donation.tiltifyCampaignID}/rewards`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${nodecg.bundleConfig.donation.tiltifyAuthToken}`
},
dataType: 'json',
}).then(response => response.json())
.then(rewards => {
let rewardArray = [];
if (rewards.data !== '') {
rewards.data.forEach(element => {
if ((element.startsAt > new Date().getTime() || element.startsAt === 0) && (element.endsAt > new Date().getTime() || element.endsAt === 0) && element.active) {
if (element.endsAt === 0)
element.endsAt = 9999999999999;
rewardArray.push({ name: element.name, description: element.description, minDonation: element.amount, endsAt: element.endsAt, img: element.image.src, id: element.id })
}
})
rewardArray.sort((a, b) => a.endsAt - b.endsAt);
rewardData.value = { dataLength: rewardArray.length, data: rewardArray };
}
});
});
}

function getOengusData() {
fetch(oengusURL, {
method: 'GET',
dataType: 'json',
}).then(response => response.json())
.then(data => {
campaignData.value = { name: data.name, url: 'https://oengus.fun/' + data.id, description: data.description, currentAmount: data.donationsTotal, targetAmount: 0 }
donationTotal.value = data.donationsTotal;

// Get incentive data.
fetch(oengusURL + '/incentives', {
method: 'GET',
dataType: 'json',
}).then(response => response.json())
.then(incentives => {
let targets = [];
let polls = [];
let rewards = [];
if (incentives !== '' || incentives !== undefined)
incentives.forEach(element => {
if (!element.locked && !element.bidWar)
targets.push({ name: element.name, currentAmount: element.currentAmount, targetAmount: element.goal, id: element.id })
else if (!element.locked && element.bidWar) {
let pollOptionArray = [];
element.bids.forEach(pollOption => {
pollOptionArray.push({ name: pollOption.name, currentAmount: pollOption.currentAmount })
})
pollOptionArray.sort((a, b) => b.currentAmount - a.currentAmount);
polls.push({ name: element.name, options: pollOptionArray, id: element.id })
}
});
targetData.value = { dataLength: targets.length, data: targets };
pollData.value = { dataLength: polls.length, data: polls };
})
})
}
}
5 changes: 0 additions & 5 deletions graphics/16x9_2p.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
</div>
</div>

<!-- Sponsor area -->
<div id="sponsor-container">
<img id="sponsor-img" />
</div>

<!-- Timer -->
<div id="timer"></div>
</body>
Expand Down
5 changes: 0 additions & 5 deletions graphics/4x3_2p.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
</div>
</div>

<!-- Sponsor area -->
<div id="sponsor-container">
<img id="sponsor-img" />
</div>

<!-- Timer -->
<div id="timer"></div>
</body>
Expand Down
5 changes: 0 additions & 5 deletions graphics/4x3_4p.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@
</div>
</div>

<!-- Sponsor area -->
<div id="sponsor-container">
<img id="sponsor-img" />
</div>

<!-- Timer -->
<div id="timer"></div>
</body>
Expand Down
5 changes: 0 additions & 5 deletions graphics/DS.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
</div>
</div>

<!-- Sponsor area -->
<div id="sponsor-container">
<img id="sponsor-img" />
</div>

<!-- Timer -->
<div id="timer"></div>
</body>
Expand Down
5 changes: 0 additions & 5 deletions graphics/GB.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
</div>
</div>

<!-- Sponsor area -->
<div id="sponsor-container">
<img id="sponsor-img" />
</div>

<!-- Timer -->
<div id="timer"></div>
</body>
Expand Down
72 changes: 72 additions & 0 deletions graphics/Interview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<!-- CSS -->
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/interview.css" />
<style>
body {
background: url('img/layouts/Interview.png') no-repeat;
}
</style>

<!-- JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="js/layouts/game-layout.js"></script>
<script src="js/utils.js"></script>
<script src="js/timer.js"></script>
<script src="js/medals.js"></script>
<script src="js/sponsors.js"></script>
</head>
<body>

<!-- Runner details -->
<div class="runner-container" id="runner-container1">
<div class="runner-name" id="runner-name1"></div>
<div class="medals" id="medals1">
<img class="medals-img" id="medals1-img" />
</div>
<div class="pronouns" id="pronouns1"></div>
</div>
<div class="runner-container" id="runner-container2">
<div class="runner-name" id="runner-name2"></div>
<div class="medals" id="medals2">
<img class="medals-img" id="medals2-img" />
</div>
<div class="pronouns" id="pronouns2"></div>
</div>
<div class="runner-container" id="runner-container3">
<div class="runner-name" id="runner-name3"></div>
<div class="medals" id="medals3">
<img class="medals-img" id="medals3-img" />
</div>
<div class="pronouns" id="pronouns3"></div>
</div>
<div class="runner-container" id="runner-container4">
<div class="runner-name" id="runner-name4"></div>
<div class="medals" id="medals4">
<img class="medals-img" id="medals4-img" />
</div>
<div class="pronouns" id="pronouns4"></div>
</div>

<!-- Game details -->
<div id="game-name"></div>

<!-- Game info -->
<div id="info-container">
<div id="category"></div>
<div id="estimate-container">
<div id="estimate-label">
<img src="img/common/timer.svg" />
</div>
<div id="estimate"></div>
</div>
</div>

<!-- Timer -->
<div id="timer"></div>
</body>
</html>
4 changes: 2 additions & 2 deletions graphics/Omnibar.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
<body>
<div id="omnibar">
<div id="charity-logo" class="omnibar-item">
<img src="img/logos/Charity_Logo_White.png" />
<img id="charity-logo-img" src="" />
</div>
<div id="donation-total" class="omnibar-item">
<span id="donation-total-text"></span>
</div>
<div id="omnibar-content" class="omnibar-item"></div>
<div id="marathon-logo" class="omnibar-item">
<img src="img/logos/HiG_Logo.png" />
<img id="marathon-logo-img"src="" />
</div>
</div>
</body>
Expand Down
22 changes: 11 additions & 11 deletions graphics/css/16x9_1p.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Runner and pronouns panel. */
#runner-container1 {
width: 392px;
width: 398px;
height: 63px;
line-height: 63px;
left: 16px;
left: 14px;
top: 304px;

padding-left: 15px;
Expand All @@ -18,8 +18,8 @@
/* Game name panel. */
#game-name {
width: 876px;
height: 84px;
line-height: 84px;
height: 86px;
line-height: 86px;
left: 999px;
top: 834px;

Expand All @@ -42,19 +42,19 @@
/* Timer panel. */
#timer {
width: 524px;
height: 117px;
line-height: 117px;
left: 459px;
top: 846px;
height: 118px;
line-height: 118px;
left: 460px;
top: 849px;
}

/* Sponsor panel. */
#sponsor-container {
width: 456px;
height: 622px;
line-height: 622px;
height: 624px;
line-height: 624px;
left: 0px;
top: 372px;
top: 371px;
}

/* Sponsor image max size. */
Expand Down
Loading

0 comments on commit 3eeb351

Please sign in to comment.