Link to message

This commit is contained in:
Denis Zheleztsov 2017-12-05 17:52:23 +03:00
parent 603083b705
commit 98b021e27b
3 changed files with 77 additions and 18 deletions

View File

@ -7,7 +7,8 @@
<link rel="stylesheet" href="css/style.css">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/script.js"></script>
<script src="js/autolink.js"></script>
<script src="js/autolink.js"></Script>
<!-- <script src="https://unpkg.com/vue"></script> -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
@ -20,16 +21,15 @@
<a href="lessmorefaq.html">FAQ</a>
<a href="stats.html">Статистика</a>
</div>
<a href = "" style="text-decoration: none; color: #babdb6;"><u>dynamic</u> | <u>less</u></a>
<a href="/" style="text-decoration: none; color: #babdb6;"><u>dynamic</u> | <u>less</u></a>
</div>
<form><select id="echoSelector" multiple size="5"></select></form>
<form><select id="echoSelector" multiple size="5"></select></form>
<div id="echoSelected"></div>
<div id="mes"></div>
<div id = "preloader" align="center">
<div id="preloader" align="center">
<img src="/img/preload.gif" onclick="showMore()" height="20em">
</div>

View File

@ -14,6 +14,11 @@ var date = new Date;
date.setDate(date.getDate() + 7);
var echo = document.cookie;
hash = parseLocationHash();
if (hash.matched) {
console.log("We are here");
requestMessage(hash.hash);
}
$(function() {
@ -24,14 +29,14 @@ $(function() {
$("#extentions").html("<b>" + data.replace("\n","<br>") + "</b>");
}
})
//initial load
if (echo != '') {
requestEcho();
} else {
requestEmptyEcho();
}
//create echoes list
$.ajax({
url: "https://dynamic.lessmore.pw/search",
@ -91,10 +96,16 @@ $(function() {
if (echo == "") requestEmptyEcho();
});
// $('#searchInput').on('change', function() {
// text = $(this).val();
// simpleTextSearch(text);
// })
//scroll to show more messages
$(window).scroll(function() {
hash = parseLocationHash();
// console.log($(document).height() - $(window).height()-$(window).scrollTop());
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5) {
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5 && hash.matched != true) {
showMore();
//console.log($(document).height() - $(window).height() - $(window).scrollTop());
}
@ -110,7 +121,6 @@ function ajaxRequest(data) {
type:"POST",
data: data,
success:function(messages){
console.log(messages);
callback(messages);
$("#mes").html(html);
}
@ -168,10 +178,31 @@ function requestAuthorMessages(_author) {
ajaxRequest(data);
}
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) {
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"query" :"' + text + '"}}, "size": 25 }';
console.log(text);
html = '';
echo = '';
author = '';
ajaxRequest(data);
}
//show messages
function callback(messages) {
function callback(messages) {
var msgArray = messages["hits"]["hits"];
console.log(msgArray);
for (hit in msgArray) {
var msgItem = msgArray[hit]['_source'];
var t = new Date(msgItem['date'] * 1);
@ -186,14 +217,13 @@ function callback(messages) {
+ '<br>To: ' + '<a href="#" onclick="requestAuthorMessages(\'' + msgItem['to'] + '\', true);">' + msgItem['to'] + '</a>'
+ '</p><p>' + msg.autoLink()
+ '</p><p align="right">'
+ msgItem['msgid'] + '</a>' + '</p></div>';
+ '<a href="?' + msgItem['msgid'] +'" onclick="requestMessage(\'' + msgItem['msgid'] + '\');">#' + msgItem['msgid'] + '</a></p></div>';
}
}
// Clenaup HTML and show messages
function cleanupCallback(messages) {
var msgArray = messages["hits"]["hits"];
console.log(msgArray);
for (hit in msgArray) {
var msgItem = msgArray[hit]['_source'];
var t = new Date(msgItem['date'] * 1);
@ -259,3 +289,18 @@ function showMenu() {
}
}
// 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};
}
}

View File

@ -7,15 +7,29 @@
"contacts": {
"email": "difrex.punk@gmail.com",
"web": "https://github.com/Difrex"
},
"description": "IDEC network aggregator. Please email me for indexing your node.",
"uplinks": [
["http://ii-net.tk/ii/ii-point.php?q=/", "15m"],
["http://idec.spline-online.tk/", "15m"],
["http://spline.rooker.ru/ii/ii-point.php?q=/", "15m"],
["http://irk39.tk/ii-point.php?q=/", "15m"],
["http://ii.club.syscall.ru/", "15m"]
[
"http://ii-net.tk/ii/ii-point.php?q=/",
"15m"
],
[
"http://idec.spline-online.tk/",
"15m"
],
[
"http://spline.rooker.ru/ii/ii-point.php?q=/",
"15m"
],
[
"http://irk39.tk/ii-point.php?q=/",
"15m"
],
[
"http://ii.club.syscall.ru/",
"15m"
]
]
}
]