2019-03-21 02:29:05 +08:00
|
|
|
var exportTimer = null;
|
|
|
|
|
2021-05-23 01:59:10 +08:00
|
|
|
function configureExportButton() {
|
|
|
|
var form = $j('#contentForm')[0];
|
|
|
|
if (!form) {
|
|
|
|
console.error("Form contentForm not found by jquery.");
|
|
|
|
return;
|
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
|
2019-12-03 02:40:02 +08:00
|
|
|
var eventCount = 0;
|
2019-12-18 23:40:51 +08:00
|
|
|
document.querySelectorAll('input[name="eids[]"]').forEach(function(el) {
|
2021-05-23 01:59:10 +08:00
|
|
|
if (el.checked) {
|
2019-12-03 02:40:02 +08:00
|
|
|
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
|
2020-09-04 22:02:43 +08:00
|
|
|
) &&
|
|
|
|
( form.elements['exportFormat'][0].checked || form.elements['exportFormat'][1].checked ) &&
|
2019-12-03 02:40:02 +08:00
|
|
|
( 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 ) {
|
2020-12-03 00:53:55 +08:00
|
|
|
var tickerText = $j('#exportProgressTicker').text();
|
2019-03-21 02:29:05 +08:00
|
|
|
if ( tickerText.length < 1 || tickerText.length > 4 ) {
|
2020-12-03 00:53:55 +08:00
|
|
|
$j('#exportProgressTicker').text('.');
|
2019-03-21 02:29:05 +08:00
|
|
|
} else {
|
2020-12-03 00:53:55 +08:00
|
|
|
$j('#exportProgressTicker').append('.');
|
2019-03-21 02:29:05 +08:00
|
|
|
}
|
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) {
|
2019-12-03 02:40:02 +08:00
|
|
|
clearInterval(exportTimer);
|
2019-03-21 02:29:05 +08:00
|
|
|
if ( respObj.result != 'Ok' ) {
|
2020-12-03 00:53:55 +08:00
|
|
|
$j('#exportProgressTicker').text(respObj.message);
|
2019-03-21 02:29:05 +08:00
|
|
|
} else {
|
2020-12-03 00:53:55 +08:00
|
|
|
$j('#exportProgressTicker').text(exportSucceededString);
|
2020-12-21 05:21:38 +08:00
|
|
|
setTimeout(startDownload, 1500, decodeURIComponent(respObj.exportFile));
|
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
|
|
|
}
|
|
|
|
|
2020-04-04 23:53:07 +08:00
|
|
|
function exportEvents( ) {
|
2020-12-21 00:54:18 +08:00
|
|
|
var formData = $j('#contentForm').serialize();
|
|
|
|
|
|
|
|
$j.getJSON(thisUrl + '?view=event&request=event&action=export', formData)
|
|
|
|
.done(exportResponse)
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
|
|
|
|
$j('#exportProgress').removeClass('hidden');
|
|
|
|
$j('#exportProgress').addClass('warnText');
|
|
|
|
$j('#exportProgress').text(exportProgressString);
|
2020-12-21 05:07:16 +08:00
|
|
|
|
2019-12-03 02:40:02 +08:00
|
|
|
//exportProgress();
|
2021-01-08 21:32:52 +08:00
|
|
|
exportTimer = setInterval(exportProgress, 500);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-09-15 21:55:32 +08:00
|
|
|
function getEventDetailModal(eid) {
|
|
|
|
$j.getJSON(thisUrl + '?request=modal&modal=eventdetail&eids[]=' + eid)
|
2020-09-16 20:57:44 +08:00
|
|
|
.done(function(data) {
|
2020-10-15 04:58:39 +08:00
|
|
|
insertModalHtml('eventDetailModal', data.html);
|
2020-09-16 20:57:44 +08:00
|
|
|
$j('#eventDetailModal').modal('show');
|
|
|
|
// Manage the Save button
|
|
|
|
$j('#eventDetailSaveBtn').click(function(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
$j('#eventDetailForm').submit();
|
|
|
|
});
|
|
|
|
})
|
2020-09-20 21:41:16 +08:00
|
|
|
.fail(logAjaxFail);
|
2020-09-15 21:55:32 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function initPage() {
|
2021-05-23 01:59:10 +08:00
|
|
|
configureExportButton();
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( exportReady ) {
|
2020-12-21 05:21:38 +08:00
|
|
|
setTimeout(startDownload, 1500, exportFile);
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2020-04-04 23:53:07 +08:00
|
|
|
document.getElementById('exportButton').addEventListener('click', exportEvents);
|
2020-09-28 01:43:12 +08:00
|
|
|
|
2020-09-15 21:55:32 +08:00
|
|
|
// Manage the eventdetail link in the export list
|
|
|
|
$j(".eDetailLink").click(function(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
var eid = $j(this).data('eid');
|
|
|
|
getEventDetailModal(eid);
|
|
|
|
});
|
2020-09-28 01:43:12 +08:00
|
|
|
|
|
|
|
// Manage the BACK button
|
|
|
|
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.history.back();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Don't enable the back button if there is no previous zm page to go back to
|
|
|
|
$j('#backBtn').prop('disabled', !document.referrer.length);
|
|
|
|
|
|
|
|
// Manage the REFRESH Button
|
|
|
|
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
window.location.reload(true);
|
|
|
|
});
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-03-21 02:29:05 +08:00
|
|
|
window.addEventListener('DOMContentLoaded', initPage);
|