/usr/share/hotot/js/ui.finder.js is in hotot-common 1:0.9.8.14-2.
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 | if (typeof ui == 'undefined') var ui = {};
ui.Finder = {
id: '',
current_pos: -1,
matched_ids: [],
query: '',
init:
function init() {
ui.Finder.id = '#finder_bar';
ui.Finder.tbox = '#tbox_finder';
$(ui.Finder.tbox).keyup(
function (event) {
if (event.keyCode == 13) { // Enter to search
var query = $.trim($(ui.Finder.tbox).val());
if (query.length == 0)
return;
if (ui.Finder.query != query) {
ui.Finder.search(query);
ui.Finder.next_result();
} else {
ui.Finder.next_result();
}
} else if (event.keyCode == 27) { //ESC to close
$('#btn_finder_close').click();
return false;
}
});
$('#btn_finder_next').click(
function (event) {
ui.Finder.next_result();
return false;
});
$('#btn_finder_prev').click(
function (event) {
ui.Finder.prev_result();
return false;
});
$('#btn_finder_close').click(
function (event) {
ui.Finder.clear();
ui.Finder.hide();
return false;
});
return this;
},
search:
function search(query) {
var tweets = $('#main_page .card:visible');
ui.Finder.finding = true;
ui.Finder.query = query;
ui.Finder.current_pos = 0;
ui.Finder.matched_ids = [];
tweets.each(
function(idx, obj) {
var tweet_li = $(obj);
if (query[0] == '@') {
if ($.trim(tweet_li.find('.who').text()).toLowerCase() == query.substring(1).toLowerCase()) {
ui.Finder.matched_ids.push('#'+tweet_li.attr('id'));
}
} else {
if (tweet_li.find('.text').text().toLowerCase().indexOf(query.toLowerCase()) != -1) {
ui.Finder.matched_ids.push('#'+tweet_li.attr('id'));
}
}
});
return this;
},
next_result:
function next_result() {
ui.Finder.current_pos += 1;
if (ui.Finder.current_pos >= ui.Finder.matched_ids.length) {
ui.Finder.current_pos = 0;
}
if (ui.Finder.matched_ids.length != 0) {
var id = ui.Finder.matched_ids[ui.Finder.current_pos];
ui.Slider.slide_to(id.split('-')[0].substring(1));
ui.Main.move_to_tweet(id);
}
if (ui.Finder.matched_ids.length == 0) {
$('#finder_matched_info').text('0 of 0');
} else {
$('#finder_matched_info').text((ui.Finder.current_pos+1)
+ ' of '
+ ui.Finder.matched_ids.length);
}
},
prev_result:
function prev_result() {
ui.Finder.current_pos -= 1;
if (ui.Finder.current_pos < 0) {
ui.Finder.current_pos = ui.Finder.matched_ids.length - 1;
}
if (ui.Finder.matched_ids.length != 0) {
var id = ui.Finder.matched_ids[ui.Finder.current_pos];
ui.Slider.slide_to(id.split('-')[0].substring(1));
ui.Main.move_to_tweet(id);
}
if (ui.Finder.matched_ids.length == 0) {
$('#finder_matched_info').text('0 of 0');
} else {
$('#finder_matched_info').text((ui.Finder.current_pos+1)
+ ' of '
+ ui.Finder.matched_ids.length);
}
},
clear:
function clear() {
$('#finder_matched_info').text('0 of 0');
$(ui.Finder.tbox).val('');
ui.Finder.query = '';
ui.Finder.matched_ids = [];
ui.Finder.current_pos = 0;
return this;
},
show:
function show() {
$(ui.Finder.id).show();
$(ui.Finder.tbox).focus();
return this;
},
hide:
function hide() {
ui.Finder.finding = false;
$(ui.Finder.id).hide();
$(ui.Finder.tbox).blur();
return this;
}
};
|