We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Jump to Post Keyboard Shortcuts
Topic Started: Aug 23 2012, 05:59 PM (1,040 Views)
Makaze
Member Avatar
Discordian
[ * ]
Tested in Google Chrome and Firefox.

Code Name:

Jump to Post Keyboard Shortcuts

What the code does:

Dynamically scrolls to an adjutant post when you press certain keys.

Preview

How to use the code:

Press Ctrl+j to go up one post and Ctrl+k to go down one.

How to install the code:

Put the following code under Admin CP » Themes » Board Template » Javascripts:

Code:
 
<script type='text/javascript' src='http://z5.ifrm.com/30040/55/0/f5127555/jqueryscrollTo.js'></script>
<script type="text/javascript">
$(document).keydown(function(e){

if (e.keyCode == 74 && e.ctrlKey) {

if ($('span.right a:contains("Post #")').length > 0) {
e.preventDefault();
};

var nextMessage = $('.c_username').filter(function(){
var Posi = $('html').offset();
var Posit = String(Posi.top).replace(/-/g, "");
var curPos = parseInt(Posit);
return $(this).offset().top < curPos;
}).parent("tr:last");

$.scrollTo(nextMessage, 200, {easing:'swing'});

return false;
};

if (e.keyCode == 75 && e.ctrlKey) {

if ($('span.right a:contains("Post #")').length > 0) {
e.preventDefault();
};

var nextMessage = $('.c_username').filter(function(){
var Posi = $('html').offset();
var Posit = String(Posi.top).replace(/-/g, "");
var curPos = parseInt(Posit);
return $(this).offset().top > curPos + 2;
}).parent("tr:first");

$.scrollTo(nextMessage, 200, {easing:'swing'}, {margin:true});

return false;
};

});
</script>

Extra notes:

Any keycodes can be used. Look here for a map of them.
Edited by Makaze, Aug 24 2012, 11:58 AM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Interesting code.

I don't think you can stop the ding in Google Chrome at the moment: http://code.google.com/p/chromium/issues/detail?id=105500

It's produced by the operating system any who, I believe.
Online Profile Quote Post Goto Top
 
Viral
Member Avatar
Viral
[ *  *  *  *  *  * ]
:O Interesting.
Offline Profile Quote Post Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

Nice code, it's pretty neat. (y)
Offline Profile Quote Post Goto Top
 
Makaze
Member Avatar
Discordian
[ * ]
Cory
Aug 24 2012, 07:20 AM
Interesting code.

I don't think you can stop the ding in Google Chrome at the moment: http://code.google.com/p/chromium/issues/detail?id=105500

It's produced by the operating system any who, I believe.
I fixed it by switching the modifier to Ctrl. It shouldn't have the ding now.
Offline Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
Scrolling up doesn't work in Opera because Ctrl + J opens the downloads page and i was going to suggest using two keys on the left like Q and E as J is a bit of stretch to hit with my left hand on a G19, not to mention pressing the Ctrl key too. But about the Page Up and Page Down buttons, keyCode 33 & 34 respectively?
Offline Profile Quote Post Goto Top
 
Makaze
Member Avatar
Discordian
[ * ]
Quozzo
Aug 24 2012, 12:45 PM
Scrolling up doesn't work in Opera because Ctrl + J opens the downloads page and i was going to suggest using two keys on the left like Q and E as J is a bit of stretch to hit with my left hand on a G19, not to mention pressing the Ctrl key too. But about the Page Up and Page Down buttons, keyCode 33 & 34 respectively?
I already set it to prevent the default actions on pages with posts. The same shortcut exists in Chrome. Does `.preventDefault()` not work in Opera?

I considered that. Just swap them out to get it working that way.

Using Pg Up and Pg Dn
Edited by Makaze, Aug 24 2012, 01:23 PM.
Offline Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
I don't think preventDefault works because the shortcut is not from the document but from Opera itself, and if a website could override those commands it could become a security issue.

BTW thanks for the edited code.
Edited by Quozzo, Aug 24 2012, 02:37 PM.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply