Code to get what happened today in history

Source: Internet
Author: User
This article mainly introduces what happened today in the history of code retrieval. The data comes from wiki. If you need it, refer to the historical json interface and share it with you. The data comes from wiki.

The Code is as follows:


// Http://history.sturgeon.mopaas.com // 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 // January 1 in history
/// Http://history.sturgeon.mopaas.com/1@1 // January 1 in history

$. 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 (/^. * death. * $/. test (key )){
DoDeath (todayObj [key]);
}
If (/^. * Event Recording. * $/. test (key )){
DoMemorabilia (todayObj [key]);
}
}
}

ParserTodayObj (todayObj );

Function doBirthday (birthdays ){
If (birthdays. length! = 0 ){

$ (Document. body). append ("Born ");
For (var I = 0; I <birthdays. length; I ++ ){
Var birthdayitem = birthdays [I];
$ (Document. body). append ("

"+ Birthdayitem +"

");
};
}
}

Function doHoliday (holidays ){
If (holidays. length! = 0 ){

$ (Document. body). append ("holiday ");
For (var I = 0; I Var item = holidays [I];
$ (Document. body). append ("

"+ Item +"

");
};
}
}

Function doDeath (deaths ){
If (deaths. length! = 0 ){

$ (Document. body). append ("death ");
For (var I = 0; I <deaths. length; I ++ ){
Var item = deaths [I];
$ (Document. body). append ("

"+ Item +"

");
};
}
}

Function doMemorabilia (memorabilias ){
If (memorabilias. length! = 0 ){

$ (Document. body). append ("major event ");
For (var I = 0; I <memorabilias. length; I ++ ){
Var item = memorabilias [I];
$ (Document. body). append ("

"+ Item +"

");
};
}
}

The Code is as follows:


// Http://history.sturgeon.mopaas.com // 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 // January 1 in history
/// Http://history.sturgeon.mopaas.com/1@1 // January 1 in history

$. 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 (/^. * death. * $/. test (key )){
DoDeath (todayObj [key]);
}
If (/^. * Event Recording. * $/. test (key )){
DoMemorabilia (todayObj [key]);
}
}
}

ParserTodayObj (todayObj );

Function doBirthday (birthdays ){
If (birthdays. length! = 0 ){

$ (Document. body). append ("Born ");
For (var I = 0; I <birthdays. length; I ++ ){
Var birthdayitem = birthdays [I];
$ (Document. body). append ("

"+ Birthdayitem +"

");
};
}
}

Function doHoliday (holidays ){
If (holidays. length! = 0 ){

$ (Document. body). append ("holiday ");
For (var I = 0; I Var item = holidays [I];
$ (Document. body). append ("

"+ Item +"

");
};
}
}

Function doDeath (deaths ){
If (deaths. length! = 0 ){

$ (Document. body). append ("death ");
For (var I = 0; I <deaths. length; I ++ ){
Var item = deaths [I];
$ (Document. body). append ("

"+ Item +"

");
};
}
}

Function doMemorabilia (memorabilias ){
If (memorabilias. length! = 0 ){

$ (Document. body). append ("major event ");
For (var I = 0; I <memorabilias. length; I ++ ){
Var item = memorabilias [I];
$ (Document. body). append ("

"+ Item +"

");
};
}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.