Skip to content

Commit

Permalink
feat: Added lightlevel, and bungie code
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimple committed Mar 17, 2022
1 parent fc9733c commit e938500
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions src/scripts/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ function setLastPlayedCharacter(lastPlayed) {
let lastPlayedCharacter = document.createElement("div");
lastPlayedCharacter.classList.add("hud");
lastPlayedCharacter.classList.add("translucent");
lastPlayedCharacter.innerText =
destinyApiClient.profile.profile.data.userInfo.displayName;
lastPlayedCharacter.innerText = `${destinyApiClient.profile.profile.data.userInfo.bungieGlobalDisplayName}#${destinyApiClient.profile.profile.data.userInfo.bungieGlobalDisplayNameCode} (${lastPlayed.light})`;

lastPlayedCharacter.style = `
background-image: url("https://www.bungie.net${lastPlayed.emblemBackgroundPath}");
Expand All @@ -54,17 +53,19 @@ function setLastPlayedCharacter(lastPlayed) {
font-size: 24px;
`;

tempGoalContainer.appendChild(lastPlayedCharacter);

let lastPlayedClass = document.createElement("div");
lastPlayedClass.classList.add("hud");
lastPlayedClass.classList.add("sub-header");
lastPlayedClass.innerHTML = `${lastPlayed.genderName} ${lastPlayed.raceName} ${lastPlayed.className}<br />Played ${formatTimespan(
lastPlayedClass.innerHTML = `${lastPlayed.genderName} ${
lastPlayed.raceName
} ${lastPlayed.className}, Played ${formatTimespan(
new Date(),
new Date(Date.now() + lastPlayed.minutesPlayedTotal * 60 * 1000)
)}`;

tempGoalContainer.appendChild(lastPlayedClass);
lastPlayedCharacter.appendChild(lastPlayedClass);

tempGoalContainer.appendChild(lastPlayedCharacter);
}

eventEmitter.addEventListener("destiny-data-loaded", async function () {
Expand Down Expand Up @@ -122,7 +123,7 @@ async function renderSubPresentationNode(presentationNode, namedObject, depth) {
for (let childNode of presentationNode.children.presentationNodes) {
let subNode =
destinyApiClient.destinyDataDefinition
.DestinyPresentationNodeDefinition[childNode.presentationNodeHash];
.DestinyPresentationNodeDefinition[childNode.presentationNodeHash];

let goal = document.createElement("div");
goal.classList.add("hud");
Expand Down Expand Up @@ -286,7 +287,8 @@ eventEmitter.addEventListener("destiny-not-authed", function () {
document.querySelector("#authenticateWithBungie").style.display = "";
document.querySelector("#logoutFromBungie").style.display = "none";

document.querySelector("#allGoals").innerHTML = "<h1>Authenticate with Bungie to see your latest played character</h1>";
document.querySelector("#allGoals").innerHTML =
"<h1>Authenticate with Bungie to see your latest played character</h1>";
});

eventEmitter.addEventListener(
Expand Down Expand Up @@ -318,31 +320,31 @@ async function loadSettings() {
);

document.getElementById("trackSeasonRank").checked = JSON.parse(
((await db.getItem("d2-track-seasonrank")) ?? "true").toString()
) ?
"checked" :
"";
((await db.getItem("d2-track-seasonrank")) ?? "true").toString()
)
? "checked"
: "";

document.getElementById("trackMilestones").checked = JSON.parse(
((await db.getItem("d2-track-milestones")) ?? "true").toString()
) ?
"checked" :
"";
((await db.getItem("d2-track-milestones")) ?? "true").toString()
)
? "checked"
: "";
document.getElementById("trackBounties").checked = JSON.parse(
((await db.getItem("d2-track-bounties")) ?? "true").toString()
) ?
"checked" :
"";
((await db.getItem("d2-track-bounties")) ?? "true").toString()
)
? "checked"
: "";
document.getElementById("trackQuests").checked = JSON.parse(
((await db.getItem("d2-track-quests")) ?? "true").toString()
) ?
"checked" :
"";
((await db.getItem("d2-track-quests")) ?? "true").toString()
)
? "checked"
: "";
document.getElementById("trackRecords").checked = JSON.parse(
((await db.getItem("d2-track-records")) ?? "true").toString()
) ?
"checked" :
"";
((await db.getItem("d2-track-records")) ?? "true").toString()
)
? "checked"
: "";
}

function downloadUpdate() {
Expand Down Expand Up @@ -494,12 +496,14 @@ function bindExitButtonEvent(window) {
setTimeout(async function () {
let hasAuthed = await destinyApiClient.isAuthenticated();
if (hasAuthed) {
document.querySelector("#authenticateWithBungie").style.display = "none";
document.querySelector("#authenticateWithBungie").style.display =
"none";
document.querySelector("#logoutFromBungie").style.display = "";
} else {
document.querySelector("#authenticateWithBungie").style.display = "";
document.querySelector("#logoutFromBungie").style.display = "none";
document.querySelector("#allGoals").innerHTML = "<h1>Authenticate with Bungie to see your latest played character</h1>";
document.querySelector("#allGoals").innerHTML =
"<h1>Authenticate with Bungie to see your latest played character and other stats</h1>";
}

let namedObject = await destinyApiClient.getNamedDataObject(false);
Expand All @@ -508,4 +512,4 @@ function bindExitButtonEvent(window) {
});

localStorage.setItem("mainWindow_opened", true);
})();
})();

0 comments on commit e938500

Please sign in to comment.