Hotkey Next Article Jump 4 at a time

Support requests, bug reports, etc. go here. Dedicated servers / VDS hosting only
blackdragon1
Bear Rating Trainee
Bear Rating Trainee
Posts: 13
Joined: 24 Oct 2013, 12:30

Hotkey Next Article Jump 4 at a time

Postby blackdragon1 » 12 Mar 2016, 17:12

Hello everyone, first let me be clear this is NOT a bug it's a request.
I've made some custom CSS that lets me see 4 articles at a time in combined feed display.
When using Ctrl+Down I would like to go to the next "row" without having to press it 4 times.

Is there a way to make a plugin overriding the number of next articles?
Or do I need to mess with a JS file, and if so can someone direct me to it?
Or perhaps a third option which I fail to see.


If someone would like to use or try, here's the CSS, just slap it on Customize option and you're good to go.

Code: Select all

div.cdm {
   border: 5px solid gray;
   padding-right: 15px;
   vertical-align: top;
   display: inline-block;
}

div.cdmHeader > span.titleWrap {
   display: table-caption;
}

div.cdmHeader * {
   display: inline;
}

div.cdm.expanded {
   max-width:20%;
}

div#floatingTitle {
   visibility: hidden !important;
}

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Hotkey Next Article Jump 4 at a time

Postby fox » 12 Mar 2016, 22:50

i think it should be possible to make this work using a plugin, you'll probably need to make a new hotkey action and set it to a keybind (i.e. HOOK_HOTKEY_MAP)

your plugin will need to include a JS file which defines the necessary function, i guess, maybe get the stock one and modify it to your liking or call it 4 times or something.

blackdragon1
Bear Rating Trainee
Bear Rating Trainee
Posts: 13
Joined: 24 Oct 2013, 12:30

Re: Hotkey Next Article Jump 4 at a time

Postby blackdragon1 » 13 Mar 2016, 20:40

It somewhat works, it jumps oddly not very 4 by 4 more like 6 then 3 at least visually. It serves its purpose, so I guess its fine.

Thanks for the help fox.

Here's the code.
Init.php

Code: Select all

<?php
class Custom_Keys extends Plugin {

   private $host;

   function about() {
      return array(1.0,
         "Custom keys to skip 4 at a time",
         "me");
   }

   function init($host) {
      $this->host = $host;

      $host->add_hook($host::HOOK_HOTKEY_MAP, $this);
   }

// KEYS can be:
//      "n"             = a single key character
//      "*n"            = Shift + key character  (Shift-n)
//      "^n"            = Ctrl + key character   (Ctrl-n)
//      "f q"           = a sequence of two keys
//      "(37)|left"     = a javascript key code and label
//      "^(38)|Ctrl-Up" = can use * Shift or ^ Ctrl with key codes
//  (search the web for "javascript key codes" for more examples)

   function hook_hotkey_map($hotkeys) {
      $hotkeys['(39)|right']   = '4xnext_article_noscroll';
      $hotkeys['(37)|left']    = '4xprev_article_noscroll';

      return $hotkeys;
   }

   function get_js() {
      return file_get_contents(dirname(__FILE__) . "/customkeys.js");
   }

   function api_version() {
      return 2;
   }

}
?>

customkeys.js

Code: Select all

hotkey_actions['4xnext_article_noscroll'] = function() {
      for (i = 0; i < 4; i++) {
         moveToPost('next', true);
      }
   };

hotkey_actions['4xprev_article_noscroll'] = function() {
      for (i = 0; i < 4; i++) {
         moveToPost('prev', true);
      }
   };

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Hotkey Next Article Jump 4 at a time

Postby fox » 13 Mar 2016, 20:58

yeah you might run into problems trying to call it 4 times in a row really fast

its probably better to rewrite the function to mark 4 articles at once and/or use small timeouts or something, idk


Return to “Support”

Who is online

Users browsing this forum: No registered users and 5 guests