Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/js/details.js
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-02-01 09:05:48 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2020-02-01 09:05:48 +0100
commit6854cb3f4d8219cf1829e32122eb2502a916eae9 (patch)
tree350feb504587d932e02837a1442b059759927646 /js/details.js
initial checkin
Diffstat (limited to 'js/details.js')
-rw-r--r--js/details.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/js/details.js b/js/details.js
new file mode 100644
index 0000000..6ee1472
--- /dev/null
+++ b/js/details.js
@@ -0,0 +1,46 @@
+Event.observe(window,'load',detailsInit);
+
+function detailsInit() {
+
+ // set current task
+ var title = document.getElementsByTagName('title')[0];
+ title = title.textContent || title.text; //IE uses .text
+ var arr = /(#)(\d+)/.exec(title);
+ if( arr != null){
+ sessionStorage.setItem('current_task', arr[2]);
+
+ // make sure the page is not in edit mode, 'details' is id of description textarea
+ if (!document.getElementById('details')) {
+ Event.observe(document,'keydown',keyboardNavigation);
+ }
+ }
+}
+function keyboardNavigation(e) {
+ var src = Event.element(e);
+ if (/input|select|textarea/.test(src.nodeName.toLowerCase())) {
+ // don't do anything if key is pressed in input, select or textarea
+ return;
+ }
+ if ((useAltForKeyboardNavigation && !e.altKey) ||
+ e.ctrlKey || e.shiftKey) {
+ return;
+ }
+ switch (e.keyCode) {
+ case 85: // "u" get back to task list
+ window.location = $('indexlink').href;
+ Event.stop(e);
+ break;
+ case 80: // "p" move to previous task
+ if ($('prev')) {
+ window.location = $('prev').href;
+ Event.stop(e);
+ }
+ break;
+ case 78: // "n" move to next task
+ if ($('next')) {
+ window.location = $('next').href;
+ Event.stop(e);
+ }
+ break;
+ }
+}