From 984035dde3becd82158414dbaad17d2aa00145c3 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Wed, 29 May 2013 07:47:27 -0400 Subject: [PATCH] Initial commit of events.js file; added it to all pages. events.js should eventually be loaded in only the events view. This commit creates #15. --- web/app/View/Layouts/default.ctp | 1 + web/app/webroot/js/events.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 web/app/webroot/js/events.js diff --git a/web/app/View/Layouts/default.ctp b/web/app/View/Layouts/default.ctp index 757f0b2e5..551d5089d 100644 --- a/web/app/View/Layouts/default.ctp +++ b/web/app/View/Layouts/default.ctp @@ -36,6 +36,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework echo $this->fetch('css'); echo $this->fetch('script'); echo $this->Html->script('jquery-2.0.1.min'); + echo $this->Html->script('events.js'); echo $this->Js->writeBuffer(); ?> diff --git a/web/app/webroot/js/events.js b/web/app/webroot/js/events.js new file mode 100644 index 000000000..e9fe3fab4 --- /dev/null +++ b/web/app/webroot/js/events.js @@ -0,0 +1,23 @@ +$(document).ready(function() { + $('[id^=Monitor_]').click(function() { + $('h2').append('loading'); + $base_url = '/events/index/'; + + if ($(this).attr('class') == 'selected') { + $(this).toggleClass('selected'); + } else { + $(this).toggleClass('selected'); + } + + $('[id^=Monitor_]').each(function() { + if ($(this).attr('class') == 'selected' ){ + $monitor_id = $(this).attr('id').split('_'); + $base_url = $base_url + 'MonitorId:'+$monitor_id[1]+'/'; + } + }); + + $('#Events').load($base_url + ' #Events', function(){ + $('h2 img').detach(); + }); + }); +});