mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Adds a vague attempt at playing with CoffeeScript.
This commit is contained in:
parent
a9469e0c48
commit
02cf7cbf51
1 changed files with 39 additions and 0 deletions
39
link_hinting.coffee
Normal file
39
link_hinting.coffee
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Inspired by QuantumVim: https://github.com/shinglyu/QuantumVim
|
||||
|
||||
BACKGROUND_COLOUR = "yellow"
|
||||
|
||||
highlight_links = () ->
|
||||
links = document.querySelector('a') # Just handles links, not buttons/inputs etc.
|
||||
code = 0
|
||||
for link in links
|
||||
link_highlight(link, code)
|
||||
code +=1
|
||||
|
||||
return code
|
||||
|
||||
link_highlight = (elem, code) ->
|
||||
elem._background = elem.style.backgroundColor
|
||||
elem._position = elem.style.position
|
||||
# Why are these being saved?
|
||||
elem.style.backgroundColor = BACKGROUND_COLOUR
|
||||
elem.style.position="relative"
|
||||
codehint = generate_codehint(code)
|
||||
elem.appendChild(codehint)
|
||||
gLinkCodes[String(code)] = {
|
||||
element: elem
|
||||
codehint
|
||||
}
|
||||
# This is really ugly, surely we can create an object with the properties of codehint?
|
||||
|
||||
generate_codehint = (code) ->
|
||||
codehint = document.createElement('span')
|
||||
codehint.textContent = code
|
||||
codehint.style.border = "solid 1 px black"
|
||||
codehint.style.backgroundColor="white"
|
||||
codehint.style.font="12px/14px bold sans-serif"
|
||||
codehint.style.color="darkred"
|
||||
codehint.style.position="absolute"
|
||||
codehint.style.top="0"
|
||||
codehint.style.left="0"
|
||||
codehint.style.padding="0.1em"
|
||||
codehint
|
Loading…
Add table
Reference in a new issue