MediaWiki:Timeless.js: mudanças entre as edições
De RubinOT Wiki
(Criou página com '→Todo o JavaScript aqui será carregado para os usuários do tema Timeless: // Função para fazer fetch dos dados function fetchData() { var url = 'https://rubinot.com.br/webservices/worlds.php'; fetch(url) .then(response => { if (!response.ok) { throw new Error('Network response was not ok ' + response.statusText); } return response.json(); }) .then(data => { console.l...') |
Sem resumo de edição |
||
(25 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
Linha 1: | Linha 1: | ||
/ | $(document).ready(function() { | ||
// Seleciona o elemento com o ID mw-wrapper | |||
var mwWrapper = document.getElementById('mw-wrapper'); | |||
if (mwWrapper) { | |||
// Obtém a altura do mw-wrapper | |||
var wrapperHeight = mwWrapper.offsetHeight; | |||
// Aplica a altura ao pseudo-elemento ::before do body | |||
var style = document.createElement('style'); | |||
style.type = 'text/css'; | |||
style.innerHTML = `body::before { height: ${wrapperHeight}px; }`; | |||
document.getElementsByTagName('head')[0].appendChild(style); | |||
} | |||
}); | |||
adjustOverlayHeight() | |||
mw.loader.using('jquery', function() { | |||
$(document).ready(function() { | |||
console.log('Document is ready, calling fetchData...'); | |||
fetchData(); | |||
fetchData1(); | |||
}); | |||
}); | |||
function fetchData() { | function fetchData() { | ||
console.log('fetchData function called'); | |||
var url = 'https://rubinot.com.br/webservices/worlds.php'; | var url = 'https://rubinot.com.br/webservices/worlds.php'; | ||
$.ajax({ | |||
. | url: url, | ||
method: 'GET', | |||
dataType: 'json', | |||
success: function(data) { | |||
console.log(data); // Exibe o conteúdo no console | |||
insertPlayerWorlds(data); | |||
}, | |||
error: function(jqXHR, textStatus, errorThrown) { | |||
console.error('There has been a problem with your fetch operation:', textStatus, errorThrown); | |||
} | |||
}); | |||
} | |||
function insertPlayerWorlds(worlds) { | |||
$('#world1').text(worlds[0].players); | |||
$('#world2').text(worlds[1].players); | |||
$('#world3').text(worlds[2].players); | |||
$('#world4').text(worlds[3].players); | |||
$('#world5').text(worlds[4].players); | |||
$('#world6').text(worlds[5].players); | |||
$('#world7').text(worlds[6].players); | |||
$('#world8').text(worlds[7].players); | |||
} | |||
function fetchData1() { | |||
console.log('fetchData1 function called'); | |||
var urla = 'https://rubinot.net/webservices/worlds.php'; | |||
$.ajax({ | |||
url: urla, | |||
method: 'GET', | |||
dataType: 'json', | |||
success: function(data) { | |||
console.log(data); // Exibe o conteúdo no console | console.log(data); // Exibe o conteúdo no console | ||
} | insertPlayerWorlds1(data); | ||
}, | |||
console.error('There has been a problem with your fetch operation:', | error: function(jqXHR, textStatus, errorThrown) { | ||
}); | console.error('There has been a problem with your fetch operation:', textStatus, errorThrown); | ||
} | |||
}); | |||
} | |||
function insertPlayerWorlds1(worlds) { | |||
$('#worldgringo').text(worlds[0].players); | |||
} | } | ||
mw.loader.using('jquery', function() { | |||
$(document).ready(function() { | |||
fetchData(); | console.log('Document is ready, calling fetchData...'); | ||
fetchData(); | |||
fetchData1(); | |||
}); | |||
}); | }); |
Edição atual tal como às 15h59min de 10 de agosto de 2024
$(document).ready(function() { // Seleciona o elemento com o ID mw-wrapper var mwWrapper = document.getElementById('mw-wrapper'); if (mwWrapper) { // Obtém a altura do mw-wrapper var wrapperHeight = mwWrapper.offsetHeight; // Aplica a altura ao pseudo-elemento ::before do body var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = `body::before { height: ${wrapperHeight}px; }`; document.getElementsByTagName('head')[0].appendChild(style); } }); adjustOverlayHeight() mw.loader.using('jquery', function() { $(document).ready(function() { console.log('Document is ready, calling fetchData...'); fetchData(); fetchData1(); }); }); function fetchData() { console.log('fetchData function called'); var url = 'https://rubinot.com.br/webservices/worlds.php'; $.ajax({ url: url, method: 'GET', dataType: 'json', success: function(data) { console.log(data); // Exibe o conteúdo no console insertPlayerWorlds(data); }, error: function(jqXHR, textStatus, errorThrown) { console.error('There has been a problem with your fetch operation:', textStatus, errorThrown); } }); } function insertPlayerWorlds(worlds) { $('#world1').text(worlds[0].players); $('#world2').text(worlds[1].players); $('#world3').text(worlds[2].players); $('#world4').text(worlds[3].players); $('#world5').text(worlds[4].players); $('#world6').text(worlds[5].players); $('#world7').text(worlds[6].players); $('#world8').text(worlds[7].players); } function fetchData1() { console.log('fetchData1 function called'); var urla = 'https://rubinot.net/webservices/worlds.php'; $.ajax({ url: urla, method: 'GET', dataType: 'json', success: function(data) { console.log(data); // Exibe o conteúdo no console insertPlayerWorlds1(data); }, error: function(jqXHR, textStatus, errorThrown) { console.error('There has been a problem with your fetch operation:', textStatus, errorThrown); } }); } function insertPlayerWorlds1(worlds) { $('#worldgringo').text(worlds[0].players); } mw.loader.using('jquery', function() { $(document).ready(function() { console.log('Document is ready, calling fetchData...'); fetchData(); fetchData1(); }); });