2 * (C) Copyright 2010 Desmond O. Chang <dochang@gmail.com>
4 * Use, modification, and distribution are subject to the terms specified in the
10 require("content-buffer.js");
12 define_keymap("github_keymap", $display_name = "github");
14 interactive("github-keyboard-shortcuts", null, function (I) {
16 var elem = buf.document.querySelector("#main a.keyboard-shortcuts");
18 browser_object_follow(buf, FOLLOW_DEFAULT, elem);
20 I.minibuffer.message("No keyboard shortcuts help link found on this page");
23 interactive("github-focus-site-search", null, function (I) {
25 var elem = buf.document.querySelector("#top_search_form input[name=q]");
27 browser_element_focus(buf, elem);
29 I.minibuffer.message("Site search box not found");
32 interactive("github-focus-issues-search", null, function (I) {
34 var elem = buf.document.querySelector("#issues span.search input[name=q]");
36 browser_element_focus(buf, elem);
38 I.minibuffer.message("Issues search box not found");
41 [// Site-wide shortcuts
42 "s", // Focus site search
43 "?", // Bring up this help dialog
45 "j", // Move selected down
46 "k", // Move selected up
49 "c", "o", "return", // Open commit
51 "j", // Move selected down
52 "k", // Move selected up
53 "o", "return", // Open issue
55 "j", // Move selected down
56 "k", // Move selected up
57 "x", // Toggle select target
58 "o", "return", // Open issue
59 "I", // Mark selected as read
60 "U", // Mark selected as unread
61 "e", // Close selected
62 "y", // Remove selected from view
66 "u", // Back to issues
67 "/", // Focus issues search
69 "left", "h", // Scroll left
70 "right", "l", // Scroll right
71 "up", "k", // Scroll up
72 "down", "j", // Scroll down
73 "t", // Toggle visibility of head labels
74 "S-left", "H", // Scroll all the way left
75 "S-right", "L", // Scroll all the way right
76 "S-up", "K", // Scroll all the way up
77 "S-down", "J"] // Scroll all the way down
78 .map(function (x) define_key(github_keymap, x, null, $fallthrough));
80 define_key(github_keymap, "?", "github-keyboard-shortcuts");
81 define_key(github_keymap, "s", "github-focus-site-search");
82 define_key(github_keymap, "/", "github-focus-issues-search");
84 define_keymaps_page_mode("github-mode",
85 build_url_regexp($domain = "github", $allow_www = true),
86 { normal: github_keymap },
87 $display_name = "Github");
89 page_mode_activate(github_mode);