This commit is contained in:
Anna Sudnitsina 2017-02-14 13:14:17 +03:00
parent fafd76561d
commit fa02fa8e42
11 changed files with 920 additions and 140 deletions

85
css/style.css Normal file
View File

@ -0,0 +1,85 @@
@media screen and (max-width: 600px){
.lessmore {right: 0px;
font-size: 20pt;
}
select {height: 50px}
.msg {padding: 0; margin: 0}
}
#menu {display: block;
position: absolute;
right: 10px;
top: 17px;
font-size:0.7em}
body {
background-color: #2E3436;
color: #eeeeec;
font-family: "Arial", sans-serif;
font-size: 1em;
}
a, a:visited, a:active {
color: #eeeeec;
//border-bottom: 1px #eeeeec dotted;
text-decoration-style: dotted;
}
//#faq {display: block;
// position: absolute; left: 10px; top: 17px; font-size:0.7em}
//#menu{display:none}
.msg {
display: block; margin: 1em 0;
background-color:#272C2D;
padding: 1.5em 3em 1.5em;
word-wrap: break-word;
}
.lessmore {
display: block;
color: #babdb6;
position:fixed;
top: 0px;
height:70px;
width:100%;
text-decoration: none;
margin-bottom: 5pt;
text-align: center;
font-size: 40pt;
background-color: #2E3436;
border-bottom: none;
}
#faq {margin: 80px 0 0;
}
select {
padding:9px 0;
margin: 80px 0 0;
width: 100%;
color:#000;
border:1px solid transparent;
border-bottom:1px solid #009688;
font-size: 1em;}
#dropdown-content {
display: none;
position:absolute;
right: 0;
top: 70px;
height: auto;
width: 300px;
background-color:#2E3436;
//padding: 20px;
font-size: 0.5em;
z-index:1;
}
#dropdown-content>a {
border:1px solid #eeeeec;
display: block;
padding: 10px
}

50
css/style.css~ Normal file
View File

@ -0,0 +1,50 @@
@media screen and (max-width: 600px){
select {
}
}
body {
background-color: #2E3436;
color: #eeeeec;
font-family: "Arial", sans-serif;
font-size: 1.5em;
}
.msg {
display: block; margin: 1em 0;
background-color:#272C2D; padding: 1.5em 3em 1.5em;
word-wrap: break-word;
}
.lessmore {
display: block;
color: #babdb6;
position:fixed;
top: 0px;
height:70px;
width:100%;
text-align: center;
font-size: 40pt;
background-color: #2E3436;
}
#paginator {color: #FFFFFF;
display: inline-block;
padding: 15px 0;
cursor:pointer; background-color:#272C2D; width: 100%;
}
select {
padding:9px 0;
margin: 80px 0 0;
width: 100%;
color:#000;
border:1px solid transparent;
border-bottom:1px solid #009688;
font-size: 1em;}
option {}

53
filter.html Normal file
View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<title>dynamic|LESS</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.7">
<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>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="lessmore">
<a id="menu" href="javascript:void(0)" onclick="showMenu()"><i class="fa fa-bars"></i></a>
<div id="dropdown-content">
<a href="/">На главную</a>
<a href="/" onclick="clearFilter()">Сбросить фильтр</a>
<a href="/lessmorefaq.html">FAQ</a>
</div>
<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-->
<div id="echoSelected"style="margin:100px 0 0"></div>
<input type="text" placeholder="Search..." id="myInput" onkeyup="searchEcho()">
<div id="echoCheckBox"></div>
<!--div id="mes"></div>
<div align="center" >
<img src="/img/preload.gif" onclick="showMore()" height="20em"> </div-->
<!--div id="paginator" align="center" onclick="showMore()">Show more</div-->
</body>
<script>
function searchEcho() {
var input, filter, box, row;
input = $("#myInput").val();
input = input.toLowerCase();
box = $("label");
row = $(".row");
console.log(box);
for (i = 0; i<box.length; i++) {
if (box[i].innerHTML.indexOf(input) > -1) {
row[i].style.display = "";
} else {
row[i].style.display = "none";
}
}
}
</script>
</html>

BIN
img/30.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
img/preload.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

View File

