歷史上的今天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>");
};
}
}