2017-12-05 13:50:04 +03:00
|
|
|
// Copyright 2016-2017 Sudnitsyna Anna lessmore.pw
|
2017-12-06 16:46:04 +03:00
|
|
|
// Copyright 2017 Denis Zheleztsov lessmore.pw
|
2017-12-05 13:50:04 +03:00
|
|
|
// Licensed under GPLv3
|
2017-02-14 13:14:17 +03:00
|
|
|
var html = '';
|
|
|
|
var options = '';
|
|
|
|
var checks = '';
|
|
|
|
var echo = '';
|
2017-12-05 13:50:04 +03:00
|
|
|
var author = '';
|
2017-02-14 13:14:17 +03:00
|
|
|
var this_page = 1;
|
|
|
|
var show_rows = 5;
|
|
|
|
var from = 0;
|
2017-12-11 13:15:42 +03:00
|
|
|
var thread = '';
|
2017-02-14 13:14:17 +03:00
|
|
|
|
|
|
|
//var date = new Date(new Date().getTime() + 60 * 1000);
|
|
|
|
var date = new Date;
|
|
|
|
date.setDate(date.getDate() + 7);
|
|
|
|
var echo = document.cookie;
|
|
|
|
|
2017-12-05 17:52:23 +03:00
|
|
|
hash = parseLocationHash();
|
|
|
|
if (hash.matched) {
|
|
|
|
console.log("We are here");
|
|
|
|
requestMessage(hash.hash);
|
|
|
|
}
|
2017-02-14 13:14:17 +03:00
|
|
|
|
|
|
|
$(function() {
|
2017-02-15 18:52:40 +03:00
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
//extentions
|
|
|
|
$.ajax({
|
|
|
|
url:"https://dynamic.lessmore.pw/idec/x/features",
|
|
|
|
success:function(data) {
|
|
|
|
$("#extentions").html("<b>" + data.replace("\n","<br>") + "</b>");
|
|
|
|
}
|
|
|
|
})
|
2017-12-05 17:52:23 +03:00
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
//initial load
|
|
|
|
if (echo != '') {
|
|
|
|
requestEcho();
|
|
|
|
} else {
|
|
|
|
requestEmptyEcho();
|
|
|
|
}
|
2017-12-05 17:52:23 +03:00
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
//create echoes list
|
2017-02-15 18:52:40 +03:00
|
|
|
$.ajax({
|
2017-12-05 13:50:04 +03:00
|
|
|
url: "https://dynamic.lessmore.pw/search",
|
|
|
|
type: "POST",
|
2017-12-05 22:18:14 +03:00
|
|
|
data: '{"sort": [{ "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"aggs": {"my_fields": { "terms": { "field": "echo","size": 1000}}}}}',
|
2017-12-11 13:15:42 +03:00
|
|
|
contentType: "application/json",
|
|
|
|
success: function(messages) {
|
|
|
|
var select = '';
|
2017-12-05 22:18:14 +03:00
|
|
|
for (i in messages['aggregations']['my_fields']['buckets']) {
|
|
|
|
var msg = messages['aggregations']['my_fields']['buckets'][i]['key'];
|
|
|
|
var doc_count = messages['aggregations']['my_fields']['buckets'][i]['doc_count'];
|
|
|
|
|
2017-12-11 13:15:42 +03:00
|
|
|
select += '<option value="' + msg + '">' + msg + " (<b>" + doc_count + "</b>)</option>";
|
|
|
|
|
2017-12-05 22:18:14 +03:00
|
|
|
msg_test = msg + " ";
|
|
|
|
echo_test = echo + " ";
|
|
|
|
if((echo_test).indexOf(msg_test) > -1 && echo != '') {
|
|
|
|
options += '<option value="' + msg + '" selected>' + msg + " (<b>" + doc_count + "</b>)</option>";
|
|
|
|
checks += '<span class="row"><input type="checkbox" class="echoes" name="ec" value="' + msg + '" checked><label>'
|
|
|
|
+ msg
|
|
|
|
+ '</label> <span style="color:#838784">('+ doc_count
|
|
|
|
+ ')</span><br></span>';
|
|
|
|
} else {
|
|
|
|
options += '<option value="' + msg + '" >' + msg + " (<b>" + doc_count + "</b>)</option>";
|
|
|
|
checks += '<span class="row"><input type="checkbox" class="echoes" name="ec" value="' + msg + '"><label>'
|
|
|
|
+ msg
|
|
|
|
+ '</label> <span style="color:#838784">('+ doc_count
|
2017-12-11 13:15:42 +03:00
|
|
|
+ ')</span><br></span>';
|
|
|
|
}
|
2017-12-05 22:18:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$('#echoSelected').html("Выбранные эхи: " + document.cookie);
|
|
|
|
$('#echoSelector').html(options);
|
2017-12-11 13:15:42 +03:00
|
|
|
$('#echoCheckBox').html(checks);
|
|
|
|
// $('#echoSelect').html(select);
|
|
|
|
$('select').multipleSelect();
|
|
|
|
}
|
|
|
|
|
2017-02-14 13:14:17 +03:00
|
|
|
})
|
2017-12-05 13:50:04 +03:00
|
|
|
|
|
|
|
$('.echoes:checked').each(function() {
|
|
|
|
echo = '';
|
|
|
|
echo += $(this).val()[i] + " ";
|
|
|
|
});
|
|
|
|
|
|
|
|
var boxes = $("input[type=checkbox]");
|
|
|
|
|
|
|
|
$("#echoCheckBox").on('change', function() {
|
|
|
|
echo = '';
|
|
|
|
for (var i=0; i<$("input[type=checkbox]:checked").length; i++) {
|
|
|
|
echo += $("input[type=checkbox]:checked")[i]["defaultValue"] + " ";}
|
|
|
|
document.cookie = echo +"; path=/; expires=" + date.toUTCString();
|
|
|
|
$('#echoSelected').html("Выбранные эхи: " + echo);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#echoSelector').on('change', function() {
|
2017-12-12 15:01:49 +03:00
|
|
|
if (!hash.matched) {
|
|
|
|
echo = '';
|
|
|
|
html = '';
|
|
|
|
for (i in $(this).val()) {
|
|
|
|
echo += $(this).val()[i] + " ";
|
|
|
|
console.log($(this).val()[i]);
|
|
|
|
}
|
|
|
|
document.cookie = echo +"; path=/; expires=" + date.toUTCString();
|
|
|
|
requestEcho();
|
|
|
|
$('#echoSelected').html("Выбранные эхи: " + echo)
|
2017-12-05 13:50:04 +03:00
|
|
|
|
2017-12-12 15:01:49 +03:00
|
|
|
if (echo == "") requestEmptyEcho();
|
|
|
|
}
|
2017-12-05 13:50:04 +03:00
|
|
|
});
|
|
|
|
|
2017-12-05 22:18:14 +03:00
|
|
|
$('#searchInput').on('change', function() {
|
|
|
|
text = $(this).val();
|
|
|
|
simpleTextSearch(text);
|
|
|
|
})
|
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
//scroll to show more messages
|
|
|
|
$(window).scroll(function() {
|
2017-12-05 17:52:23 +03:00
|
|
|
hash = parseLocationHash();
|
2017-02-15 18:52:40 +03:00
|
|
|
// console.log($(document).height() - $(window).height()-$(window).scrollTop());
|
2017-12-12 15:01:49 +03:00
|
|
|
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5 && !hash.matched) {
|
2017-02-15 18:52:40 +03:00
|
|
|
showMore();
|
|
|
|
//console.log($(document).height() - $(window).height() - $(window).scrollTop());
|
2017-12-12 15:01:49 +03:00
|
|
|
}
|
2017-12-05 13:50:04 +03:00
|
|
|
});
|
2017-02-15 18:52:40 +03:00
|
|
|
}) //end of .ready() method
|
2017-02-14 13:14:17 +03:00
|
|
|
|
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
// Main AJAX function
|
2017-02-15 18:52:40 +03:00
|
|
|
function ajaxRequest(data) {
|
|
|
|
$.ajax({
|
2017-12-05 13:50:04 +03:00
|
|
|
url:"https://dynamic.lessmore.pw/search",
|
|
|
|
type:"POST",
|
|
|
|
data: data,
|
2017-12-11 13:15:42 +03:00
|
|
|
contentType: "application/json",
|
2017-12-05 13:50:04 +03:00
|
|
|
success:function(messages){
|
|
|
|
callback(messages);
|
|
|
|
$("#mes").html(html);
|
|
|
|
}
|
2017-02-15 18:52:40 +03:00
|
|
|
})
|
2017-12-05 13:50:04 +03:00
|
|
|
}
|
2017-02-14 13:14:17 +03:00
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
// Cleanup AJAX function
|
|
|
|
function ajaxCleanupRequest(data) {
|
|
|
|
$.ajax({
|
|
|
|
url:"https://dynamic.lessmore.pw/search",
|
|
|
|
type:"POST",
|
|
|
|
data: data,
|
|
|
|
success:function(messages){
|
|
|
|
cleanupCallback(messages);
|
|
|
|
$("#mes").html(html);
|
|
|
|
}
|
|
|
|
})
|
2017-02-15 18:52:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function requestEmptyEcho() {
|
|
|
|
var data = '{"sort": [{"date": {"order": "desc"}}, {"_score": {"order": "desc" }}], "size": 5}';
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function requestEcho() {
|
|
|
|
var data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": {"query_string" : {"fields": ["echo"], "query": "' + echo + '"}}, "size":' + 5 + '}';
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
|
|
|
|
2017-12-07 13:20:44 +03:00
|
|
|
function requestTmpEcho(e) {
|
|
|
|
echo = e;
|
|
|
|
html = '';
|
|
|
|
var data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": {"query_string" : {"fields": ["echo"], "query": "' + echo + '"}}, "size":' + 5 + '}';
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
function requestEmptyEchoOffset() {
|
|
|
|
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}';
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
function requestEchoOffset() {
|
|
|
|
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ show_rows + ', "from":'+ from + '}';
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
2017-02-14 13:14:17 +03:00
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
function requestAuthorOffset() {
|
|
|
|
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["author"], "query" :"' + author + '"}}, "size":'+ show_rows + ', "from":'+ from + '}';
|
|
|
|
echo = '';
|
|
|
|
console.log("Author offset");
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
2017-02-15 18:52:40 +03:00
|
|
|
|
2017-12-05 13:50:04 +03:00
|
|
|
function requestAuthorMessages(_author) {
|
|
|
|
author = _author;
|
|
|
|
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["author"], "query" :"' + author + '"}}, "size": 5 }';
|
|
|
|
html = '';
|
|
|
|
echo = '';
|
|
|
|
console.log(author);
|
|
|
|
console.log(data);
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
2017-02-15 18:52:40 +03:00
|
|
|
|
2017-12-05 17:52:23 +03:00
|
|
|
function requestMessage(msgid) {
|
|
|
|
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["msgid"], "query" :"' + msgid + '"}}, "size": 5 }';
|
|
|
|
console.log("Link to message: " + msgid);
|
|
|
|
html = '';
|
|
|
|
echo = '';
|
|
|
|
author = '';
|
|
|
|
ajaxRequest(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search functions
|
|
|
|
// ----------------
|
|
|
|
function simpleTextSearch(text) {
|
2017-12-12 14:06:32 +03:00
|
|
|
var data = '{"sort": [{"date": {"order": "desc"}},{"_score": {"order": "desc"}}],"query": {"query_string": {"query": "' + text + '"}},"size": 25,"highlight" : {"fields" : {"message": { "fragment_size" : 150, "number_of_fragments" : 3, "pre_tags" : ["<font color=\\"red\\">"], "post_tags" : ["</font>"], "highlight_query": { "bool": { "must": { "match": { "message": {"query": "' + text + '"} } } } } }}} }';
|
|
|
|
console.log(data);
|
2017-12-05 17:52:23 +03:00
|
|
|
html = '';
|
|
|
|
echo = '';
|
|
|
|
author = '';
|
2017-12-12 14:06:32 +03:00
|
|
|
searchRequest(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function searchRequest(data) {
|
|
|
|
$.ajax({
|
|
|
|
url:"https://dynamic.lessmore.pw/search",
|
|
|
|
type:"POST",
|
|
|
|
data: data,
|
|
|
|
contentType: "application/json",
|
|
|
|
success:function(messages){
|
|
|
|
callbackHS(messages);
|
|
|
|
$("#mes").html(html);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//show messages
|
|
|
|
function callbackHS(messages) {
|
|
|
|
var msgArray = messages["hits"]["hits"];
|
|
|
|
// console.log(msgArray);
|
|
|
|
|
|
|
|
for (hit in msgArray) {
|
2017-12-12 15:01:49 +03:00
|
|
|
hash = parseLocationHash();
|
2017-12-12 14:06:32 +03:00
|
|
|
var msgItem = msgArray[hit]['_source'];
|
|
|
|
var t = new Date(msgItem['date'] * 1000);
|
|
|
|
var msg = '';
|
2017-12-12 15:01:49 +03:00
|
|
|
|
|
|
|
if (hash.matched && msgItem['msgid'] == hash.hash) {
|
|
|
|
// // commentnsole.log(msgArray.length);
|
|
|
|
html += '<div class="hsMessage">';
|
|
|
|
}
|
|
|
|
|
2017-12-12 14:06:32 +03:00
|
|
|
// console.log(msgItem['date']);
|
|
|
|
// console.log(t);
|
|
|
|
var t_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
|
|
|
|
|
|
|
|
// msg = msgItem['message'].replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(new RegExp("\n",'g'), "<br>\n");
|
|
|
|
if ('highlight' in msgArray[hit]) {
|
2017-12-12 15:01:49 +03:00
|
|
|
msg = msgArray[hit]['highlight']['message'][0].replace(/&/g, '&').replace(/"/g, '"').replace(new RegExp("\n",'g'), "<br>\n") + '...';
|
2017-12-12 14:06:32 +03:00
|
|
|
} else {
|
|
|
|
msg = msgItem['message'].replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(new RegExp("\n",'g'), "<br>\n");
|
|
|
|
}
|
|
|
|
console.log(msg);
|
|
|
|
|
|
|
|
var to =
|
|
|
|
html += '<div class="msg">'
|
|
|
|
+ '<p align="left"><i class="fa fa-hourglass-half"></i> ' + t_formatted + '<i class="fa fa-angle-right"></i> <!--/p-->'
|
|
|
|
|
|
|
|
// Author to receiver
|
|
|
|
+ '<a style="text-decoration:underline; text-decoration-style:dotted;" title="' + msgItem["address"] + '" "href="javascript:void(0)" onclick="requestAuthorMessages(\'' + msgItem['author'] + '\');">' + msgItem['author'] + '</a>'
|
|
|
|
+ ' <i class="fa fa-angle-double-right"></i> '
|
|
|
|
+ '<a href="javascript:void(0)" onclick="requestAuthorMessages(\'' + msgItem['to'] + '\', true);">' + msgItem['to'] + '</a></p>'
|
|
|
|
|
|
|
|
// Header
|
|
|
|
+ ' <p style="color:#0099cc;font: 1.5em Open Sans, sans-serif;">'
|
|
|
|
+ '<a class="headerLink" href="javascript:void(0)" onclick="requestBuildThread(\'' + msgItem['msgid'] + '\', true)">'
|
|
|
|
+ msgItem['subg'] + '</a>'
|
|
|
|
+ ' <i class="fa fa-at"></i> <i><a class="headerLink" href="javascript:void(0)" onclick="requestTmpEcho(\'' + msgItem['echo'] + '\')">' + msgItem['echo']
|
|
|
|
+ '</a></i></p></p>'
|
|
|
|
+ '<p>' + msg.autoLink()
|
|
|
|
+ '</p><p align="right">'
|
|
|
|
|
|
|
|
// Msgid
|
|
|
|
+ '<a href="?' + msgItem['msgid'] +'" onclick="requestMessage(\'' + msgItem['msgid'] + '\');"><i class="fa fa-link"></i>' + msgItem['msgid'] + '</a></p></div>';
|
2017-12-12 15:01:49 +03:00
|
|
|
|
|
|
|
if (hash.matched && msgItem['msgid'] == hash.hash) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
2017-12-12 14:06:32 +03:00
|
|
|
}
|
2017-12-05 17:52:23 +03:00
|
|
|
}
|
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
//show messages
|
2017-12-05 17:52:23 +03:00
|
|
|
function callback(messages) {
|
2017-02-15 18:52:40 +03:00
|
|
|
var msgArray = messages["hits"]["hits"];
|
2017-12-11 13:15:42 +03:00
|
|
|
// console.log(msgArray);
|
2017-12-12 15:01:49 +03:00
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
for (hit in msgArray) {
|
2017-12-12 15:01:49 +03:00
|
|
|
hash = parseLocationHash();
|
2017-02-15 18:52:40 +03:00
|
|
|
var msgItem = msgArray[hit]['_source'];
|
2017-12-11 16:50:53 +03:00
|
|
|
var t = new Date(msgItem['date'] * 1000);
|
2017-12-11 13:15:42 +03:00
|
|
|
// console.log(msgItem['date']);
|
|
|
|
// console.log(t);
|
2017-02-15 18:52:40 +03:00
|
|
|
var t_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
|
2017-12-12 15:01:49 +03:00
|
|
|
|
|
|
|
if (hash.matched && msgItem['msgid'] == hash.hash) {
|
|
|
|
html += '<div class="hsMessage">';
|
|
|
|
}
|
2017-12-05 13:50:04 +03:00
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
msg = msgItem['message'].replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(new RegExp("\n",'g'), "<br>\n");
|
2017-12-05 13:50:04 +03:00
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
var to =
|
2017-12-06 17:15:11 +03:00
|
|
|
html += '<div class="msg">'
|
2017-12-06 17:30:02 +03:00
|
|
|
+ '<p align="left"><i class="fa fa-hourglass-half"></i> ' + t_formatted + '<i class="fa fa-angle-right"></i> <!--/p-->'
|
2017-12-06 17:15:11 +03:00
|
|
|
|
|
|
|
// Author to receiver
|
2017-12-11 13:15:42 +03:00
|
|
|
+ '<a style="text-decoration:underline; text-decoration-style:dotted;" title="' + msgItem["address"] + '" "href="javascript:void(0)" onclick="requestAuthorMessages(\'' + msgItem['author'] + '\');">' + msgItem['author'] + '</a>'
|
2017-12-06 17:15:11 +03:00
|
|
|
+ ' <i class="fa fa-angle-double-right"></i> '
|
2017-12-07 13:20:44 +03:00
|
|
|
+ '<a href="javascript:void(0)" onclick="requestAuthorMessages(\'' + msgItem['to'] + '\', true);">' + msgItem['to'] + '</a></p>'
|
2017-12-06 17:15:11 +03:00
|
|
|
|
2017-12-07 13:25:54 +03:00
|
|
|
// Header
|
2017-12-06 17:15:11 +03:00
|
|
|
+ ' <p style="color:#0099cc;font: 1.5em Open Sans, sans-serif;">'
|
2017-12-11 13:15:42 +03:00
|
|
|
+ '<a class="headerLink" href="javascript:void(0)" onclick="requestBuildThread(\'' + msgItem['msgid'] + '\', true)">'
|
|
|
|
+ msgItem['subg'] + '</a>'
|
|
|
|
+ ' <i class="fa fa-at"></i> <i><a class="headerLink" href="javascript:void(0)" onclick="requestTmpEcho(\'' + msgItem['echo'] + '\')">' + msgItem['echo']
|
|
|
|
+ '</a></i></p></p>'
|
2017-12-06 17:15:11 +03:00
|
|
|
+ '<p>' + msg.autoLink()
|
2017-12-05 13:50:04 +03:00
|
|
|
+ '</p><p align="right">'
|
2017-12-07 13:25:54 +03:00
|
|
|
|
|
|
|
// Msgid
|
2017-12-11 13:15:42 +03:00
|
|
|
+ '<a href="?' + msgItem['msgid'] +'" onclick="requestMessage(\'' + msgItem['msgid'] + '\');"><i class="fa fa-link"></i>' + msgItem['msgid'] + '</a></p></div>';
|
2017-12-12 15:01:49 +03:00
|
|
|
|
|
|
|
if (hash.matched && msgItem['msgid'] == hash.hash) {
|
|
|
|
html += '</div>';
|
|
|
|
}
|
2017-12-06 16:46:04 +03:00
|
|
|
}
|
2017-12-05 13:50:04 +03:00
|
|
|
}
|
|
|
|
|
2017-02-14 13:14:17 +03:00
|
|
|
//show more messages
|
|
|
|
function showMore(){
|
2017-12-05 13:50:04 +03:00
|
|
|
console.log("Show more messages, please.");
|
|
|
|
console.log("Selected echo: " + echo);
|
|
|
|
console.log("Selected author: " + author);
|
2017-02-14 13:14:17 +03:00
|
|
|
this_page += 1;
|
|
|
|
from += show_rows;
|
2017-12-05 13:50:04 +03:00
|
|
|
if (author != '') {
|
|
|
|
requestAuthorOffset();
|
|
|
|
} else if (echo != '') {
|
2017-02-15 18:52:40 +03:00
|
|
|
requestEchoOffset();
|
2017-02-14 13:14:17 +03:00
|
|
|
} else {
|
2017-12-05 13:50:04 +03:00
|
|
|
requestEmptyEchoOffset();
|
2017-02-14 13:14:17 +03:00
|
|
|
}
|
2017-02-15 18:52:40 +03:00
|
|
|
}
|
2017-02-14 13:14:17 +03:00
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
function searchEcho() {
|
2017-12-05 13:50:04 +03:00
|
|
|
var input, filter, box, row;
|
|
|
|
input = $("#myInput").val();
|
|
|
|
input = input.toLowerCase();
|
|
|
|
|
|
|
|
box = $("label");
|
|
|
|
row = $(".row");
|
|
|
|
|
|
|
|
for (i = 0; i<box.length; i++) {
|
|
|
|
if (box[i].innerHTML.indexOf(input) > -1) {
|
|
|
|
row[i].style.display = "";
|
|
|
|
} else {
|
|
|
|
row[i].style.display = "none";
|
|
|
|
}
|
2017-02-15 18:52:40 +03:00
|
|
|
}
|
2017-02-14 13:14:17 +03:00
|
|
|
}
|
|
|
|
|
2017-12-11 13:15:42 +03:00
|
|
|
// Thread building
|
|
|
|
function ajaxThreadRequest(data) {
|
|
|
|
$.ajax({
|
|
|
|
url:"https://dynamic.lessmore.pw/search",
|
|
|
|
type:"POST",
|
|
|
|
data: data,
|
|
|
|
contentType: "application/json",
|
|
|
|
success: function(messages) {
|
|
|
|
requestBuildThread(messages, false);
|
|
|
|
$("#mes").html(html);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function requestBuildThread(msg, init) {
|
|
|
|
var data = ''
|
|
|
|
if (init) {
|
|
|
|
console.log("We are here;");
|
|
|
|
html = '';
|
|
|
|
thread = [];
|
|
|
|
var data = '{"query": {"query_string" : {"fields" : ["msgid"], "query" :"' + msg + '"}}';
|
|
|
|
} else {
|
|
|
|
var data = messages["hits"]["hits"][0]["_source"]["msgid"];
|
|
|
|
}
|
|
|
|
}
|
2017-02-14 13:14:17 +03:00
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
function clearFilter() {
|
|
|
|
document.cookie = "";
|
2017-02-14 13:14:17 +03:00
|
|
|
}
|
|
|
|
|
2017-02-15 18:52:40 +03:00
|
|
|
function showMenu() {
|
|
|
|
if ($("#dropdown-content").css("display") == "none") {
|
|
|
|
$("#dropdown-content").css("display","block");
|
|
|
|
} else {
|
|
|
|
$("#dropdown-content").css("display","none");
|
|
|
|
}
|
2017-02-14 13:14:17 +03:00
|
|
|
}
|
2017-02-15 18:52:40 +03:00
|
|
|
|
2017-12-05 22:18:14 +03:00
|
|
|
function showSearch() {
|
|
|
|
if ($("#searchInput").css("display") == "none") {
|
|
|
|
$("#searchInput").css("display","block");
|
|
|
|
} else {
|
|
|
|
$("#searchInput").css("display","none");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-05 17:52:23 +03:00
|
|
|
|
|
|
|
// Parsing functions
|
|
|
|
function parseLocationHash() {
|
|
|
|
var hash = window.location.search.replace(/\?/, "");
|
|
|
|
if (hash) {
|
|
|
|
if (hash.match(/(.{20})/)) {
|
|
|
|
console.log("Matched! " + hash);
|
|
|
|
return {matched: true, hash: hash};
|
|
|
|
} else {
|
|
|
|
return {matched: false};
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return {matched: false};
|
|
|
|
}
|
|
|
|
}
|