Hs initial

This commit is contained in:
Denis Zheleztsov 2017-12-12 14:06:32 +03:00
parent 6fa2859631
commit bbf5057081

View File

@ -117,12 +117,11 @@ $(function() {
$(window).scroll(function() {
hash = parseLocationHash();
// console.log($(document).height() - $(window).height()-$(window).scrollTop());
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5 && hash.matched != true) {
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5 && !(hash.matched)) {
showMore();
//console.log($(document).height() - $(window).height() - $(window).scrollTop());
}
});
}) //end of .ready() method
@ -210,12 +209,80 @@ function requestMessage(msgid) {
// Search functions
// ----------------
function simpleTextSearch(text) {
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"query" :"' + text + '"}}, "size": 25 }';
console.log(text);
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);
html = '';
echo = '';
author = '';
ajaxRequest(data);
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);
if (msgArray.length == 1) {
// console.log(msgArray.length);
html += '<div class="hsMessage">';
} else {
single = 0;
}
for (hit in msgArray) {
var msgItem = msgArray[hit]['_source'];
var t = new Date(msgItem['date'] * 1000);
var msg = '';
// 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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(new RegExp("\n",'g'), "<br>\n");
if ('highlight' in msgArray[hit]) {
msg = msgArray[hit]['highlight']['message'][0].replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(new RegExp("\n",'g'), "<br>\n");
} else {
msg = msgItem['message'].replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').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>';
}
if (msgArray.length == 1) {
html += '</div>';
console.log(html);
}
}
//show messages
@ -260,7 +327,6 @@ function callback(messages) {
}
if (msgArray.length == 1) {
html += '</div>';
console.log(html);
}
}