代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> 3n + 1 Game </title>
<link rel="stylesheet" href="./bt.css">
</head>
<body>
输入十进制数字: <input type="number" id="ipt" />
<span id="cbs">显示</span>队列前的零<input id="cbz" type="checkbox" checked />
<!-- Maybe I can make it more beautiful, but I just want keep it simple. -->
<div id="sticker">
<p id="cls">X</p>
<p id="currLoc"></p>
<p id="rowCnt"></p>
</div>
<table>
<tbody id="insertRow"></tbody>
</table>
<script type="text/javascript" src="./bt.js"></script>
<script>
'use strict';
const insertRow = document.querySelector('#insertRow');
const sticker = document.querySelector('#sticker');
const rowCnt = document.querySelector('#rowCnt');
const currLoc = document.querySelector('#currLoc');
// Show Step In Web
function showSteps(num) {
insertRow.textContent = '';
let cnt = 0, width = 0;
const callBack1 = () => {
let tr = document.createElement("tr");
let td2 = document.createElement("td");
td2.innerHTML = '<tt>' + robots.map(e => ROBOT_SIGN[e]).join('')
+ '</tt><tt>' + track.map(e => TRACK_SIGN[e]).join('') + '</tt>';
tr.appendChild(td2);
insertRow.appendChild(tr);
}
}
// add Event Listener
(() => {
document.getElementById('ipt').addEventListener('change', function (evn) {
showSteps(Math.abs(parseInt(this.value, 10)));
}, false);
document.getElementById('cls').addEventListener('click', function (evn) {
sticker.style.visibility = 'hidden';
}, false);
document.getElementById('cbz').addEventListener('change', function (evn) {
fillZero = this.checked;
document.getElementById('cbs').textContent = this.checked ? '显示' : '清除';
showSteps(Math.abs(parseInt(document.getElementById('ipt').value, 10)));
}, false);
insertRow.addEventListener('click', evt => {
let target = evt.target, rowIndex = 0;
switch (target.nodeName) {
case 'TT':
rowIndex = target.parentElement.parentElement.rowIndex;
break;
case 'TD':
rowIndex = target.parentElement.rowIndex;
break;
case 'TR':
rowIndex = target.rowIndex;
break;
default:
break;
}
// console.log('row : %d , char : %d ',rowIndex, Math.ceil(evt.offsetX / 15));
currLoc.textContent = `row : ${rowIndex}, col : ${Math.ceil(evt.offsetX / 15)}`;
sticker.style.visibility = 'visible';
});
})();
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。