Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // lock out "Weekly checker"
- var todayStamp =new Date();
- var today = todayStamp.getDay();
- var sinceYesterday = 0;
- var now = todayStamp.getHours();
- var resetTime = new Date();
- var offset = new Date().getTimezoneOffset();
- offset=offset/60;
- if (region == "us")
- {
- resetTime.setHours(15-offset,0,0,0);
- }
- else
- {
- resetTime.setHours(7-offset,0,0,0);
- }
- sinceYesterday = resetTime.getTime();
- //attempt to fix post-midnight pre-reset
- if (now < 15-offset && now > -1 && region == "us") //if it's after midnight but before 11am
- {
- sinceYesterday-=86400000;
- }
- if (now < 7-offset && now > -1 && region == "eu") //if it's after midnight but before 7am
- {
- sinceYesterday-=86400000;
- }
- // now we have to figure out how long it's been since tuesday
- var sinceTuesday =new Date();
- var reset = region == "eu" ? 3 : 2; // 2 for tuesday, 3 for wednesday
- var midnight = new Date();
- midnight.setHours(0,0,0,0);
- sinceTuesday = resetTime*1;
- if (today == reset) //it IS tuesday!
- {
- //attempt to fix post-midnight pre-reset
- if ((now < 7-offset && now > -1 && region == "eu") || (now < 15-offset && now > -1 && region == "us")) //if it's after midnight but before 7am
- {
- sinceTuesday-=(86400000*7);
- }
- }
- if (today > reset)
- {
- // wednesday (thurs eu) - saturday
- sinceTuesday = sinceTuesday-(today-reset)*86400000;
- }
- else if (today < reset)
- {
- // sunday + monday (tues eu)
- sinceTuesday = sinceTuesday-((7+today-reset))*86400000; // this was 6, but to account for EU it was changed to 7-reset to be either 6 or 5 to account for Wednesday resets
- }
- // Raid stat sub-categories
- var CURRENT_XPAC = 7;
- var raidInstancesSortOrder = [];
- var raidDifficultySortOrder = ["Raid Finder", "Normal", "Heroic", "Mythic"];
- for (i = 43; i <= 43; i++) // BfA raids start at 40, increase i <= when more are released
- {
- raidInstancesSortOrder.push(toon.progression.raids[i].name);
- }
- var instanceDetails = { "dungeons":{},"raids":{} };
- for (i in raidInstancesSortOrder)
- {
- instanceDetails.raids[raidInstancesSortOrder[i]] = {};
- }
- var getShortInstanceName = function (inputString)
- {
- var split = inputString.split(" ");
- if (split.length !== 1)
- {
- var retstring = "";
- for (i in split)
- {
- retstring = retstring + split[i].slice(0, 1);
- }
- return retstring;
- }
- else
- {
- return split[0].slice(0,3).toUpperCase();
- }
- };
- var getRaidAndBossName = function(inputString)
- {
- var info = "";
- //attempt to get boss name, raid, and difficulty by splitting based on this string
- if (inputString.indexOf("defeats") !== -1)
- {
- info = inputString.split(" defeats (");
- }
- else if (inputString.indexOf("redemptions") !== -1)
- {
- info = inputString.split(" redemptions (");
- }
- else if (inputString.indexOf("defenses") !== -1)
- {
- info = inputString.split(" defenses (");
- }
- else
- {
- info = inputString.split(" kills (");
- }
- var bossName = info.shift(); // first we get boss name
- info = info[0].split(" ");
- var difficultyName = "";
- var nameForInstance = "";
- if (info[0] === "Raid")
- {
- difficultyName = info.shift() + " " + info.shift(); // Raid Finder
- nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
- }
- else if (info[0] !== "Return")
- {
- difficultyName = info.shift(); // first info is what difficultie we have
- nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
- }
- else // this should only be Return to Karazhan
- {
- difficultyName = "Mythic";
- nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
- }
- return [bossName, nameForInstance, difficultyName];
- };
- for (var instanceNumber in toon.statistics.subCategories[5].subCategories[CURRENT_XPAC].statistics)
- {
- var instanceBoss = toon.statistics.subCategories[5].subCategories[CURRENT_XPAC].statistics[instanceNumber];
- var instanceReturns = getRaidAndBossName(instanceBoss.name);
- var bossName = instanceReturns[0];
- var nameOfInstance = instanceReturns[1];
- var difficultyName = instanceReturns[2];
- var typeOfInstance = "Dungeon";
- for (var raid in raidInstancesSortOrder)// this is needed this as "the" is missing from instances.
- {
- if (raidInstancesSortOrder[raid].indexOf(nameOfInstance) !== -1)
- {
- nameOfInstance = raidInstancesSortOrder[raid];
- typeOfInstance = "Raid";
- }
- }
- var thisInstance = typeOfInstance === "Raid" ? instanceDetails.raids : instanceDetails.dungeons;
- thisInstance[nameOfInstance] = thisInstance[nameOfInstance] || {};
- thisInstance[nameOfInstance][difficultyName] = thisInstance[nameOfInstance][difficultyName] || {};
- thisInstance[nameOfInstance][difficultyName].bosses = thisInstance[nameOfInstance][difficultyName].bosses || {};
- var infoForBoss = { "kills": instanceBoss.quantity };
- if (typeOfInstance === "Dungeon" && difficultyName === "Heroic")
- {
- infoForBoss.lockout = instanceBoss.lastUpdated > sinceYesterday;
- }
- else if (typeOfInstance !== "Dungeon" || difficultyName !== "Normal")// everything except normal dungeons
- {
- infoForBoss.lockout = instanceBoss.lastUpdated > sinceTuesday;
- }
- if (nameOfInstance.indexOf("Violet Hold")===-1)
- {
- thisInstance[nameOfInstance][difficultyName].bosses[bossName] = infoForBoss;
- }
- else
- {
- var oldInfo = thisInstance[nameOfInstance][difficultyName].bosses["Violet Hold End Boss"] || {};
- if (oldInfo.kills)
- {
- infoForBoss.kills += oldInfo.kills;
- infoForBoss.lockout = infoForBoss.lockout || oldInfo.lockout; // since 0 is false and 1 is true this will work.
- }
- thisInstance[nameOfInstance][difficultyName].bosses["Violet Hold End Boss"] = infoForBoss;
- }
- thisInstance[nameOfInstance][difficultyName].kills = thisInstance[nameOfInstance][difficultyName].kills || 0;
- thisInstance[nameOfInstance][difficultyName].kills += instanceBoss.quantity;
- }
- var displayInfo = { "raid": {}, "dungeon": {} };
- for (var instanceType in instanceDetails)
- {
- var instances = instanceDetails[instanceType];
- var infoOnDifficulty = {};
- for (var instanceName in instances)
- {
- var instance = instances[instanceName];
- if (instanceType === "raids") // for dungeons we take lockout for all instances, for raid we do it for each instance.
- {
- infoOnDifficulty = {};
- }
- for (var difficulty in instance)
- {
- infoOnDifficulty[difficulty] = infoOnDifficulty[difficulty] || {
- "activeWeeks":0, "lockout":0, "instanceLength": 0, "progress": 0, "kills": 0
- };
- var thisDifficulty = infoOnDifficulty[difficulty];
- var bosses = instance[difficulty].bosses;
- for (var boss in bosses)
- {
- var bossInfo = bosses[boss];
- thisDifficulty.activeWeeks = Math.max(thisDifficulty.activeWeeks, bossInfo.kills);
- thisDifficulty.instanceLength++;
- thisDifficulty.kills += bossInfo.kills;
- thisDifficulty.progress += bossInfo.kills === 0 ? 0 : 1;
- thisDifficulty.lockout += bossInfo.lockout ? 1 : 0;
- if (instanceType === "dungeons" && difficulty === "Mythic" && bossInfo.lockout)
- {
- thisDifficulty.details = thisDifficulty.details ? thisDifficulty.details + ", " + getShortInstanceName(instanceName) : getShortInstanceName(instanceName);
- }
- }
- // really didn't want to do it this way, but... Daz needs special code to deal with alliance/horde having different entries in stats
- if (instanceName == "Battle of Dazar'alor")
- {
- thisDifficulty.instanceLength = 9;
- }
- }
- if (instanceType === "raids")
- {
- displayInfo.raid[instanceName] = infoOnDifficulty;
- }
- }
- if (instanceType === "dungeons")
- {
- displayInfo.dungeon = infoOnDifficulty;
- }
- }
- //code for displaying missing mythics instead of completed, needs updating of more mythics are added
- var missingMythics ="Missing: ";
- // remove the undefined if 0 completed, or the "Missing: " if all completed (increment this if more dungeons added)
- if (!displayInfo.dungeon.Mythic.details || displayInfo.dungeon.Mythic.lockout ==10)
- {
- displayInfo.dungeon.Mythic.details = "";
- missingMythics = "";
- }
- else if (listMissing == true)
- {
- var mythicList = ["ATA", "FRE", "KR", "SotS", "SoB", "ToS", "TM", "TU", "TD", "WM"]; //add abbrvs to list if more are added
- for (i=0; i<mythicList.length; i++)
- {
- var n=displayInfo.dungeon.Mythic.details.search(mythicList[i]);
- if (n==-1)
- {
- missingMythics = missingMythics + mythicList[i] + " ";
- }
- }
- displayInfo.dungeon.Mythic.details = missingMythics;
- }
- var worldBosses = [52196, 52163, 52169, 52181, 52157, 52166];
- var worldBossKill = "";
- var warfront = "";
- var islandExpeditions = "";
- for (i=0; i < toon.quests.length; i++)
- {
- if (worldBosses.indexOf(toon.quests[i]) > -1)
- {
- worldBossKill = worldBossKill + "Weekly: \u2713 "; //unicode checkmark
- }
- if (toon.quests[i] == 54895 || toon.quests[i] == 54896)
- {
- worldBossKill = worldBossKill + "Ivus: \u2713 ";
- }
- if (toon.quests[i] == 52847 || toon.quests[i] == 52848)
- {
- worldBossKill = worldBossKill + "DH: \u2713 ";
- }
- if (toon.quests[i] == 53414 || toon.quests[i] == 53416)
- {
- warfront = warfront + "Stormgarde: \u2713 ";
- }
- if (toon.quests[i] == 53955 || toon.quests[i] == 53992)
- {
- warfront = warfront + "Darkshore: \u2713 ";
- }
- if (toon.quests[i] == 53435 || toon.quests[i] == 53436)
- {
- islandExpeditions = "\u2713 ";
- }
- }
- RAW Paste Data
- // lock out "Weekly checker"
- var todayStamp =new Date();
- var today = todayStamp.getDay();
- var sinceYesterday = 0;
- var now = todayStamp.getHours();
- var resetTime = new Date();
- var offset = new Date().getTimezoneOffset();
- offset=offset/60;
- if (region == "us")
- {
- resetTime.setHours(15-offset,0,0,0);
- }
- else
- {
- resetTime.setHours(7-offset,0,0,0);
- }
- sinceYesterday = resetTime.getTime();
- //attempt to fix post-midnight pre-reset
- if (now < 15-offset && now > -1 && region == "us") //if it's after midnight but before 11am
- {
- sinceYesterday-=86400000;
- }
- if (now < 7-offset && now > -1 && region == "eu") //if it's after midnight but before 7am
- {
- sinceYesterday-=86400000;
- }
- // now we have to figure out how long it's been since tuesday
- var sinceTuesday =new Date();
- var reset = region == "eu" ? 3 : 2; // 2 for tuesday, 3 for wednesday
- var midnight = new Date();
- midnight.setHours(0,0,0,0);
- sinceTuesday = resetTime*1;
- if (today == reset) //it IS tuesday!
- {
- //attempt to fix post-midnight pre-reset
- if ((now < 7-offset && now > -1 && region == "eu") || (now < 15-offset && now > -1 && region == "us")) //if it's after midnight but before 7am
- {
- sinceTuesday-=(86400000*7);
- }
- }
- if (today > reset)
- {
- // wednesday (thurs eu) - saturday
- sinceTuesday = sinceTuesday-(today-reset)*86400000;
- }
- else if (today < reset)
- {
- // sunday + monday (tues eu)
- sinceTuesday = sinceTuesday-((7+today-reset))*86400000; // this was 6, but to account for EU it was changed to 7-reset to be either 6 or 5 to account for Wednesday resets
- }
- // Raid stat sub-categories
- var CURRENT_XPAC = 7;
- var raidInstancesSortOrder = [];
- var raidDifficultySortOrder = ["Raid Finder", "Normal", "Heroic", "Mythic"];
- for (i = 43; i <= 43; i++) // BfA raids start at 40, increase i <= when more are released
- {
- raidInstancesSortOrder.push(toon.progression.raids[i].name);
- }
- var instanceDetails = { "dungeons":{},"raids":{} };
- for (i in raidInstancesSortOrder)
- {
- instanceDetails.raids[raidInstancesSortOrder[i]] = {};
- }
- var getShortInstanceName = function (inputString)
- {
- var split = inputString.split(" ");
- if (split.length !== 1)
- {
- var retstring = "";
- for (i in split)
- {
- retstring = retstring + split[i].slice(0, 1);
- }
- return retstring;
- }
- else
- {
- return split[0].slice(0,3).toUpperCase();
- }
- };
- var getRaidAndBossName = function(inputString)
- {
- var info = "";
- //attempt to get boss name, raid, and difficulty by splitting based on this string
- if (inputString.indexOf("defeats") !== -1)
- {
- info = inputString.split(" defeats (");
- }
- else if (inputString.indexOf("redemptions") !== -1)
- {
- info = inputString.split(" redemptions (");
- }
- else if (inputString.indexOf("defenses") !== -1)
- {
- info = inputString.split(" defenses (");
- }
- else
- {
- info = inputString.split(" kills (");
- }
- var bossName = info.shift(); // first we get boss name
- info = info[0].split(" ");
- var difficultyName = "";
- var nameForInstance = "";
- if (info[0] === "Raid")
- {
- difficultyName = info.shift() + " " + info.shift(); // Raid Finder
- nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
- }
- else if (info[0] !== "Return")
- {
- difficultyName = info.shift(); // first info is what difficultie we have
- nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
- }
- else // this should only be Return to Karazhan
- {
- difficultyName = "Mythic";
- nameForInstance = info.join(" ").slice(0, -1); // rest is the name and we remove the last ")"
- }
- return [bossName, nameForInstance, difficultyName];
- };
- for (var instanceNumber in toon.statistics.subCategories[5].subCategories[CURRENT_XPAC].statistics)
- {
- var instanceBoss = toon.statistics.subCategories[5].subCategories[CURRENT_XPAC].statistics[instanceNumber];
- var instanceReturns = getRaidAndBossName(instanceBoss.name);
- var bossName = instanceReturns[0];
- var nameOfInstance = instanceReturns[1];
- var difficultyName = instanceReturns[2];
- var typeOfInstance = "Dungeon";
- for (var raid in raidInstancesSortOrder)// this is needed this as "the" is missing from instances.
- {
- if (raidInstancesSortOrder[raid].indexOf(nameOfInstance) !== -1)
- {
- nameOfInstance = raidInstancesSortOrder[raid];
- typeOfInstance = "Raid";
- }
- }
- var thisInstance = typeOfInstance === "Raid" ? instanceDetails.raids : instanceDetails.dungeons;
- thisInstance[nameOfInstance] = thisInstance[nameOfInstance] || {};
- thisInstance[nameOfInstance][difficultyName] = thisInstance[nameOfInstance][difficultyName] || {};
- thisInstance[nameOfInstance][difficultyName].bosses = thisInstance[nameOfInstance][difficultyName].bosses || {};
- var infoForBoss = { "kills": instanceBoss.quantity };
- if (typeOfInstance === "Dungeon" && difficultyName === "Heroic")
- {
- infoForBoss.lockout = instanceBoss.lastUpdated > sinceYesterday;
- }
- else if (typeOfInstance !== "Dungeon" || difficultyName !== "Normal")// everything except normal dungeons
- {
- infoForBoss.lockout = instanceBoss.lastUpdated > sinceTuesday;
- }
- if (nameOfInstance.indexOf("Violet Hold")===-1)
- {
- thisInstance[nameOfInstance][difficultyName].bosses[bossName] = infoForBoss;
- }
- else
- {
- var oldInfo = thisInstance[nameOfInstance][difficultyName].bosses["Violet Hold End Boss"] || {};
- if (oldInfo.kills)
- {
- infoForBoss.kills += oldInfo.kills;
- infoForBoss.lockout = infoForBoss.lockout || oldInfo.lockout; // since 0 is false and 1 is true this will work.
- }
- thisInstance[nameOfInstance][difficultyName].bosses["Violet Hold End Boss"] = infoForBoss;
- }
- thisInstance[nameOfInstance][difficultyName].kills = thisInstance[nameOfInstance][difficultyName].kills || 0;
- thisInstance[nameOfInstance][difficultyName].kills += instanceBoss.quantity;
- }
- var displayInfo = { "raid": {}, "dungeon": {} };
- for (var instanceType in instanceDetails)
- {
- var instances = instanceDetails[instanceType];
- var infoOnDifficulty = {};
- for (var instanceName in instances)
- {
- var instance = instances[instanceName];
- if (instanceType === "raids") // for dungeons we take lockout for all instances, for raid we do it for each instance.
- {
- infoOnDifficulty = {};
- }
- for (var difficulty in instance)
- {
- infoOnDifficulty[difficulty] = infoOnDifficulty[difficulty] || {
- "activeWeeks":0, "lockout":0, "instanceLength": 0, "progress": 0, "kills": 0
- };
- var thisDifficulty = infoOnDifficulty[difficulty];
- var bosses = instance[difficulty].bosses;
- for (var boss in bosses)
- {
- var bossInfo = bosses[boss];
- thisDifficulty.activeWeeks = Math.max(thisDifficulty.activeWeeks, bossInfo.kills);
- thisDifficulty.instanceLength++;
- thisDifficulty.kills += bossInfo.kills;
- thisDifficulty.progress += bossInfo.kills === 0 ? 0 : 1;
- thisDifficulty.lockout += bossInfo.lockout ? 1 : 0;
- if (instanceType === "dungeons" && difficulty === "Mythic" && bossInfo.lockout)
- {
- thisDifficulty.details = thisDifficulty.details ? thisDifficulty.details + ", " + getShortInstanceName(instanceName) : getShortInstanceName(instanceName);
- }
- }
- // really didn't want to do it this way, but... Daz needs special code to deal with alliance/horde having different entries in stats
- if (instanceName == "Battle of Dazar'alor")
- {
- thisDifficulty.instanceLength = 9;
- }
- }
- if (instanceType === "raids")
- {
- displayInfo.raid[instanceName] = infoOnDifficulty;
- }
- }
- if (instanceType === "dungeons")
- {
- displayInfo.dungeon = infoOnDifficulty;
- }
- }
- //code for displaying missing mythics instead of completed, needs updating of more mythics are added
- var missingMythics ="Missing: ";
- // remove the undefined if 0 completed, or the "Missing: " if all completed (increment this if more dungeons added)
- if (!displayInfo.dungeon.Mythic.details || displayInfo.dungeon.Mythic.lockout ==10)
- {
- displayInfo.dungeon.Mythic.details = "";
- missingMythics = "";
- }
- else if (listMissing == true)
- {
- var mythicList = ["ATA", "FRE", "KR", "SotS", "SoB", "ToS", "TM", "TU", "TD", "WM"]; //add abbrvs to list if more are added
- for (i=0; i<mythicList.length; i++)
- {
- var n=displayInfo.dungeon.Mythic.details.search(mythicList[i]);
- if (n==-1)
- {
- missingMythics = missingMythics + mythicList[i] + " ";
- }
- }
- displayInfo.dungeon.Mythic.details = missingMythics;
- }
- var worldBosses = [52196, 52163, 52169, 52181, 52157, 52166];
- var worldBossKill = "";
- var warfront = "";
- var islandExpeditions = "";
- for (i=0; i < toon.quests.length; i++)
- {
- if (worldBosses.indexOf(toon.quests[i]) > -1)
- {
- worldBossKill = worldBossKill + "Weekly: \u2713 "; //unicode checkmark
- }
- if (toon.quests[i] == 54895 || toon.quests[i] == 54896)
- {
- worldBossKill = worldBossKill + "Ivus: \u2713 ";
- }
- if (toon.quests[i] == 52847 || toon.quests[i] == 52848)
- {
- worldBossKill = worldBossKill + "DH: \u2713 ";
- }
- if (toon.quests[i] == 53414 || toon.quests[i] == 53416)
- {
- warfront = warfront + "Stormgarde: \u2713 ";
- }
- if (toon.quests[i] == 53955 || toon.quests[i] == 53992)
- {
- warfront = warfront + "Darkshore: \u2713 ";
- }
- if (toon.quests[i] == 53435 || toon.quests[i] == 53436)
- {
- islandExpeditions = "\u2713 ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement