2016-04-15 01:53:10 +08:00
|
|
|
var jsTranslatedAddText;
|
|
|
|
var jsTranslatedCloneText;
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function setButtonStates( element )
|
|
|
|
{
|
|
|
|
var form = element.form;
|
|
|
|
var checked = 0;
|
|
|
|
for ( var i = 0; i < form.elements.length; i++ )
|
|
|
|
{
|
|
|
|
if ( form.elements[i].type == "checkbox" )
|
|
|
|
{
|
|
|
|
if ( form.elements[i].checked )
|
|
|
|
{
|
|
|
|
if ( checked++ > 1 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-19 03:38:10 +08:00
|
|
|
$(element).closest("tr").toggleClass("danger");
|
2008-07-14 21:54:50 +08:00
|
|
|
form.editBtn.disabled = (checked!=1);
|
2016-04-15 01:53:10 +08:00
|
|
|
form.addBtn.value = (checked==1) ? jsTranslatedCloneText:jsTranslatedAddText;
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
form.deleteBtn.disabled = (checked==0);
|
|
|
|
}
|
|
|
|
|
2016-04-15 01:53:10 +08:00
|
|
|
function addMonitor( element)
|
|
|
|
{
|
|
|
|
|
|
|
|
var form = element.form;
|
|
|
|
var dupParam;
|
|
|
|
var monitorId=-1;
|
|
|
|
if (form.addBtn.value == jsTranslatedCloneText)
|
|
|
|
{
|
|
|
|
// get the value of the first checkbox
|
|
|
|
for ( var i = 0; i < form.elements.length; i++ )
|
|
|
|
{
|
|
|
|
if ( form.elements[i].type == "checkbox" )
|
|
|
|
{
|
|
|
|
if ( form.elements[i].checked )
|
|
|
|
{
|
|
|
|
monitorId = form.elements[i].value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dupParam = (monitorId == -1 ) ? '': '&dupId='+monitorId;
|
|
|
|
createPopup( '?view=monitor'+dupParam, 'zmMonitor0','monitor' );
|
|
|
|
}
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function editMonitor( element )
|
|
|
|
{
|
|
|
|
var form = element.form;
|
|
|
|
for ( var i = 0; i < form.elements.length; i++ )
|
|
|
|
{
|
|
|
|
if ( form.elements[i].type == "checkbox" )
|
|
|
|
{
|
|
|
|
if ( form.elements[i].checked )
|
|
|
|
{
|
|
|
|
var monitorId = form.elements[i].value;
|
|
|
|
createPopup( '?view=monitor&mid='+monitorId, 'zmMonitor'+monitorId, 'monitor' );
|
|
|
|
form.elements[i].checked = false;
|
2008-07-17 00:03:53 +08:00
|
|
|
setButtonStates( form.elements[i] );
|
2009-03-30 16:56:31 +08:00
|
|
|
//$(form.elements[i]).getParent( 'tr' ).removeClass( 'highlight' );
|
2008-07-14 21:54:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteMonitor( element )
|
|
|
|
{
|
|
|
|
if ( confirm( 'Warning, deleting a monitor also deletes all events and database entries associated with it.\nAre you sure you wish to delete?' ) )
|
|
|
|
{
|
|
|
|
var form = element.form;
|
|
|
|
form.elements['action'].value = 'delete';
|
|
|
|
form.submit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function reloadWindow()
|
|
|
|
{
|
|
|
|
window.location.replace( thisUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
function initPage()
|
|
|
|
{
|
2016-04-15 01:53:10 +08:00
|
|
|
jsTranslatedAddText = translatedAddText;
|
|
|
|
jsTranslatedCloneText = translatedCloneText;
|
2008-07-14 21:54:50 +08:00
|
|
|
reloadWindow.periodical( consoleRefreshTimeout );
|
|
|
|
if ( showVersionPopup )
|
|
|
|
createPopup( '?view=version', 'zmVersion', 'version' );
|
|
|
|
if ( showDonatePopup )
|
|
|
|
createPopup( '?view=donate', 'zmDonate', 'donate' );
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEvent( 'domready', initPage );
|