This file is indexed.

/usr/share/GNUstep/SOGo/WebServerResources/HTMLElement.js is in sogo-common 2.1.1b-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/* -*- Mode: js-mode; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

["HTMLCollection", "NodeList"].each(
    function (className) {
        if (className in window) {
            var contClass = window[className];
            var _each = contClass.prototype.forEach;
            if (!_each) {
                _each = function HTMLElement_each(iterator, context) {
                    for (var i = 0, length = this.length >>> 0; i < length; i++) {
                        if (i in this) iterator.call(context, this[i], i, this);
                    }
                };
            }
            contClass.prototype._each = _each;
            Object.extend(contClass.prototype, Enumerable);
        }
    }
);

/* custom extensions to the DOM api */
Element.addMethods({
        addInterface: function(element, objectInterface) {
            element = $(element);
            Object.extend(element, objectInterface);
            if (element.bind)
                element.bind();
        },

        allTextContent: function(element) {
            var content = "";
            for (var i = 0; i < element.childNodes.length; i++) {
                var node = $(element.childNodes[i]);
                if (node.nodeType == Node.TEXT_NODE) {
                    content += node.nodeValue;
                }
                else if (node.nodeType === Node.ELEMENT_NODE) {
                    content += Element.allTextContent(node);
                }
            }

            return content;
        },

        childNodesWithTag: function(element, tagName) {
            element = $(element);

            var matchingNodes = new Array();
            tagName = tagName.toUpperCase();

            for (var i = 0; i < element.childNodes.length; i++) {
                var childNode = $(element.childNodes[i]);
                if (Object.isElement(childNode)
                    && childNode.tagName
                    && childNode.tagName.toUpperCase() == tagName)
                    matchingNodes.push(childNode);
            }

            return matchingNodes;
        },

        getParentWithTagName: function(element, tagName) {
            element = $(element);
            var currentElement = element;
            tagName = tagName.toUpperCase();

            currentElement = currentElement.parentNode;
            while (currentElement
                   && currentElement.tagName != tagName) {
                currentElement = currentElement.parentNode;
            }

            return currentElement;
        },

        cascadeLeftOffset: function(element) {
            element = $(element);
            var currentElement = element;

            var offset = 0;
            while (currentElement) {
                offset += currentElement.offsetLeft;
                currentElement = $(currentElement).getParentWithTagName("div");
            }

            return offset;
        },

        cascadeTopOffset: function(element) {
            element = $(element);
            var currentElement = element;
            var offset = 0;

            var i = 0;

            while (currentElement && currentElement.tagName) {
                offset += currentElement.offsetTop;
                currentElement = currentElement.parentNode;
                i++;
            }

            return offset;
        },

        dump: function(element, additionalInfo, additionalKeys) {
            element = $(element);
            var id = element.getAttribute("id");
            var nclass = element.getAttribute("class");

            var str = element.tagName;
            if (id)
                str += "; id = " + id;
            if (nclass)
                str += "; class = " + nclass;

            if (additionalInfo)
                str += "; " + additionalInfo;

            if (additionalKeys)
                for (var i = 0; i < additionalKeys.length; i++) {
                    var value = element.readAttribute(additionalKeys[i]);
                    if (value)
                        str += "; " + additionalKeys[i] + " = " + value;
                }

            log (str);
        },

        getSelectedNodes: function(element) {
            element = $(element);

            if (!element.selectedElements)
                element.selectedElements = new Array();

            return element.selectedElements;
        },

        getSelectedNodesId: function(element) {
            element = $(element);

            var selArray = null;
            if (element.selectedIds) {
                selArray = element.selectedIds;
            }
            else {
                selArray = [];
                if (element.selectedElements) {
                    for (var i = 0; i < element.selectedElements.length; i++) {
                        var node = element.selectedElements[i];
                        selArray.push(node.getAttribute("id"));
                    }
                }
            }

            return selArray;
        },

        onContextMenu: function(element, event) {
            element = $(element);
            if (document.currentPopupMenu)
                hideMenu(document.currentPopupMenu);

            var popup = element.sogoContextMenu;
            var menuTop = Event.pointerY(event);
            var menuLeft = Event.pointerX(event);
            var heightDiff = (window.height()
                              - (menuTop + popup.offsetHeight));
            if (heightDiff < 0)
                menuTop += heightDiff;

            var leftDiff = (window.width()
                            - (menuLeft + popup.offsetWidth));
            if (leftDiff < 0)
                menuLeft -= popup.offsetWidth;

            var isVisible = true;
            if (popup.prepareVisibility)
                isVisible = popup.prepareVisibility();

            Event.stop(event);

            if (isVisible) {
                popup.setStyle( { top: menuTop + "px",
                            left: menuLeft + "px",
                            visibility: "visible" } );
                document.currentPopupMenu = popup;
                $(document.body).on("mousedown", onBodyClickMenuHandler);
            }
            else
                log ("Warning: not showing the contextual menu " + element.id);
        },

        attachMenu: function(element, menuName) {
            element = $(element);
            element.sogoContextMenu = $(menuName);
            element.on("contextmenu", element.onContextMenu);
        },

        selectElement: function(element) {
            element = $(element);
            element.addClassName('_selected');
            var parent = element.up();
            if (!parent.selectedElements || !parent.selectedIds) {
                // Selected nodes are kept in a array at the
                // container level.
                parent.selectedElements = new Array();
                parent.selectedIds = new Array();
            }
            for (var i = 0; i < parent.selectedElements.length; i++)
                if (parent.selectedElements[i] == element) return;
            parent.selectedElements.push(element); // use index instead ?
            if (element.id) {
                for (var i = 0; i < parent.selectedIds.length; i++)
                    if (parent.selectedIds[i] == element.id) return;
                parent.selectedIds.push(element.id);
            }
        },

        selectRange: function(element, startIndex, endIndex) {
            element = $(element);
            var s;
            var e;
            var rows;

            if (startIndex > endIndex) {
                s = endIndex;
                e = startIndex;
            }
            else {
                s = startIndex;
                e = endIndex;
            }
            if (element.tagName == 'UL')
                rows = element.getElementsByTagName('LI');
            else
                rows = element.getElementsByTagName('TR');
            while (s <= e) {
                if (rows[s].nodeType == 1)
                    $(rows[s]).selectElement();
                s++;
            }
        },

        selectAll: function(element) {
            element = $(element);
            if (element.tagName == 'UL')
                rows = element.getElementsByTagName('LI');
            else
                rows = element.select('TBODY TR');
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].nodeType == 1)
                    $(rows[i]).selectElement();
            }
        },

        deselect: function(element) {
            element = $(element);
            element.removeClassName('_selected');
            var parent = element.parentNode;
            if (parent) {
                if (parent.selectedElements)
                    parent.selectedElements = parent.selectedElements.without(element);
                if (parent.selectedIds)
                    parent.selectedIds = parent.selectedIds.without(element.id);
            }
        },

        deselectAll: function(element) {
            if (element.tagName == 'TABLE') {
                var tbody = element.tBodies[0];
                if (tbody)
                    element = tbody;
            }
            element = $(element);
            var s = element.select("._selected");
            for (var i = 0; i < s.length; i++)
                s[i].removeClassName("_selected");

            element.selectedElements = null;
            element.selectedIds = null;
        },

        refreshSelectionByIds: function(element, selectedIds) {
            element = $(element);
            var selectedCount = 0;
            if (selectedIds)
                element.selectedIds = selectedIds;
            if (element.selectedIds) {
                for (var i = 0; i < element.selectedIds.length; i++) {
                    //var e = element.down('#'+element.selectedIds[i]); // buggy with IE
                    var e = $(element.selectedIds[i]);
                    if (e) {
                        if (!e.hasClassName('_selected'))
                            e.addClassName('_selected');
                        selectedCount++;
                    }
                    else {
                        log ("refreshSelectionByIds Error: " + element.tagName
                             + " select by ID " + element.selectedIds[i]
                             + " not found (" + element.childNodes.length + " children)");
                    }
                }
            }
            return selectedCount;
        },

        setCaretTo: function(element, pos) {
            element = $(element);
            if (element.setSelectionRange) {  // For Mozilla and Safari
                element.focus();
                element.setSelectionRange(pos, pos);
            }
            else if (element.createTextRange) {  // For IE
                var range = element.createTextRange();
                range.move("character", pos);
                range.select();
            }
        },

        selectText: function(element, start, end) {
            element = $(element);
            if (element.setSelectionRange) {     // For Mozilla and Safari
                element.setSelectionRange(start, end);
            }
            else if (element.createTextRange) {  // For IE
                var textRange = element.createTextRange();
                textRange.moveStart("character", start);
                textRange.moveEnd("character", end-element.value.length);
                textRange.select();
            }
            else {
                element.select();
            }
        },

        getRadioValue: function(element, radioName) {
            element = $(element);
            var radioValue;
            Form.getInputs(element, 'radio', radioName).each(function(input) {
                    if (input.checked)
                        radioValue = input.value;
                });
            return radioValue;
        },

        setRadioValue: function(element, radioName, value) {
            element = $(element);
            var i = 0;

            Form.getInputs(element, 'radio', radioName).each(function(input) {
                    if (i == value)
                        input.checked = 1;
                    i++;
                });
        },

        getCheckBoxListValues: function(element, checkboxName) {
            element = $(element);
            var values = new Array();
            var i = 0;

            Form.getInputs(element, 'checkbox', checkboxName).each(function(input) {
                    if (input.checked)
                        values.push(i+1);

                    i++;
                });
            return values.join(",");
        },

        setCheckBoxListValues: function(element, checkboxName, values) {
            element = $(element);
            var v = values.split(',');
            var i = 1;

            Form.getInputs(element, 'checkbox', checkboxName).each(function(input) {

                    if ($(v).indexOf(i+"") != -1)
                        input.checked = 1;
                    i++;
                });
        }
});