// Browser specific XmlHttpRequest Object function getXmlHttpRequestObject() { if( window.XMLHttpRequest ) { return new XMLHttpRequest(); // Not IE } else if( window.ActiveXObject ) { return new ActiveXObject( "Microsoft.XMLHTTP" ); // IE } /*else { alert( "Your browser doesn't support this function, sorry!" ); }*/ } var receiveReq = new Array(); // Called on clicking 'search' function getDirSize( path, deploy ) { receiveReq[path] = getXmlHttpRequestObject(); if( receiveReq[path].readyState == 4 || receiveReq[path].readyState == 0 ) { var url = 'http://fss.powellwilliams.co.uk/xml_dirsize.php?path='+path; if( deploy != false ) { url += '&deploy='+deploy; } receiveReq[path].open("GET", url, true); receiveReq[path].onreadystatechange = handleAddr; receiveReq[path].send(null); } } // This is incremented with the size of each dir sized by the callback. var dirSizeSum=0; // Called on callback. function handleAddr() { // 4 == finished for( keyVar in receiveReq ) { if( receiveReq[keyVar] && receiveReq[keyVar].readyState == 4 ) { var doc = receiveReq[keyVar].responseText; var data = doc.split( "\n"); if( data.length == 3 ) { var destdiv = document.getElementById( data[0] ); destdiv.innerHTML = data[1]; dirSizeSum += parseInt(data[2]); var destdiv = document.getElementById( "DeploymentTotalSize" ); if( destdiv ) { destdiv.innerHTML = size_translate( dirSizeSum ); } } else { alert( 'Error reading size: access denied.' ); } receiveReq[keyVar] = null } } // for } // Allow a structure of file trees to build an array of "Get Size" button paths // currently displayed to the user, so that later we can run a global 'get size' // operation. var ftDirs = new Array(); function ftAddDir( path ) { ftDirs.push( path ); } // Runs over the list of dirs built above and calls the GetSize function for each. function ftGetAllSizes() { for(i=0;i arrayPowers[i] || filesize == arrayPowers[i] ) { filesize = Math.round((Math.round(filesize / arrayPowers[i] * 100) / 100)*100)/100 + " " + i; } } return filesize; }