@ -3,149 +3,29 @@
<head>
<title>dynamic|LESS</title>
<meta charset="utf-8">
<style>
body {
background-color: #2E3436;
color: #eeeeec;
font-family: "Arial", sans-serif;
}
.lessmore {
display: block;
color: #babdb6;
text-align: center;
font-size: 40pt;
}
#paginator a {color: #FFFFFF; display: inline-block; margin: 10px}
select {padding:9px 0; margin: 10px 0; width:100%;color:#000;border:1px solid transparent;border-bottom:1px solid #009688}
</style>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=0.7">
<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>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="lessmore"><u>dynamic</u> | <u>less</u></div>
<div class="lessmore">
<a id="menu" href="javascript:void(0)" onclick="showMenu()"><i class="fa fa-bars"></i></a>
<div id="dropdown-content">
<a href="/filter.html">Настроить фильтр</a>
<a href="/" onclick="clearFilter()">Сбросить фильтр</a>
<a href="/lessmorefaq.html">FAQ</a>
</div>
<a href = "" style="text-decoration: none; color: #babdb6;"><u>dynamic</u> | <u>less</u></a>
</div>
<!--a href = "javascript:void(0)" onclick="filterByEcho()">Filter</a-->
<form><select id="echoSelector"></select></form>
<form><select id="echoSelector" multiple size="5"></select></form>
<div id="echoSelected"></div>
<div id="mes"></div>
<div id="paginator" align="center"></div>
<script type='text/javascript'>
//initial load
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
var html = '';
//show messages
function callback(messages) {
var huinya = 'wtf??';
console.log(messages);
for (hit in messages["hits"]["hits"]) {
var t = new Date(messages['hits']['hits'][hit]['_source']['date'] * 1000);
var t_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
html += ' <p><b>'
+ messages['hits']['hits'][hit]['_source']['subg']
+ '</b><br><i>Date: ' + t_formatted
+ '</i><br> WTF??: ' +
+ huinya + '<br>Echo: '
+ messages['hits']['hits'][hit]['_source']['echo']
+ '<br>Author: '
+ messages['hits']['hits'][hit]['_source']['author']
+ '<br>To: '
+ messages['hits']['hits'][hit]['_source']['to']
+ '<br>'
+ messages['hits']['hits'][hit]['_source']['message']
+ '<br>ID: '
+ messages['hits']['hits'][hit]['_source']['_id']
+ '<br>Msgid: '
+ messages['hits']['hits'][hit]['_source']['msgid'] + '<br></p>' ;
}
}
var from = 0;
var options = '';
//create echoes list
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"aggs": {"my_fields": { "terms": { "field": "echo","size": 1000}}}}}',
success:function(messages){for (i in messages['aggregations']['my_fields']['buckets']){options += '<option>' + messages['aggregations']['my_fields']['buckets'][i]['key'] + '</option>'};
$('#echoSelector').html(options);}
})
//show msgs when echo is selected
var echo = '';
$('#echoSelector').on('change', function() {
console.log($(this).val());
echo = $(this).val();
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data:'{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":5}',
success:function(messages){html = ''; callback(messages);$("#mes").html(html);
}
});
});
function filterByEcho() {
console.log('func');
var author = "(echo:develop.16)";
var from = 0;
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["author"], "query" : "Andrew Lobanov"}}, "size":5}',
success:function(messages){html=''; callback(messages); $("#mes").html(html);
}
})
}
var this_page = 1;
var show_rows = 5;
var from = 0;
$("#paginator").html('<a href="javascript:void(0)" onclick="showMore()">Show more</a>');
function showMore(){
this_page += 1;
from += show_rows;
var author = "(author:Difrex)";
if (echo != '') {
console.log("im here");
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
} else {
console.log ("or here?");
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
}
}
</script>
</body>
<div align="center" >
<div id = "preloader"> <img src="/img/preload.gif" onclick="showMore()" height="20em"> </div></div>
<!--div id="paginator" align="center" onclick="showMore()">Show more</div-->
</body>
</html>

218
js/script.js Normal file
View File

