Skip to content

Commit

Permalink
Merge pull request #40 from tybayn/feature/Translation-Framework
Browse files Browse the repository at this point in the history
Version 8, new framework that is compatible with localization, variou…
  • Loading branch information
tybayn authored Dec 30, 2024
2 parents 67bc90a + 986ca88 commit 0bc3f28
Show file tree
Hide file tree
Showing 47 changed files with 4,612 additions and 2,379 deletions.
2 changes: 1 addition & 1 deletion backup-data/ghosts_backup.json

Large diffs are not rendered by default.

68 changes: 0 additions & 68 deletions discord-v7/discord-v1.js

This file was deleted.

File renamed without changes.
65 changes: 65 additions & 0 deletions discord-v8/discord-v1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

let discord_user = {}

function getLink(){
try{
znid = getCookie("znid")

discord_user = JSON.parse(getCookie("discord_link"))
document.getElementById("discord_avatar").src = `https://cdn.discordapp.com/avatars/${discord_user['id']}/${discord_user['avatar']}`
$("#discord_avatar").addClass("avatar")
document.getElementById("discord_name").innerText = discord_user['username']
document.getElementById("discord_link_date").innerText = `${lang_data['{{discord_link_h2}}']} ${discord_user['last_linked']}`
$("#discord_link_date").removeClass("hidden")
$("#discord_instructions").removeClass("hidden")
document.getElementById("discord_note").innerText = "You have successfully linked your Discord account! In order for your stats to be most accurate, be sure to select the correct number of evidences and mark the correct ghost before hitting 'Save & Reset'"
document.getElementById("discord_login_button").innerText = lang_data['{{discord_link_b3}}']
$("#discord_unlink_button").removeClass("hidden")
document.getElementById("reset").innerHTML = `${lang_data['{{save_and_reset}}']}<div class='reset_note'>(${lang_data['{{right_click_for_more}}']})</div>`
fetch(`https://zero-network.net/zn/${znid}/${discord_user['id']}`, {signal: AbortSignal.timeout(6000)})
.then(data => data.json())
.then(data => {
var stats_info = `<strong>${lang_data['{{discord_link_h3}}']}</strong>: ${data.total_games}<hr><div style="display:grid; grid-template-columns: 60%;">`

stats_info += `<div class="discord-entry">${lang_data['{{amateur}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['3A'] || '0' : '0'}</span></div>`
stats_info += `<div class="discord-entry">${lang_data['{{intermediate}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['3I'] || '0' : '0'}</span></div>`
stats_info += `<div class="discord-entry">${lang_data['{{professional}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['3'] || '0' : '0'}</span></div>`
stats_info += `<div class="discord-entry">${lang_data['{{nightmare}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['2'] || '0' : '0'}</span></div>`
stats_info += `<div class="discord-entry">${lang_data['{{insanity}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['1'] || '0' : '0'}</span></div>`
stats_info += `<div class="discord-entry">${lang_data['{{apocalypse_iii}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['0'] || '0' : '0'}</span></div>`
stats_info += `<div class="discord-entry">${lang_data['{{custom}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['-1'] || '0' : '0'}</span></div>`
stats_info += `<div class="discord-entry">${lang_data['{{weekly_challenge}}']}: <span class="discord-num" style="float:right;">${data.hasOwnProperty('game_evidence') ? data['game_evidence']['-5'] || '0' : '0'}</span></div>`


stats_info += `</div><br><strong>${lang_data['{{discord_link_h4}}']}</strong><hr><div style="display:grid; grid-template-columns: 50% 50%;">`
for (const g in data['ghost_stats']){
stats_info += `<div class="discord-entry" style="${g == 'Unknown'?'color:#555;':''}">${all_ghosts[g]}: <span class="discord-num" style="float:right;">${data['ghost_stats'][g]}</span></div>`
}
stats_info += '</div>'

document.getElementById("discord_stats").innerHTML = stats_info
document.getElementById("discord-stats-link").href = `https://zero-network.net/phasmo-stats/?discord-id=${discord_user['id']}-${discord_user['avatar']}&username=${discord_user['username']}`
document.getElementById("discord_link_status").className = "connected"
})

} catch(Error){

}
}

function applyPerms(){
return new Promise((resolve, reject) => {
if(Object.keys(discord_user).length > 0){
$('.card_icon_guess').show()
$('.card_icon_died').show()
$('.discord_voice_commands').show()
}
resolve("Discord Link Permissions Applied")
})
}

function discord_unlink(){
discord_user = {}
setCookie("discord_link",JSON.stringify(discord_link),-1)
window.location.href = window.location.href.split("?")[0]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0bc3f28

Please sign in to comment.