mirror of
https://github.com/Xkeeper0/jul.git
synced 2025-07-25 17:21:58 -07:00
cruft
css
errors
ext
images
js
hex.js
jquery.hotkeys-0.7.9.min.js
jquery.min.js
latestposts.js
useful.js
lib
numgfx
schemes
tlayouts
.editorconfig
.gitignore
README.md
acs.php
activeusers.php
activity.php
activity2.php
activity3.php
activity3u.php
admin-editforums.php
admin-editmods.php
admin-slammer.php
admin-threads.php
admin-threads2.php
admin.php
adnonsense.php
announcement.php
avatar.php
biggestposters.php
calendar.php
del.php
doomcounter.php
editpost.php
editprofile.php
editthread.php
edituser.php
faq.php
favicon.ico
forum.php
hex.php
index.php
ipsearch.php
irc.php
latestposts.php
login.php
memberlist.php
milestones.php
newreply.php
newthread.php
numgfx.php
numgfxbig.php
online.php
posticons.dat
postradar.php
postsbyforum.php
postsbythread.php
postsbytime.php
postsbyuser.php
private.php
profile.php
ranks.php
register.php
sendprivate.php
shitbugs.php
shop.php
shoped.php
shoph.php
showprivate.php
sigsize.php
smilies.dat
smilies.php
smilies2.dat
smilies2.php
smilieslol.dat
stats-daily.php
stats.php
status.php
thread.php
118 lines
3.6 KiB
JavaScript
118 lines
3.6 KiB
JavaScript
function filter(func, list) {
|
|
var retl = [];
|
|
var idx = 0;
|
|
for (var i = 0; i < list.length; i++) {
|
|
if (func(list[i]) == 1) {
|
|
retl[idx] = list[i];
|
|
idx++;
|
|
}
|
|
}
|
|
return retl;
|
|
}
|
|
|
|
function pluralize(val, str) {
|
|
if (val == 1) {
|
|
return String(val) + " " + str;
|
|
} else if (val == 0 || val >= 2) {
|
|
return String(val) + " " + str + "s";
|
|
}
|
|
}
|
|
|
|
function htmlattrs(attrs) {
|
|
var attrStrings = [];
|
|
for (var i in attrs) {
|
|
attrStrings.push(i + '="' + attrs[i] + '"');
|
|
}
|
|
return attrStrings.join(" ");
|
|
}
|
|
|
|
var gen_row = function (elements, attrs) { return "<tr"+(attrs["row"]!=undefined?" "+htmlattrs(attrs["row"]):"")+">"+elements.join("")+"</tr>"; }
|
|
var gen_cell = function (text, attrs) { return "<td"+(attrs!=undefined?" "+htmlattrs(attrs):"")+">"+text+"</td>"; }
|
|
|
|
function htmlchars(str) {
|
|
return str;
|
|
}
|
|
|
|
function linkify(text, attrs) {
|
|
var attrStrings = [];
|
|
for (var i in attrs) {
|
|
attrStrings.push(i + '="' + htmlchars(attrs[i]) + '"')
|
|
}
|
|
return "<a "+(attrStrings.join(" "))+">"+htmlchars(text)+"</a>";
|
|
}
|
|
|
|
var postlist = function() {$.get("latestposts.php", {raw: 1}, function(data) {
|
|
var ctime = new Date();
|
|
var lines = data.split("\n");
|
|
var splitter = /"(.*?)"/gi;
|
|
var noCommas = function(e) { return e != ","; }
|
|
var rows = [];
|
|
for (var i = 0; i < lines.length; i++) {
|
|
rows[i] = filter(noCommas, lines[i].split(splitter));
|
|
rows[i].splice(0,1);
|
|
}
|
|
var html_rows = function() {
|
|
var trows = [];
|
|
var statr1 = {class: "tbl tdbg1 font center"};
|
|
var statr2 = {class: "tbl tdbg2 font"};
|
|
var statr3 = {class: "tbl tdbg1 font"};
|
|
var statr4 = {class: "tbl tdbg2 font center"};
|
|
trows[0] = gen_row([gen_cell("<b>Latest Posts</b>", {class: "tbl tdbgc font center", colspan: "5"})], {});
|
|
trows[1] = gen_row([
|
|
gen_cell(" ", {class: "tbl tdbgh font center", width: 30}),
|
|
gen_cell("Forum", {class: "tbl tdbgh font center", width: 200}),
|
|
gen_cell("Thread",{class: "tbl tdbgh font center"}),
|
|
gen_cell("User", {class: "tbl tdbgh font center", width: 200}),
|
|
gen_cell("Time", {class: "tbl tdbgh font center", width: 130})], {});
|
|
for (var i = 2; i < rows.length; i++) {
|
|
var trow = rows[i-2];
|
|
var dt = new datetime(trow[8]);
|
|
trows[i] = gen_row([
|
|
gen_cell(trow[0], statr2),
|
|
gen_cell(linkify(trow[1], {href: "/forum.php?id="+trow[2], target: "blank"}),statr4),
|
|
gen_cell(linkify(trow[3], {href: "/thread.php?pid="+trow[0]+"&r=1#"+trow[0], target: "blank"}), statr3),
|
|
gen_cell("<span style='font-weight: bold; color: #"+trow[7]+";'>"+trow[4]+"</span>", statr1),
|
|
gen_cell(dt.since(), statr4)
|
|
], {});
|
|
}
|
|
var html = trows.join("");
|
|
return html;
|
|
};
|
|
$("table[name=latest]").html(html_rows());
|
|
});}
|
|
|
|
function datetime(tstamp) {
|
|
var ctime = new Date();
|
|
this.timestamp = tstamp-10800;
|
|
this.now = ctime.valueOf()/1000;
|
|
this.since = function() {
|
|
var delta = (this.now - this.timestamp);
|
|
if (delta >= 0 && delta <= 10) {
|
|
return "Just now";
|
|
} else if (delta < 60 && delta > 10) {
|
|
var val = Math.round(delta/60).toString();
|
|
return pluralize(val, "second")
|
|
} else if (delta < 3600 && delta > 59) {
|
|
var val = Math.round(delta/60).toString();
|
|
return pluralize(val, "minute");
|
|
} else if (delta < 86400 && delta > 3599) {
|
|
var val = Math.round(delta/3600).toString();
|
|
return pluralize(val, "hour");
|
|
}
|
|
return delta;
|
|
}
|
|
this.idelta = function() {
|
|
return (this.now - this.timestamp);
|
|
}
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
var UPDATE_TIME = 250;
|
|
postlist();
|
|
setInterval(
|
|
function() {
|
|
postlist();
|
|
}, 30000);
|
|
});
|
|
|