Widget:BabylRaids

From Granblue Fantasy Wiki
Revision as of 11:55, 22 September 2020 by FabulousCupcake (talk | contribs) (Add temporary workaround to cache problems)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<script type="text/javascript">
;(function() {
'use strict';

// Traverse up until we find layer
function getParentLayer(child) {
  var parent = child.parentElement;
  if (!parent) return false;
  if (parent.classList.contains("babyl-layer")) return parent;
  return getParentLayer(parent);
}


// Layer Picker
const selectLayer = layerNumber => {
  const layers = document.querySelectorAll(".babyl-layer");
  const selectedLayer = document.querySelector(`.babyl-layer[data-layer-number='${layerNumber}']`);

  layers.forEach(layer => layer.classList.remove("active"));
  selectedLayer.classList.add("active");
};

document.querySelectorAll(".babyl-layers a").forEach(layer => {
  layer.addEventListener("click", e => {
    e.preventDefault();
    selectLayer(layer.href.split("#")[1]);
  });
});


// Quest Picker
const highlightQuest = questNumber => {
  const selectedQuest = document.querySelector(`.babyl-quest[data-quest-number='${questNumber}']`);
  const layer = getParentLayer(selectedQuest);
  const quests = layer.querySelectorAll(".babyl-quest");

  quests.forEach(quest => quest.classList.remove("active"));
  selectedQuest.classList.add("active");
  history.replaceState(null, null, '#' + questNumber);
};

const loadQuest = async (questNumber) => {
  highlightQuest(questNumber);

  const questEl = document.querySelector(`.babyl-quest[data-quest-number='${questNumber}']`);
  const layerEl = getParentLayer(questEl);
  const contentEl = layerEl.querySelector(".content");

  // Fetch and show
  // Append page revision ID as temporary workaround of caching behavior
  const curRevisionId = mw.config.get("wgCurRevisionId");
  const url = `https://gbf.wiki/Raids:Tower_of_Babyl_${questNumber}?action=render&t=${curRevisionId}`;
  const content = await fetch(url, { cache: "force-cache" });
  contentEl.innerHTML = await content.text();
};

document.querySelectorAll(".babyl-layer").forEach(layer => {
  const contentEl = layer.querySelector(".content");
  const missionDetails = contentEl.innerHTML;

  layer.querySelectorAll(".content-picker [data-quest-number]").forEach(quest => {
    const questNumber = quest.getAttribute("data-quest-number");
    quest.addEventListener("click", () => {
      loadQuest(questNumber);
    });
  });

  layer.querySelector(".content-picker .missions").addEventListener("click", () => {
    const quests = layer.querySelectorAll(".babyl-quest");
    quests.forEach(quest => quest.classList.remove("active"));
    contentEl.innerHTML = missionDetails;
  });
});


// Read from location.hash for permalinking support
const loadLocationHash = () => {
  const questNumberMatch = location.hash.match(/\d+-\d+/);
  if (!questNumberMatch) {
    selectLayer(1);
    return;
  }

  const questNumber = questNumberMatch[0];
  const questEl = document.querySelector(`.babyl-quest[data-quest-number='${questNumber}']`);
  const layerEl = getParentLayer(questEl);
  const layerNumber = layerEl.getAttribute("data-layer-number");

  selectLayer(layerNumber);
  loadQuest(questNumber);
  document.querySelector(".babyl-layers").scrollIntoView();
};

window.setTimeout(loadLocationHash, 0);

})();
</script>

