diff --git a/fortune_generator/fortune.js b/fortune_generator/fortune.js
index 088a940..41c52ca 100644
--- a/fortune_generator/fortune.js
+++ b/fortune_generator/fortune.js
@@ -14,14 +14,16 @@ fetch("fortune.json")
badFortunes = data.badFortunes;
})
-const textColor = ["#e74c3c", "#e74c3c", "#e74c3c", "#5eb95e", "#000000bf", "#000000bf", "#000000bf"];
-const fortuneStatus = ["大吉", "中吉", "小吉", "中平", "凶", "小凶", "大凶"];
+const textColor = ["#e74c3c", "#e74c3c", "#e74c3c", "#e74c3c", "#e74c3c", "#e74c3c", "#5eb95e", "#5eb95e", "#000000bf", "#000000bf", "#000000bf"];
+const fortuneStatus = ["大吉", "中吉", "中吉", "小吉", "小吉", "小吉", "中平", "中平", "凶", "凶", "大凶"];
const chineseMonth = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"];
const week = ['日', '一', '二', '三', '四', '五', '六'];
-const title = `今日運勢`;
-const allGood = `萬事皆宜`;
-const allBad = `諸事不宜`;
+const title = `今日運勢`;
+const allGood = `萬事皆宜`;
+const allBad = `諸事不宜`;
+
+
const d = new Date();
const date = d.getDate();
@@ -29,9 +31,9 @@ const day = d.getDay();
const month = d.getMonth() + 1;
const year = d.getFullYear();
-const showMonth = `${chineseMonth[month - 1] + "月"}`;
-const showDate = `${("0" + date).substr(-2)}`;
-const showDay = `${"星期" + week[day]}`;
+const showMonth = `${chineseMonth[month - 1] + "月"}`;
+const showDate = `${("0" + date).substr(-2)}`;
+const showDay = `${"星期" + week[day]}`;
$('#month').html(showMonth);
$('#date').html(showDate);
@@ -54,14 +56,15 @@ function Appear() {
num[p] = num[p] * 10 + parseInt(ip[i]);
}
-
+ const goodLen = goodFortunes.length;
+ const badLen = badFortunes.length;
+ const statusLen = fortuneStatus.length;
+
let hashDate = Math.round(Math.log10(year * ((month << 3) ^ (date << 1))));
let seed1 = (num[0] >> hashDate) * (num[1] >> Math.min(hashDate, 2)) + (num[2] << 1) * (num[3] >> 3) + (date << 3) * (month << hashDate) + year;
let seed2 = (num[0] << (hashDate + 2)) * (num[1] << hashDate) + (num[2] << 1) * (num[3] << 3) + (date << (hashDate - 1)) * (month << 4) + year >> hashDate;
- const goodLen = goodFortunes.length;
- const badLen = badFortunes.length;
- let status = `§ ${fortuneStatus[seed1 % 7]} §`;
+ let status = `§ ${fortuneStatus[seed1 % statusLen]} §`;
$('#ip-to-fortune').html(status);
let l_1_event, l_1_desc, l_2_event, l_2_desc, r_1_event, r_1_desc, r_2_event, r_2_desc;
@@ -77,22 +80,22 @@ function Appear() {
set.add(badFortunes[r1].event);
r2 = (((((seed1 << 3 ) + (d.getFullYear() >> 5) * (date << 2)) % badLen) * seed2) >> 6) % badLen;
while(set.has(badFortunes[r2].event)) r2 = (r2 + 1) % badLen;
- l_1_event = `宜: ${goodFortunes[l1].event}`;
- l_1_desc = `${goodFortunes[l1].description}`;
- l_2_event = `宜: ${goodFortunes[l2].event}`;
- l_2_desc = `${goodFortunes[l2].description}`;
- r_1_event = `忌: ${badFortunes[r1].event}`;
- r_1_desc = `${badFortunes[r1].description}`;
- r_2_event = `忌: ${badFortunes[r2].event}`;
- r_2_desc = `${badFortunes[r2].description}`;
- if(seed1 % 7 == 0){
+ l_1_event = `宜: ${goodFortunes[l1].event}`;
+ l_1_desc = `${goodFortunes[l1].description}`;
+ l_2_event = `宜: ${goodFortunes[l2].event}`;
+ l_2_desc = `${goodFortunes[l2].description}`;
+ r_1_event = `忌: ${badFortunes[r1].event}`;
+ r_1_desc = `${badFortunes[r1].description}`;
+ r_2_event = `忌: ${badFortunes[r2].event}`;
+ r_2_desc = `${badFortunes[r2].description}`;
+ if(seed1 % statusLen == 0){
$('#r-1-event').html(allGood);
$('#l-1-event').html(l_1_event);
$('#l-1-desc').html(l_1_desc);
$('#l-2-event').html(l_2_event);
$('#l-2-desc').html(l_2_desc);
}
- else if(seed1 % 7 == 6){
+ else if(seed1 % statusLen == statusLen - 1){
$('#l-1-event').html(allBad);
$('#r-1-event').html(r_1_event);
$('#r-1-desc').html(r_1_desc);