var sm_shoutbox_lastid = 0;
function sm_shoutbox_getMessages() {
jQuery.getJSON("content/sm_addons/shoutbox.php", {ajax: true, lastid: sm_shoutbox_lastid}, function(json) {
jQuery("#sm_shoutbox_loading").remove();
jQuery("#sm_shoutbox_tabs ul li").eq(3).text("Jackpot: "+json.jackpot);
sm_shoutbox_lastid = json.lastId;
jQuery.each(json.messages, function(i, message) {
var postdate = new Date(message.time*1000);
var showdate = "am "+postdate.getDate()+". "+(postdate.getMonth()+1)+". "+postdate.getFullYear()+" um "+postdate.getHours()+":"+(postdate.getMinutes() < 10 ? "0"+postdate.getMinutes() : postdate.getMinutes())+":"+(postdate.getSeconds() < 10 ? "0"+postdate.getSeconds() : postdate.getSeconds());
jQuery("
").html("
"+message.text+"
").prependTo("#sm_shoutbox_anzeige");
});
});
}
jQuery(function() {
jQuery("
").attr("rel", "stylesheet").attr("type", "text/css").attr("href", "themes/base/jquery-ui.css").appendTo("head");
jQuery("#sm_shoutbox_tabs").tabs();
sm_shoutbox_getMessages();
setInterval("sm_shoutbox_getMessages()", 30000);
jQuery.getJSON("content/sm_addons/shoutbox.php", {ajax: true, archiv: true}, function(json) {
jQuery.each(json.messages, function(i, message) {
var postdate = new Date(message.time*1000);
var showdate = "am "+postdate.getDate()+". "+(postdate.getMonth()+1)+". "+postdate.getFullYear()+" um "+postdate.getHours()+":"+(postdate.getMinutes() < 10 ? "0"+postdate.getMinutes() : postdate.getMinutes())+":"+(postdate.getSeconds() < 10 ? "0"+postdate.getSeconds() : postdate.getSeconds());
jQuery("
").html("
"+message.text+"
").prependTo("#sm_shoutbox_archiv");
});
});
jQuery("#sm_shoutbox_senden").click(function() {
if (jQuery("#sm_shoutbox_message").val().length <= 2000 && jQuery("#sm_shoutbox_message").val().length >= 0) {
jQuery.post("?content=/sm_addons/shoutbox",
{text: jQuery("#sm_shoutbox_message").val()},
function() {
jQuery("#sm_shoutbox_message").val("");
sm_shoutbox_getMessages();
});
} else {
jQuery("
").attr("title", "Error").text("Der Text darf maximal 2000 und muss mindestens 0 Zeichen enthalten!").dialog();
}
});
});