Skip to content

Commit

Permalink
Added global data submission, removed cards with flavornames
Browse files Browse the repository at this point in the history
  • Loading branch information
suitangi committed May 9, 2023
1 parent 1605ae2 commit 78e0cbf
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cardList.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
</ul>
<div id="seeCard" style="display:none;"><span class="material-symbols-outlined">forward</span></div>
</div>
<div id="dailyDataDummy" style="display:none;"><div>
</body>

</html>
47 changes: 46 additions & 1 deletion scripts/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const canVibrate = window.navigator.vibrate;
const befuddleAppVersion = "2023.5.6";

//Helper: Get Query
function getParameterByName(name, url) {
Expand Down Expand Up @@ -284,6 +285,10 @@ function submitLetter(char) {
if (window.game.mode == 'free') {
gameLostFree();
} else if (window.game.mode == 'daily') {
if (!window.gameSesh.submitted) {
window.gameSesh.submitted = true;
submitDailyData('x');
}
gameLostDaily();
}
}
Expand Down Expand Up @@ -316,6 +321,10 @@ function submitLetter(char) {
if (window.game.mode == 'free') {
gameWinFree();
} else if (window.game.mode == 'daily') {
if (!window.gameSesh.submitted) {
window.gameSesh.submitted = true;
submitDailyData(window.gameSesh.wrongGuess.length);
}
gameWinDaily();
}
}
Expand Down Expand Up @@ -1109,6 +1118,10 @@ function menuModal() {
document.getElementById('seeCard').style = '';
if (window.game.mode == 'daily') {
window.gameSesh.giveUp = true;
if (!window.gameSesh.submitted) {
window.gameSesh.submitted = true;
submitDailyData('x');
}
gameLostDaily();
} else if (window.game.mode == 'free')
gameLostFree();
Expand Down Expand Up @@ -1949,9 +1962,40 @@ function checkTabFocused() {
}
}

//Submits daily data
function submitDailyData(win) {
const uri = "https://docs.google.com/forms/u/0/d/e/1FAIpQLSf8M4zoBjF6ZcY0v4ebBXmBCKr0vpB_EtAZLPE2-B0ZDfGBLg/formResponse";
const entryNames = ['entry.1034508364', 'entry.462826655', 'entry.2082961611'];
const values = [window.gameSesh.doy % 1000, window.gameSesh.guesses, win];

let tmpinput;
let ddFrame = document.createElement('iframe');
ddFrame.setAttribute('name', 'dummydailyframe');
ddFrame.setAttribute('id', 'dummydailyframe');
ddFrame.style = "display: none;";
let form = document.createElement('form');
form.setAttribute('id', 'dailyForm');
form.setAttribute('action', uri);
form.setAttribute('target', 'dummydailyframe');
form.setAttribute('method', 'post');
entryNames.forEach((en, i) => {
tmpinput = document.createElement('input');
tmpinput.setAttribute('type', 'hidden');
tmpinput.setAttribute('value', values[i]);
tmpinput.setAttribute('name', en);
form.appendChild(tmpinput);
});
document.getElementById('dailyDataDummy').appendChild(ddFrame);
document.getElementById('dailyDataDummy').appendChild(form);
form.submit();
setTimeout(() => {
document.getElementById('dailyDataDummy').innerHTML = '';
}, 2000);
}

//start script
$(document).ready(function() {

console.log('Befuddle version: ' + befuddleAppVersion);
console.log('https://tinyurl.com/specialcardforbefuddle');

window.displayKeyboard = {};
Expand All @@ -1975,6 +2019,7 @@ $(document).ready(function() {

window.gameSesh = {};
window.gameSesh.end = true;
window.gameSesh.submitted = false;

window.stats = {};
window.stats.daily = {};
Expand Down

0 comments on commit 78e0cbf

Please sign in to comment.