历史上的今天json接口 ,分享给大家,数据来源于wiki
$.getJSON(\'http://history.sturgeon.mopaas.com/jsonp?callback=?\',function(data){
parserTodayObj(data);
});
function parserTodayObj(todayObj){
for(var key in todayObj){
if(/^.*出生.*$/.test(key)){
doBirthday(todayObj[key]);
}
if(/^.*假日.*$/.test(key)){
doHoliday(todayObj[key]);
}
if(/^.*风俗.*$/.test(key)){
doHoliday(todayObj[key]);
}
if(/^.*逝世.*$/.test(key)){
doDeath(todayObj[key]);
}
if(/^.*事记.*$/.test(key)){
doMemorabilia(todayObj[key]);
}
}
}
parserTodayObj(todayObj);
function doBirthday(birthdays){
if(birthdays.length != 0){
$(document.body).append(\"<h3>出生</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>节日</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>逝世</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>重大事件</h3>\");
for (var i = 0; i < memorabilias.length; i++) {
var item = memorabilias[i];
$(document.body).append(\"<p>\"+item+\"</p>\");
};
}
}
本文地址:https://www.stayed.cn/item/24370
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我