A calendar made by JavaScript

Source: Internet
Author: User

The calendar on the Xiaomi phone looks good, just try to do it with JavaScript,

The core content is three parts, the Gregorian part--->script.js, the lunar part--->lunar.js, the weather part--->weather.js, although the calendar to add a weather seems not so appropriate, but it is practice, the way to write.

Script.js mainly on the table to fill in the date information and binding some event handlers, basically a calendar object, the process is to get the day of the week and the number of days of the month, so that the Gregorian calendar date information is complete, and the last month and next month's Gregorian information is also followed.

Lunar.js with the Gregorian calendar date information as input parameters, calculated the corresponding lunar dates, the calculation of the lunar date, referring to the online tabular method, the table contains 1900-2049 of this 50 years of information, in particular, first calculate the date of the day from the lunar 1900.1.1 days of the total number of days, and then based on the number of the day of the agricultural Calendar Date

Weather.js used to obtain weather information, the data source is the interface of China's weather network, these interfaces have returned JSON data, there is also return XML data, need to use Ajax to get resources to parse, but because the browser of the same-origin policy Ajax can not cross-domain, so the use of getweather.php to get JS On the data, in addition to query the weather needs the corresponding city code, this weather online also has data, wrote a python file to take these city code to crawl down.

The specific source code is here: Https://github.com/ckzhou/MIUI-Calendar

A calendar made by JavaScript

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.