2008-07-14 21:54:50 +08:00
|
|
|
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()
|
|
|
|
{
|
2009-05-26 02:03:46 +08:00
|
|
|
var tickerText = $('exportProgressTicker').get('text');
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( tickerText.length < 1 || tickerText.length > 4 )
|
2009-03-28 00:01:59 +08:00
|
|
|
$('exportProgressTicker').set( 'text', '.' );
|
2008-07-14 21:54:50 +08:00
|
|
|
else
|
|
|
|
$('exportProgressTicker').appendText( '.' );
|
|
|
|
}
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function exportResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-03-28 00:01:59 +08:00
|
|
|
window.location.replace( thisUrl+'?view='+currentView+'&'+eidParm+'&exportFile='+respObj.exportFile+'&generated='+((respObj.result=='Ok')?1:0) );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function exportEvent( form )
|
|
|
|
{
|
|
|
|
var parms = 'view=request&request=event&action=export';
|
2009-03-27 17:14:54 +08:00
|
|
|
parms += '&'+$(form).toQueryString();
|
2009-03-28 00:01:59 +08:00
|
|
|
var query = new Request.JSON( { url: thisUrl, method: 'post', data: parms, onComplete: exportResponse } );
|
|
|
|
query.send();
|
2008-07-14 21:54:50 +08:00
|
|
|
$('exportProgress').removeClass( 'hidden' );
|
|
|
|
$('exportProgress').setProperty( 'class', 'warnText' );
|
2009-03-28 00:01:59 +08:00
|
|
|
$('exportProgressText').set( 'text', exportProgressString );
|
2008-07-14 21:54:50 +08:00
|
|
|
exportProgress();
|
|
|
|
exportTimer = exportProgress.periodical( 500 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function initPage()
|
|
|
|
{
|
|
|
|
configureExportButton( $('exportButton') );
|
|
|
|
if ( exportReady )
|
|
|
|
{
|
|
|
|
startDownload.pass( exportFile ).delay( 1500 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEvent( 'domready', initPage );
|