Code to get what happened today in history

  • 2020-03-30 02:35:59
  • OfStack

Today's json interface in history, to share with you, data from the wiki


//http://history.sturgeon.mopaas.com // The home page 
//http://history.sturgeon.mopaas.com/jsonp?callback=?  //jsonp interface 
//http://history.sturgeon.mopaas.com/jsonp  //json interface 
//http://history.sturgeon.mopaas.com/jsonp/1@1 // In the history of the 1 month 1 day 
//http://history.sturgeon.mopaas.com/1@1  // In the history of the 1 month 1 day 
$.getJSON('http://history.sturgeon.mopaas.com/jsonp?callback=?',function(data){
 parserTodayObj(data);
});
function parserTodayObj(todayObj){
 for(var key in todayObj){
  if(/^.* born .*$/.test(key)){
   doBirthday(todayObj[key]);
  }
  if(/^.* holiday .*$/.test(key)){
   doHoliday(todayObj[key]);
  }
  if(/^.* customs .*$/.test(key)){
   doHoliday(todayObj[key]);
  }
  if(/^.* The death of .*$/.test(key)){
   doDeath(todayObj[key]);
  }
  if(/^.* catalogue .*$/.test(key)){
   doMemorabilia(todayObj[key]);
  }
 } 
}
parserTodayObj(todayObj);
function doBirthday(birthdays){
 if(birthdays.length != 0){
  $(document.body).append("<h3> born </h3>");
  for (var i = 0; i < birthdays.length; i++) {
   var birthdayitem = birthdays[i];
   $(document.body).append("<p>"+birthdayitem+"</p>");
  };
 }
}
function doHoliday(holidays){
 if(holidays.length != 0){
  $(document.body).append("<h3> holiday </h3>");
  for (var i = 0; i < holidays.length; i++) {
   var item = holidays[i];
   $(document.body).append("<p>"+item+"</p>");
  };
 }
}
function doDeath(deaths){
 if(deaths.length != 0){
  $(document.body).append("<h3> The death of </h3>");
  for (var i = 0; i < deaths.length; i++) {
   var item = deaths[i];
   $(document.body).append("<p>"+item+"</p>");
  };
 }
}
function doMemorabilia(memorabilias){
 if(memorabilias.length != 0){
  $(document.body).append("<h3> Significant events </h3>");
  for (var i = 0; i < memorabilias.length; i++) {
   var item = memorabilias[i];
   $(document.body).append("<p>"+item+"</p>");
  };
 }
}

The same code at the page code block index 0


Related articles: