var phpmvRowsArray = new Array(); function getHTTPObject(elt,url,typeResponse,loadingRow) { var xmlhttp = false; /* Compilation conditionnelle d'IE */ /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ /* on essaie de créer l'objet si ce n'est pas déjà fait */ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } if (xmlhttp) { /* on définit ce qui doit se passer quand la page répondra */ xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200 || xmlhttp.status == 304 ) { switch ( typeResponse ) { case 'xml': if (window.ActiveXObject){ vXMLDoc = new ActiveXObject("Microsoft.XMLDOM"); vXMLDoc.async = false; vXMLDoc.loadXML(xmlhttp.responseText); } else { var vParser = new DOMParser(); vXMLDoc = vParser.parseFromString(xmlhttp.responseText, "text/xml"); } traitementDOM(elt,vXMLDoc,url,loadingRow); //var parentElt = elt.parentNode; //if(parentElt) parentElt.removeChild(loadingRow); break; case 'html': phpmvRowsArray[url] = xmlhttp.responseText; elt.innerHTML = xmlhttp.responseText; break; } } } } } return xmlhttp; } function createLoadingRow (elt) { var myDocument = elt.ownerDocument; var loadingRow = myDocument.createElement('tr'); var loadingCell = myDocument.createElement('td'); setAttributeDom(loadingCell,'colspan', elt.getElementsByTagName("td").length); var txtNode = myDocument.createTextNode('Loading...'); loadingCell.appendChild(txtNode); loadingRow.appendChild(loadingCell); insertAfterRow(elt,loadingRow); return loadingRow; } function viewRowsDetails(elt,url,p_changeImage) { // add or remove sub-row details var myDocument = elt.ownerDocument; var exp; // Change expand / collapse image if ((typeof(p_changeImage) == "undefined") || (p_changeImage)) { var myImgExpandCollapse = elt.getElementsByTagName("td")[0].getElementsByTagName("img"); if (myImgExpandCollapse.length > 0) { exp = new RegExp(/(.*)(switch[a-b])(\..*)/); var tabElt = exp.exec(myImgExpandCollapse[0].getAttribute('src')); if (tabElt != null) { switchStr = (tabElt[2]=='switcha') ? 'switchb':'switcha'; setAttributeDom(myImgExpandCollapse[0],'src',tabElt[1]+switchStr+tabElt[3]); } } } exp = new RegExp(/(.*)\sselectedRow/); // unselected all rows var allRows = myDocument.getElementsByTagName("tr"); for (var i=0;i0;i--) { var isInterrest = false; // if the rows details is in table with header if (response.getElementsByTagName("th").length>0) isInterrest = true; // we are in table with header cells var newRow = myDocument.createElement('tr'); if (allRows[i-1].getAttributeNode('onclick')!=null) { // add attributes for the new row setAttributeDom(newRow,'onclick',allRows[i-1].attributes.getNamedItem('onclick').value); setAttributeDom(newRow,'class','expandcollapse'); } else if (isInterrest) { setAttributeDom(newRow,'class','details'); } // add header's details cells var myRow = allRows[i-1].getElementsByTagName("th"); for (var j=0;j 0) { exp = new RegExp(/(.*)(switch[a-b])(\..*)/); var tabElt = exp.exec(myImgExpandCollapse[0].getAttribute('src')); if (tabElt != null) { if (tabElt[2]=='switchb') setAttributeDom(myImgExpandCollapse[0],'src',tabElt[1]+'switcha'+tabElt[3]); } } var exp = /.*(\(this,')(.*)('\)).*/; //var curURL = exp.exec(phpmvRowsArray[url][i].attributes.getNamedItem('onclick').value); var curURL = exp.exec(phpmvRowsArray[url][i].getAttribute('onclick')); if (curURL != null) curURL = curURL[2]; removeDetails(phpmvRowsArray[url][i],curURL); } parentElt.removeChild(phpmvRowsArray[url][i]); } } } function displayInterest( curElt ) { // display complet table for more information exp = new RegExp(/(.*)(.*)(<\/span>.*)/i); var tabElt = exp.exec(curElt.innerHTML); switchStr = (tabElt[2]=='+') ? '-':'+'; curElt.innerHTML = tabElt[1] + switchStr + tabElt[3]; // switch '+' and '-' when expand/collapse var tmpElt = curElt.nextSibling; while (tmpElt.tagName != 'DIV') { tmpElt = tmpElt.nextSibling; } if (tmpElt.style.display == 'block') tmpElt.style.display = 'none'; else tmpElt.style.display = 'block'; } function changeDetails(curElt,url) { // load complete content with cache var tmpElt = curElt.parentNode; while (tmpElt.tagName != 'DIV') { tmpElt = tmpElt.parentNode; } if (phpmvRowsArray[url] == undefined) { curElt.parentNode.innerHTML = 'Loading...'; var xmlhttp = getHTTPObject(tmpElt,url,'html'); xmlhttp.open("GET",url,true); xmlhttp.send( null ); } else { tmpElt.innerHTML = phpmvRowsArray[url]; } } function removeOldRows(tmpElt,url) { var curTable = tmpElt.parentNode; var myTmpRow; var myTmpElt = tmpElt; while (!attributeExist(myTmpElt,'id') && !attributeExist(myTmpElt,'onclick')) { // search for parent rows wich contain link myTmpRow = myTmpElt; myTmpElt = myTmpElt.previousSibling; curTable.removeChild(myTmpRow); if (myTmpElt == null) { break; } } exp = new RegExp(/(.*')(.*)('.*)/); var tabElt = exp.exec(myTmpElt.getAttribute('onclick')); if (myTmpElt.onclick != null) { //setAttributeDom(tmpElt,'onclick','javascript:alert('+tabElt[1]+url+tabElt[2]+')'); if (url != tabElt[2]) { setAttributeDom(tmpElt,'onclick',tabElt[1]+url+tabElt[3]); } } return myTmpElt; } function setAttributeDom(myElt,attributeName,attributeValue) { var testWithOnlyOneCharacter = 'test'+attributeValue; // indexOf don't work with only 1 character :-( if (attributeName == 'colspan' && testWithOnlyOneCharacter.indexOf(' ') != -1) { attributeValue = attributeValue.substring(attributeValue.lastIndexOf(' '),attributeValue.length); } z = document.createAttribute(attributeName); z.value = attributeValue; //SS myElt.setAttributeNode(z); myElt.setAttribute(attributeName,attributeValue); if (attributeName=='onclick') { myElt.onclick = function() { eval(attributeValue) } } } function attributeExist(myElt,attrName) { // test if an element has the specified attribute, because hasAttribute DOM's function is buggy if (myElt.getAttributeNode(attrName) != null) { if (myElt.getAttributeNode(attrName).value == 'null' || myElt.getAttributeNode(attrName).value == '') { //saloperie d'IE ! return false; } else { return true; } } else { return false; } } // Ajout CMI function inverseSpan( cur ) { if(cur.innerHTML == ' - ') cur.innerHTML = ' + '; else cur.innerHTML = ' - '; } function getDisplay( i ) { d = i.style.display; if(d == 'none') return 'none'; else return ''; } function inverseDisplay( i ) { if(getDisplay(i)=='') { newD = 'none'; returned = false; } else { newD = ''; returned = true; } setDisplay(i, newD); return returned; } function setDisplay(i, d) { i.style.display = d; } function findFirstChildWithType( targetNode, type ) { for(var i = 0; i < targetNode.childNodes.length; i++) { var child = targetNode.childNodes[i]; if (child.nodeName == type ) return child; } return false; } function pointer( current ) { current.style.cursor = 'pointer'; } function loadUrl( url ) { window.location = url; } function hideIt(current) { inverseDisplay(current); } function displayVariables( cur ) { hideIt( findFirstChildWithType( cur, 'DIV') ); spanToInverse = findFirstChildWithType( cur, 'SPAN'); inverseSpan( spanToInverse ); }