-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
291 lines (290 loc) · 10.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<html lang='zh-tw' mainfest="dqm.manifest">
<head>
<title>大奇門遁甲</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="pure-min.0.6.0.css" >
<link rel="stylesheet" type="text/css" href="dqm.css" >
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="bookmark" href="/favicon.ico" />
<script>
function updateSite(event) {
window.applicationCache.swapCache() ;
}
window.applicationCache.addEventListener('updateready',updateSite,false);
</script>
<!-- include require script lib -->
<script src="js/string.js"></script>
<script src="js/jiqi.js"></script>
<script src="js/bazi.js"></script>
<script src="js/lunar.js"></script>
<script src="js/qimen_min.js"></script>
</head>
<body>
<div id="menu">
<div class="pure-g" >
<div class="pure-u-1-8" ><input type="number" name="txtYear" style='border:1' placeholder='yyyy' class='pure-u-1'/></div>
<div class="pure-u-1-8" >
<select name="cboMonth" class="pure-input-1">
<script>
for(var i = 1; i < 13; i++)
document.write('<option value="{0}">{0}月</option>'.format(i));
</script>
</select>
</div>
<div class="pure-u-1-8" >
<select name="cboDay">
<script>
for(var i = 1; i < 32; i++)
document.write('<option value="{0}">{0}日</option>'.format(i));
</script>
</select>
</div>
<div class="pure-u-1-8" >
<select name="cboHour">
<script>
for(var i = 0; i < 24; i++)
document.write('<option value="{0}">{0}時</option>'.format(i));
</script>
</select>
</div>
<div class="pure-u-1-8" >
<select name="cboMinute">
<script>
for(var i = 0; i < 60; i++)
document.write('<option value="{0}">{0}分</option>'.format(i));
</script>
</select>
</div>
<div class="pure-u-1-8" >
<select name="cboSecond">
<script>
for(var i = 0; i < 60; i++)
document.write('<option value="{0}">{0}秒</option>'.format(i));
</script>
</select>
</div>
<div class="pure-u-1-8" ><input type="number" name="txtMSec" style='border:1' placeholder='yyyy' class='pure-input-1'/></div>
<div class="pure-u-1-8" ><input class="pure-button pure-input-1" type="button" value="計算" onclick="calc()" /></div>
</div>
</div>
<div class="hr"></div>
<div id="info">
<div><span id="lblDate"></span></div>
<div><span id="lblDateLunar"></span></div>
<div><span id="lblBazi"></span></div>
<div><span id="lblJiqi"></span><span id="lblYuen"></span>元<span style="visibility:hidden">,</span><span id="lblDun"></span>遁<span id="lblKok"></span>局</div>
<div>值符天<span id="lblFu"></span><span style="visibility:hidden">,</span>值使<span id="lblShi"></span>門</div>
</div>
<div id="mainTable" class="table">
<div class="tr">
<div class="td" id="p4"></div>
<div class="td" id="p9"></div>
<div class="td" id="p2"></div>
</div>
<div class="tr">
<div class="td" id="p3"></div>
<div class="td" id="p5"></div>
<div class="td" id="p7"></div>
</div>
<div class="tr">
<div class="td" id="p8"></div>
<div class="td" id="p1"></div>
<div class="td" id="p6"></div>
</div>
</div>
<div id="tplTable" class="table" style="display:none">
<div class="tr">
<div class="td" id="i4">4</div>
<div class="td" id="i9">9</div>
<div class="td" id="i2">2</div>
</div>
<div class="tr">
<div class="td" id="i3">3</div>
<div class="td" id="i5">5</div>
<div class="td" id="i7">7</div>
</div>
<div class="tr">
<div class="td" id="i8">8</div>
<div class="td" id="i1">1</div>
<div class="td" id="i6">6</div>
</div>
</div>
<div class="hr"></div>
<!-- credits -->
<div id="credits">
<p><a target="_blank" href="https://www.facebook.com/groups/681148321946000/">大奇門遁甲青龍大殿</a></p>
<p><a href="https://github.com/nozomi199/nozomi199.github.io/archive/master.zip">Download here</a>, <a target="_blank" href="http://github.com/nozomi199">Github Source</a></p>
<p>It is used for demostrate the QIMEN STAR chinese astrology calculation library.</p>
</div>
</body>
<script>
"use strict";
var gblDate = new Date();
var qs = window.location.href;
if(qs.indexOf('?')) {
var id = qs.substr(qs.indexOf('?')+1);
var patt1=/^[0-9]{4}[0-9]{2}[0-9]{2}-[0-9]{2}[0-9]{2}[0-9]{2}$/i;
var patt2=/^[0-9]{4}[0-9]{2}[0-9]{2}-[0-9]{2}[0-9]{2}[0-9]{2}.[0-9]{1,3}$/i;
var daysInMonth = [0,31,28,31,30,31,30,31,31,30,31,30,31];
if(id.match(patt1)) {
// If evenly divisible by 4 and not evenly divisible by 100,
// or is evenly divisible by 400, then a leap year
var y = (id.substr(0,4))*1;
var m = (id.substr(4,2))*1 - 1;
var d = (id.substr(6,2))*1;
var h = (id.substr(9,2))*1;
var i = (id.substr(11,2))*1;
var s = (id.substr(13,2))*1;
var ms = 0;
gblDate = new Date(y,m,d,h,i,s,ms);
} else if(id.match(patt2)) {
// If evenly divisible by 4 and not evenly divisible by 100,
// or is evenly divisible by 400, then a leap year
var y = (id.substr(0,4))*1;
var m = (id.substr(4,2))*1 - 1;
var d = (id.substr(6,2))*1;
var h = (id.substr(9,2))*1;
var i = (id.substr(11,2))*1;
var s = (id.substr(13,2))*1;
var ms = (id.substr(16,3))*1;
gblDate = new Date(y,m,d,h,i,s,ms);
}
}
var jiqi = QIMEN_STAR.jiqi.GetJiqiInfo(
gblDate.getFullYear(),
gblDate.getMonth()+1,
gblDate.getDate(),
gblDate.getHours(),
gblDate.getMinutes(),
gblDate.getSeconds(),
gblDate.getMilliseconds()
);
var qimenInfo = QIMEN_STAR.calc_kok(jiqi);
var qimenPan = QIMEN_STAR.qimenCalc(qimenInfo.dun,qimenInfo.kook,jiqi.bazi.substr(6,2));
var gzid = QIMEN_STAR.bazi.gz2idx(jiqi.bazi.substr(6,2));
function calc(){
var a = parseInt(document.querySelector("input[name=txtYear]").value);
var b = parseInt(document.querySelector("input[name=txtMSec]").value);
if(a < 1) {
alert('請輸入正確年份(大於0)');
return;
}
if(b < 0|b>999) {
alert('請輸入正確毫秒(大於-1小於1000)');
return;
}
gblDate = new Date(
parseInt(document.querySelector("input[name=txtYear]").value),
parseInt(document.querySelector("select[name=cboMonth]").value)-1,
parseInt(document.querySelector("select[name=cboDay]").value),
parseInt(document.querySelector("select[name=cboHour]").value),
parseInt(document.querySelector("select[name=cboMinute]").value),
parseInt(document.querySelector("select[name=cboSecond]").value),
parseInt(document.querySelector("input[name=txtMSec]").value)
);
jiqi = QIMEN_STAR.jiqi.GetJiqiInfo(
gblDate.getFullYear(),
gblDate.getMonth()+1,
gblDate.getDate(),
gblDate.getHours(),
gblDate.getMinutes(),
gblDate.getSeconds(),
gblDate.getMilliseconds()
);
qimenInfo = QIMEN_STAR.calc_kok(jiqi);
qimenPan = QIMEN_STAR.qimenCalc(qimenInfo.dun,qimenInfo.kook,jiqi.bazi.substr(6,2));
gzid = QIMEN_STAR.bazi.gz2idx(jiqi.bazi.substr(6,2));
//
calc2();
}
function calc2() {
document.querySelector("#lblDateLunar").innerText = QIMEN_STAR.Solar2Lunar(gblDate.getFullYear(),gblDate.getMonth()+1,gblDate.getDate());
document.querySelector("#lblDate").innerText = QIMEN_STAR.jiqi.JTime(jiqi.julian)+"."+gblDate.getMilliseconds();
(function(){
var d = ['年','月','日','時','分','秒','毫秒','無極','混元','究境'];
var bz = jiqi.bazi;
d.forEach(function(v,k) {
d[k] = bz.substr(k*2,2)+d[k];
});
document.querySelector('#lblBazi').innerHTML = d.join('<span style="visibility:hidden">,</span>');
})();
(function() {
var q = qimenInfo;
document.querySelector('#lblJiqi').innerText = q.jiqi;
document.querySelector('#lblYuen').innerText = q.yuen;
document.querySelector('#lblDun').innerText = "陰陽"[q.dun];
document.querySelector('#lblKok').innerText = "零一二三四五六七八九"[q.kook];
document.querySelector('#lblFu').innerText = qimenPan.info.符;
document.querySelector('#lblShi').innerText = qimenPan.info.使;
})();
(function() {
var idx = "0123456789123456789123456789123456789".substr(qimenInfo.kook+4,11);
if(qimenInfo.dun == 0) idx = idx.split("").reverse().join("");
console.log(idx);
//console.log(idx, idx.length)
var gz = jiqi.bazi.substr(6,2);
var hmon = "662792448318".substr(parseInt(gzid/10)*2,2);
var god = {'符':'值符',
'蛇':'螣蛇',
'陰':'太陰',
'合':'六合',
'白':'白虎',
'玄':'玄武',
'地':'九地',
'天':'九天'};
for(var i = 1; i < 10; i++) {
var kok = idx[i];
var qpan = QIMEN_STAR.qimenCalc(qimenInfo.dun,kok,gz);
var pan = document.querySelector("#p"+i);
var dei = qpan['地'][5];
for(var j = 1; j < 10; j++) {
var dei = ',';
var hung = ',';
var godd = ",,,,\n";
var door = ",,,,\n";
var star = ",,,{0}".format(qpan['地'][j]);
if(hmon[0] == j || hmon[1] == j) hung = 'O';
if(qpan['星'][j] == '苪') dei = qpan['地'][5];
if(j != 5) {
godd = "{1}{0},\n".format(god[qpan['神'][j]], hung);
door = "{2}{0}門{1}\n".format(qpan['門'][j],qpan['天'][j],dei);
star = ",天{0}{1}".format(qpan['星'][j],qpan['地'][j]);
}
pan.querySelector("#i"+j).innerHTML =
(godd+
door+
star).replaceAll("\n","<br />").replaceAll(",",'<span style="visibility:hidden">,</span>');
}
}
})();
}
document.addEventListener("DOMContentLoaded",function() {
(function() {
document.querySelector("input[name=txtYear]").value = gblDate.getFullYear();
document.querySelector("select[name=cboMonth]").value = gblDate.getMonth()+1;
document.querySelector("select[name=cboDay]").value = gblDate.getDate();
document.querySelector("select[name=cboHour]").value = gblDate.getHours();
document.querySelector("select[name=cboMinute]").value = gblDate.getMinutes();
document.querySelector("select[name=cboSecond]").value = gblDate.getSeconds();
document.querySelector("input[name=txtMSec]").value = gblDate.getMilliseconds();
})();
(function() {
var tpl = document.querySelector("#tplTable").cloneNode(true);
tpl.style.display = "";
var tmp = tpl.querySelectorAll(".td");
[].forEach.call(tmp,function(v,k) {
v.style.textAlign = "center";
v.style.border = "1px dotted #999"
v.style.overflow = "hidden";
});
var tmp = document.querySelectorAll("#mainTable .td");
[].forEach.call(tmp,function(v,k){
v.appendChild(tpl.cloneNode(true));
v.style.border = "1px solid #999";
});
})();
calc2();
});
</script>
</html>