From c28c91327d523fd55bf4bcf8a5624484d8b14cdd Mon Sep 17 00:00:00 2001 From: Toban Wiebe Date: Sun, 8 Jul 2018 12:13:37 -0700 Subject: [PATCH 1/2] highlight nav links on focus (along with hover) --- style.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/style.css b/style.css index 64bf8b9..bc16efc 100644 --- a/style.css +++ b/style.css @@ -57,35 +57,35 @@ code { .filetype_image { color: #ffbb00; } -.filetype_image:hover { +.filetype_image:hover, .filetype_image:focus { color: black; background-color: #ffbb00; } .filetype_text { color: white; } -.filetype_text:hover { +.filetype_text:hover, .filetype_text:focus { color: black; background-color: white; } .filetype_directory { color: #66f; } -.filetype_directory:hover { +.filetype_directory:hover, .filetype_directory:focus { color: black; background-color: #66f; } .filetype_link { color: #0CC; } -.filetype_link:hover { +.filetype_link:hover, .filetype_link:focus { color: black; background-color: #0CC; } .filetype_targz { color: #c44; } -.filetype_targz:hover { +.filetype_targz:hover, .filetype_targz:focus { color: black; background-color: #c44; } From f152cabae172d1bdb930f98509c6bb84be7c6504 Mon Sep 17 00:00:00 2001 From: Toban Wiebe Date: Sun, 8 Jul 2018 18:15:58 -0700 Subject: [PATCH 2/2] basic ranger-like menu navigation --- changelog.html | 26 ++++++++++++++++--------- contact.html | 26 ++++++++++++++++--------- documentation.html | 26 ++++++++++++++++--------- download.html | 26 ++++++++++++++++--------- index.html | 26 ++++++++++++++++--------- keyboard.js | 47 ++++++++++++++++++++++++++++++++++++++++++++++ screenshots.html | 26 ++++++++++++++++--------- 7 files changed, 149 insertions(+), 54 deletions(-) create mode 100644 keyboard.js diff --git a/changelog.html b/changelog.html index ecb1d43..dff02d8 100644 --- a/changelog.html +++ b/changelog.html @@ -6,19 +6,18 @@ -
@@ -511,6 +510,15 @@

2010-06-09: Version 1.1.0

+ + +
diff --git a/contact.html b/contact.html index bb2e7e0..59e07cc 100644 --- a/contact.html +++ b/contact.html @@ -6,19 +6,18 @@ -
@@ -65,6 +64,15 @@

Donations

  • Akin Fernandez: "Ranger is the file manager we have been waiting for. It perfects an i3 setup." (2016-06-06)
  • + + +
    diff --git a/documentation.html b/documentation.html index 8303065..4d72c69 100644 --- a/documentation.html +++ b/documentation.html @@ -6,19 +6,18 @@ -
    @@ -88,6 +87,15 @@

    Dependencies

    + + +
    diff --git a/download.html b/download.html index 028d107..44edb71 100644 --- a/download.html +++ b/download.html @@ -6,19 +6,18 @@ -
    @@ -127,6 +126,15 @@

    Package Managers

    + + +
    diff --git a/index.html b/index.html index cffd87c..f7a46ea 100644 --- a/index.html +++ b/index.html @@ -6,19 +6,18 @@ -
    @@ -116,6 +115,15 @@

    Relocated website

    + + + diff --git a/keyboard.js b/keyboard.js new file mode 100644 index 0000000..e2a8b4c --- /dev/null +++ b/keyboard.js @@ -0,0 +1,47 @@ +var navclass = "kbnav"; + +function kbNav(key) { + + // convert HTMLCollection to array for indexing + var navlinks = [].slice.call(document.getElementsByClassName(navclass)); + var navindex = -1; // initialize counter before the first post + + var currentfocus = document.activeElement; // get current index of focused post + + // get current post index + if ( currentfocus.className.includes(navclass) ) { + navindex = navlinks.indexOf(currentfocus); + } + + // increment post index + if ( key === 'j' && navindex < navlinks.length - 1 ) { + navindex++; + } else if (key === 'k' && navindex > 0 ) { + navindex--; + } else if (key === 'g') { + navindex = 0; + } else if (key === 'G') { + navindex = navlinks.length - 1; + } + + // move focus + navlinks[navindex].focus(); +} + +function kbLaunch() { + var currentfocus = document.activeElement; // get current index of focused post + // open focused link + if ( currentfocus.className.includes(navclass) ) { + window.location.href = currentfocus; + } + +} + +Mousetrap.bind({ + 'j': function() { kbNav('j'); }, + 'k': function() { kbNav('k'); }, + 'g g': function() { kbNav('g'); }, + 'G': function() { kbNav('G'); }, + 'l': function() { kbLaunch(); }, + 'g h': function() { window.location.href = "index.html"; } +}) diff --git a/screenshots.html b/screenshots.html index fab73ba..c3faaa4 100644 --- a/screenshots.html +++ b/screenshots.html @@ -6,19 +6,18 @@ -
    @@ -44,6 +43,15 @@

    Screenshots

    + + +