A separate (minified) JS to load only the comment count for each `<a href="...#isso-thread">...</a>` link. If there are no comments, return a 404, otherwise return the number JSON formatted. To built `count.ks`, run `r.js -o build.count.js`.pull/16/head
parent
1105e3e016
commit
45d4e18aef
@ -0,0 +1,16 @@
|
||||
define(["app/api", "lib/HTML"], function(api, HTML) {
|
||||
return function() {
|
||||
HTML.query("a").each(function(el, i, all) {
|
||||
if (! el.href.match("#isso-thread$")) {
|
||||
return;
|
||||
};
|
||||
|
||||
var uri = el.href.match("^(.+)#isso-thread$")[1]
|
||||
.replace(/^.*\/\/[^\/]+/, '');
|
||||
console.log(uri)
|
||||
api.count(uri).then(function(rv) {
|
||||
el.textContent = rv + (rv > 1 ? " Kommentare" : " Kommentar");
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
({
|
||||
bseUrl: ".",
|
||||
name: "lib/almond",
|
||||
include: ['count'],
|
||||
out: "count.min.js",
|
||||
wrap: true
|
||||
})
|
@ -0,0 +1,5 @@
|
||||
require(["lib/ready", "app/count"], function(domready, count) {
|
||||
domready(function() {
|
||||
count();
|
||||
})
|
||||
});
|
@ -1,5 +1,6 @@
|
||||
require(["lib/ready", "app/isso"], function(domready, isso) {
|
||||
require(["lib/ready", "app/isso", "app/count"], function(domready, isso, count) {
|
||||
domready(function() {
|
||||
count();
|
||||
isso.init();
|
||||
})
|
||||
});
|
||||
|
Loading…
Reference in new issue