-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add number chart. Move index to separate
- Loading branch information
Showing
5 changed files
with
90 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
body { | ||
line-height: 1.5em; | ||
} | ||
li { | ||
margin: 0; | ||
} | ||
ul ul { | ||
padding-top: 0; | ||
} | ||
h2, h3 { | ||
border-bottom: 1px solid rgba(0,0,0,.5); | ||
} | ||
input[type=number] { | ||
width: 5rem; | ||
display: inline; | ||
font-weight: bold; | ||
margin:0; | ||
padding: .1rem .5rem; | ||
} | ||
label { | ||
display: inline; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Use scroll wheel to change numbers | ||
window.addEventListener('wheel', e => { | ||
let el = e.target; | ||
if (!el.matches('input[type=number]')) return; | ||
if (el.step === 'any') return; | ||
let numIters = ~~Math.abs(Math.round(e.deltaY)); | ||
if (e.deltaY < 0) { | ||
for (let i = 0; i< numIters; i++) el.stepUp(); | ||
} else { | ||
for (let i = 0; i< numIters; i++) el.stepDown(); | ||
} | ||
e.preventDefault(); | ||
}); | ||
|
||
// Link to pages that have parameters | ||
window.addEventListener('click', e => { | ||
if (e.target.tagName !== 'A') return; | ||
let form = e.target.closest('form'); | ||
if (form) { | ||
e.preventDefault(); | ||
form.action = e.target.href; | ||
form.submit(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<style> | ||
body { | ||
display:grid; | ||
grid-template: repeat(10, 1fr) / repeat(10, 1fr); | ||
} | ||
.num { | ||
font-size: 2rem; | ||
padding: 1rem; | ||
box-sizing: border-box; | ||
border: 1px solid rgba(0,0,0,.5); | ||
text-align: center; | ||
cursor: default; | ||
} | ||
.num:hover { | ||
color: green; | ||
border-color: green; | ||
} | ||
</style> | ||
<body> | ||
</body> | ||
<script> | ||
let $el = (t, props) => { | ||
let el = document.createElement(t); | ||
Object.assign(el, props); | ||
return el; | ||
}; | ||
document.body.append( | ||
...[...Array(100).keys()] | ||
.map(n => $el('div', {className: 'num', innerText: n}))); | ||
</script> |