function configureExportButton( element ) { var form = element.form; var checkCount = 0; var radioCount = 0; for ( var i = 0; i < form.elements.length; i++ ) if ( form.elements[i].type == "checkbox" && form.elements[i].checked ) checkCount++; else if ( form.elements[i].type == "radio" && form.elements[i].checked ) radioCount++; form.elements['exportButton'].disabled = (checkCount == 0 || radioCount == 0); } function startDownload( exportFile ) { window.location.replace( exportFile ); } var exportTimer = null; function exportProgress() { var tickerText = $('exportProgressTicker').getText(); if ( tickerText.length < 1 || tickerText.length > 4 ) $('exportProgressTicker').setText( '.' ); else $('exportProgressTicker').appendText( '.' ); } function exportResponse( respText ) { if ( respText == 'Ok' ) return; var response = Json.evaluate( respText ); window.location.replace( thisUrl+'?view='+currentView+'&'+eidParm+'&exportFile='+response.exportFile+'&generated='+((response.result=='Ok')?1:0) ); } function exportEvent( form ) { var parms = 'view=request&request=event&action=export'; parms += '&'+$(form).toQueryString(); var query = new Ajax( thisUrl, { method: 'post', data: parms, onComplete: exportResponse } ); query.request(); $('exportProgress').removeClass( 'hidden' ); $('exportProgress').setProperty( 'class', 'warnText' ); $('exportProgressText').setText( exportProgressString ); exportProgress(); exportTimer = exportProgress.periodical( 500 ); } function initPage() { configureExportButton( $('exportButton') ); if ( exportReady ) { startDownload.pass( exportFile ).delay( 1500 ); } } window.addEvent( 'domready', initPage );