Goodtoknow.com

Good News, by Students, for the World

Line 1: Line 1:
(function () {
+
function get_month(month) {
   fetch("skins/GTKLight/resources/todayis.json").then(response => response.json())
+
  var data = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
    .then(data => {
+
          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
      var today = new Date();
+
  return data[month];
      var month = data.month[today.toLocaleString("default", { month: "short" })];
+
}
      var event = "";
+
   fetch("skins/GTKLight/resources/todayis.json")
      for (var i = 0; i < month.length; i++) {
+
  .then(function (response) {
        if (month[i].date == today.getDate()) {
+
    return response.json();
          event = month[i].day[Math.floor(Math.random() * month[i].day.length)];
+
  })
          break;
+
  .then(function (data) {
        }
+
    var today = new Date();
 +
    var month = get_month(today.getMonth());
 +
    var event = "";
 +
    var i = 0;
 +
    for (i = 0; i < month.length; i++) {
 +
      if (month[i].date == today.getDate()) {
 +
        event = month[i].day[Math.floor(Math.random() * month[i].day.length)];
 +
        break;
 
       }
 
       }
      if (event != "") {
+
    }
        document.getElementById("today-in-history").innerHTML = "Today is " + event;
+
    if (event !== "") {
      }
+
      document.getElementById("today-in-history").innerHTML =
     });
+
        "Today is " + event;
}());
+
    }
 +
     })

Revision as of 15:01, 27 January 2023

function get_month(month) {
  var data = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
	          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  return data[month];
}
  fetch("skins/GTKLight/resources/todayis.json")
  .then(function (response) {
    return response.json();
  })
  .then(function (data) {
    var today = new Date();
    var month = get_month(today.getMonth());
    var event = "";
    var i = 0;
    for (i = 0; i < month.length; i++) {
      if (month[i].date == today.getDate()) {
        event = month[i].day[Math.floor(Math.random() * month[i].day.length)];
        break;
      }
    }
    if (event !== "") {
      document.getElementById("today-in-history").innerHTML =
        "Today is " + event;
    }
    })