egroupware_official/notifications/js/notificationajaxpopup.js
2009-03-04 20:50:06 +00:00

80 lines
2.3 KiB
JavaScript

/**
* eGroupWare - Notifications
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package notifications
* @subpackage ajaxpoup
* @link http://www.egroupware.org
* @author Cornelius Weiss <nelius@cwtech.de>
* @version $Id$
*/
var notifymessages = new Array();
function egwpopup_init() {
window.setTimeout("egwpopup_refresh();", 1000);
}
function egwpopup_setTimeout() {
window.setTimeout("egwpopup_refresh();", 60000);
}
function egwpopup_refresh() {
xajax_doXMLHTTP("notifications.ajaxnotifications.check_mailbox");
xajax_doXMLHTTP("notifications.ajaxnotifications.get_egwpopup_notifications");
egwpopup_setTimeout();
}
function egwpopup_display() {
var egwpopup;
var egwpopup_message;
var Browserwidth;
var Browserheight;
var egwpopup_ok_button;
egwpopup = document.getElementById("egwpopup");
egwpopup_message = document.getElementById("egwpopup_message");
egwpopup_ok_button = document.getElementById("egwpopup_ok_button");
egwpopup.style.display = "block";
egwpopup.style.position = "absolute";
egwpopup.style.width = "500px";
Browserwidth = (window.innerWidth || document.body.clientWidth || 640)
Browserheight = (window.innerHeight || document.body.clientHeight || 480)
egwpopup.style.left = (Browserwidth/2 - 250) + "px";
egwpopup.style.top = (Browserheight/4) + "px";
egwpopup_message.style.maxHeight = (Browserheight/2) + "px";
egwpopup_message.innerHTML = notifymessages[0];
if(notifymessages.length-1 > 0 ) {
egwpopup_ok_button.value = "OK (" + (notifymessages.length-1) + ")";
} else {
egwpopup_ok_button.value = "OK";
}
}
function notificationbell_switch(mode) {
var notificationbell;
notificationbell = document.getElementById("notificationbell");
if(mode == "active") {
notificationbell.style.display = "inline";
} else {
notificationbell.style.display = "none";
}
}
function egwpopup_button_ok() {
var egwpopup;
var egwpopup_message;
egwpopup = document.getElementById("egwpopup");
egwpopup_message = document.getElementById("egwpopup_message");
egwpopup_message.scrollTop = 0;
notifymessages.shift();
if(notifymessages.length > 0) {
egwpopup_display();
} else {
egwpopup.style.display = "none";
egwpopup_message.innerHTML = "";
notificationbell_switch("inactive");
}
}
function append_notification_message(_message) {
notifymessages.push(_message);
}