Skip to content
Permalink
Browse files

show rewards time left

  • Loading branch information...
Manuel-777 committed Feb 14, 2019
1 parent 9b01d7a commit dd97cd5de4c95d2ea5a0e8714d32d853e13505d4
Showing with 45 additions and 1 deletion.
  1. +9 −1 window_background/background.js
  2. +7 −0 window_background/labels.js
  3. +23 −0 window_main/home.js
  4. +6 −0 window_main/renderer.js
@@ -25,7 +25,8 @@ global
onLabelOutDraftMakePick,
onLabelInEventCompleteDraft,
onLabelMatchGameRoomStateChangedEvent,
onLabelInEventGetSeasonAndRankDetail
onLabelInEventGetSeasonAndRankDetail,
onLabelGetPlayerInventoryGetRewardSchedule
*/
var electron = require('electron');

@@ -998,6 +999,13 @@ function onLogEntryFound(entry) {
}
break;

case "PlayerInventory.GetRewardSchedule":
if (entry.arrow == "<==") {
json = entry.json();
onLabelGetPlayerInventoryGetRewardSchedule(entry, json);
}
break;

default:
break;
}
@@ -1002,3 +1002,10 @@ function onLabelInEventGetSeasonAndRankDetail(entry, json) {
ipc_send("set_season", {starts: season_starts, ends: season_ends});
updateRank();
}


function onLabelGetPlayerInventoryGetRewardSchedule(entry, json) {
if (!json) return;

ipc_send("set_reward_resets", {daily: json.dailyReset, weekly: json.weeklyReset});
}
@@ -29,6 +29,8 @@ let listInterval = [];
let touStates = {};
let topWildcards = null;

let homeInterval = null;

// Should separate these two into smaller functions
function open_home_tab(arg, opentab = true) {
let mainDiv = document.getElementById("ux_0");
@@ -51,7 +53,28 @@ function open_home_tab(arg, opentab = true) {
users.setAttribute("tooltip-content", "In the last 24 hours.");
users.setAttribute("tooltip-bottom", "");
users.style.textAlign = "center";

let daily = createDivision(["text_centered", "white", "daily_left"], "Daily rewards end: -");
daily.style.textAlign = "center";

let weekly = createDivision(["text_centered", "white", "weekly_left"], "Weekly rewards end: -");
weekly.style.textAlign = "center";

if (homeInterval !== null) clearInterval(homeInterval);

homeInterval = window.setInterval(() => {
let dd = new Date(rewards_daily_ends);
let timeleft = (dd.getTime() / 1000) - timestamp();
$('.daily_left').html("Daily rewards end: "+toHHMMSS(timeleft));

dd = new Date(rewards_weekly_ends);
timeleft = (dd.getTime() / 1000) - timestamp();
$('.weekly_left').html("Weekly rewards end: "+toHHMMSS(timeleft));
}, 250);

mainDiv.appendChild(users);
mainDiv.appendChild(daily);
mainDiv.appendChild(weekly);
}

let d = createDivision(["list_fill"]);
@@ -94,6 +94,8 @@ let economyHistory = [];

let season_starts = new Date();
let season_ends = new Date();
let rewards_daily_ends = new Date();
let rewards_weekly_ends = new Date();

let deck_tags = {};
let tags_colors = {};
@@ -244,6 +246,10 @@ ipc.on('set_season', function (event, arg) {
season_ends = arg.ends;
});

ipc.on('set_reward_resets', function (event, arg) {
rewards_daily_ends = new Date(arg.daily);
rewards_weekly_ends = new Date(arg.weekly);
});

//
ipc.on('set_decks', function (event, arg) {

0 comments on commit dd97cd5

Please sign in to comment.
You can’t perform that action at this time.