Bone Overlord.gif The Roost of the Graveborn Quest Spoiler!
Domine Graveborn: todos os bosses e mecânicas ilustradas!
Saiba mais ➔
Winter Tree.png Winter Update 2025
Acompanhe tudo sobre o Winter Update 2025!
Saiba mais ➔
Stag.gif The Order of the Stag Quest Spoiler!
Conheça Isle of Ada: sua quest, missões secundárias e todos os bosses!
Saiba mais ➔

MediaWiki:FeaturedCreatures.js

De Tibia Wiki - A Enciclopédia do Tibia
Revisão de 22h05min de 4 de agosto de 2022 por Master Player (discussão | contribs) (Criou página com '$(document).ready(function () { const $img = $('#boostedcreature_home_img') const $txt = $('#boostedcreature_home_txt') function getBoostedCreature (callback) { $.a...')
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
Ir para navegação Ir para pesquisar

Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.

  • Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
  • Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
  • Internet Explorer/Edge: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
  • Opera: Pressione Ctrl-F5.
$(document).ready(function () {
  const $img = $('#boostedcreature_home_img')
  const $txt = $('#boostedcreature_home_txt')

  function getBoostedCreature (callback) {
    $.ajax({
      url: 'https://api.tibiadata.com/v3/creatures', dataType: 'json', success: function (res) {
        callback(res.creatures.boosted)
      }
    })
  }

  function searchCreatureData (boosted) {
    $.ajax({
      url: '/index.php?action=raw&title=' + boosted.name,
      success: function (data) {
        if (data.match(/Infobox[_ ]Criatura/)) {
          $img.html(`<a href="/wiki/${boosted.name}"><img src="/wiki/Especial:Redirecionar/file/${boosted.name}.gif" alt="${boosted.name}"></a>`)
          $txt.html(`<a style="color:#FFFFFF; text-decoration:none;" class="plainlinks" href="/wiki/${boosted.name}">${boosted.name}</a>`)
        } else {
          fallback(boosted)
        }
      },
      error: _ => fallback(boosted)
    })
  }

  function fallback (boosted) {
    if ($img.children('a').length === 0) {
      $img.html(`<a href="#"><img src="${boosted.image_url}" alt="${boosted.name}"></a>`)
      $txt.html(`<a style="color:#FFFFFF; text-decoration:none;" class="plainlinks" href="#">${boosted.name}</a>`)
    }
  }

  getBoostedCreature(function (boosted) {
    searchCreatureData(boosted)
  })
})