This repository has been archived by the owner on Oct 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
85 lines (85 loc) · 5.07 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var fullurl = ""
var classfile = ""
var doshowall = false;
var filters;
const ls = window.localStorage;
const d2 = new Date();
const weekdays = ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"];
Date.prototype.getWeekNumber=function(){var d=new Date(Date.UTC(this.getFullYear(),this.getMonth(),this.getDate()));var dayNum=d.getUTCDay()||7;d.setUTCDate(d.getUTCDate()+4-dayNum);var yearStart=new Date(Date.UTC(d.getUTCFullYear(),0,1));weekNum=Math.ceil((((d-yearStart)/86400000)+1)/7);return(weekNum<10?"0":"")+weekNum;}
function redir() { window.location.href = fullurl+new Date().getWeekNumber()+classfile; };
function f5() { if (window.navigator.onLine) { location.reload(true);} };
function hideold(includeall) {
while (document.getElementsByTagName("h2")[0]) { document.getElementsByTagName("h2")[0].parentNode.removeChild(document.getElementsByTagName("h2")[0]) };
var dateofprevitem = document.getElementsByClassName("item")[0].classList[0].match(/[0-9]{1,2}\.[0-9]{1,2}\./g)[0].match(/[0-9]{1,2}/g);
document.getElementsByClassName("item")[0].insertAdjacentHTML("beforebegin", "<h2>"+getweekday(dateofprevitem[1]-1, dateofprevitem[0])+" "+((dateofprevitem[0].length<2?"0":"")+dateofprevitem[0])+"."+((dateofprevitem[1].length<2?"0":"")+dateofprevitem[1])+"</h2>");
for (i=0; i<document.getElementsByClassName("item").length; i++) {
var daymonth = document.getElementsByClassName("item")[i].classList[0].match(/[0-9]{1,2}\.[0-9]{1,2}\./g)[0].match(/[0-9]{1,2}/g);
if ( ((daymonth[0] < d2.getDate() && daymonth[1] <= (d2.getMonth()+1)) || daymonth[1] < (d2.getMonth()+1) || (daymonth[0] == d2.getDate() && d2.getHours() > 16)) && !includeall ) {
document.getElementsByClassName("item")[i].style.display = "none";
}
if (Number(daymonth[0]) > Number(dateofprevitem[0]) || Number(daymonth[1]) > Number(dateofprevitem[1])) {
document.getElementsByClassName("item")[i].insertAdjacentHTML("beforebegin", "<h2>"+getweekday(daymonth[1]-1, daymonth[0])+" "+((daymonth[0].length<2?"0":"")+daymonth[0])+"."+((daymonth[1].length<2?"0":"")+daymonth[1])+"</h2>");
dateofprevitem[0] = daymonth[0];
dateofprevitem[1] = daymonth[1];
}}
if (!includeall) {
for (j=0; j<document.getElementsByTagName("h2").length; j++) {
var h2dm = document.getElementsByTagName("h2")[j].innerHTML.replace(/^[a-zA-Z]*? /, "").replace(/^0/, "").replace(/\.0/, ".").match(/[0-9]{1,2}\.[0-9]{1,2}/g)[0].match(/[0-9]{1,2}/g);
var min_1_visible = false;
for (k=0; k<document.getElementsByClassName(h2dm[0]+"."+h2dm[1]+".").length; k++) {
if (document.getElementsByClassName(h2dm[0]+"."+h2dm[1]+".")[k].style.display !== "none") { min_1_visible = true;};
}
if (!min_1_visible) {document.getElementsByTagName("h2")[j].style.display = "none";};
}}
}
function getweekday(day, month) {
var weekday = new Date(d2.getFullYear(), day, month).getDay();
return weekdays[weekday];
}
function selectview() {
if (!doshowall) {
document.getElementById("viewsel").classList.remove("fa-eye");
document.getElementById("viewsel").classList.add("fa-eye-slash");
for (i=0; i<document.getElementsByClassName("item").length; i++) {
document.getElementsByClassName("item")[i].style.display = "";
}
hideold(true);
doshowall = true;
} else if (doshowall) {
document.getElementById("viewsel").classList.remove("fa-eye-slash");
document.getElementById("viewsel").classList.add("fa-eye");
filter();
doshowall = false;
}}
function openfm() {
filters = prompt("enter comma separated filters, if an item contains a filter, it will be hidden, enter nothing to undo the filters", (ls.getItem("filters")==="cXZ4QTdFekpOQ2czS20zeQo" || ls.getItem("filters")===null) ? "" : ls.getItem("filters"));
if (filters === "") {
ls.setItem("filters", "cXZ4QTdFekpOQ2czS20zeQo"); //regex that won't match
} else if (filters !== null && filters !== "null") {
ls.setItem("filters", filters);
}
filter();
}
function filter() {
if (ls.getItem("filters") !== null && ls.getItem("filters") !== "null") {
filters = ls.getItem("filters").split(",");
for (i=0; i<filters.length; i++) {
filters[i] = filters[i].toString().replace(/^ +/, "").replace(/ +$/, "");
}
for (i=0; i<document.getElementsByClassName("item").length; i++) {
document.getElementsByClassName("item")[i].style.display = "";
var text;
document.getElementsByClassName("item")[i].innerHTML.match(/<p class=".*">.*?<\/p>/g).forEach(function(x){text = x.replace(/<.*?class=.*?>/gi, " ").replace(/<\/p>/, "")});
for (j=0; j<filters.length; j++) {
if (filters[j] === "") { break; };
if (text.match(new RegExp(".*"+filters[j]+".*", "i"))) {
document.getElementsByClassName("item")[i].style.display = "none";
}}}} hideold(false); }
function pinheader() {
var header = document.getElementsByClassName("header")[0];
(window.pageYOffset > header.offsetTop) ? header.classList.add("sticky") : header.classList.remove("sticky");
}
window.addEventListener('DOMContentLoaded', (event) => {
filter();
});
window.onscroll = function() { pinheader(); };