Working threads mode

This commit is contained in:
Denis Zheleztsov 2018-01-02 22:22:01 +03:00
parent 20567e68a8
commit ae8748cf7c
5 changed files with 182 additions and 83 deletions

View File

@ -91,6 +91,12 @@ body {
padding: 10px
}
/* #dropdown-content>input { */
/* border:1px solid #eeeeec; */
/* display: block; */
/* padding: 10px */
/* } */
#faq {
margin: 80px 0 0;
}
@ -164,3 +170,72 @@ body {
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 40px;
height: 24px;
}
/* Hide default HTML checkbox */
.switch input {display:none;}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 2pt;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 19px;
width: 19px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(20px);
-ms-transform: translateX(20px);
transform: translateX(20px);
}
/* Rounded sliders */
.slider.round {
border-radius: 14px;
}
.slider.round:before {
border-radius: 50%;
}
#preloader {
position: fixed;
left: 0;
top: 0;
z-index: 999;
width: 100%;
height: 100%;
overflow: visible;
background: #2E3436 url('/img/preload.gif') no-repeat center center;
}

View File

@ -17,34 +17,39 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="threadView" id="thread"></div>
<div class="lessmore">
<a id="searchButton" href="javascript:void(0)" onclick="showSearch()"><i class="fa fa-search"></i></a>
<!-- <div class="logo"><a href="/" style="text-decoration: none; color: #c9c9c9;">dynamic | less</a></div> -->
<input type="search" id="searchInput" placeholder="Example: python">
<div id="selector">
<form><a href="/" style="text-decoration: none; color: #c9c9c9;"><i id="siteIcon" class="fa fa-sitemap" ></i> </a> <select id="echoSelector" multiple size="5"></select><a href="javascript:void(0)" onclick="toggleViewMode()">Mode</a></form>
<body>
<div class="threadView" id="thread"></div>
<div class="lessmore">
<a id="searchButton" href="javascript:void(0)" onclick="showSearch()"><i class="fa fa-search"></i></a>
<!-- <div class="logo"><a href="/" style="text-decoration: none; color: #c9c9c9;">dynamic | less</a></div> -->
<input type="search" id="searchInput" placeholder="Example: python">
<div id="selector">
<form><a href="/" style="text-decoration: none; color: #c9c9c9;"><i id="siteIcon" class="fa fa-sitemap" ></i> </a> <select id="echoSelector" multiple size="5"></select>
</form>
</div>
<a id="menu" href="javascript:void(0)" onclick="showMenu()"><i class="fa fa-bars"></i></a>
<div id="dropdown-content">
</div>
<!-- <form><select id="echoSelector" multiple size="5"></select></form> -->
<!-- <a href="/" id="logo" style="text-decoration: none; color: #c9c9c9;">dynamic | less</a> -->
</div>
<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>
<a href="stats.html">Статистика</a>
<div class="content">
<div id="mes"></div>
</div>
<!-- <form><select id="echoSelector" multiple size="5"></select></form> -->
<!-- <a href="/" id="logo" style="text-decoration: none; color: #c9c9c9;">dynamic | less</a> -->
</div>
<div class="content">
<div id="mes"></div>
</div>
<div id="preloader" align="center">
<img src="/img/preload.gif" onclick="showMore()" height="20em">
</div>
</body>
<div id="preloader" align="center" onclick="showMore()">
<!-- <img src="/img/preload.gif" onclick="showMore()" height="20em"> -->
</div>
<script>
jQuery(document).ready(function($) {
$(window).load(function() {
setTimeout(function() {
$('#preloader').fadeOut('slow', function() {});
}, 2000);
});});
</script>
</body>
</html>

View File

