2019-03-21 02:29:05 +08:00
|
|
|
var exportTimer = null;
|
|
|
|
|
2019-12-03 02:40:02 +08:00
|
|
|
function configureExportButton(element) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
|
2019-12-03 02:40:02 +08:00
|
|
|
var eventCount = 0;
|
|
|
|
document.querySelectorAll('input[name="eids[]"]').forEach(function(el){
|
|
|
|
if ( el.checked ) {
|
|
|
|
eventCount ++;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2019-12-03 02:40:02 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
form.elements['exportButton'].disabled = (
|
|
|
|
eventCount &&
|
|
|
|
(
|
|
|
|
form.elements['exportDetail'].checked ||
|
|
|
|
form.elements['exportFrames'].checked ||
|
|
|
|
form.elements['exportImages'].checked ||
|
|
|
|
form.elements['exportVideo'].checked ||
|
|
|
|
form.elements['exportMisc'].checked
|
|
|
|
)
|
|
|
|
&&
|
|
|
|
( form.elements['exportFormat'][0].checked || form.elements['exportFormat'][1].checked )
|
|
|
|
&&
|
|
|
|
( form.elements['exportCompress'][0].checked || form.elements['exportCompress'][1].checked )
|
|
|
|
);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-03-21 02:29:05 +08:00
|
|
|
function startDownload(file) {
|
2019-12-03 02:40:02 +08:00
|
|
|
console.log('Starting download of ' + file);
|
2019-03-21 02:29:05 +08:00
|
|
|
window.location.replace(file);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function exportProgress() {
|
2019-03-21 02:29:05 +08:00
|
|
|
if ( exportTimer ) {
|
|
|
|
var tickerText = $('exportProgressTicker').get('text');
|
|
|
|
if ( tickerText.length < 1 || tickerText.length > 4 ) {
|
|
|
|
$('exportProgressTicker').set('text', '.');
|
|
|
|
} else {
|
|
|
|
$('exportProgressTicker').appendText('.');
|
|
|
|
}
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-03-21 02:29:05 +08:00
|
|
|
function exportResponse(respObj, respText) {
|
2018-07-10 00:01:09 +08:00
|
|
|
|
2019-12-03 02:40:02 +08:00
|
|
|
clearInterval(exportTimer);
|
2019-03-21 02:29:05 +08:00
|
|
|
if ( respObj.result != 'Ok' ) {
|
|
|
|
$('exportProgressTicker').set('text', respObj.message);
|
|
|
|
} else {
|
|
|
|
$('exportProgressTicker').set('text', exportSucceededString);
|
2019-12-03 02:40:02 +08:00
|
|
|
startDownload.pass(decodeURIComponent(respObj.exportFile)).delay(1500);
|
2019-03-21 02:29:05 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( 0 ) {
|
2019-03-28 21:43:31 +08:00
|
|
|
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;
|
|
|
|
}
|
2018-07-10 00:01:09 +08:00
|
|
|
}
|
|
|
|
}
|
2019-03-21 02:29:05 +08:00
|
|
|
form.submit();
|
|
|
|
|
|
|
|
//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
|
|
|
}
|
|
|
|
|
2019-03-21 02:29:05 +08:00
|
|
|
function exportEvent( ) {
|
|
|
|
var parms = 'view=event&request=event&action=export';
|
|
|
|
parms += '&'+$('contentForm').toQueryString();
|
|
|
|
var query = new Request.JSON( {
|
|
|
|
url: thisUrl,
|
|
|
|
method: 'post',
|
|
|
|
data: parms,
|
|
|
|
onSuccess: exportResponse
|
|
|
|
} );
|
2017-05-19 01:50:56 +08:00
|
|
|
query.send();
|
2019-12-03 02:40:02 +08:00
|
|
|
$('exportProgress').removeClass('hidden');
|
|
|
|
$('exportProgress').setProperty('class', 'warnText');
|
|
|
|
$('exportProgressText').set('text', exportProgressString);
|
|
|
|
//exportProgress();
|
2017-05-19 01:50:56 +08:00
|
|
|
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 ) {
|
2019-12-03 02:40:02 +08:00
|
|
|
startDownload.pass(exportFile).delay(1500);
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2019-03-21 02:29:05 +08:00
|
|
|
document.getElementById('exportButton').addEventListener('click', exportEvent);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-03-21 02:29:05 +08:00
|
|
|
window.addEventListener('DOMContentLoaded', initPage);
|