Skip to content

Instantly share code, notes, and snippets.

@mooz
Created January 23, 2010 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mooz/284513 to your computer and use it in GitHub Desktop.
Save mooz/284513 to your computer and use it in GitHub Desktop.
key.setViewKey('>', function (ev, arg) {
let pattern = /(.*?)([0]*)([0-9]+)([^0-9]*)$/;
let url = content.location.href;
let digit = url.match(pattern);
if (digit[1] && digit[3])
{
let len = digit[3].length;
let next = +digit[3] + (arg ? arg : 1);
content.location.href = digit[1] + (digit[2] ||"").slice(next.toString().length - len) + next + (digit[4] ||"");
}
}, 'Increment last digit in the URL');
key.setViewKey('<', function (ev, arg) {
let pattern = /(.*?)([0]*)([0-9]+)([^0-9]*)$/;
let url = content.location.href;
let digit = url.match(pattern);
if (digit[1] && digit[3])
{
let len = digit[3].length;
let next = +digit[3] - (arg ? arg : 1);
content.location.href = digit[1] + (digit[2] ||"").slice(next.toString().length - len) + next + (digit[4] ||"");
}
}, 'Decrement last digit in the URL');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment