Skip to content

Commit

Permalink
Added cookies & STREAKSgit add .! :D
Browse files Browse the repository at this point in the history
  • Loading branch information
sam committed Mar 4, 2023
1 parent 75faaba commit 68723d9
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 25 deletions.
Binary file removed images/.certified_trapper.png.icloud
Binary file not shown.
Binary file removed images/.fax_females.png.icloud
Binary file not shown.
Binary file removed images/.ohio_block.png.icloud
Binary file not shown.
Binary file added images/certified_trapper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fax_females.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ohio_block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<p class="btn-text" id="final-2">Backwords: 001</p>
<p class="btn-text" id="final-3">01 Attempts 🟨🟨🟨🟨b</p>
<p class="btn-text" id="final-4">2/3 Hints 🟨🟨🟨</p>
<p class="btn-text">#Backwords</p>
<p class="btn-text" id="final-5">1 Day Streak 🐢</p>
<textarea id="plswork">www</textarea>
<button id="share-button" onclick="copyFunction()">Copy<i class="fa-light fa-share-nodes"></i></button>
<a id="tweet-balls" href="#" onclick="f1(); return false;"><button id="share-button-tweet" onclick="copyFunction()">Tweet<i class="fa-light fa-share-nodes"></i></button></a>
Expand Down
136 changes: 112 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ sharing = document.getElementById("score");
var daysUntilJanuaryFirst = daysBetween(currentDate, januaryFirst);
var dayN = daysUntilJanuaryFirst * -1;
text = readTextFile("words/phrases.txt");
document.getElementById("popup-1").classList.toggle("active")
document.getElementById("share-1").classList.toggle("unactive")
var lines = text.split("\n");
realPhrase = lines[dayN - 1];
Expand Down Expand Up @@ -40,30 +39,55 @@ var orderArray1 = orderFile1.split("\n");

var orderArray2 = orderFile2.split("\n");

// //var streakCookie = getCookie("streak");
// //if(streakCookie == null){
// document.cookie = "streak=0";
// }; f


//var solved = getCookie("hasGotten");
if(getCookie("streak") == null){
document.cookie = "streak=0;";
};

// if(solved == true)
// {
// //counter = getCookie("guesses");
// toggleshare;
// }
if(getCookie("hasGotten") == false || getCookie("hasGotten") == null){
document.cookie = "guesses=0;";
document.cookie = "hasGotten=false;"
}

//var dayCookie = getCookie("currentDay");

// if(dayCookie == null || dayCookie !=dayN){
// document.cookie("guesses=0")
// document.cookie("hasGotten=false")
// docuement.cookie(`currentDay=${dayN}`)
// console.log("it works?")
// }
function getCookie(name){
const cDecoded = decodeURIComponent(document.cookie);
const cArray = cDecoded.split("; ")
let result = null;

cArray.forEach(element => {
if(element.indexOf(name) == 0){
result = element.substring(name.length+1)
}
})
return result;
}




if(getCookie("hasGotten") == "true"){
counter = parseInt(getCookie("guesses")) -1;
toggleshare();
} else {
document.getElementById("popup-1").classList.toggle("active")
}


if(getCookie("currentDay") == null || getCookie("currentDay") == (dayN -1 )){
document.cookie = "guesses=0;";
document.cookie = "hasGotten=false;";
document.cookie = `currentDay=${dayN};`;
}

if(getCookie("currentDay") == null || getCookie("currentDay") <= (dayN -2 )){
document.cookie = "guesses=0;";
document.cookie = "hasGotten=false;";
document.cookie = `currentDay=${dayN};`;
document.cookie = 'streak=0;';
}

