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: mudanças entre as edições

De Tibia Wiki - A Enciclopédia do Tibia
Ir para navegação Ir para pesquisar
Linha 20: Linha 20:


   function searchCreatureData (boosted, targetImg, targetTxt) {
   function searchCreatureData (boosted, targetImg, targetTxt) {
     $.ajax({
     try {
      url: '/index.php?action=raw&title=' + boosted.name,
      const api = new mw.Api();
       success: function (data) {
      api.get({
         if (data.match(/Infobox[_ ]Criatura/)) {
        action: 'opensearch',
        search: boosted.name,
        limit: 1
       }).done(function (data) {
         if (data[1] && data[1][0] && data[1][0].toLowerCase() === boosted.name.toLowerCase()) {
          boosted.name = data[1][0]
           targetImg.html(`<a href="/wiki/${boosted.name}"><img src="/wiki/Especial:Redirecionar/file/${boosted.name}.gif" alt="${boosted.name}" style="height: 64px;"></a>`)
           targetImg.html(`<a href="/wiki/${boosted.name}"><img src="/wiki/Especial:Redirecionar/file/${boosted.name}.gif" alt="${boosted.name}" style="height: 64px;"></a>`)
           targetTxt.html(`<a style="color:#FFFFFF; text-decoration:none;" class="plainlinks" href="/wiki/${boosted.name}">${boosted.name}</a>`)
           targetTxt.html(`<a style="color:#FFFFFF; text-decoration:none;" class="plainlinks" href="/wiki/${boosted.name}">${boosted.name}</a>`)
Linha 29: Linha 34:
           fallback(boosted, targetImg, targetTxt)
           fallback(boosted, targetImg, targetTxt)
         }
         }
       },
       });
       error: _ => fallback(boosted, targetImg, targetTxt)
    } catch (e) {
     })
       fallback(boosted, targetImg, targetTxt)
     }
   }
   }



Edição das 00h45min de 7 de agosto de 2022

$(document).ready(function () {

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

  $.ajax({
    url: 'https://api.tibiadata.com/v3/boostablebosses', dataType: 'json', success: function (res) {
      searchCreatureData(res.boostable_bosses.boosted, $('#boostedboss_home_img'), $('#boostedboss_home_txt'))
    }
  })

  $.ajax({
    url: 'https://api.tibialabs.com/v2/dreamscar/name', success: function (res) {
      searchCreatureData({name: res}, $('#dreamscarboss_home_img'), $('#dreamscarboss_home_txt'))
    }
  })

  function searchCreatureData (boosted, targetImg, targetTxt) {
    try {
      const api = new mw.Api();
      api.get({
        action: 'opensearch',
        search: boosted.name,
        limit: 1
      }).done(function (data) {
        if (data[1] && data[1][0] && data[1][0].toLowerCase() === boosted.name.toLowerCase()) {
          boosted.name = data[1][0]
          targetImg.html(`<a href="/wiki/${boosted.name}"><img src="/wiki/Especial:Redirecionar/file/${boosted.name}.gif" alt="${boosted.name}" style="height: 64px;"></a>`)
          targetTxt.html(`<a style="color:#FFFFFF; text-decoration:none;" class="plainlinks" href="/wiki/${boosted.name}">${boosted.name}</a>`)
        } else {
          fallback(boosted, targetImg, targetTxt)
        }
      });
    } catch (e) {
      fallback(boosted, targetImg, targetTxt)
    }
  }

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