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
 
(36 intermediate revisions by one other user not shown)
Line 2: Line 2:
if ( mw.config.get('wgPageName') === 'Current_worldguards' ) {
if ( mw.config.get('wgPageName') === 'Current_worldguards' ) {
   function fetch_worldguard_data() {
   function fetch_worldguard_data() {
   fetch("https://betadynmap.puucraft.net/standalone/regions_world.json")
   fetch("https://puucraft-dynmap-regionsworldjson-test.mixarium.repl.co/", {"method": "GET", "mode": 'cors', "content-security-policy": "connect-src 'self'"})
     .then(function(response) {
     .then(function(response) {
       if (response.ok) {
       if (response.ok) {
         return response.json()
         return response.json();
       } else {
       } else {
         throw new Error("NETWORK RESPONSE ERROR")
         throw new Error("NETWORK RESPONSE ERROR");
       };
       };
     })
     })
     .then(function(data) {
     .then(function(data) {
       let div_for_worldguard_list = document.getElementById('load_fetched_json_worldguard_data');
       var div_for_worldguard_list = document.getElementById('load_fetched_json_worldguard_data');
       let list = document.createElement('ul');
       var list = document.createElement('ul');
    };
 
    for (worldguardName in data) {
      for (var i = 0; i < Object.keys(data).length; i++) {
        let li = document.createElement('li');
          var li = document.createElement('li');
        li.innerHTML = worldguardName;
          li.innerHTML = data[i]['name'];
        list.appendChild(li);
          list.appendChild(li);
        div_for_worldguard_list.appendChild(list);
          div_for_worldguard_list.appendChild(list);
     };
     };
     })
     })
     .catch(function (error) {console.error("FETCH ERROR:", error)})
     .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)
};