Skip to content

Commit

Permalink
regex tests, small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliumxyz committed Apr 29, 2017
1 parent 3a66271 commit dc9c25e
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 202 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<h1>press space or tap the screen</h1>
<div class='center'>
<ul class='options'>
<ul class='options terminal'>
<li>
<span class='cursor'>b</span>ounds? <span class="option active">y</span>/<span class='option'>n</span>
</li>
Expand Down
42 changes: 17 additions & 25 deletions load.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,29 @@ window.onresize = _ => {
window.onload = window.onresize

// look I'll fix this later lol.
function moveCursor() {
const options = select('.options')
options.innerHTML = options.innerHTML
.replace(/<span class="cursor.*?<\/span>/, "<span")
const moveCursor = {
left: ev => {
const terminal = select('.terminal')
const match = terminal
.innerHTML
.replace(/(.)<span class="cursor">(.*?)<\/span>/,'<span class="cursor">$1</span>$2')
terminal.innerHTML = match
},
right: ev => {
const terminal = select('.terminal')
const match = terminal
.innerHTML
.replace(/<span class="cursor">(.*?)<\/span>(.)/,'$1<span class="cursor">$2</span>')
terminal.innerHTML = match
},
}



// maybe replace this with regex?
// function moveCursor() {
// const options = selectAll('.option')
// const cursor = select('cursor')

// options.forEach(option => {
// if (option === cursor){
// select('cursor').setAttribute('class', 'option')
// option.setAttribute('class', 'option cursor')
// console.log(option)
// }
// })
// }

// function moveCursorLeft() {
// moveCursor


const keys = []
keys[32] = loadScript
// keys[37] = moveCursor
keys[37] = moveCursor.left
// keys[38] = moveCursor
// keys[39] = moveCursor
keys[39] = moveCursor.right
// keys[40] = moveCursor

// call the function corresponding to the key.
Expand Down
Loading

0 comments on commit dc9c25e

Please sign in to comment.