@ -0,0 +1,218 @@
var html = '';
var options = '';
var checks = '';
var echo = '';
var this_page = 1;
var show_rows = 5;
var from = 0;
function clearFilter(){
document.cookie = "";
console.log("test");
}
function showMenu() {
console.log($("#dropdown-content").css("display"));
if($("#dropdown-content").css("display") == "none") {
$("#dropdown-content").css("display","block");
}else {
$("#dropdown-content").css("display","none");
}
console.log("Menu");
}
//var date = new Date(new Date().getTime() + 60 * 1000);
var date = new Date;
date.setDate(date.getDate() + 7);
var echo = document.cookie;
console.log("echo: " + echo);
console.log("cookie: " + document.cookie);
if("lenta.rss".indexOf(echo) > -1 ) {
console.log(echo);}
//console.log("echoes: "+ echo );
$(function() {
//extentions
$.ajax({
url:"https://dynamic.lessmore.pw/idec/x/features",
success:function(data){console.log(data); $("#extentions").html("<b>" + data.replace("\n","<br>") + "</b>")}
})
//initial load
if (echo != '') {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);
}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
}
//create echoes list
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"aggs": {"my_fields": { "terms": { "field": "echo","size": 1000}}}}}',
success:function(messages){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'];
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
+ ')</span><br></span>';}
}
$('#echoSelected').html("Выбранные эхи: " + document.cookie);
$('#echoSelector').html(options);
$('#echoCheckBox').html(checks);}
})
//show msgs when echo is selected
$('.echoes:checked').each(function() {
echo = '';
console.log(echo);
echo += $(this).val()[i] + " ";
});
var boxes = $("input[type=checkbox]");
$("#echoCheckBox").on('change', function() {
echo = '';
console.log($("input[type=checkbox]:checked")[0]["defaultValue"]);
console.log($("input[type=checkbox]:checked").length);
for (var i=0; i<$("input[type=checkbox]:checked").length; i++) {
console.log($("input[type=checkbox]:checked")[i]["defaultValue"]);
echo += $("input[type=checkbox]:checked")[i]["defaultValue"] + " ";}
document.cookie = echo +"; path=/; expires=" + date.toUTCString();
//echo += $(this).val()[i] + " "};
//console.log(echo);
$('#echoSelected').html("Выбранные эхи: " + echo);
});
$('#echoSelector').on('change', function() {
echo = '';
for (i in $(this).val()) {echo += $(this).val()[i] + " "};
document.cookie = echo +"; path=/; expires=" + date.toUTCString();
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data:'{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":5}',
success:function(messages){html = ''; callback(messages);$("#mes").html(html);$('#echoSelected').html("Выбранные эхи: " + echo); }
});
});
//scroll
$(window).scroll(function() {
// console.log($(document).height() - $(window).height()-$(window).scrollTop());
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5) {
showMore();
//console.log($(document).height() - $(window).height() - $(window).scrollTop());
}
});
})
//show more messages
function showMore(){
this_page += 1;
from += show_rows;
var author = "(author:Difrex)";
if (echo != '') {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages);
$("#mes").html(html);
// if(messages.hits.hits.length == 0){$("#preloader")[0].style.display = "none"} else {$("#preloader").css("display", "block")}
}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html); }
})
}
}
//show messages
function callback(messages) {
for (hit in messages["hits"]["hits"]) {
var t = new Date(messages['hits']['hits'][hit]['_source']['date'] * 1000);
var t_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
// Replace new line with <br>
msg = messages['hits']['hits'][hit]['_source']['message'].replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(new RegExp("\n",'g'), "<br>\n");
html += '<div class="msg"><p align="right">' + t_formatted + '</p> <p style="font-size: 1.5em; font-family: "Open Sans", sans-serif;">'
+ messages['hits']['hits'][hit]['_source']['subg']
+ '</p><p>Echo: '
+ messages['hits']['hits'][hit]['_source']['echo']
+ '<br>Author: '
+ messages['hits']['hits'][hit]['_source']['author']
+ '<br>To: '
+ messages['hits']['hits'][hit]['_source']['to']
+ '</p><p>'
+ msg
// + messages['hits']['hits'][hit]['_source']['message']
+ '</p><p align="right">'
+ messages['hits']['hits'][hit]['_source']['msgid'] + '</p></div>' ;
}
}
//not used
/*
function filterByEcho() {
console.log('func');
var author = "(echo:develop.16)";
var from = 0;
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["author"], "query" : ""}}, "size":5}',
success:function(messages){html=''; callback(messages); $("#mes").html(html);
}
})
}
*/

139
js/script.js~ Normal file
View File

