2017-05-19 01:50:56 +08:00
|
|
|
function configureExportButton( element ) {
|
|
|
|
var form = element.form;
|
|
|
|
|
|
|
|
var checkCount = 0;
|
|
|
|
var radioCount = 0;
|
|
|
|
for ( var i = 0; i < form.elements.length; i++ ) {
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( form.elements[i].type == "checkbox" && form.elements[i].checked ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
checkCount++;
|
2019-01-19 23:32:40 +08:00
|
|
|
} else if ( form.elements[i].type == "radio" && form.elements[i].checked ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
radioCount++;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
|
|
|
form.elements['exportButton'].disabled = (checkCount == 0 || radioCount == 0);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2018-07-10 00:01:09 +08:00
|
|
|
function startDownload(exportFile) {
|
|
|
|
window.location.replace(exportFile);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var exportTimer = null;
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function exportProgress() {
|
|
|
|
var tickerText = $('exportProgressTicker').get('text');
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( tickerText.length < 1 || tickerText.length > 4 ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
$('exportProgressTicker').set( 'text', '.' );
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2017-05-19 01:50:56 +08:00
|
|
|
$('exportProgressTicker').appendText( '.' );
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function exportResponse( respObj, respText ) {
|
2018-07-10 00:01:09 +08:00
|
|
|
console.log(respObj);
|
|
|
|
console.log(respText);
|
|
|
|
|
|
|
|
var form = $j('#contentForm')[0];
|
|
|
|
var eids = new Array();
|
|
|
|
for (var i = 0, len=form.elements.length; i < len; i++) {
|
|
|
|
if ( form.elements[i].name == 'eids[]' ) {
|
|
|
|
eids[eids.length] = 'eids[]='+form.elements[i].value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window.location.replace( thisUrl+'?view='+currentView+'&'+eids.join('&')+'&exportFile='+respObj.exportFile+'&generated='+((respObj.result=='Ok')?1:0) );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function exportEvent( form ) {
|
|
|
|
var parms = 'view=request&request=event&action=export';
|
|
|
|
parms += '&'+$(form).toQueryString();
|
2019-01-19 23:32:40 +08:00
|
|
|
var query = new Request.JSON( {url: thisUrl, method: 'post', data: parms, onSuccess: exportResponse} );
|
2017-05-19 01:50:56 +08:00
|
|
|
query.send();
|
|
|
|
$('exportProgress').removeClass( 'hidden' );
|
|
|
|
$('exportProgress').setProperty( 'class', 'warnText' );
|
|
|
|
$('exportProgressText').set( 'text', exportProgressString );
|
|
|
|
exportProgress();
|
|
|
|
exportTimer = exportProgress.periodical( 500 );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function initPage() {
|
|
|
|
configureExportButton( $('exportButton') );
|
|
|
|
if ( exportReady ) {
|
|
|
|
startDownload.pass( exportFile ).delay( 1500 );
|
|
|
|
}
|
2019-02-09 18:01:26 +08:00
|
|
|
document.getElementById('exportButton').addEventListener('click', function onClick() {
|
|
|
|
exportEvent(this.form);
|
|
|
|
});
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-01-22 00:14:32 +08:00
|
|
|
window.addEventListener( 'DOMContentLoaded', initPage );
|