@ -1,24 +1,30 @@
function bake_cookie(name, value) {
var echo = read_cookie("echo");
var threads = read_cookie("threads");
if (name != "echo") {
var cookie = ["echo=", echo, ';', "threads", '=', value, '; domain=.', window.location.host.toString(), '; path=/;'].join('');
document.cookie = cookie;
} else if (threads) {
var cookie = ["echo=", value, ';', "threads", '=', threads, '; domain=.', window.location.host.toString(), '; path=/;'].join('');
document.cookie = cookie;
} else {
console.log("Setting echoes " + value);
var cookie = ["echo=", value, ';', 'domain=.', window.location.host.toString(), '; path=/;'].join('');
document.cookie = cookie;
}
console.log("Cookie: " + document.cookie);
// Set cookie with v=threads
function toggleViewModeOn() {
Cookies.set("threads", "on", {expires: 365});
}
function read_cookie(name) {
var result = document.cookie.match(new RegExp(name + '=([^;]+)'));
if (result) {
result = result[1];
}
return result;
// Remove cookie with v=threads
function toggleViewModeOff() {
Cookies.set("threads", "off", {expires: 365});
}
function toggleViewMode() {
if (checkViewMode()) {
toggleViewModeOff();
location.reload();
} else {
toggleViewModeOn();
location.reload();
}
}
// Check view mode
function checkViewMode() {
if (Cookies.get("threads") && Cookies.get("threads") == "on") {
console.log('THREADS ON');
return true
} else {
console.log('NORMAL');
return false
}
}

View File

@ -23,8 +23,36 @@ if (hash.matched) {
requestMessage(hash.hash);
}
// Add checker to menu
function makeMenu() {
if (checkViewMode()) {
$("#dropdown-content").html(
`<a style="text-decoration:none !important;" href="javascript:void(0)">Threads mode <label class="switch">
<input id="threadsCheckbox" type="checkbox" onclick="toggleViewMode()" checked>
<span class="slider round"></span>
</label>
</a>
<a href="filter.html">Настроить фильтр</a>
<a href="" onclick="clearFilter()">Сбросить фильтр</a>
<a href="lessmorefaq.html">FAQ</a>
<a href="stats.html">Статистика</a>`);
} else {
$("#dropdown-content").html(
`<a style="text-decoration:none !important;" href="javascript:void(0)">Threads mode <label class="switch">
<input id="threadsCheckbox" type="checkbox" onclick="toggleViewMode()">
<span class="slider round"></span>
</label>
</a>
<a href="filter.html">Настроить фильтр</a>
<a href="" onclick="clearFilter()">Сбросить фильтр</a>
<a href="lessmorefaq.html">FAQ</a>
<a href="stats.html">Статистика</a>`);
}
}
$(function() {
makeMenu();
//extentions
$.ajax({
url:"https://dynamic.lessmore.pw/idec/x/features",
@ -148,7 +176,12 @@ function requestEmptyEcho() {
}
function requestEcho() {
var data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": {"query_string" : {"fields": ["echo"], "query": "' + echo + '"}}, "size":' + 5 + '}';
var data = '';
if (checkViewMode()) {
data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": {"bool": { "must": [ { "query_string" : {"fields": ["echo", "repto"], "query": "' + echo +' AND repto.keyword:\\"\\""}}]}}, "size":5}';
} else {
data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": {"query_string" : {"fields": ["echo"], "query": "' + echo + '"}}, "size":' + 5 + '}';
}
ajaxRequest(data);
}
@ -160,13 +193,23 @@ function requestTmpEcho(e) {
}
function requestEmptyEchoOffset() {
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}';
var data = '';
if (checkViewMode()) {
data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": { "query_string" : {"fields": ["repto"], "query": "repto.keyword:\\"\\""}}, "size":' + show_rows + ', "from":' + from + '}';
} else {
data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}],"size":'+ show_rows + ', "from":'+ from + '}';
}
ajaxRequest(data);
}
function requestEchoOffset() {
var data = '{"sort": [ { "date": { "order": "desc" }}, { "_score": { "order": "desc" }}], "query": {"query_string" : {"fields" : ["echo"], "query" :"' + echo + '"}}, "size":'+ show_rows + ', "from":'+ from + '}';
var data = '';
if (checkViewMode()) {
data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": {"bool": { "must": [ { "query_string" : {"fields": ["echo", "repto"], "query": "' + echo +' AND repto.keyword:\\"\\""}}]}}, "size":' + show_rows + ', "from":' + from + '}';
} else {
data = '{"sort": [{"date": {"order": "desc"}}, {"_score": { "order": "desc" }}], "query": {"query_string" : {"fields": ["echo"], "query": "' + echo + '"}}, "size":' + show_rows + ', "from":' + from + '}';
}
ajaxRequest(data);
}
@ -314,14 +357,14 @@ function callback(messages) {
}
// Header
html += ' <p style="color:#0099cc;font: 1.5em Open Sans, sans-serif;">'
html += ' <p style="color:#0099cc;font: 1.5em Open Sans, sans-serif;">'
+ '<a class="headerLink" href="/?j=' + msgItem['msgid'] + '">'
+ 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>';

View File

@ -1,6 +1,5 @@
var thread_html = "";
var top_id = "";
var view_mode = false;
$(function() {
var jumpLocation = parseLocation();
@ -92,35 +91,6 @@ function parseLocation() {
}
}
// Set cookie with v=threads
function toggleViewModeOn() {
Cookies.set("threads", "on");
}
// Remove cookie with v=threads
function toggleViewModeOff() {
Cookies.set("threads", "off");
}
function toggleViewMode() {
if (checkViewMode()) {
toggleViewModeOff();
} else {
toggleViewModeOn();
}
}
// Check view mode
function checkViewMode() {
if (Cookies.get("threads") && Cookies.get("threads") == "on") {
console.log('THREADS ON');
return true
} else {
console.log('NORMAL');
return false
}
}
// Make message HTML
function makeMessageHTML(msgItem) {
var t = new Date(msgItem['date'] * 1000);