2017-05-19 01:50:56 +08:00
|
|
|
function closeWindows() {
|
|
|
|
window.close();
|
|
|
|
// This is a hack. The only way to close an existing window is to try and open it!
|
|
|
|
var filterWindow = window.open( thisUrl+'?view=none', 'zmFilter', 'width=1,height=1' );
|
|
|
|
filterWindow.close();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-01-22 00:11:40 +08:00
|
|
|
function setButtonStates( element ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
var checked = element.checked;
|
2018-06-16 03:21:10 +08:00
|
|
|
form.viewBtn.disabled = !(canViewEvents && checked);
|
|
|
|
form.editBtn.disabled = !(canEditEvents && checked);
|
2017-05-19 01:50:56 +08:00
|
|
|
form.archiveBtn.disabled = unarchivedEvents?!checked:true;
|
2018-06-16 03:21:10 +08:00
|
|
|
form.unarchiveBtn.disabled = !(canEditEvents && archivedEvents && checked);
|
|
|
|
form.downloadBtn.disabled = !(canViewEvents && checked);
|
|
|
|
form.exportBtn.disabled = !(canViewEvents && checked);
|
|
|
|
form.deleteBtn.disabled = !(canEditEvents && checked);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function configureButton(event) {
|
|
|
|
var element = event.target;
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
var checked = element.checked;
|
|
|
|
if ( !checked ) {
|
2019-02-07 02:31:34 +08:00
|
|
|
for (var i = 0, len=form.elements.length; i < len; i++) {
|
|
|
|
if ( form.elements[i].name.indexOf('markEids') == 0) {
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
checked = true;
|
|
|
|
break;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( !element.checked ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
form.toggleCheck.checked = false;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2018-06-16 03:21:10 +08:00
|
|
|
form.viewBtn.disabled = !(canViewEvents && checked);
|
|
|
|
form.editBtn.disabled = !(canEditEvents && checked);
|
2017-05-19 01:50:56 +08:00
|
|
|
form.archiveBtn.disabled = (!checked)||(!unarchivedEvents);
|
2018-06-16 03:21:10 +08:00
|
|
|
form.unarchiveBtn.disabled = !(canEditEvents && checked && archivedEvents);
|
|
|
|
form.downloadBtn.disabled = !(canViewEvents && checked);
|
|
|
|
form.exportBtn.disabled = !(canViewEvents && checked);
|
|
|
|
form.deleteBtn.disabled = !(canEditEvents && checked);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function deleteEvents( element ) {
|
2018-06-16 03:21:10 +08:00
|
|
|
if ( ! canEditEvents ) {
|
|
|
|
alert("You do not have permission to delete events.");
|
|
|
|
return;
|
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
2019-02-07 02:31:34 +08:00
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
var count = 0;
|
2019-02-07 02:31:34 +08:00
|
|
|
// This is slightly more efficient than a jquery selector because we stop after finding one.
|
2017-05-19 01:50:56 +08:00
|
|
|
for (var i = 0; i < form.elements.length; i++) {
|
2019-02-07 02:31:34 +08:00
|
|
|
if (form.elements[i].name.indexOf('markEids') == 0) {
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
count++;
|
|
|
|
break;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
|
|
|
if ( count > 0 ) {
|
|
|
|
if ( confirm( confirmDeleteEventsString ) ) {
|
2018-02-03 05:07:13 +08:00
|
|
|
form.elements['action'].value = 'delete';
|
2017-05-19 01:50:56 +08:00
|
|
|
form.submit();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function editEvents( element ) {
|
2018-06-16 03:21:10 +08:00
|
|
|
if ( ! canEditEvents ) {
|
|
|
|
alert("You do not have permission to delete events.");
|
|
|
|
return;
|
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
var eids = new Array();
|
2019-02-07 02:31:34 +08:00
|
|
|
for (var i = 0, len=form.elements.length; i < len; i++) {
|
|
|
|
if (form.elements[i].name.indexOf('markEids') == 0) {
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
eids[eids.length] = 'eids[]='+form.elements[i].value;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
|
|
|
createPopup( '?view=eventdetail&'+eids.join( '&' ), 'zmEventDetail', 'eventdetail' );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function downloadVideo( element ) {
|
2017-12-04 03:04:33 +08:00
|
|
|
var form = element.form;
|
|
|
|
var eids = new Array();
|
2019-02-07 02:31:34 +08:00
|
|
|
for (var i = 0, len=form.elements.length; i < len; i++) {
|
|
|
|
if (form.elements[i].name.indexOf('markEids') == 0 ) {
|
2017-12-04 03:04:33 +08:00
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
eids[eids.length] = 'eids[]='+form.elements[i].value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-07 02:31:34 +08:00
|
|
|
createPopup( '?view=download&'+eids.join('&'), 'zmDownload', 'download' );
|
2017-12-04 03:04:33 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function exportEvents( element ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
var eids = new Array();
|
2019-02-07 02:31:34 +08:00
|
|
|
for (var i = 0, len=form.elements.length; i < len; i++) {
|
|
|
|
if (form.elements[i].name.indexOf('markEids') == 0 ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
eids[eids.length] = 'eids[]='+form.elements[i].value;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
|
|
|
createPopup( '?view=export&'+eids.join( '&' ), 'zmExport', 'export' );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function viewEvents( element ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
|
|
|
var events = new Array();
|
2019-02-07 02:31:34 +08:00
|
|
|
for (var i = 0, len=form.elements.length; i < len; i++) {
|
|
|
|
if ( form.elements[i].name.indexOf('markEids') == 0 ) {
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( form.elements[i].checked ) {
|
|
|
|
events[events.length] = form.elements[i].value;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
|
|
|
if ( events.length > 0 ) {
|
2019-01-18 23:00:55 +08:00
|
|
|
var filter = '&filter[Query][terms][0][attr]=Id&filter[Query][terms][0][op]=%3D%5B%5D&filter[Query][terms][0][val]='+events.join('%2C');
|
2017-12-06 01:50:49 +08:00
|
|
|
window.location.href = thisUrl+'?view=event&eid='+events[0]+filter+sortQuery+'&page=1&play=1';
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function archiveEvents(element) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
2018-02-03 05:07:13 +08:00
|
|
|
form.elements['action'].value = 'archive';
|
2017-05-19 01:50:56 +08:00
|
|
|
form.submit();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function unarchiveEvents(element) {
|
2018-06-16 03:21:10 +08:00
|
|
|
if ( ! canEditEvents ) {
|
|
|
|
alert("You do not have permission to delete events.");
|
|
|
|
return;
|
|
|
|
}
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
2018-02-03 05:07:13 +08:00
|
|
|
form.elements['action'].value = 'unarchive';
|
2017-05-19 01:50:56 +08:00
|
|
|
form.submit();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( openFilterWindow ) {
|
|
|
|
//opener.location.reload(true);
|
|
|
|
createPopup( '?view=filter&page='+thisPage+filterQuery, 'zmFilter', 'filter' );
|
|
|
|
location.replace( '?view='+currentView+'&page='+thisPage+filterQuery );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2017-12-13 23:20:02 +08:00
|
|
|
|
2019-02-07 02:31:34 +08:00
|
|
|
function thumbnail_onmouseover(event) {
|
|
|
|
var img = event.target;
|
|
|
|
img.src = img.getAttribute('stream_src');
|
|
|
|
}
|
|
|
|
function thumbnail_onmouseout(event) {
|
|
|
|
var img = event.target;
|
|
|
|
img.src = img.getAttribute('still_src');
|
|
|
|
}
|
|
|
|
|
2019-01-18 23:00:55 +08:00
|
|
|
function initPage() {
|
2019-02-07 02:31:34 +08:00
|
|
|
if ( window.history.length == 1 ) {
|
2017-12-14 01:34:31 +08:00
|
|
|
$j('#controls').children().eq(0).html('');
|
2017-12-13 23:20:02 +08:00
|
|
|
}
|
2019-02-09 02:48:38 +08:00
|
|
|
$j('.colThumbnail img').each(function() {
|
|
|
|
this.addEventListener('mouseover', thumbnail_onmouseover, false);
|
|
|
|
this.addEventListener('mouseout', thumbnail_onmouseout, false);
|
2019-02-07 02:31:34 +08:00
|
|
|
});
|
2019-02-09 02:48:38 +08:00
|
|
|
$j('input[name=markEids\\[\\]]').each(function() {
|
|
|
|
this.addEventListener('click', configureButton, false);
|
2019-02-07 02:31:34 +08:00
|
|
|
});
|
2017-12-13 23:20:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$j(document).ready(initPage);
|