3 Star 12 Fork 4

foxnes / 梅花易数排盘

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.html 11.61 KB
一键复制 编辑 原始数据 按行查看 历史
foxnes 提交于 2020-12-18 16:16 . 自动时间起卦
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>梅花易数 在线排盘</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style type="text/css">
*{margin: 0;padding: 0;box-sizing: border-box;}
html{background-color: white;color: #1f1f1f;font-size: 17px;font-family: 微软雅黑,"Microsoft Yahei",arial;}
body{max-width: 800px;margin: 0 auto;}
a{color: inherit;text-decoration: underline;}
#卦域{
margin: 0 auto;
max-width: 500px;
padding: 5px;
user-select: none;
}
#卦域 .row{
float: left;
width: 30%;
}
#卦域 .row + .row{
margin-left: 5%;
}
.阴爻, .阳爻{
background-color: transparent;
height: 25px;
}
.阴爻:after{
content: '';
display: block;
position: relative;
height: 25px;
width: 15%;
top: 0;
left: 42.5%;
background-color: white;
}
.单卦{
background-color: black;
}
.单卦 .br{
height: 10px;
background: white;
}
.clear{
display: block;
height: 0;
clear: both;
}
input{
width: 3.5em;
padding: 3px 5px;
border-radius: 2px;
background-color: white;
border: 1px solid gray;
color: inherit;
}
button{
padding: 4px 18px;
background-color: #3F3F3F;
color: #e3e3e3;
border: none;
border-radius: 5px;
cursor: pointer;
transition: all 0.1s;
outline: none;
}
input, button{
font-family: inherit;
font-size: 18px;
margin: 5px;
font-weight: 800;
}
button:active{
background-color: #171717;
}
.起卦{
margin: 25px auto;
text-align: center;
user-select: none;
}
.卦名{
text-align: center;
background-color: white;
font-size: 20px;
height: 35px;
overflow: hidden;
white-space: nowrap;
font-weight: 800;
color: #323232;
letter-spacing: 2px;
}
#卦辞{
padding: 15px;
}
@media screen and (max-width: 380px){
#卦域 .row{
float: left;
width: 32%;
}
#卦域 .row + .row{
margin-left: 2%;
}
input, button{
font-size: 15px;
}
}
.logo{
text-align: center;
padding-top: 25px;
user-select: none;
overflow: hidden;
}
.logo small{
font-size: 0.8em;
color: gray;
}
.logo img{
transition: all 1.5s;
transition-timing-function: ease-in-out;
width: 4.5cm;
height: 4.5cm;
display: inline-block;
transform: rotate(65deg);
display: block;
margin: 0 auto;
}
#回到顶部{
position: fixed;
bottom: 1em;
right: 1em;
font-size: 25px;
line-height: 25px;
user-select: none;
color: #929292;
display: none;
}
::selection{
color: #e5e5e5;
background-color: #1f1f1f;
}
.main{
min-height: calc(100vh - 68px);
}
.foot{
color: gray;
font-size: 14px;
line-height: 19px;
text-align: center;
padding: 15px;
height: 68px;
}
</style>
</head>
<body>
<div class="main">
<div class="logo">
<img ondragstart='return false;' src="bg.svg" />
</div>
<form action="" method="get" onsubmit="return (function(){
算卦动画();return false;
})();">
<div class="起卦">
<input type="number" id="入上卦" placeholder="上卦" min="0" onclick="this.value = null;this.onclick=null">
<input type="number" id="入下卦" placeholder="下卦" min="0" onclick="this.value = null;this.onclick=null">
<input type="number" id="入爻动" placeholder="爻动" min="0" onclick="this.value = null;this.onclick=null">
<button type="submit">走你</button>
</div>
</form>
<div id="卦域">
<div class="clear"></div>
<div class="row" id="本卦"><div class="卦名">༺乾༻</div>
<div id="上本卦" class="单卦" style="background-color: #f6f6f6;"><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div></div>
<div id="下本卦" class="单卦" style="background-color: #f6f6f6;"><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div></div>
</div>
<div class="row" id="互卦"><div class="卦名">༺乾༻</div>
<div id="上互卦" class="单卦" style="background-color: #f6f6f6;"><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div></div>
<div id="下互卦" class="单卦" style="background-color: #f6f6f6;"><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div></div>
</div>
<div class="row" id="变卦"><div class="卦名">༺乾༻</div>
<div id="上变卦" class="单卦" style="background-color: #f6f6f6;"><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div></div>
<div id="下变卦" class="单卦" style="background-color: #f6f6f6;"><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div><div class="阳爻"></div><div class="br"></div></div>
</div>
<div class="clear"></div>
</div>
<div id="卦辞"></div>
</div>
<div id="回到顶部"></div>
<div class="foot">
「在线起卦」<br />
&copy;2020 <a href="http://gitee.com/foxnes">luuljh</a>
</div>
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript">
时间 = new Date();
农历 = calendar.solar2lunar(时间.getFullYear(), 时间.getMonth()+1, 时间.getDate());
生肖对应 = {
'': 1, '': 2, '': 3, '': 4, '': 5, '': 6, '': 7, '': 8, '': 9, '': 10, '': 11, '': 12
}
农历.lYear = 生肖对应[农历.Animal]
// 农历.lYear 农历.lMonth 农历.lDay
时辰 = 时间.getHours()
if (时辰 % 2 == 1) 时辰 += 1
时辰 = 时辰/2 + 1
$('#入上卦').val((农历.lYear+农历.lMonth+农历.lDay)%8)
$('#入下卦').val((农历.lYear+农历.lMonth+农历.lDay+时辰)%8)
$('#入爻动').val((农历.lYear+农历.lMonth+农历.lDay+时辰)%6)
// 坤卦提前
八卦 = [
['','000', ''],
['','111', ''],
['','011', ''],
['','101', ''],
['','001', ''],
['','110', ''],
['','010', ''],
['','100', '']
];
六四卦 = [["","111111"],["","000000"],["","100010"],["","010001"],["","111010"],["","010111"],["","010000"],["","000010"],["小畜","111011"],["","110111"],["","111000"],["","000111"],["同人","101111"],["大有","111101"],["","001000"],["","000100"],["","100110"],["","011001"],["","110000"],["","000011"],["噬嗑","100101"],["","101001"],["","000001"],["","100000"],["无妄","100111"],["大畜","111001"],["","100001"],["大过","011110"],["","010010"],["","101101"],["","001110"],["","011100"],["","001111"],["大壮","111100"],["","000101"],["明夷","101000"],["家人","101011"],["","110101"],["","001010"],["","010100"],["","110001"],["","100011"],["","111110"],["","011111"],["","000110"],["","011000"],["","010110"],["","011010"],["","101110"],["","011101"],["","100100"],["","001001"],["","001011"],["归妹","110100"],["","101100"],["","001101"],["","011011"],["","110110"],["","010011"],["","110010"],["中孚","110011"],["小过","001100"],["既济","101010"],["未济","010101"]];
function $(id){
// 只能选一个元素
return {
dom: document.querySelector(id),
val: function(text){
if (typeof text == 'undefined'){
return $(id).dom.value;
}else{
$(id).dom.value = text;
}
},
html: function(code, add){
if (typeof code == 'undefined'){
return $(id).dom.innerHTML;
}else{
if (typeof add == 'undefined'){
$(id).dom.innerHTML = code;
}else{
$(id).dom.innerHTML += code;
}
}
},
画爻: function(){
$(id).html('');
// 爻 如 101
= .split('');
.forEach(function(item){
if (item == 1){
// 阳爻
$(id).html('<div class="阳爻"></div><div class="br"></div>', '+');
}else{
$(id).html('<div class="阴爻"></div><div class="br"></div>', '+');
}
});
// 画完卦判断一下是哪个卦,好定五行颜色
八卦.forEach(function(item){
if (item[1] == .join('')){
$(id).五行着色(item[2]);
}
})
},
五行着色: function(五行){
let color = 'black';
switch (五行){
case '':
color = '#ebbb00';
break;
case '':
color = '#00982d';
break;
case '':
color = '#005f98';
break;
case '':
color = '#b82200';
break;
case '':
color = '#9e5900';
break;
}
$(id).dom.style = 'background-color: '+color+';';
}
}
}
function 算卦动画(){
$('.logo img').dom.style.transform = $('.logo img').dom.style.transform == 'rotate(965deg)' ? 'rotate(65deg)' : 'rotate(965deg)';
setTimeout(function(){
算卦();
}, 500);
}
function 算卦(){
while (document.getElementsByClassName('卦名').length > 0){
document.getElementsByClassName('卦名')[0].remove();
}
if ($('#入上卦').val() == "" ||
$('#入下卦').val() == "" ||
$('#入爻动').val() == ""
){
return "";
}
var = ($('#入上卦').val()%8);
var = ($('#入下卦').val()%8);
var = ($('#入爻动').val()%6);
// 本卦
$('#上本卦').画爻(八卦[][1]);
$('#下本卦').画爻(八卦[][1]);
var 本卦 = 八卦[][1] + 八卦[][1];
// 互卦
var 互卦 = 八卦[][1].substr(1, 2)+八卦[][1].substr(0, 1);
互卦 += 八卦[][1].substr(2, 1)+八卦[][1].substr(0, 2);
$('#上互卦').画爻(互卦.substr(0, 3));
$('#下互卦').画爻(互卦.substr(3, 3));
// 变卦
var 变卦 = (八卦[][1] + 八卦[][1]).split('');
= ( == 0) ? 0 : (6 - );
变卦[] = (变卦[] == '1') ? '0' : '1';
变卦 = 变卦.join('');
$('#上变卦').画爻(变卦.substr(0, 3));
$('#下变卦').画爻(变卦.substr(3, 3));
// 判断重卦
function 断重卦(id, 卦象){
for (var i = 0; i < 六四卦.length; i++) {
// 这里需要把卦象反过来!!!因为顺序不一样
if (六四卦[i][1] == 卦象.split('').reverse().join('')){
$(id).html('<div class="卦名">༺'+六四卦[i][0]+'༻</div>' + $(id).html());
let index = i+1;
$(id).dom.onclick = function(){
展示爻辞(index);
}
}
}
}
断重卦('#本卦', 本卦);
断重卦('#互卦', 互卦);
断重卦('#变卦', 变卦);
}
function 展示爻辞(index){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
$('#卦辞').html(xmlhttp.responseText);
}
}
xmlhttp.open("GET", "./64guaci/"+index, true);
xmlhttp.send();
}
window.onscroll = function(){
if (document.documentElement.scrollTop > 700){
$('#回到顶部').dom.style = "display: block;"
}else{
$('#回到顶部').dom.style = "";
}
}
$('#回到顶部').dom.onclick = function(){
back2top = setInterval(function(){
var dtop = document.documentElement.scrollTop;
var speed = Math.floor(-dtop/8);
document.documentElement.scrollTop = dtop+speed;
if(dtop==0){
clearInterval(back2top);
}
}, 10);
}
</script>
</body>
</html>
HTML/CSS
1
https://gitee.com/foxnes/zy-mhys.git
git@gitee.com:foxnes/zy-mhys.git
foxnes
zy-mhys
梅花易数排盘
master

搜索帮助