This repository has been archived on 2023-06-10. You can view files and clone it, but cannot push or open issues or pull requests.
Kai Wansart 9c3e560900 .
2018-02-02 00:21:59 +01:00

62 lines
1.9 KiB
JavaScript

//------------------------------------------------------------------------------
// CM - Hauptfunktion
//------------------------------------------------------------------------------
class CM
{
constructor ()
{
this.BodyDataAction();
console.log("CM LOADED");
}
BodyDataAction ()
{
var menuButtons = document.getElementById("navbarBtn").
getElementsByTagName("button");
for (var i = 0; i < menuButtons.length; i++) {
menuButtons[i].onclick = function(evt) {
var res = evt.target.id;
CM_o.Menu(res);
};
}
}
Menu (message)
{
var selectedId = $(".selected").attr('id');
switch (message)
{
case 'pageDevices':
console.log( "pageDevices")
this.LoadContent('html/devices.html');
document.getElementById('pageDevices').className = "btn btn-outline-light text-dark active";
document.getElementById('pageSettings').className = "btn btn-outline-light text-dark";
break;
case 'pageSettings':
console.log( "pageDevices")
this.LoadContent('html/settings.html');
document.getElementById('pageDevices').className = "btn btn-outline-light text-dark";
document.getElementById('pageSettings').className = "btn btn-outline-light text-dark active";
break;
default:
alert ('[CM] Unbekannte Anfrage: ' + message);
}
}
LoadContent ( path )
{
$.get( path, function( data ) {
$( ".content" ).html( data );
console.log( "Load was performed." );
});
}
}
$(function() {
console.log("ONLOAD");
CM_o = new CM();
CM_o.Menu("pageDevices");
});