历史上的今天json接口 ,分享给大家,数据来源于wiki
//http://history.sturgeon.mopaas.com //主页
//http://history.sturgeon.mopaas.com/jsonp?callback=? //jsonp接口
//http://history.sturgeon.mopaas.com/jsonp //json接口
//http://history.sturgeon.mopaas.com/jsonp/1@1 //历史上的1月1日
//http://history.sturgeon.mopaas.com/1@1 //历史上的1月1日$.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>");
};
}
}
//http://history.sturgeon.mopaas.com //主页
//http://history.sturgeon.mopaas.com/jsonp?callback=? //jsonp接口
//http://history.sturgeon.mopaas.com/jsonp //json接口
//http://history.sturgeon.mopaas.com/jsonp/1@1 //历史上的1月1日
//http://history.sturgeon.mopaas.com/1@1 //历史上的1月1日$.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>");
};
}
}