Widget:BabylRaids

From Granblue Fantasy Wiki
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.png BattleRaid The Frozen Hopes.png BattleRaid The Nature's Cradle.png BattleRaid The Cursed Trespass.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