This file is indexed.

/usr/share/hotot/js/widget.autocomplete.js is in hotot-common 1:0.9.8.14-3.

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
// widget.autocomplete.js - user name autocomplete

if (typeof(widget) == 'undefined') widget = {}
function WidgetAutoComplete(obj) {
    var self = this;
    self._me = null;
    self._inDetecting = false;
    self.inputText = '';
    self.timer = null;

    self.init = function init(obj) {
        self._me = obj;
        self.candidate = $('<ul class="autocomplete"></ul>');
        self.candidate.insertAfter(self._me);
        self._me.bind('keydown', self.onKeyDown);
    };

    self.onKeyDown = function onKeyDown(event) {
        var key_code = event.keyCode;
        
        clearInterval(self.timer);
        if (key_code == 13) {
            if (self._inDetecting) {
                // Do username autocompletion because user pressed enter.
                var selectedItem = self.candidate.children('.selected');
                if (selectedItem.length != 0) {
                    // At this point self.inputText is the part of the
                    // user name that already has been typed (but with
                    // some strange casing).  selectedItem.text() is
                    // the username to be autocompleted.
                    self.replaceName(
                        selectedItem.text(), self.inputText.length 
                    );
                }
                self.stopDetecting();
                return false;
            }
        }
        
        if (event.keyCode == 27) { // esc
            self.candidate.hide();
        }

        if (key_code == 32) {
            if (self._inDetecting) {
                self.stopDetecting();
            }
            return;
        }

        if (key_code == 38 || key_code == 40) { 
            var current = self.candidate.children('.selected');
            var target = null; 
            if (key_code == 38) {
                target = current.prev();
                if (target.length == 0) {
                    target = self.candidate.children('li:last-child');
                }
            } else {
                target = current.next();
                if (target.length == 0) {
                    target = self.candidate.children('li:first-child');
                }
            }
            target.addClass('selected');
            self.candidate.stop().transition({scrollTop: target.get(0).offsetTop - self.candidate.get(0).offsetTop}); 
            current.removeClass('selected');
            return false;
        }

        if ((key_code <= 90 && 65 <= key_code)
            || (48 <= key_code && key_code <= 57)
            || 95 == key_code || key_code == 8) {
            self.detect(event);
        }
        if (key_code === 229) { // for imeKey
            self.timer = setInterval(function () {
                self.detect(event)
            }, 500);
        }
    };

    self.startDetecting = function startDetect() { 
        self._inDetecting = true;
        self.candidate.css({
            'width': self._me.width() + 'px', 'left':self._me.get(0).offsetLeft+'px'});
        self.candidate.slideDown('fast');
    };

    self.stopDetecting = function stopDetect() {
        self._inDetecting = false;
        self.inputText = '';
        self.candidate.slideUp('fast');
    };

    self.detect = function detect(event) {
        var text = self._me.val();
        // scan for '@' character
        var curPos = self.getCursorPos();
        var rearText = text.substring(0, curPos);
        var atIdx = rearText.lastIndexOf('@');
        if (atIdx == -1 || atIdx == curPos) {
            self.stopDetecting();
            return; 
        }
        // get the text after '@'
        if (event.keyCode == 8) {
            self.inputText = rearText.substring(atIdx + 1, curPos - 1) 
        } else {
            self.inputText = rearText.substring(atIdx + 1, curPos);
            if (event.keyCode !== 229) {
                self.inputText += String.fromCharCode(event.keyCode);
            }
        }
        if (self.inputText.match(/^[\S]+$/g) == null) {
            return;
        }
        // start 
        if (!self._inDetecting) {
            self.startDetecting();
        }

        var handleResult = function (result_list) {
            if (result_list.length == 0) {
                self.candidate.hide();
                return;
            }
            self.candidate.children('li').unbind('click');
            self.candidate.empty();
            for (var i = 0, l = result_list.length; i < l; i++) {
                self.candidate.append($('<li/>').text(result_list[i]));
            }
            self.candidate.show();
            self.candidate.children('li').click(function (event) {
                // Do username autocompletion because user clicked
                // a name from the list

                // self.inputText is the part of the name that has 
                // already be entered. $(this).text() is the username
                // to be autocompleted.
                self.replaceName($(this).text(), self.inputText.length);
                self.stopDetecting();
            });
            if (self.candidate.children('.selected').length === 0){
                self.candidate.children('li:first').addClass('selected');
            } 
        }
        handleResult(self.quickFilter(self.inputText));
        // self.filter(self.inputText, handleResult);
    };

    // This function does the actual autocomplete for user names.
    // 'append' is the part that is to be added to the part that
    // has already been typed
    self.competeName = function competeName(append) {
        var text = self._me.val();
        var curPos = self.getCursorPos();
        self._me.val(
            text.substr(0, curPos)
                + append + text.substring(curPos));
        self._me.get(0).selectionStart = curPos + append.length;
        self._me.get(0).selectionEnd = curPos + append.length;
    };

    // This function replaces the last nChars of the text of the
    // calling window by name. This keeps the casing of name intact
    // (see #371)
    self.replaceName = function(name, nChars) {
        var text = self._me.val();  // the current text
        var curPos = self.getCursorPos();  // location of the cursor
        var namePos = curPos - nChars;  // location for autocompleted name

        self._me.val(
            text.substr(0, namePos)
                + name + text.substring(curPos));
       
        // Not sure what the following lines do; I just copied and
        // adapted them from competeName.
 
        self._me.get(0).selectionStart = namePos + name.length;
        self._me.get(0).selectionEnd = namePos + name.length;
    }

    self.filter = function filter(text, callback) {
        db.get_screen_names_starts_with(text,
        function (tx, rs) {
            var result_list = []
            for (var i = 0, l = rs.rows.length; i < l; i += 1) { 
                result_list.push(rs.rows.item(i).screen_name)
            }
            callback(result_list);
        });
    };

    self.quickFilter = function quickFilter(text) {
        var result_list = globals.conversant.filter(
            function (x) {
                return x.toLowerCase().indexOf(text.toLowerCase()) === 0;
            });
        return result_list;
    };

    self.getCursorPos = function getCursorPos(){
        var pos = 0;
        var box = self._me.get(0);
        self._me.focus();
        if (document.selection) {
        // IE
            var sel = document.selection.createRange();
            sel.moveStart('character', -box.value.length);
            pos = sel.text.length;
        } else if (box.selectionStart || box.selectionStart == '0') {
        // others
            pos = box.selectionStart;
        }
        return pos;
    },

    self.hide = function hide() {
        self.candidate.hide();
    }

    self.init(obj);
}

widget.autocomplete = WidgetAutoComplete;
widget.autocomplete.connect = function bind(obj) {
    return new widget.autocomplete(obj);
}