From 2ea43105ecdcad2d81be4a7a11e60abb6e455389 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Thu, 11 Jul 2013 11:58:39 -0400 Subject: [PATCH] Merged config.js and events.js into main.js. This should fix #15 as I'm keeping all JS in a single file, instead of a file per page. --- web/app/View/Layouts/default.ctp | 5 +- web/app/webroot/js/main.js | 158 +++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 web/app/webroot/js/main.js diff --git a/web/app/View/Layouts/default.ctp b/web/app/View/Layouts/default.ctp index c1a16c19e..7b4bbb09f 100644 --- a/web/app/View/Layouts/default.ctp +++ b/web/app/View/Layouts/default.ctp @@ -39,9 +39,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework echo $this->Html->script('jquery-2.0.1.min'); echo $this->Html->script('jquery-ui.min'); echo $this->Html->script('masonry.pkgd.min'); - echo $this->Html->script('events.js'); - echo $this->Html->script('config.js'); - echo $this->Js->writeBuffer(); + echo $this->Html->script('main'); ?> @@ -66,5 +64,6 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework element('sql_dump'); ?> +Js->writeBuffer(); ?> diff --git a/web/app/webroot/js/main.js b/web/app/webroot/js/main.js new file mode 100644 index 000000000..d9cc52376 --- /dev/null +++ b/web/app/webroot/js/main.js @@ -0,0 +1,158 @@ +$(document).ready(function() { + + // Logs // + $("#Component").change(function(){ + if (!!$(this).val()) { + $("#tblComponents").load("/logs/index/Component:" + $(this).val() + ' #tblComponents'); + } else { + $("#tblComponents").load('/logs/index/ #tblComponents'); + } + }); + + $("#btnComponentRefresh").button().click(function(){ + if (!!$("#Component").val()) { + $("#tblComponents").load("/logs/index/Component:" + $("#Component").val() + ' #tblComponents'); + } else { + $("#tblComponents").load('/logs/index/ #tblComponents'); + } + }); + // Logs // + + // Events // + $( "#selectable" ).selectable({ + stop: function() { + $("#selectable input").removeAttr("checked"); + $(".ui-selected input", this).each(function() { + $(this).attr("checked", "checked"); + }) + } + }); + + $("#Events_list").selectable({ appendTo: "#Events_list li", filter: "li" }); + + $("#EventsButtonDelete").click(function () { + $("#Events_list li.ui-selected").each(function() { + console.log($(this).attr('id')); + }); + }); + + $("#EventsButtonSearch").button().click(function() { + $base_url = '/events/index/'; + + $( "li.ui-selected" ).each(function() { + $monitor_id = $(this).attr('id').split('_'); + $base_url = $base_url + 'MonitorId:'+$monitor_id[1]+'/'; + }); + + $start_date = $("#EventStartDate").val(); + $start_hour = $("#EventStartHour").val(); + $start_min = $("#EventStartMinute").val(); + + $end_date = $("#EventEndDate").val(); + $end_hour = $("#EventEndHour").val(); + $end_min = $("#EventEndMinute").val(); + + var start = $start_date + ' ' + $start_hour + ':' + $start_min; + var end = $end_date + ' ' + $end_hour + ':' + $end_min; + + var start_epoch = new Date(start).getTime()/1000.0; + var end_epoch = new Date(end).getTime()/1000.0; + + $base_url = $base_url + 'StartTime:'+start_epoch+'/'; + $base_url = $base_url + 'StartTime:'+end_epoch+'/'; + + $('#Events').load($base_url + ' #Events'); + }); + + $( "#EventStartDate" ).datepicker({ + changeMonth: true, + changeYear: true, + defaultDate: -1, + onClose: function( selectedDate ) { + $("#EventEndDate").datepicker( "option", "minDate", selectedDate ); + } + }); + $("#EventStartDate").datepicker( "option", "dateFormat", "MM d, yy" ); + + $( "#EventEndDate" ).datepicker({ + changeMonth: true, + changeYear: true, + defaultDate: +0, + onClose: function( selectedDate ) { + $("#EventStartDate").datepicker( "option", "maxDate", selectedDate ); + } + }); + $("#EventEndDate").datepicker( "option", "dateFormat", "MM d, yy" ); + + $("#PreviousEvent").button({ + text: false, + icons: { primary: 'ui-icon-seek-start' } + }); + $("#NextEvent").button({ + text: false, + icons: { primary: 'ui-icon-seek-end' } + }); + $("#RewindEvent").button({ + text: false, + icons: { primary: 'ui-icon-seek-prev' } + }); + $("#FastForwardEvent").button({ + text: false, + icons: { primary: 'ui-icon-seek-next' } + }); + + $("#PlayEvent").button({ + text: false, + icons: { primary: "ui-icon-play" } + }) + .click(function() { + var options; + if ( $( this ).text() === "play" ) { + options = { + label: "pause", + icons: { primary: "ui-icon-pause" } + }; + console.log('Pausing!'); + } else { + options = { + label: "play", + icons: { primary: "ui-icon-play" } + }; + } + $( this ).button( "option", options ); + }); + + $("#ZoomOutEvent").button({ + text: false, + icons: { primary: 'ui-icon-zoomout' } + }); + + + + $("#daemonStatus").button(); + $("#daemonStatus").click(function(){ + $.post("/app/daemonControl", {command:'stop'}) + .done(function(data) { + console.log(data); + }); + }); + // Events // + + // Config // + $("#tabs").tabs(); + $(document).tooltip({ track:true }); + $('#tabs .row:even').addClass('highlight'); + // Config // + + // Global // + $('#loadingDiv').hide(); + $(document) + .ajaxStart(function() { + $('#loadingDiv').show(); + }) + .ajaxStop(function() { + $('#loadingDiv').hide(); + }); + // Global // + +});