autism die zweite

This commit is contained in:
Flummi 2016-11-17 07:00:12 +01:00
parent bb7eda3a1a
commit 2af6dfb63d
4 changed files with 67 additions and 108 deletions

View File

@ -6,7 +6,7 @@
<link rel="stylesheet" type="text/css" href="./s/style.css"> <link rel="stylesheet" type="text/css" href="./s/style.css">
</head> </head>
<body> <body>
<div class="navbar"><a href="/">f0ck.me</a> | <a href="/how">how to</a> | <a href="/contact">Contact</a> | <span id="themes"></span></div> <div class="navbar"><a href="/">f0ck.me</a> | <a href="/how">how to</a> | <a href="/contact">Contact</a> | <span id="themes"></span></div>
<ul id="posts" data-last="{{ last }}"> <ul id="posts" data-last="{{ last }}">
{% for item in items %}<li class="post"><a href="./{{ item.id }}" title="{{ item.mime }}"><img class="thumb" src="./t/{{ item.id }}.png" /></a></li> {% for item in items %}<li class="post"><a href="./{{ item.id }}" title="{{ item.mime }}"><img class="thumb" src="./t/{{ item.id }}.png" /></a></li>
{% endfor %} {% endfor %}

View File

@ -10,11 +10,11 @@
<div class="return"><a href="/" title="return to main">f0ck.me</a></div> <div class="return"><a href="/" title="return to main">f0ck.me</a></div>
<div class="controls"> <div class="controls">
{% if next != null %} {% if next != null %}
<a id="next" href="/{{ next }}"><<-</a>&nbsp;|&nbsp; <a id="next" href="/{{ next }}"><<-</a>&nbsp;|&nbsp;
{% endif %} {% endif %}
<a id="random" href="/random">random</a>&nbsp; <a id="random" href="/random">random</a>&nbsp;
{% if prev != null %} {% if prev != null %}
&nbsp;| <a id="prev" href="/{{ prev }}">->></a> &nbsp;| <a id="prev" href="/{{ prev }}">->></a>
{% endif %} {% endif %}
</div> </div>

View File

@ -1,17 +1,17 @@
var load = false; var load = false;
$(()=>{ $(()=>{
$(window).scroll(()=>{ $(window).scroll(()=>{
if($(window).scrollTop() + $(window).height() >= $(document).height() - 130 && !load) { if($(window).scrollTop() + $(window).height() >= $(document).height() - 130 && !load) {
load = true; load = true;
$.getJSON('./api/p/'+$('#posts').data('last'), (msg) => { $.getJSON('./api/p/'+$('#posts').data('last'), (msg) => {
var html = ""; var html = "";
for(var i = 0; i < msg.items.length; i++) for(var i = 0; i < msg.items.length; i++)
if(msg.items[i].id) if(msg.items[i].id)
html += "<li class=\"post\"><a href=\"./"+msg.items[i].id+"\" title=\""+msg.items[i].mime+"\"><img class=\"thumb\" src=\"./t/"+msg.items[i].id+".png\" /></a></li>\n"; html += "<li class=\"post\"><a href=\"./"+msg.items[i].id+"\" title=\""+msg.items[i].mime+"\"><img class=\"thumb\" src=\"./t/"+msg.items[i].id+".png\" /></a></li>\n";
$('#posts').append(html); $('#posts').append(html);
$('#posts').data('last', msg.last); $('#posts').data('last', msg.last);
load = false; load = false;
}); });
} }
});
}); });
});

View File

