Archived
1
0
This commit is contained in:
Jeff Becker
2016-12-31 08:36:28 -05:00
parent e35adda727
commit 536b1161c9
9 changed files with 103 additions and 43 deletions

View File

@@ -0,0 +1,24 @@
/**
* @brief initialize a board page
*/
function neochan_board_init(root, board) {
var thread_init = function (j) {
var elem = document.createElement("div");
for(var idx = 0; idx < j.length; idx ++) {
var post = j[idx];
neochan_post_fadein(elem, post);
}
return elem;
}
// inject threads
onready(function() {
for (var idx = 0; idx < board.posts.length; idx ++) {
var posts = board.posts[idx];
var elem = thread_init(posts);
root.appendChild(elem);
}
});
}

View File

@@ -1,5 +0,0 @@
// Generated by CoffeeScript 1.11.1
(function() {
}).call(this);

View File

@@ -0,0 +1,23 @@
function neochan_post_new(j) {
var post = document.createElement("div");
post.id = j.PostHash;
post.setAttribute("class", "neochan-post-wrapper");
var header = document.createElement("div");
header.setAttribute("class", "neochan-post-header");
post.appendChild(header);
var body = document.createElement("div");
body.setAttribute("class", "neochan-post-body");
neochan_postify(body, j.Message);
return post;
}
function neochan_post_fadein(elem, j) {
var post = neochan_post_new(j);
$(post).fadein();
elem.appendChild(post);
}

View File

@@ -0,0 +1,37 @@
function _neochan_filter_boardlink(match) {
match = match.toLowerCase();
var a = document.createElement("a");
a.href = "/" + match + "-0.html";
match = ">>>/" + match + "/";
a.appendChild(document.createTextNode(match));
return a;
}
function _neochan_filter_postlink(match) {
}
var _neochan_post_filters = [
[/>>>\/(overchan\\.[a-zA-z0-9\\.]+[a-zA-Z0-9])\//g, _neochan_filter_boardlink],
[/>>? ([a-fA-F0-9])/g, _neochan_filter_postlink],
[/==(.+)==/g, _neochan_filter_redtext],
[/@@(.+)@@/g, _neochan_filter_psytext],
[/^>/g, _neochan_filter_greentext],
];
/**
* @brief create post body from raw text
*/
function neochan_postify(elem, text) {
$.each(_neochan_post_filters, function(idx, ent) {
var re = ent[0];
var func = ent[1];
text = text.replace(re, function(m) {
var e = func(m);
return "";
});
});
}

View File

@@ -1,3 +1 @@
# neochan javascript directory
sass files for neochan templates