function generateOrder(distances) {
return Object.keys(distances).sort((a, b) => distances[a] - distances[b]);
}
Expand Down Expand Up @@ -330,11 +354,14 @@ if(number2 > 1000 || number2 == -1){

if (number1 == 0 && number2 == 0)
{
if(getCookie("hasGotten") != "true" || getCookie("hasGotten") == null){
streakN = parseInt(getCookie("streak"));
streakN++
console.log(streakN)
console.log("balls")
document.cookie = `streak=${streakN};`;
}
toggleshare();
//docuement.cookies("hasGotten=true")
//streakN = docuement.getCookie("streak")
// streakN++
//docuement.cookie(`streak=${streakN}`)
}
verbal_hint1 = generateVerbalHint(
wordOne,
Expand All @@ -352,7 +379,8 @@ if(number2 > 1000 || number2 == -1){
score = document.getElementById("score");
getScore(wordOne + wordTwo, realPhrase, counter);
counter++;
localStorage.setItem('guesses', counter)

document.cookie = `guesses=${counter};`;
};


Expand Down Expand Up @@ -412,6 +440,7 @@ function togglePopup() {
}

function toggleshare() {
document.cookie = 'hasGotten=true;';
document.getElementById("share-1").classList.toggle("active");
document.getElementById("final-1").innerHTML=("The real phrase was: " + realPhrase)
document.getElementById("final-2").innerHTML=("Backwords 0" + dayN)
Expand Down Expand Up @@ -471,6 +500,37 @@ function toggleshare() {
{
document.getElementById("final-4").innerHTML=("3/3 Hints ⬛⬛⬛ ")
}
let streakTxt = ""
if(getCookie("streak") == "1"){
streakTxt = "1 Day Streak 🤢"
} else if (getCookie("streak") == "2"){
streakTxt = "2 Day Streak 🤢🐢"
} else if (getCookie("streak") == "3"){
streakTxt = "3 Day Streak 🤢🐢🍏"
}else if (getCookie("streak") == "4"){
streakTxt = "4 Day Streak 🤢🐢🍏📗"
}else if (getCookie("streak") == "5"){
streakTxt = "5 Day Streak 🤢🐢🍏📗✅"
}else if (getCookie("streak") == "6"){
streakTxt = "6 Day Streak ⭐🐢🍏📗✅"
}else if (getCookie("streak") == "7"){
streakTxt = "7 Day Streak ⭐⭐🍏📗✅"
}else if (getCookie("streak") == "8"){
streakTxt = "8 Day Streak ⭐⭐🌟📗✅"
}else if (getCookie("streak") == "9"){
streakTxt = "9 Day Streak ⭐⭐🌟🌟✅"
}else if (getCookie("streak") == "10"){
streakTxt = "10 Day Streak ⭐⭐🌟🌟💫"
}else if (getCookie("streak") == "100"){
streakTxt = "100 Day Streak 💯💯💯💯💯"
} else if (parseInt(getCookie("streak")) > 10 && (parseInt(getCookie("streak"))!= 100)){
streakTxt = `${getCookie("streak")} Day Streak ⭐⭐🌟🌟💫 `
}

document.getElementById("final-5").innerHTML=(streakTxt);



copyFunction();

}
Expand All @@ -492,6 +552,33 @@ function copyFunction(){
hintTxt = "3/3 Hints ⬛⬛⬛ "
}

let streakTxt = ""
if(getCookie("streak") == "1"){
streakTxt = "1 Day Streak 🤢"
} else if (getCookie("streak") == "2"){
streakTxt = "2 Day Streak 🤢🐢"
} else if (getCookie("streak") == "3"){
streakTxt = "3 Day Streak 🤢🐢🍏"
}else if (getCookie("streak") == "4"){
streakTxt = "4 Day Streak 🤢🐢🍏📗"
}else if (getCookie("streak") == "5"){
streakTxt = "5 Day Streak 🤢🐢🍏📗✅"
}else if (getCookie("streak") == "6"){
streakTxt = "6 Day Streak ⭐🐢🍏📗✅"
}else if (getCookie("streak") == "7"){
streakTxt = "7 Day Streak ⭐⭐🍏📗✅"
}else if (getCookie("streak") == "8"){
streakTxt = "8 Day Streak ⭐⭐🌟📗✅"
}else if (getCookie("streak") == "9"){
streakTxt = "9 Day Streak ⭐⭐🌟🌟✅"
}else if (getCookie("streak") == "10"){
streakTxt = "10 Day Streak ⭐⭐🌟🌟💫"
}else if (getCookie("streak") == "100"){
streakTxt = "100 Day Streak 💯💯💯💯💯"
} else if (parseInt(getCookie("streak")) > 10 && (parseInt(getCookie("streak"))!= 100)){
streakTxt = `${getCookie("streak")} Day Streak ⭐⭐🌟🌟💫 `
}

let attemptEmojis = ""
let yellow_number = 0
yellow_number = (long_johnson/(counter+1))*5 +1
Expand Down Expand Up @@ -522,7 +609,7 @@ function copyFunction(){
`Backwords 0${dayN}
${counter} Attempts ${attemptEmojis}
${hintTxt}
#backwords
${streakTxt}
backwords.xyz`
document.getElementById("plswork").value = copyString;
inputElement.value = copyString;
Expand All @@ -537,6 +624,7 @@ document.getElementById("plswork").value = copyString;
`Backwords 0${dayN}%0A
${counter} Attempts ${attemptEmojis}%0A
${hintTxt}%0A
${streakTxt}%0A
backwords.xyz%0A`
const link = `https://twitter.com/intent/tweet?text=${twitterString}&hashtags=backwords`;
document.getElementById("tweet-balls").href=link;
Expand Down

0 comments on commit 68723d9

Please sign in to comment.