BattleRaid The Obscured Sands.pngBattleRaid The Frozen Hopes.pngBattleRaid The Nature's Cradle.pngBattleRaid The Cursed Trespass.pngBattleRaid The Forlorn Peaks.pngBattleRaid The Cryptic Remains.png
BattleRaid The Brahmic Scripture.pngBattleRaid The Abyssal Depths.png
4F
BattleRaid Tower of Babyl 4-1.png
4-1
Icon attribute 1.png
3F
BattleRaid Tower of Babyl 3-1.png
3-1
Icon attribute 1.png
BattleRaid Tower of Babyl 3-2.png
3-2
Icon attribute 5.png
2F
BattleRaid Tower of Babyl 2-1.png
2-1
Icon attribute 1.png
BattleRaid Tower of Babyl 2-2.png
2-2
Icon attribute 5.png
1F
BattleRaid Tower of Babyl 1-1.png
1-1
Icon attribute 1.png
BattleRaid Tower of Babyl 1-2.png
1-2
Icon attribute 5.png
BattleRaid Tower of Babyl 1-3.png
1-3
Icon attribute 4.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 1 Crystal square.jpg Crystal ×100
Master all quests on floor 2 Crystal square.jpg Crystal ×100
Master all quests on floor 3 Crystal square.jpg Crystal ×100
Clear 3-1 within 1 turn Brimstone Earrings square.jpg Brimstone Earrings ×1
Clear 3-2 within 1 turn Sunbeam Earrings square.jpg Sunbeam Earrings ×1
Clear 4-1 within 1 turn Azure Accolade square.jpg Azure Accolade ×1
Master Layer of Obscured Sands Premium Draw Ticket square.jpg Premium Draw Ticket ×3
8F
BattleRaid Tower of Babyl 8-1.png
8-1
Icon attribute 2.pngIcon attribute 2.png
7F
BattleRaid Tower of Babyl 7-1.png
7-1
Icon attribute 2.png
BattleRaid Tower of Babyl 7-2.png
7-2
Icon attribute 6.png
6F
BattleRaid Tower of Babyl 6-1.png
6-1
Icon attribute 2.png
BattleRaid Tower of Babyl 6-2.png
6-2
Icon attribute 6.png
5F
BattleRaid Tower of Babyl 5-1.png
5-1
Icon attribute 2.png
BattleRaid Tower of Babyl 5-2.png
5-2
Icon attribute 6.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 5 Crystal square.jpg Crystal ×100
Master all quests on floor 6 Crystal square.jpg Crystal ×100
Master all quests on floor 7 Crystal square.jpg Crystal ×100
Clear 7-1 with a skill Permafrost Earrings square.jpg Permafrost Earrings ×1
Clear 7-2 with a skill Nightshade Earrings square.jpg Nightshade Earrings ×1
Clear 8-1 with a C.A. Azure Accolade square.jpg Azure Accolade ×1
Master Layer of Frozen Hopes Premium Draw Ticket square.jpg Premium Draw Ticket ×3
12F
BattleRaid Tower of Babyl 12-1.png
12-1
Icon attribute 4.pngIcon attribute 4.png
11F
BattleRaid Tower of Babyl 11-1.png
11-1
Icon attribute 4.png
BattleRaid Tower of Babyl 11-2.png
11-2
Icon attribute 3.png
10F
BattleRaid Tower of Babyl 10-1.png
10-1
Icon attribute 4.png
BattleRaid Tower of Babyl 10-2.png
10-2
Icon attribute 3.png
9F
BattleRaid Tower of Babyl 9-1.png
9-1
Icon attribute 4.png
BattleRaid Tower of Babyl 9-2.png
9-2
Icon attribute 3.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 9 Crystal square.jpg Crystal ×100
Master all quests on floor 10 Crystal square.jpg Crystal ×100
Master all quests on floor 11 Crystal square.jpg Crystal ×100
Clear 11-1 using no potions Jetstream Earrings square.jpg Jetstream Earrings ×1
Clear 11-2 using no potions Brickearth Earrings square.jpg Brickearth Earrings ×1
Clear 12-1 using no potions Azure Accolade square.jpg Azure Accolade ×1
Master Layer of Nature's Cradle Premium Draw Ticket square.jpg Premium Draw Ticket ×3
16F
BattleRaid Tower of Babyl 16-1.png
16-1
Icon attribute 0.pngIcon attribute 0.png
15F
BattleRaid Tower of Babyl 15-1.png
15-1
Icon attribute 5.png
14F
BattleRaid Tower of Babyl 14-1.png
14-1
Icon attribute 4.png
BattleRaid Tower of Babyl 14-2.png
14-2
Icon attribute 6.png
13F
BattleRaid Tower of Babyl 13-1.png
13-1
Icon attribute 3.png
BattleRaid Tower of Babyl 13-2.png
13-2
Icon attribute 1.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 13 Crystal square.jpg Crystal ×100
Master all quests on floor 14 Crystal square.jpg Crystal ×100
Clear 14-2 losing no allies Intricacy Ring square.jpg Intricacy Ring ×1
Clear 15-1 losing no allies Intricacy Ring square.jpg Intricacy Ring ×1
Clear 16-1 losing no allies Cloud Commendation square.jpg Cloud Commendation ×1
Master Layer of Cursed Trespass Premium 10-Part Ticket square.jpg Premium 10-Part Ticket ×1
20F
BattleRaid Tower of Babyl 20-1.png
20-1
Icon attribute 1.png
BattleRaid Tower of Babyl 20-2.png
20-2
Icon attribute 5.png
19F
BattleRaid Tower of Babyl 19-1.png
19-1
Icon attribute 5.png
18F
BattleRaid Tower of Babyl 18-1.png
18-1
Icon attribute 1.png
17F
BattleRaid Tower of Babyl 17-1.png
17-1
Icon attribute 1.png
BattleRaid Tower of Babyl 17-2.png
17-2
Icon attribute 5.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 17 Crystal square.jpg Crystal ×100
Master all quests on floor 20 Crystal square.jpg Crystal ×100
Clear 19-1 within 3 turns Sunbeam Earrings square.jpg Sunbeam Earrings ×1
Clear 20-1 within 3 turns Brimstone Earrings square.jpg Brimstone Earrings ×1
Clear 20-2 within 3 turns Azure Accolade square.jpg Azure Accolade ×1
Master Layer of Forlorn Peaks Premium Draw Ticket square.jpg Premium Draw Ticket ×3
24F
BattleRaid Tower of Babyl 24-1.png
24-1
Icon attribute 6.pngIcon attribute 2.pngIcon attribute 6.png
23F
BattleRaid Tower of Babyl 23-1.png
23-1
Icon attribute 6.png
BattleRaid Tower of Babyl 23-2.png
23-2
Icon attribute 2.png
22F
BattleRaid Tower of Babyl 22-1.png
22-1
Icon attribute 6.png
BattleRaid Tower of Babyl 22-2.png
22-2
Icon attribute 2.png
21F
BattleRaid Tower of Babyl 21-1.png
21-1
Icon attribute 6.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 22 Crystal square.jpg Crystal ×100
Master all quests on floor 23 Crystal square.jpg Crystal ×100
Clear 23-1 within 2 party switches Intricacy Ring square.jpg Intricacy Ring ×1
Clear 23-2 within 2 party switches Intricacy Ring square.jpg Intricacy Ring ×1
Clear 24-1 within 3 party switches Azure Accolade square.jpg Azure Accolade ×1
Master Layer of Cryptic Remains Premium Draw Ticket square.jpg Premium Draw Ticket ×3
28F
BattleRaid Tower of Babyl 28-1.png
28-1
Icon attribute 3.pngIcon attribute 3.png
BattleRaid Tower of Babyl 28-2.png
28-2
Icon attribute 4.pngIcon attribute 4.png
27F
BattleRaid Tower of Babyl 27-1.png
27-1
Icon attribute 4.png
26F
BattleRaid Tower of Babyl 26-1.png
26-1
Icon attribute 3.png
25F
BattleRaid Tower of Babyl 25-1.png
25-1
Icon attribute 3.png
BattleRaid Tower of Babyl 25-2.png
25-2
Icon attribute 4.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 25 Crystal square.jpg Crystal ×100
Master all quests on floor 28 Crystal square.jpg Crystal ×100
Clear 27-1 within 3 turns Jetstream Earrings square.jpg Jetstream Earrings ×1
Clear 28-1 within 3 turns Brickearth Earrings square.jpg Brickearth Earrings ×1
Clear 28-2 within 5 turns Azure Accolade square.jpg Azure Accolade ×1
Master Layer of Brahmic Scripture Premium Draw Ticket square.jpg Premium Draw Ticket ×3
32F
BattleRaid Tower of Babyl 32-1.png
32-1
Icon attribute 0.pngIcon attribute 0.png
31F
BattleRaid Tower of Babyl 31-1.png
31-1
Icon attribute 4.png
BattleRaid Tower of Babyl 31-2.png
31-2
Icon attribute 6.png
30F
BattleRaid Tower of Babyl 30-1.png
30-1
Icon attribute 2.png
29F
BattleRaid Tower of Babyl 29-1.png
29-1
Icon attribute 6.png
BattleRaid Tower of Babyl 29-2.png
29-2
Icon attribute 1.png
Babyl-mission-button.png

Click on a quest on the left side to view its details. [edit]

Mission Rewards
Master all quests on floor 29 Crystal square.jpg Crystal ×300
Master all quests on floor 31 Crystal square.jpg Crystal ×300
Clear 31-1 losing no allies Intricacy Ring square.jpg Intricacy Ring ×1
Clear 31-2 losing no allies Intricacy Ring square.jpg Intricacy Ring ×1
Clear 32-1 losing no allies Cloud Commendation square.jpg Cloud Commendation ×1
Master Layer of Abyssal Depths Premium 10-Part Ticket square.jpg Premium 10-Part Ticket ×1