Ahoi alle
habe mit jquery und ohne ein Script gebastelt, auf ursprüngliche Anregung von Matthias, um a) auf die gesamtübersicht mit einem link zu kommen (/all) b) den refresh auf 60 sekunden zu setzen c) ein popup-div zu bekommen, dass mir anzeigt, ob neue nachrichten da sind (aber nur, wenn ich auf /, /all, /meta oder /self bin).
für diese dialogbox muss man extra ein div in den baum einhängen. das ist sicherlich overdone.
mich würden code-optimierungen interessieren.
$(document).ready(function() {
//set links für beide foren
var linkTitle = "/all";
var elems = [ "#top ul li:first", "#content nav ul li:first"];
$.each( elems, function( i, elem ) {
$(elem).after('<li><a href="/all">' + linkTitle + '</a></li>');
});
// für das kleine fensterchen ein riesen aufwand - jquery ui, jquery css und hidden divbutton einhänten ...;
var createTooltipDialogDiv = function () {
cssHref = "https://code.jquery.com/ui/1.11.4/themes/start/jquery-ui.css";
$("<link rel='stylesheet' type='text/css' href='"+ cssHref +"'>").appendTo( "head" );
scriptName = "https://code.jquery.com/ui/1.11.4/jquery-ui.js";
$.getScript(scriptName, function() {
$( "<div id='dialog' style='display:none'></div>" ).appendTo( "body" )
$("#dialog").dialog({
title: nachrichtenZahlString + ' Nachrichten',
buttons: {
lesen: function () {
$(this).dialog('close');
top.location.href="http://forum.selfhtml.org/notifications";
}
}
});
});
}
var locationsList = ["http://forum.selfhtml.org/all", "http://forum.selfhtml.org/", "http://forum.selfhtml.org/meta", "http://forum.selfhtml.org/self"];
// nur für all, meta, self und /
if($.inArray(top.location.href, locationsList) !== -1) {
$('[http-equiv="refresh"]').attr('content','60; URL=http://forum.selfhtml.org/all');
//nachrichten da?
var nachrichtenZahlString = $("#notifications-display").html();
if(parseInt(nachrichtenZahlString) > 0) {
createTooltipDialogDiv();
}
}
});
Dank und Gruß,
bob from berlin