2018-07-13 02:07:19 +08:00
|
|
|
function configureExportButton( element ) {
|
|
|
|
var form = element.form;
|
|
|
|
|
|
|
|
var radioCount = 0;
|
2019-03-21 02:29:05 +08:00
|
|
|
for ( var i = 0, len=form.elements.length; i < len; i++ ) {
|
2019-03-21 02:51:39 +08:00
|
|
|
if ( form.elements[i].type == "radio" && form.elements[i].checked ) {
|
2018-07-13 02:07:19 +08:00
|
|
|
radioCount++;
|
2019-03-21 02:51:39 +08:00
|
|
|
}
|
2018-07-13 02:07:19 +08:00
|
|
|
}
|
|
|
|
form.elements['exportButton'].disabled = (radioCount == 0);
|
|
|
|
}
|
|
|
|
|
2017-12-04 03:04:33 +08:00
|
|
|
function startDownload( exportFile ) {
|
2019-07-25 00:31:43 +08:00
|
|
|
console.log("Starting download from " + exportFile);
|
2017-12-04 03:04:33 +08:00
|
|
|
window.location.replace( exportFile );
|
|
|
|
}
|
|
|
|
|
|
|
|
var exportTimer = null;
|
|
|
|
|
|
|
|
function exportProgress() {
|
|
|
|
var tickerText = $('exportProgressTicker').get('text');
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( tickerText.length < 1 || tickerText.length > 4 ) {
|
2017-12-04 03:04:33 +08:00
|
|
|
$('exportProgressTicker').set( 'text', '.' );
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2017-12-04 03:04:33 +08:00
|
|
|
$('exportProgressTicker').appendText( '.' );
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2017-12-04 03:04:33 +08:00
|
|
|
}
|
|
|
|
|
2019-07-27 00:28:02 +08:00
|
|
|
function exportResponse(respObj, respText) {
|
2019-07-25 00:31:43 +08:00
|
|
|
console.log(respObj);
|
|
|
|
window.location.replace(
|
2019-07-27 00:28:02 +08:00
|
|
|
thisUrl+'?view='+currentView+'&'+eidParm
|
|
|
|
+'&exportFormat='+respObj.exportFormat
|
|
|
|
+'&exportFile='+respObj.exportFile
|
|
|
|
+'&generated='+((respObj.result=='Ok')?1:0)
|
|
|
|
+'&connkey='+connkey
|
2019-07-25 00:31:43 +08:00
|
|
|
);
|
2017-12-04 03:04:33 +08:00
|
|
|
}
|
|
|
|
|
2019-07-25 00:31:43 +08:00
|
|
|
function exportEvent( element ) {
|
|
|
|
var form = element.form;
|
2017-12-04 03:04:33 +08:00
|
|
|
var parms = 'view=request&request=event&action=download';
|
|
|
|
parms += '&'+$(form).toQueryString();
|
2019-07-25 00:31:43 +08:00
|
|
|
console.log(parms);
|
2019-01-19 23:32:40 +08:00
|
|
|
var query = new Request.JSON( {url: thisUrl, method: 'post', data: parms, onSuccess: exportResponse} );
|
2017-12-04 03:04:33 +08:00
|
|
|
query.send();
|
|
|
|
$('exportProgress').removeClass( 'hidden' );
|
|
|
|
$('exportProgress').setProperty( 'class', 'warnText' );
|
|
|
|
$('exportProgressText').set( 'text', exportProgressString );
|
|
|
|
exportProgress();
|
|
|
|
exportTimer = exportProgress.periodical( 500 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function initPage() {
|
|
|
|
if ( exportReady ) {
|
|
|
|
startDownload.pass( exportFile ).delay( 1500 );
|
|
|
|
}
|
2019-02-09 17:16:32 +08:00
|
|
|
document.getElementById('exportButton').addEventListener("click", function onClick(evt) {
|
2019-07-25 00:31:43 +08:00
|
|
|
exportEvent(this);
|
2019-02-09 17:16:32 +08:00
|
|
|
});
|
2017-12-04 03:04:33 +08:00
|
|
|
}
|
|
|
|
|
2019-01-22 00:14:32 +08:00
|
|
|
window.addEventListener( 'DOMContentLoaded', initPage );
|