@ -0,0 +1,139 @@
var html = '';
var options = '';
var echo = '';
var this_page = 1;
var show_rows = 5;
var from = 0;
var date = new Date(new Date().getTime() + 60 * 1000);
var echo = document.cookie;
console.log("echoes: "+ echo );
$(function() {
//initial load
if (echo != '') {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
}
//create echoes list
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"aggs": {"my_fields": { "terms": { "field": "echo","size": 1000}}}}}',
success:function(messages){for (i in messages['aggregations']['my_fields']['buckets']){options += '<option>'
+ messages['aggregations']['my_fields']['buckets'][i]['key']
+ " (<b>" + messages['aggregations']['my_fields']['buckets'][i]['doc_count'] + "</b>)"
+ '</option>'}$
$('#echoSelector').html(options);}
})
//show msgs when echo is selected
$('#echoSelector').on('change', function() {
echo = '';
for (i in $(this).val()) {echo += $(this).val()[i] + " "};
console.log(echo);
document.cookie = echo +"; path=/; expires=" + date.toUTCString();
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data:'{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":5}',
success:function(messages){html = ''; callback(messages);$("#mes").html(html); }
});
});
//scroll
$(window).scroll(function() {
console.log($(document).height() - $(window).height()-$(window).scrollTop());
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5) {
showMore();
//console.log($(document).height() - $(window).height() - $(window).scrollTop());
}
});
})
//show more messages
function showMore(){
this_page += 1;
from += show_rows;
var author = "(author:Difrex)";
if (echo != '') {
console.log("im here");
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
}
}
//show messages
function callback(messages) {
var huinya = 'wtf??';
console.log(messages);
for (hit in messages["hits"]["hits"]) {
var t = new Date(messages['hits']['hits'][hit]['_source']['date'] * 1000);
var t_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
// Replace new line with <br>
msg = messages['hits']['hits'][hit]['_source']['message'].replace(new RegExp("\n",'g'), "<br>\n");
html += '<div class="msg"><p align="right">' + t_formatted + '</p> <p style="font-size: 1.5em; font-family: "Open Sans", sans-serif;">'
+ messages['hits']['hits'][hit]['_source']['subg']
+ '</p><p>Echo: '
+ messages['hits']['hits'][hit]['_source']['echo']
+ '<br>Author: '
+ messages['hits']['hits'][hit]['_source']['author']
+ '<br>To: '
+ messages['hits']['hits'][hit]['_source']['to']
+ '</p><p>'
+ msg
// + messages['hits']['hits'][hit]['_source']['message']
+ '<br>Msgid: '
+ messages['hits']['hits'][hit]['_source']['msgid'] + '</p></div>' ;
}
}
//not used
/*
function filterByEcho() {
console.log('func');
var author = "(echo:develop.16)";
var from = 0;
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["author"], "query" : "Andrew Lobanov"}}, "size":5}',
success:function(messages){html=''; callback(messages); $("#mes").html(html);
}
})
}
*/

139
js/script2.js Normal file
View File

