-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathindex.html
359 lines (343 loc) · 15 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!DOCTYPE html>
<html lang="zh"
prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#">
<head>
<meta charset="utf-8">
<title>生辰小助手</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="生辰八字,五行属相,起名指引">
<meta name="description" content="免费生辰八字查询,免费五行查询">
<!-- Alternative links -->
<!-- CSS and JS-->
<script src="//cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="//cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="//cdn.bootcss.com/moment.js/2.15.2/moment-with-locales.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap-datetimepicker/4.17.43/js/bootstrap-datetimepicker.min.js"></script>
<link href="//cdn.bootcss.com/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker.min.css"
rel="stylesheet">
<!--
<link href="//cdn.bootcss.com/bootstrap-datetimepicker/4.17.43/css/bootstrap-datetimepicker-standalone.min.css" rel="stylesheet">-->
<script type="text/javascript" src="./stemsbranch.js"></script>
<script type="text/javascript" src="./calendar.js"></script>
<style>
body {
padding-top: 0px;
}
span.hl {
color: red;
}
.vspace {
padding: .5em;
}
#result {
display: none;
}
.c3 {
padding-left: 0;
padding-right: 0;
}
.c4 {
padding-left: 0;
}
</style>
<script>
var dp;
function calc() {
moment.locale('zh-CN');
var str = $('#birthday').val();
var birth = moment(str, 'YYYY年M月D日HH点');
var start = moment('1970-01-01');
var days = birth.diff(start, 'days');
var offset = days + 17;
var dayCol = StemsBranch.StemsBranchTable[offset % 60];
//console.log(dayCol);
var lunar = calendar.solar2lunar(birth.year(), birth.month() + 1, birth.date());
//console.log(lunar);
$('#result').hide();
var isLocal = $("#isLocal").is(':checked');
if (isLocal) {
v1_local(birth, lunar);
} else {
v2(birth);
}
}
$(document).ready(function () {
dp = $('#datetimepicker1').datetimepicker({
locale: 'zh-CN',
minDate: moment('1901-01-01'),
maxDate: moment('2100-12-31'),
format: 'YYYY年M月D日HH点'
});
var m = '<option value="0">-请选择-</option>';
for (var y = 1901; y < 2100; y++) {
m += '<option value="' + y + '">' + y + '年</option>';
}
$("#year").html(m);
$("#year").change(function () {
var o = $(this).find("option:selected");
var v = parseInt(o.val());
var ss = o.text();
if (v > 0) {
var str = $('#birthday').val();
if (str) {
$('#birthday').val(v + str.substr(4));
} else {
$('#birthday').val(ss + '1月1日00点');
}
//var d = moment($('#birthday').val(), 'YYYY年M月D日HH点');
//dp.date(d);
dp.show();
}
});
var today = moment();
$('#year').val(today.year());
$('#birthday').val(today.format('YYYY年M月D日HH点'));
$('#birthday').change(function () {
var s = $(this).val();
dp.date(moment(s, 'YYYY年M月D日HH点'));
});
$("#isLunar").change(function () {
if ($("#isLunar").is(':checked')) {
$("#isLocal").attr("disabled", "disabled");
$("#isLeap").removeAttr("disabled");
} else {
$("#isLocal").removeAttr("disabled");
$("#isLeap").attr("disabled", "disabled");
}
});
$("#isLocal").change(function () {
if ($("#isLocal").is(':checked')) {
$("#isLunar").attr("disabled", "disabled");
$("#isLeap").attr("disabled", "disabled");
} else {
$("#isLunar").removeAttr("disabled");
$("#isLeap").removeAttr("disabled");
}
});
});
function v1_local(birth, lunar) {
$('#o-solar').html(birth.format('YYYY年M月D日HH点 dddd'));
$('#o-lunar')
.html(lunar.lYear + '年' + lunar.lMonth + '月' + lunar.lDay + '日(' + lunar.IMonthCn + lunar.IDayCn + ')');
var dayStems = lunar.gzDay.substring(0, 1);
var hSection = StemsBranch.getHourStems(dayStems, birth.hour()) + StemsBranch.getHourBranch(birth.hour());
$('#o-animal').html('属<span class="hl">' + StemsBranch.getAnimal(lunar.gzYear) + '</span>');
$('#o-eight').html(
lunar.gzYear + ' ' + lunar.gzMonth + ' ' + lunar.gzDay + ' ' + hSection + ' 属<span class="hl">'
+ StemsBranch.getStemsElement(dayStems)) + "</span>";
var allfive = StemsBranch.getStemsBranchElement(lunar.gzYear) + ' '
+ StemsBranch.getStemsBranchElement(lunar.gzMonth) + ' ' + StemsBranch.getStemsBranchElement(lunar.gzDay) + ' '
+ StemsBranch.getStemsBranchElement(hSection);
var lose = '金木水火土';
for (var i = 0; i < allfive.length; i++) {
lose = lose.replace(allfive.charAt(i), '');
}
if (lose.length > 0) {
lose = ' 缺<span class="hl">' + lose + '<span>';
}
$('#o-five').html(allfive + lose);
$('#result').show();
}
function v2(birth) {
var p = document.location.protocol;
var api = 'http://api.ieclipse.cn/wnl/';
if (p == 'https:')
{
api = 'https://cdn.ieclipse.cn/wnl/';
}
var isLunar = $("#isLunar").is(':checked');
var isLeap = $("#isLeap").is(':checked')
var date = birth.format('YYYY-MM-DD-HH');//console.log(date);
api += isLunar ? 'solar' : 'lunar';
$.getJSON(api, {date: date, l: isLeap}, function (data) {
if (data) {
if (data.code === 0) {
v2_callback(data.data)
} else {
$('#result').html('<span class="hl">' + data.msg + '</span>');
}
$('#result').show();
}
});
}
function v2_callback(data) {
$('#o-solar').html(data.sYear + '年' + data.sMonth + '月' + data.sDay + '日' + data.sHour + '时 星期' + data.cWeek);
$('#o-lunar')
.html(data.lYear + '年' + data.lMonth + '月' + data.lDay + '日(' + data.hzYear + '年' + data.hzMonth + '月' + data.hzDay + ')');
var dayStems = data.cDay.substring(0, 1);
var hSection = data.cHour;//StemsBranch.getHourStems(dayStems, birth.hour()) + StemsBranch.getHourBranch(birth.hour());
$('#o-animal').html('属<span class="hl">' + data.cAnimal + '</span>');
$('#o-eight').html(
data.cYear + ' ' + data.cMonth + ' ' + data.cDay + ' ' + hSection + ' 属<span class="hl">'
+ StemsBranch.getStemsElement(dayStems)) + "</span>";
var allfive = StemsBranch.getStemsBranchElement(data.cYear) + ' '
+ StemsBranch.getStemsBranchElement(data.cMonth) + ' ' + StemsBranch.getStemsBranchElement(data.cDay) + ' '
+ StemsBranch.getStemsBranchElement(hSection);
var lose = '金木水火土';
for (var i = 0; i < allfive.length; i++) {
lose = lose.replace(allfive.charAt(i), '');
}
if (lose.length > 0) {
lose = ' 缺<span class="hl">' + lose + '<span>';
}
$('#o-five').html(allfive + lose);
$('#result').show();
}
</script>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span
class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="navbar-brand" href="./index.html">生辰助手</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="./index.html">生辰八字</a></li>
<li><a href="./name.html">起名</a></li>
<li><a href="./baike/index.html">小百科</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/Jamling/birthday-tool/">Github</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div class="container">
<div class="page-header">
<h1>
生辰八字查询
<small>查询生辰八字,五行属性</small>
</h1>
</div>
<div class="input-group col-md-5">
<span class="input-group-addon">
<span class="glyphicon glyphicon-list"></span> 出生年份</span>
<select class="form-control" id="year">
</select>
<span class="input-group-btn">
</span>
</div>
<div class='input-group date col-md-5 .hidden-xs' id='datetimepicker1'>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span> 出生日期</span>
<input type='text' class="form-control" style="padding-left: 4px; padding-right: 4px;" id="birthday"/>
<span class="input-group-btn">
<button class="btn btn-default" onclick="calc();">神机妙算</button>
</span>
</div>
<div class="visible-xs-block2" id="datetime-m">
<!--<div class="row">-->
<!--<div class="col-xs-6">-->
<!--<select class="form-control">-->
<!--<option>2000</option>-->
<!--</select>-->
<!--</div>-->
<!--<div class="col-xs-3 c3">-->
<!--<select class="form-control c3">-->
<!--<option>12</option>-->
<!--</select>-->
<!--</div>-->
<!--<div class="col-xs-3 c4">-->
<!--<select class="form-control c3">-->
<!--<option>13</option>-->
<!--</select>-->
<!--</div>-->
<!--<div class="col-xs-5">-->
<!--<select class="form-control">-->
<!--<option>13</option>-->
<!--</select>-->
<!--</div>-->
<!--</div>-->
</div>
<div class='input-group date col-md-5 checkbox'>
<label for="isLunar">
<input type='checkbox' id="isLunar">日期为农历
</label>
<label for="isLeap">
<input type='checkbox' id="isLeap" disabled="disabled">农历闰月
</label>
<label for="isLocal" class="col-xs-12">
<input type='checkbox' id="isLocal" name="isLocal">使用旧版(以正月初一作为农历一年的开始)
</label>
</div>
<div>
使用说明:
<ul>
<li>点击“<span class="glyphicon glyphicon-time"></span> 出生日期</span>”可以弹出日期控件</li>
<li>点击“神机妙算”,查看对应的生辰八字</li>
<li>出生日期精确到小时即可</li>
<li>出生日期须在公历1900-2100年之间(超过此时段,测算不准确哟)</li>
<li>输入日期为农历,请勾选“日期为农历”(旧版不支持农历选项),如果为闰月,请勾选“农历闰月”</li>
<li style="color: #e00;">当更改“年份或日期后”,需要点两次“<span class="glyphicon glyphicon-time"></span> 出生日期</span>”日期控件才会变成更改后的年份</li>
</ul>
</div>
<div class="col-md-6" style="padding-left: 0;">
<div class="vspace"></div>
<div class="panel panel-success" id="result">
<div class="panel-heading">
<h3 class="panel-title">生辰八字</h3>
</div>
<div class="panel-body">
<div>
<label>阳历:</label><span id="o-solar"></span>
</div>
<div>
<label>阴历:</label><span id="o-lunar"></span>
</div>
<div>
<label>生肖:</label><span id="o-animal"></span>
</div>
<div>
<label>八字:</label><span id="o-eight"></span>
</div>
<div>
<label>五行:</label><span id="o-five"></span>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div>
<p>生辰助手支持小程序啦,使用手机微信扫一扫即可打开,操作更方便哟</p>
<img src="./microprogram.jpg" alt="小程序" title="使用手机微信扫一扫,打开小程序版本"/>
</div>
<div>
<!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
<span class="jiathis_txt">分享到:</span>
<a class="jiathis_button_tools_1"></a>
<a class="jiathis_button_tools_2"></a>
<a class="jiathis_button_tools_3"></a>
<a class="jiathis_button_tools_4"></a>
<a href="http://www.jiathis.com/share?uid=2064663"
class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript">
var jiathis_config = {data_track_clickback: 'true'};
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=2064663" charset="utf-8"></script>
<!-- JiaThis Button END -->
</div>
<!-- UY BEGIN -->
<div id="uyan_frame"></div>
<script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=2064663"></script>
<!-- UY END -->
</div>
</body>
</html>