67 lines
1.7 KiB
JavaScript
67 lines
1.7 KiB
JavaScript
var PENTAMEDIA = 'http://pentamedia.hq.c3d2.de';
|
|
|
|
/*** Kommentare in der News-Übersicht ***/
|
|
|
|
var links = {};
|
|
|
|
$(document).ready(
|
|
function() {
|
|
var load = false;
|
|
$(".more").find("a").each(
|
|
function() {
|
|
var a = $(this);
|
|
var href = a.attr("href");
|
|
var m;
|
|
if ((m = /\/([^\/\.]+)\.[^\/\.]+$/.exec(href))) {
|
|
links[m[1]] = a;
|
|
load = true;
|
|
}
|
|
});
|
|
if (load) {
|
|
$(document).append('<script src="' + PENTAMEDIA + '/comments.json?jsonp=ShowStats" type="text/javascript"></script>');
|
|
}
|
|
});
|
|
|
|
function ShowStats(comments) {
|
|
for(var filename in comments) {
|
|
var amount = comments[filename];
|
|
var text;
|
|
if (amount == 1)
|
|
text = amount.toString() + " Kommentar";
|
|
else
|
|
text = amount.toString() + " Kommentare";
|
|
|
|
var slug = filename.split(".")[0];
|
|
if (links[slug])
|
|
links[slug].after(" <span class='comments'>" + text + "</span>");
|
|
}
|
|
}
|
|
|
|
/*** Kommentare auf jeder Seite ***/
|
|
|
|
var slug;
|
|
|
|
$(document).ready(
|
|
function() {
|
|
var m;
|
|
if ((m = /\/(penta[a-zA-Z0-9\-]+)\./.exec(document.location))) {
|
|
slug = m[1];
|
|
$(document).append('<script src="'+PENTAMEDIA+'/'+slug+'/comments.json?jsonp=ShowComments" type="text/javascript"></script>');
|
|
}
|
|
});
|
|
|
|
function ShowComments(r) {
|
|
r.comments.forEach(
|
|
function(comment) {
|
|
var div = $("<div></div>");
|
|
$("#content").append(div);
|
|
div.addClass("comment");
|
|
div.append(comment.text);
|
|
div.append($("<span class='author'></small>"));
|
|
div.find('.author').text(comment.author);
|
|
div.append($("<small class='date'></small>"));
|
|
div.find('.date').text(comment.date);
|
|
});
|
|
$("#content").append("<p><a href='" + PENTAMEDIA + r.new_link + "'>Kommentar hinzufügen</a></p>");
|
|
}
|