@ -0,0 +1,139 @@
var html = '';
var options = '';
var echo = '';
var this_page = 1;
var show_rows = 5;
var from = 0;
var date = new Date(new Date().getTime() + 60 * 1000);
var echo = document.cookie;
console.log("echoes: "+ echo );
$(function() {
//initial load
if (echo != '') {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
}
//create echoes list
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"aggs": {"my_fields": { "terms": { "field": "echo","size": 1000}}}}}',
success:function(messages){for (i in messages['aggregations']['my_fields']['buckets']){options += '<option>'
+ messages['aggregations']['my_fields']['buckets'][i]['key']
+ " (<b>" + messages['aggregations']['my_fields']['buckets'][i]['doc_count'] + "</b>)"
+ '</option>'}$
$('#echoSelector').html(options);}
})
//show msgs when echo is selected
$('#echoSelector').on('change', function() {
echo = '';
for (i in $(this).val()) {echo += $(this).val()[i] + " "};
console.log(echo);
document.cookie = echo +"; path=/; expires=" + date.toUTCString();
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data:'{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":5}',
success:function(messages){html = ''; callback(messages);$("#mes").html(html); }
});
});
//scroll
$(window).scroll(function() {
console.log($(document).height() - $(window).height()-$(window).scrollTop());
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5) {
showMore();
//console.log($(document).height() - $(window).height() - $(window).scrollTop());
}
});
})
//show more messages
function showMore(){
this_page += 1;
from += show_rows;
var author = "(author:Difrex)";
if (echo != '') {
console.log("im here");
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
}
}
//show messages
function callback(messages) {
var huinya = 'wtf??';
console.log(messages);
for (hit in messages["hits"]["hits"]) {
var t = new Date(messages['hits']['hits'][hit]['_source']['date'] * 1000);
var t_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
// Replace new line with <br>
msg = messages['hits']['hits'][hit]['_source']['message'].replace(new RegExp("\n",'g'), "<br>\n");
html += '<div class="msg"><p align="right">' + t_formatted + '</p> <p style="font-size: 1.5em; font-family: "Open Sans", sans-serif;">'
+ messages['hits']['hits'][hit]['_source']['subg']
+ '</p><p>Echo: '
+ messages['hits']['hits'][hit]['_source']['echo']
+ '<br>Author: '
+ messages['hits']['hits'][hit]['_source']['author']
+ '<br>To: '
+ messages['hits']['hits'][hit]['_source']['to']
+ '</p><p>'
+ msg
// + messages['hits']['hits'][hit]['_source']['message']
+ '<br>Msgid: '
+ messages['hits']['hits'][hit]['_source']['msgid'] + '</p></div>' ;
}
}
//not used
/*
function filterByEcho() {
console.log('func');
var author = "(echo:develop.16)";
var from = 0;
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["author"], "query" : "Andrew Lobanov"}}, "size":5}',
success:function(messages){html=''; callback(messages); $("#mes").html(html);
}
})
}
*/

136
js/script2.js~ Normal file
View File

@ -0,0 +1,136 @@
var html = '';
var options = '';
var echo = '';
var this_page = 1;
var show_rows = 5;
var from = 0;
var date = new Date(new Date().getTime() + 60 * 1000);
var echo = document.cookie;
console.log("echoes: "+ echo );
$(function() {
//initial load
if (echo != '') {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
//data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ 5 + '}',
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":5}',
success:function(messages){callback(messages);$("#mes").html(html);}
})
}
//create echoes list
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"aggs": {"my_fields": { "terms": { "field": "echo","size": 1000}}}}}',
success:function(messages){for (i in messages['aggregations']['my_fields']['buckets']){options += '<option>' + messages['aggregations']['my_fields']['buckets'][i]['key'] + '</option>'}$
$('#echoSelector').html(options);}
})
//show msgs when echo is selected
$('#echoSelector').on('change', function() {
echo = '';
for (i in $(this).val()) {echo += $(this).val()[i] + " "};
console.log(echo);
document.cookie = echo +"; path=/; expires=" + date.toUTCString();
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data:'{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":5}',
success:function(messages){html = ''; callback(messages);$("#mes").html(html); }
});
});
//scroll
$(window).scroll(function() {
console.log($(document).height() - $(window).height()-$(window).scrollTop());
if ($(document).height() - $(window).height() - $(window).scrollTop() < 1.5) {
showMore();
//console.log($(document).height() - $(window).height() - $(window).scrollTop());
}
});
})
//show more messages
function showMore(){
this_page += 1;
from += show_rows;
var author = "(author:Difrex)";
if (echo != '') {
console.log("im here");
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
} else {
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}',
success:function(messages){callback(messages); $("#mes").html(html);}
})
}
}
//show messages
function callback(messages) {
var huinya = 'wtf??';
console.log(messages);
for (hit in messages["hits"]["hits"]) {
var t = new Date(messages['hits']['hits'][hit]['_source']['date'] * 1000);
var t_formatted = t.getFullYear() + "/" + (t.getMonth() + 1) + "/" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds();
// Replace new line with <br>
msg = messages['hits']['hits'][hit]['_source']['message'].replace(new RegExp("\n",'g'), "<br>\n");
html += '<div class="msg"><p align="right">' + t_formatted + '</p> <p style="font-size: 1.5em; font-family: "Open Sans", sans-serif;">'
+ messages['hits']['hits'][hit]['_source']['subg']
+ '</p><p>Echo: '
+ messages['hits']['hits'][hit]['_source']['echo']
+ '<br>Author: '
+ messages['hits']['hits'][hit]['_source']['author']
+ '<br>To: '
+ messages['hits']['hits'][hit]['_source']['to']
+ '</p><p>'
+ msg
// + messages['hits']['hits'][hit]['_source']['message']
+ '<br>Msgid: '
+ messages['hits']['hits'][hit]['_source']['msgid'] + '</p></div>' ;
}
}
//not used
/*
function filterByEcho() {
console.log('func');
var author = "(echo:develop.16)";
var from = 0;
$.ajax({
url:"https://dynamic.lessmore.pw/search",
type:"POST",
data: '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["author"], "query" : "Andrew Lobanov"}}, "size":5}',
success:function(messages){html=''; callback(messages); $("#mes").html(html);
}
})
}
*/

