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.
This commit is contained in:
Kyle Johnson 2013-07-11 11:58:39 -04:00
parent 80ebaad07b
commit 2ea43105ec
2 changed files with 160 additions and 3 deletions

View File

@ -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');
?>
</head>
<body>
@ -66,5 +64,6 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
</div>
</div>
<?php echo $this->element('sql_dump'); ?>
<?php echo $this->Js->writeBuffer(); ?>
</body>
</html>

158
web/app/webroot/js/main.js Normal file
View File

@ -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 //
});