var EventX = null; var EventY = null; var TOGGLE_ELEMENT = ''; var bLoadUI = false; // Objektinstanz var objXMLHTTP; var arSendQueue = new Array(); // ----------------------------------------------------------------------------- // | AJAX Kommando // | Command = Befehl // | CallBack = R?ckgabefunktion // | Data = Dateninhalt function AJAXCommand(Command,CallBack,Data) { this.Command = Command; this.CallBack = CallBack; this.Data = Data; } // ----------------------------------------------------------------------------- // | initialisiere die AJAX Komponente function initAJAX() { if (window.ActiveXObject) { try { objXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { objXMLHTTP = false; } } } else if (window.XMLHttpRequest) { try { objXMLHTTP = new XMLHttpRequest(); } catch (e) { objXMLHTTP = false; } } } // ----------------------------------------------------------------------------- // | arbeitet die Sendequeue ab // | function sendQueue() { self.status = 'In der Queue sind '+arSendQueue.length+' Elemente.'; for (i=arSendQueue.length;i>0;i--) { var oCmd = arSendQueue[i-1]; var stPost = "&command="+escape(oCmd.Command); //Senden sDispatcher = location.href; sDispatcher = sDispatcher.replace(".php",".ajaxdispatcher.php"); objXMLHTTP.open("POST", sDispatcher, true); objXMLHTTP.setRequestHeader("Method", "POST " + sDispatcher + " HTTP/1.1"); objXMLHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); stPost+="&data="+escape(oCmd.Data); objXMLHTTP.onreadystatechange= function() { self.status = 'Ready-State: '+objXMLHTTP.readyState; if (objXMLHTTP.readyState==4) { if (objXMLHTTP.status == 200) { self.status = 'Status: '+objXMLHTTP.status; toggleInfoContainer(false); eval("oCmd.CallBack();"); } } else return; } stPost = stPost.replace(/\+/g,escape("+")); objXMLHTTP.send(stPost); toggleInfoContainer(true); //Eintrag aus Queue l?schen delete oCmd; if (arSendQueue.length > 1) arSendQueue.length = arSendQueue.length -1; else arSendQueue = new Array(); } window.setTimeout("sendQueue()",2000); } // ----------------------------------------------------------------------------- // | Debug function vd(obj) { st = ""; if (obj == undefined) { alert('obj ist undefined'); return; } for (i in obj) st+=i + " = " + obj[i] + "\n"; alert(st); } function trim_ (zeichenkette) { // Erst führende, dann Abschließende Whitespaces entfernen // und das Ergebnis dieser Operationen zurückliefern return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, ''); } function toggleInfoContainer(bVisible) { var obj = document.getElementById('AJAX_Container'); if (obj==null) return false; var oElement; if (TOGGLE_ELEMENT!='') { oElement = document.getElementById(TOGGLE_ELEMENT); } if (oElement!=undefined) { iHeight = oElement.style.height; iLeft = oElement.style.left + 300; iWidth = oElement.style.width; iTop = oElement.style.top+100; } else if (EventX!=null) { iHeight = 40; iLeft = EventX-200; iWidth = 300; iTop = EventY; } else { iHeight = 40; iLeft = 250; iWidth = 300; iTop = 300; } obj.style.height = iHeight; obj.style.left = iLeft; obj.style.width = iWidth; obj.style.top = iTop; obj.style.display = (bVisible ? 'block' : 'none'); TOGGLE_ELEMENT = ''; }