Skip to content

Commit

Permalink
v2.7 calendar.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Xremn committed Feb 24, 2023
1 parent ca6afc8 commit 74b3cc6
Show file tree
Hide file tree
Showing 8 changed files with 1,351 additions and 26 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@

## 更新日志

#### 2.7(2023.02.24)

##### Features

* 使用 [calendar.js](https://github.com/jjonline/calendar.js) 代替农历查询接口

##### Bug Fixes

* 时区查询接口增加兜底,默认`东八区`

#### 2.6 (2023.01.04)

##### Features
Expand Down
Binary file modified beta/css/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions beta/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
<script src="js/cookie.js"></script>
<script src="js/main.js"></script>
<script src="js/calendar.js"></script>
</head>

<body scroll="no">
Expand Down
666 changes: 666 additions & 0 deletions beta/js/calendar.js

Large diffs are not rendered by default.

28 changes: 5 additions & 23 deletions beta/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ window.onload = function () {
// Keys
var KEY_UNSPLASH = "bXwWoUhPeVw-yvSesGMgaOENnlSzhHYB43kZIQOR8cQ";
var KEY_QWEATHER = getCookie("qweatherKey"); // "f3c3540923c24847b9f4d194888dbcef"; // https://console.qweather.com/#/apps
var KEY_LUNAR = "LwExDtUWhF3rH5ib";

// APIs
var API_HITOKOTO = "https://v1.hitokoto.cn?encode=json&charset=utf-8";
var API_IP_INFO = "https://ipapi.co/json?languages=zh-CN";
var API_LUNAR = "https://v2.alapi.cn/api/lunar?token=";
var API_WEATHER = "https://devapi.qweather.com/v7/weather/now?";
var API_WEIBO = "https://tenapi.cn/resou/";

Expand Down Expand Up @@ -247,27 +245,11 @@ function clock(autoMode) {
}

function getLunar() {
var xhr = createXHR();
xhr.open("GET", API_LUNAR + KEY_LUNAR, true);
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
var data = JSON.parse(this.responseText);
if (data.code == 200) {
var lunar_data = data.data;
document.getElementById("lunar").innerHTML =
lunar_data.ganzhi_year +
"年" +
lunar_data.lunar_month_chinese +
lunar_data.lunar_day_chinese;
// if (lunar_data.festival.length)
// document.getElementById("holiday").innerHTML =
// "&nbsp;&nbsp;" + lunar_data.festival[0];
} else {
console.error("农历数据获取失败");
}
}
};
xhr.send(null);
var lunar = calendar.solar2lunar();
document.getElementById("lunar").innerHTML =
lunar.gzYear + "年" + lunar.IMonthCn + lunar.IDayCn;
document.getElementById("holiday").innerHTML =
"&nbsp;&nbsp;" + (lunar.lunarFestival || "") + (lunar.festival || "");
}

function weather() {
Expand Down
Binary file modified css/.DS_Store
Binary file not shown.
666 changes: 666 additions & 0 deletions js/calendar.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/main.js

Large diffs are not rendered by default.

0 comments on commit 74b3cc6

Please sign in to comment.