Threads #3

Merged
Difrex merged 1 commits from threads into master 2018-01-02 22:23:39 +03:00
5 changed files with 182 additions and 83 deletions

View File

@ -91,6 +91,12 @@ body {
padding: 10px padding: 10px
} }
/* #dropdown-content>input { */
/* border:1px solid #eeeeec; */
/* display: block; */
/* padding: 10px */
/* } */
#faq { #faq {
margin: 80px 0 0; 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

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

View File

@ -1,24 +1,30 @@
function bake_cookie(name, value) { // Set cookie with v=threads
var echo = read_cookie("echo"); function toggleViewModeOn() {
var threads = read_cookie("threads"); Cookies.set("threads", "on", {expires: 365});
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);
} }
function read_cookie(name) { // Remove cookie with v=threads
var result = document.cookie.match(new RegExp(name + '=([^;]+)')); function toggleViewModeOff() {
if (result) { Cookies.set("threads", "off", {expires: 365});
result = result[1]; }
}
return result; 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); 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() { $(function() {
makeMenu();
//extentions //extentions
$.ajax({ $.ajax({
url:"https://dynamic.lessmore.pw/idec/x/features", url:"https://dynamic.lessmore.pw/idec/x/features",
@ -148,7 +176,12 @@ function requestEmptyEcho() {
} }
function requestEcho() { 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); ajaxRequest(data);
} }
@ -160,13 +193,23 @@ function requestTmpEcho(e) {
} }
function requestEmptyEchoOffset() { 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); ajaxRequest(data);
} }
function requestEchoOffset() { 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); ajaxRequest(data);
} }

View File

@ -1,6 +1,5 @@
var thread_html = ""; var thread_html = "";
var top_id = ""; var top_id = "";
var view_mode = false;
$(function() { $(function() {
var jumpLocation = parseLocation(); 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 // Make message HTML
function makeMessageHTML(msgItem) { function makeMessageHTML(msgItem) {
var t = new Date(msgItem['date'] * 1000); var t = new Date(msgItem['date'] * 1000);