1 $(document).ready(function() {
4 $('.filterboxfield').focus(function() {
5 if (!$('#ninja_refresh_control').attr('checked')) {
6 // save previous refresh rate
7 // to be able to restore it later
8 old_refresh = current_interval;
9 $('#ninja_refresh_lable').css('font-weight', 'bold');
11 $("#ninja_refresh_control").attr('checked', true);
15 $('.filterboxfield').blur(function() {
16 if ($(this).val() != '') {
17 // don't do anything if we have a current filter value
20 if ($('#ninja_refresh_control').attr('checked')) {
21 // restore previous refresh rate
22 ninja_refresh(old_refresh);
23 $("#ninja_refresh_control").attr('checked', false);
24 $('#ninja_refresh_lable').css('font-weight', '');
30 ========================
32 ========================
36 $('#hostcomments_table').tablesorter({headers:{0:{sorter:false}}});
38 $('#clearhostsearch').click(function() {
39 $('#hostfilterbox').val('').trigger('keyup').trigger('blur');
43 $('#hostfilterbox').keyup(function(){
44 filter_table(this, 'hostcomments_table');})
46 if(this.value==_filter_label) {
51 if (this.value == '') {
52 this.value = _filter_label;
58 .submit(function(ev) {
64 $('#servicecomments_table').tablesorter({headers:{0:{sorter:false}}});
66 $('#clearservicesearch').click(function() {
67 $('#servicefilterbox').val('').trigger('keyup').trigger('blur');
71 $('#servicefilterbox').keyup(function(){
72 filter_table(this, 'servicecomments_table');})
74 if(this.value==_filter_label) {
79 if (this.value == '') {
80 this.value = _filter_label;
84 $('.pnp_graph').map(function() {
86 pnp_popup(el, el.data());
91 ========================
92 scheduled downtime filters
93 ========================
95 // host scheduled downtime
97 $('#scheduled_host_downtime').tablesorter({headers:{0:{sorter:false}}});
99 $('#clearhostsearch_sched').click(function() {
100 $('#hostfilterbox_sched').val('').trigger('keyup').trigger('blur');
104 $('#hostfilterbox_sched').keyup(function(){
105 filter_table(this, 'scheduled_host_downtime');})
107 if(this.value==_filter_label) {
112 if (this.value == '') {
113 this.value = _filter_label;
118 // service scheduled downtime
120 $('#scheduled_service_downtime').tablesorter({headers:{0:{sorter:false}}});
122 $('#clearservicesearch_sched').click(function() {
123 $('#servicefilterbox_sched').val('').trigger('keyup').trigger('blur');
127 $('#servicefilterbox_sched').keyup(function(){
128 filter_table(this, 'scheduled_service_downtime');})
130 if(this.value==_filter_label) {
135 if (this.value == '') {
136 this.value = _filter_label;
140 $('.extinfo_contactgroup').each(function() {
141 $(this).bind('click', function() {
142 var the_id = $(this).attr('id');
143 the_id = the_id.replace('extinfo_contactgroup_', '');
144 $('#extinfo_contacts_' + the_id).toggle();
149 setTimeout('hide_del_msg()', 3000);
151 $('#del_host_downtime_form').bind('submit', function() {
155 var validate_host_submit = function() {
156 $('.deletecommentbox_host').each(function() {
157 if (!$(this).is(':visible'))
158 $(this).attr('checked', false);
160 if (!$('.deletecommentbox_host').filter(':checked').length) {
161 $('.host_feedback').text(' Nothing selected...');
162 setTimeout(function() {$('.host_feedback').hide();}, 5000);
165 $('.host_feedback').text('');
169 $('#del_submithost_svc').click(function() {
170 if (validate_host_submit() == false)
173 var hostform = $(this).parents('form');
175 // this moves the checkboxes from the service form to the host form before submitting.
176 var cb = trigger_cb_on_nth_call(function() {hostform.submit();}, $('.deletecommentbox_host').length);
177 hostform.append('<input type="hidden" name="del_submithost_svc" value="1" />');
178 $('.deletecommentbox_host').each(function() {
179 if ($(this).attr('checked')) {
180 var hostname = $(this).closest('tr').find('td:nth-child(2)').text();
181 $('#scheduled_service_downtime').find('tr td:nth-child(2)').each(function() {
182 if ($(this).text() == hostname) {
183 hostform.append($(this).closest('tr').find('td:nth-child(1) input[type="checkbox"]').css('display', 'none').attr('checked', true));
192 // check that user selected any checkboxes before submitting
193 $('#del_submithost').click(validate_host_submit);
195 $('#del_submitservice').click(function() {
196 $('.deletecommentbox_service').each(function() {
197 if (!$(this).is(':visible'))
198 $(this).attr('checked', false);
200 if (!$('.deletecommentbox_service').filter(':checked').length) {
201 $('.service_feedback').text(' Nothing selected...');
202 setTimeout(function() {$('.service_feedback').hide();}, 5000);
205 $('.service_feedback').text('');
208 $('.custom_command a').fancybox({
209 'overlayOpacity': 0.7,
210 'overlayColor' : '#000000',
211 'hideOnContentClick': false,
212 'hideOnOverlayClick': false,
214 'showCloseButton': false,
215 'enableEscapeButton': false,
216 'autoDimensions': true,
220 .css('border-bottom', '1px dotted #777');
221 $('.custom_command a').click(function() {
222 // Don't refresh page while script is running.
223 clearInterval(_interval);
224 var cmd = $(this).attr('title');
225 cmd = cmd.replace(/;/g, "/");
226 $('#fancybox-content').text('Executing command, please wait for acknowledgement.');
227 // Load executing function with custom var name as parameter
228 $('#fancybox-content').load(_site_domain+'index.php/command/exec_custom_command/'+encodeURI(cmd), function() {
229 $('#fancybox-close').show();
230 // It's ok to refresh again so let's start doing so.
236 function hide_del_msg() {
237 $('#comment_del_msg').hide('slow');
240 function filter_table (phrase, _id){
241 var words = phrase.value.toLowerCase().split(" ");
242 var table = document.getElementById(_id);
245 for (var r = 1; r < table.rows.length; r++){
246 ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,"");
247 var displayStyle = 'none';
248 if (table.rows[r].className.indexOf('submit') == -1) {
249 for (var i = 0; i < words.length; i++) {
250 if (ele.toLowerCase().indexOf(words[i])>=0)
253 displayStyle = 'none';
258 table.rows[r].style.display = displayStyle;