80
lessmorefaq.html Normal file
View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>dynamic|LESS</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.7">
<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>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<!--div class="lessmore"><a href = "" style="text-decoration: none; color: #babdb6;"><u>FAQ</u> | <a href="/">dynamic</a></a></div-->
<div class="lessmore">
<a id="menu" href="javascript:void(0)" onclick="showMenu()"><i class="fa fa-bars"></i></a>
<div id="dropdown-content">
<a href="/">На главную</a>
<a href="/filter.html">Настроить фильтр</a>
<a href="/" onclick="clearFilter()">Сбросить фильтр</a>
</div>
<a href = "/" style="text-decoration: none; color: #babdb6;"><u>dynamic</u> | <u>less</u></a>
</div>
<div style= "margin: 100px 0 0">
<h1 class="faq" align = "center">FAQ</h1>
<h2>Что это?</h2>
<p>Это агрегатор сети <a href="https://ii-net.tk/idec-doc/?p=main">IDEC</a>. Тут собраны все сообщения со всех нод до которых он смог дотянуться.</p>
<h2>Ну и что тут делать?</h2>
<p>Можно читать сразу несколько эх, или только одну. Можно читать абсолютно весь(на самом деле нет) стрим сети почти в прямом эфире.</p>
<h2>А можно писать?</h2>
<p>Пока нельзя, но скоро будет можно, как через клиент, так и через веб-сайт.</p>
<h2>Этим чекбоксом невозможно пользоваться!</h2>
<p>С помощью стрелок на клавиатуре и кнопки CTRL вы можете сформировать свою ленту. А можете воспользоваться <a href="https://dynamic.lessmore.pw/filter.html">страницей</a> настройки.</p>
<h2>А клиентом можно читать?</h2>
<p>Можно. Пока что реализовано простейшее(скоро будет больше) ii API, а точнее схемы <b>/e/</b> и <b>/m/</b>. Из расширений доступны: <span id="extentions">/list.txt </span> <br><br>
Строка для подключения: <b>https://dynamic.lessmore.pw/idec/</b>
</p>
<h2>А API есть?</h2>
<p>Да. И оно открыто для всех желающих <a href="https://dynamic.lessmore.pw/search">тут</a>. Это Elasticsearch, так что читайте <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html">документацию</a> по нему.</p>
<h2>Как это работает?</h2>
<p>
<a href="https://gitea.difrex.ru/Umbrella/fetcher">Фетчер</a> собирает сообщения со станций сети. Эхи он берет из /list.txt.
Далее сообщение парсится, приводится к стурктуре в JSON и отправляется в Elasticsearch. В браузере Javascript ходит в API и формирует ленту.
Выбранные эхи сохраняются в куку. Да, этот сайт использует куки.
</p>
<h2>Я требую исходный код!</h2>
<p>Конечно-конечно! Исходники фетчера доступны <a href="https://gitea.difrex.ru/Umbrella/fetcher">тут</a>, IDEC-ноды <a href="https://gitea.difrex.ru/Umbrella/lessmore">тут</a>, а исходники веб-интерфейса можно увидеть щелкнув правой кнопкой мышки. </p>
<h2>Куда писать про баги и хотелки?</h2>
<p>Лучше всего если вы будете писать в эху <b>dynamic.lessmore.pw</b>, только убедитесь, что ваша нода индексируется и эха есть в /list.txt.</p>
<p>Еще можно написать на <a href="mailto:difrex.punk@gmail.com">почту</a>.</p>
<h2>Известные проблемы</h2>
<p>В индексе нет тегов и адреса. Это отколнение от стандарта и оно будет скоро исправленно.</p>
</div>
</body>
</html>