Jump to content

MediaWiki:Common.js: Difference between revisions

From Puucraft Wiki
oldpuuwiki>Mixarium
No edit summary
m 46 revisions imported: Imported from wiki.puucraft.net
 
(44 intermediate revisions by one other user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
function fetch_worldguard_data() {
if ( mw.config.get('wgPageName') === 'Current_worldguards' ) {
  fetch("https://betadynmap.puucraft.net/standalone/regions_world.json")
  function fetch_worldguard_data() {
  .then((response) => {
  fetch("https://puucraft-dynmap-regionsworldjson-test.mixarium.repl.co/", {"method": "GET", "mode": 'cors', "content-security-policy": "connect-src 'self'"})
    if (response.ok) {
    .then(function(response) {
      return response.json()
      if (response.ok) {
    } else {
        return response.json();
      throw new Error("NETWORK RESPONSE ERROR")
      } else {
    }
        throw new Error("NETWORK RESPONSE ERROR");
  })
      };
  .then(data => {
    })
    let list = document.createElement('ul')
    .then(function(data) {
  }
      var div_for_worldguard_list = document.getElementById('load_fetched_json_worldguard_data');
  for (worldguardName in data) {
      var list = document.createElement('ul');
      let li = document.createElement('li')
 
      li.innerHTML = worldguardName
      for (var i = 0; i < Object.keys(data).length; i++) {
      list.appendChild(li)
          var li = document.createElement('li');
  }
          li.innerHTML = data[i]['name'];
  })
          list.appendChild(li);
  .catch((error) => console.error("FETCH ERROR:", error))
          div_for_worldguard_list.appendChild(list);
}
    };
    })
    .catch(function (error) {console.error(error)})
};


fetch_worldguard_data()
fetch_worldguard_data()
};
if ( mw.config.get('wgPageName') === 'Puucraft' ) {
  function get_time_difference_from_current(unix_in_ms) {
  var map_launch = new Date(unix_in_ms);
  var current_date = new Date();
  var diff = new Date(current_date.getTime() - map_launch.getTime() - 10800000);
  var to_modify = document.getElementById('map_age')
  to_modify.innerHTML = "The current map, Map 11, is " + (diff.getYear() - 70) + " year(s), " + diff.getMonth() + " month(s), " + diff.getDate() + " day(s), " + diff.getHours() + " hour(s), " + diff.getMinutes() + " minute(s), " + diff.getSeconds() + " second(s) old."
  };
  get_time_difference_from_current(1628798400000)
};

Latest revision as of 20:49, 13 July 2026

/* Any JavaScript here will be loaded for all users on every page load. */
if ( mw.config.get('wgPageName') === 'Current_worldguards' ) {
  function fetch_worldguard_data() {
   fetch("https://puucraft-dynmap-regionsworldjson-test.mixarium.repl.co/", {"method": "GET", "mode": 'cors', "content-security-policy": "connect-src 'self'"})
    .then(function(response) {
      if (response.ok) {
        return response.json();
      } else {
        throw new Error("NETWORK RESPONSE ERROR");
      };
    })
    .then(function(data) {
      var div_for_worldguard_list = document.getElementById('load_fetched_json_worldguard_data');
      var list = document.createElement('ul');

      for (var i = 0; i < Object.keys(data).length; i++) {
          var li = document.createElement('li');
          li.innerHTML = data[i]['name'];
          list.appendChild(li);
          div_for_worldguard_list.appendChild(list);
    };
    })
    .catch(function (error) {console.error(error)})
};

fetch_worldguard_data()
};

if ( mw.config.get('wgPageName') === 'Puucraft' ) {
  function get_time_difference_from_current(unix_in_ms) {
   var map_launch = new Date(unix_in_ms);
   var current_date = new Date();
   var diff = new Date(current_date.getTime() - map_launch.getTime() - 10800000);

   var to_modify = document.getElementById('map_age')
   to_modify.innerHTML = "The current map, Map 11, is " + (diff.getYear() - 70) + " year(s), " + diff.getMonth() + " month(s), " + diff.getDate() + " day(s), " + diff.getHours() + " hour(s), " + diff.getMinutes() + " minute(s), " + diff.getSeconds() + " second(s) old."
  };
  get_time_difference_from_current(1628798400000)
};