55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
import cfg from './cfg.js';
|
|
import rt from './runtimes.js';
|
|
|
|
export const getpos = elems => [elems[0], elems[elems.length-1]].map(e => [e.children[0], e.parentNode].reduce((a, b) => a.offsetTop + b.offsetTop));
|
|
export const getposall = elems => [...new Set([...elems].map(e => [e.children[0], e.parentNode].reduce((a,b) => a.offsetTop + b.offsetTop)))];
|
|
|
|
export const getlink = tmp => {
|
|
const blah = {
|
|
mode: "",
|
|
user: "",
|
|
mime: "",
|
|
last: 0,
|
|
post: 0
|
|
};
|
|
const api = "./api/";
|
|
if(!tmp.match(/\,/))
|
|
tmp = "#new";
|
|
tmp = (tmp.match(/,/)?tmp:`${tmp},`).substr(1).split(",");
|
|
const args = {
|
|
l: tmp[0].split("/"),
|
|
r: tmp[1].split("/")
|
|
};
|
|
blah.mode = ( args.l[0].length === 0 )? "new" : args.l[0];
|
|
blah.last = parseInt(args.r[0]) || 0;
|
|
blah.post = parseInt(args.r[1]) || 0;
|
|
switch(blah.mode) {
|
|
case "user":
|
|
blah.user = ( args.l[1] )? args.l[1] : "";
|
|
blah.mime = ( args.l[2] )? args.l[2] : "";
|
|
break;
|
|
case "mime":
|
|
blah.user = ( args.l[2] )? args.l[2] : "";
|
|
blah.mime = ( args.l[1] )? args.l[1] : "";
|
|
break;
|
|
}
|
|
return {
|
|
mode: blah.mode,
|
|
user: blah.user,
|
|
stamp: blah.last,
|
|
mime: blah.mime,
|
|
eps: this._dims.eps,
|
|
sort: this._lastmode
|
|
};
|
|
};
|
|
|
|
export const render = items => {
|
|
items.forEach(item => {
|
|
let thumb = document.createElement('a');
|
|
thumb.className = "thumb";
|
|
thumb.href = "#";
|
|
thumb.style.backgroundImage = `url("//f0ck.me/t/${item.id}.png")`;
|
|
thumb.append(document.createElement('dummy'));
|
|
cfg.container.thumbs.append(thumb);
|
|
});
|
|
}; |