PageSourceSearch

http://myadmin.pirg.bplaced.net/js/dist/keyhandler.js?v=5.2.0

js pirg.bplaced.net collected 2026-10-09 23:02:45 UTC 2,988 bytes, 150 lines download raw bytes

1// global var that holds: 0- if ctrl key is not pressed 1- if ctrl key is pressed
2var ctrlKeyHistory = 0;
3/**
4  * Allows moving around inputs/select by Ctrl+arrows
5  *
6  * @param {object} event data
7  */
8
9function onKeyDownArrowsHandler(event) {
10  var e = event || window.event;
11  var o = e.srcElement || e.target;
12
13  if (!o) {
14    return;
15  }
16
17  if (o.tagName !== 'TEXTAREA' && o.tagName !== 'INPUT' && o.tagName !== 'SELECT') {
18    return;
19  }
20
21  if (e.which !== 17 && e.which !== 37 && e.which !== 38 && e.which !== 39 && e.which !== 40) {
22    return;
23  }
24
25  if (!o.id) {
26    return;
27  }
28
29  if (e.type === 'keyup') {
30    if (e.which === 17) {
31      ctrlKeyHistory = 0;
32    }
33
34    return;
35  } else if (e.type === 'keydown') {
36    if (e.which === 17) {
37      ctrlKeyHistory = 1;
38    }
39  }
40
41  if (ctrlKeyHistory !== 1) {
42    return;
43  }
44
45  e.preventDefault();
46  var pos = o.id.split('_');
47
48  if (pos[0] !== 'field' || typeof pos[2] === 'undefined') {
49    return;
50  }
51
52  var x = pos[2];
53  var y = pos[1];
54
55  switch (e.keyCode) {
56    case 38:
57      // up
58      y--;
59      break;
60
61    case 40:
62      // down
63      y++;
64      break;
65
66    case 37:
67      // left
68      x--;
69      break;
70
71    case 39:
72      // right
73      x++;
74      break;
75
76    default:
77      return;
78  } // eslint-disable-next-line compat/compat
79
80
81  var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox/') > -1;
82  var id = 'field_' + y + '_' + x;
83  var nO = document.getElementById(id);
84
85  if (!nO) {
86    id = 'field_' + y + '_' + x + '_0';
87    nO = document.getElementById(id);
88  } // skip non existent fields
89
90
91  if (!nO) {
92    return;
93  } // for firefox select tag
94
95
96  var lvalue = o.selectedIndex;
97  var nOvalue = nO.selectedIndex;
98  nO.focus();
99
100  if (isFirefox) {
101    var ffcheck = 0;
102    var ffversion;
103
104    for (ffversion = 3; ffversion < 25; ffversion++) {
105      var isFirefoxV24 = navigator.userAgent.toLowerCase().indexOf('firefox/' + ffversion) > -1;
106
107      if (isFirefoxV24) {
108        ffcheck = 1;
109        break;
110      }
111    }
112
113    if (ffcheck === 1) {
114      if (e.which === 38 || e.which === 37) {
115        nOvalue++;
116      } else if (e.which === 40 || e.which === 39) {
117        nOvalue--;
118      }
119
120      nO.selectedIndex = nOvalue;
121    } else {
122      if (e.which === 38 || e.which === 37) {
123        lvalue++;
124      } else if (e.which === 40 || e.which === 39) {
125        lvalue--;
126      }
127
128      o.selectedIndex = lvalue;
129    }
130  }
131
132  if (nO.tagName !== 'SELECT') {
133    nO.select();
134  }
135
136  e.returnValue = false;
137}
138
139AJAX.registerTeardown('keyhandler.js', function () {
140  $(document).off('keydown keyup', '#table_columns');
141  $(document).off('keydown keyup', 'table.insertRowTable');
142});
143AJAX.registerOnload('keyhandler.js', function () {
144  $(document).on('keydown keyup', '#table_columns', function (event) {
145    onKeyDownArrowsHandler(event.originalEvent);
146  });
147  $(document).on('keydown keyup', 'table.insertRowTable', function (event) {
148    onKeyDownArrowsHandler(event.originalEvent);
149  });
150});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.