@ -1,5 +1,4 @@
/* Thanks to StephenLynx, I modified his Theme Changer from the Penumbra Lynx Frontend for the Lynxchan Software https://gitgud.io/LynxChan/LynxChan and reused it to make f0ck a nicer place. */ /* Thanks to StephenLynx, I modified his Theme Changer from the Penumbra Lynx Frontend for the Lynxchan Software https://gitgud.io/LynxChan/LynxChan and reused it to make f0ck a nicer place. */
var themes = [ { var themes = [ {
file : 'cyber.css', file : 'cyber.css',
label : 'Cyber', label : 'Cyber',
@ -13,109 +12,69 @@ var themes = [ {
label : 'TERM', label : 'TERM',
id : 'TERM' id : 'TERM'
}]; }];
var customCss; var customCss;
var addedTheme; var addedTheme;
function updateCss() { function updateCss() {
if (addedTheme) { if (addedTheme) {
addedTheme.parentNode.removeChild(addedTheme); addedTheme.parentNode.removeChild(addedTheme);
addedTheme = null; addedTheme = null;
} }
for (var i = 0; i < themes.length; i++) { for (var i = 0; i < themes.length; i++) {
var theme = themes[i]; var theme = themes[i];
if (theme.id === localStorage.selectedTheme) { if (theme.id === localStorage.selectedTheme) {
addedTheme = theme.element; addedTheme = theme.element;
document.head.insertBefore(theme.element, customCss); document.head.insertBefore(theme.element, customCss);
} }
} }
} }
for (var i = 0; i < document.head.children.length; i++) {
for (var i = 0; i < document.head.children.length; i++) { var element = document.head.children[i];
var element = document.head.children[i]; if (element.rel === 'stylesheet' && element.href.indexOf('/custom.css') > -1) {
customCss = element;
if (element.rel === 'stylesheet' break;
&& element.href.indexOf('/custom.css') > -1) { }
}
customCss = element; for (var i = 0; i < themes.length; i++) {
break; themes[i].element = document.createElement('link');
themes[i].element.type = 'text/css';
themes[i].element.rel = 'stylesheet';
themes[i].element.href = './s/' + themes[i].file;
}
updateCss();
var postingLink = document.getElementById('themes');
if (postingLink) {
var divider = document.createElement('span');
divider.innerHTML = '';
var referenceNode = postingLink.nextSibling;
postingLink.parentNode.insertBefore(divider, referenceNode);
var themeSelector = document.createElement('select');
themeSelector.id = 'themeSelector';
var vanillaOption = document.createElement('option');
vanillaOption.innerHTML = 'Default';
themeSelector.appendChild(vanillaOption);
for (i = 0; i < themes.length; i++) {
var theme = themes[i];
var themeOption = document.createElement('option');
themeOption.innerHTML = theme.label;
if (theme.id === localStorage.selectedTheme) {
themeOption.selected = true;
} }
themeSelector.appendChild(themeOption);
} }
themeSelector.onchange = function() {
for (var i = 0; i < themes.length; i++) { if (!themeSelector.selectedIndex) {
themes[i].element = document.createElement('link'); if (localStorage.selectedTheme) {
themes[i].element.type = 'text/css'; delete localStorage.selectedTheme;
themes[i].element.rel = 'stylesheet'; updateCss();
themes[i].element.href = './s/' + themes[i].file;
}
updateCss();
var postingLink = document.getElementById('themes');
if (postingLink) {
var divider = document.createElement('span');
divider.innerHTML = '';
var referenceNode = postingLink.nextSibling;
postingLink.parentNode.insertBefore(divider, referenceNode);
var themeSelector = document.createElement('select');
themeSelector.id = 'themeSelector';
var vanillaOption = document.createElement('option');
vanillaOption.innerHTML = 'Default';
themeSelector.appendChild(vanillaOption);
for (i = 0; i < themes.length; i++) {
var theme = themes[i];
var themeOption = document.createElement('option');
themeOption.innerHTML = theme.label;
if (theme.id === localStorage.selectedTheme) {
themeOption.selected = true;
} }
return;
themeSelector.appendChild(themeOption);
} }
var selectedTheme = themes[themeSelector.selectedIndex - 1];
themeSelector.onchange = function() { if (selectedTheme.id === localStorage.selectedTheme) {
return;
if (!themeSelector.selectedIndex) { }
localStorage.selectedTheme = selectedTheme.id;
if (localStorage.selectedTheme) { updateCss();
};
delete localStorage.selectedTheme; postingLink.parentNode.insertBefore(themeSelector, referenceNode);
}
updateCss();
}
return;
}
var selectedTheme = themes[themeSelector.selectedIndex - 1];
if (selectedTheme.id === localStorage.selectedTheme) {
return;
}
localStorage.selectedTheme = selectedTheme.id;
updateCss();
};
postingLink.parentNode.insertBefore(themeSelector, referenceNode);
}