mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
place/userthreads: id & order fix in html output
This commit is contained in:
parent
cace711db3
commit
bcbf2785d8
1 changed files with 24 additions and 34 deletions
|
@ -267,17 +267,15 @@ setSubject(id, thread) {
|
||||||
|
|
||||||
// TODO: topic uebergeben
|
// TODO: topic uebergeben
|
||||||
addEntry(text, unick, thread) {
|
addEntry(text, unick, thread) {
|
||||||
mapping* entries;
|
int id = sizeof(_thread);
|
||||||
mapping newentry = ([
|
mapping newentry = ([
|
||||||
"text" : text,
|
"id": id,
|
||||||
"author" : unick,
|
"text": text,
|
||||||
"date" : time(),
|
"author": unick,
|
||||||
"thread" : thread || "",
|
"date": time(),
|
||||||
|
"thread": thread || "",
|
||||||
]);
|
]);
|
||||||
entries = _thread || ({ });
|
_thread += ({ newentry });
|
||||||
entries += ({ newentry });
|
|
||||||
int id = sizeof(entries) - 1;
|
|
||||||
_thread = entries;
|
|
||||||
save();
|
save();
|
||||||
castmsg(ME, "_notice_thread_entry",
|
castmsg(ME, "_notice_thread_entry",
|
||||||
thread ?
|
thread ?
|
||||||
|
@ -528,23 +526,18 @@ displayMain(last) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
htmlEntries(array(mapping) entries, int last, int js, string chan, string submit) {
|
htmlEntries(array(mapping) entries, int js, string chan, string submit) {
|
||||||
P3((">> threads:htmlentries(%O, %O)\n", entries, last))
|
P3((">> threads:htmlentries(%O, %O, %O, %O)\n", entries, js, chan, submit))
|
||||||
string t;
|
string t, ht = "";
|
||||||
string ht = "";
|
string id_prefix = chan ? chan + "-" : "";
|
||||||
if (js) ht +=
|
if (js) ht +=
|
||||||
"<script type='text/javascript'>\n"
|
"<script type='text/javascript'>\n"
|
||||||
"function toggle(e) { e = document.getElementById(e); e.className = e.className.match('hidden') ? e.className.replace(/ *hidden/, '') : e.className + ' hidden'; }\n"
|
"function toggle(e) { e = document.getElementById(e); e.className = e.className.match('hidden') ? e.className.replace(/ *hidden/, '') : e.className + ' hidden'; }\n"
|
||||||
"</script>\n";
|
"</script>\n";
|
||||||
string id_prefix = chan ? chan + "-" : "";
|
|
||||||
|
|
||||||
mapping item;
|
foreach (mapping item : entries) {
|
||||||
int n = 0;
|
P3((">>> item: %O\n", item))
|
||||||
int id;
|
unless (item) continue;
|
||||||
// reverse order
|
|
||||||
for (id = sizeof(entries) - 1; id >= 0; id--) {
|
|
||||||
P3((">>> entries[%O]: %O\n", id, entries[id]))
|
|
||||||
unless (item = entries[id]) continue;
|
|
||||||
|
|
||||||
t = htquote(item["text"]);
|
t = htquote(item["text"]);
|
||||||
t = replace(t, "\n", "<br>\n");
|
t = replace(t, "\n", "<br>\n");
|
||||||
|
@ -559,48 +552,45 @@ htmlEntries(array(mapping) entries, int last, int js, string chan, string submit
|
||||||
ht +=
|
ht +=
|
||||||
"<div class='entry'>\n"
|
"<div class='entry'>\n"
|
||||||
"<div class='title'>\n"
|
"<div class='title'>\n"
|
||||||
"<span class='id'>#" + id + "</span> - \n"
|
"<span class='id'>#" + item["id"] + "</span> - \n"
|
||||||
"<span class='author'>" + item["author"] + "</span>\n"
|
"<span class='author'>" + item["author"] + "</span>\n"
|
||||||
+ (item["thread"] && strlen(item["thread"]) ? " - " : "") +
|
+ (item["thread"] && strlen(item["thread"]) ? " - " : "") +
|
||||||
"<span class='subject'>" + htquote(item["thread"]) + "</span>\n"
|
"<span class='subject'>" + htquote(item["thread"]) + "</span>\n"
|
||||||
"</div>\n"
|
"</div>\n"
|
||||||
"<div class='body'>\n"
|
"<div class='body'>\n"
|
||||||
"<div class='text'>" + t + "</div>\n"
|
"<div class='text'>" + t + "</div>\n"
|
||||||
"<div id='comments-" + id_prefix + id + "' class='comments hidden'>" + c +
|
"<div id='comments-" + id_prefix + item["id"] + "' class='comments hidden'>" + c +
|
||||||
(submit && strlen(submit) ?
|
(submit && strlen(submit) ?
|
||||||
"<div class='comment-submit'>"
|
"<div class='comment-submit'>"
|
||||||
"<textarea autocomplete='off'></textarea>"
|
"<textarea autocomplete='off'></textarea>"
|
||||||
//FIXME: cmd is executed twice, because after a set-cookie it's parsed again
|
//FIXME: cmd is executed twice, because after a set-cookie it's parsed again
|
||||||
"<input type='button' value='Comment' onclick=\"cmd('comment " + id + " '+ this.previousSibling.value, '" + submit + "')\">"
|
"<input type='button' value='Comment' onclick=\"cmd('comment " + item["id"] + " '+ this.previousSibling.value, '" + submit + "')\">"
|
||||||
"</div>" : "") +
|
"</div>" : "") +
|
||||||
"</div>\n"
|
"</div>\n"
|
||||||
"</div>\n"
|
"</div>\n"
|
||||||
"<div class='footer'>\n"
|
"<div class='footer'>\n"
|
||||||
"<span class='date'>" + isotime(ctime(item["date"]), 1) + "</span>\n"
|
"<span class='date'>" + isotime(ctime(item["date"]), 1) + "</span>\n"
|
||||||
"<span class='comments-link'>"
|
"<span class='comments-link'>"
|
||||||
"<a onclick=\"toggle('comments-" + id_prefix + id + "')\">" + sizeof(item["comments"]) + " comments</a>"
|
"<a onclick=\"toggle('comments-" + id_prefix + item["id"] + "')\">" + sizeof(item["comments"]) + " comments</a>"
|
||||||
"</span>\n"
|
"</span>\n"
|
||||||
"</div>\n"
|
"</div>\n"
|
||||||
"</div>\n";
|
"</div>\n";
|
||||||
if (last && ++n >= last) break;
|
|
||||||
}
|
}
|
||||||
P3((">>> ht: %O\n", ht))
|
P3((">>> ht: %O\n", ht))
|
||||||
return "<div class='threads'>" + ht + "</div>";
|
return "<div class='threads'>" + ht + "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
htMain(int last) {
|
htMain(int last) {
|
||||||
return htmlEntries(_thread, last, 1);
|
return htmlEntries(entries(last), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
entries(int last) {
|
entries(int last) {
|
||||||
array(mapping) entries = ({ });
|
array(mapping) entries = ({ });
|
||||||
int n = 0;
|
int i, n = 0;
|
||||||
int id;
|
for (i = sizeof(_thread) - 1; i >= 0; i--) {
|
||||||
// reverse order
|
P3((">>> _thread[%O]: %O\n", i, _thread[i]))
|
||||||
for (id = sizeof(_thread) - 1; id >= 0; id--) {
|
unless (_thread[i]) continue;
|
||||||
P3((">>> _thread[%O]: %O\n", id, _thread[id]))
|
entries += ({ _thread[i] });
|
||||||
unless (_thread[id]) continue;
|
|
||||||
entries += ({ _thread[id] });
|
|
||||||
if (++n >= last) break;
|
if (++n >= last) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue