forked from tsawyer/allmon2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallmon.js
More file actions
104 lines (86 loc) · 3.74 KB
/
allmon.js
File metadata and controls
104 lines (86 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// when DOM is ready
$(document).ready(function() {
// Is user authenticated
if ($.cookie('allmon_loggedin') == 'yes') {
$('#loginlink').hide();
} else {
$('#connect_form').hide();
$('#logoutlink').hide();
}
// Login dialog
$("#login").dialog( {
autoOpen: false,
title: 'Manager Login',
modal: true,
buttons: { "Login": function() {
var user = $('form input:text').val();
var passwd = $('input:password').val();
$(this).dialog("close");
$('#test_area').load("login.php", { 'user' : user, 'passwd' : passwd }, function(response) {
if (response.substr(0,5) != 'Sorry') {
$('#connect_form').show();
$('#logoutlink').show();
$('#loginlink').hide();
$.cookie('allmon_loggedin', 'yes', { expires: 7, path: '/' });
}
});
$('#test_area').stop().css('opacity', 1).fadeIn(50).delay(1000).fadeOut(2000);
} }
});
// Login dialog opener
$("#loginlink").click(function() {
$("#login").dialog('open');
return false;
});
// Logout
$('#logoutlink').click(function(event) {
$.cookie('allmon_loggedin', null, { path: '/' });
$('#loginlink').show();
$('#logoutlink').hide();
$('#connect_form').hide();
event.preventDefault();
});
// Ajax function a link
$('#connect, #monitor, #permanent, #localmonitor, #disconnect').click(function() {
var button = this.id; // which button was pushed
var localNode = $('#localnode').val();
var remoteNode = $('#node').val();
var perm = $('input:checkbox:checked').val();
if (remoteNode.length == 0) {
alert('Please enter the remote node number.');
return;
}
if (button == 'disconnect') {
r = confirm("Disconnect " + remoteNode + " from " + localNode + "?");
if (r !== true) {
return;
}
}
$.ajax( { url:'connect.php', data: { 'remotenode' : remoteNode, 'perm' : perm, 'button' : button, 'localnode' : localNode }, type:'post', success: function(result) {
$('#test_area').html(result);
$('#test_area').stop().css('opacity', 1).fadeIn(50).delay(1000).fadeOut(2000);
}
});
});
$('#controlpanel').click(function (event) {
var url = "controlpanel.php?node=" + $('#localnode').val();
var windowName = "controlPanel";
var windowSize = 'height=300, width=640';
window.open(url, windowName, windowSize);
event.preventDefault();
});
// Click on a cell to populate the input form
$('table').on('click', 'td', function( event ) {
// Shows the table ID, the text of the cell, the class of the cell and the ID of the cell.
//console.log('clicked:', $( this ).closest('table').attr('id'), $( this ).text(), $( this ).attr('class'), $( this ).attr('id'));
// shows x and y coordinates of clicked cell
//console.log('coordinates:', 'y=' + this.cellIndex, 'x=' + this.parentNode.rowIndex);
if ( $( this ).attr('class') == 'nodeNum') {
// Put node number into id="node"
$('#connect_form #node').val($( this ).text());
// split table ID and put node into id="localnode"
var idarr = $( this ).closest('table').attr('id').split('_');
$('#connect_form #localnode').val(idarr[1]);
}
});
});