2016-09-06 10:14:54 +02:00
$ ( document ) . ready ( function ( ) {
2016-09-15 20:42:58 +02:00
$ ( "#main-nav" ) . hide ( ) ;
$ ( "#page-content" ) . hide ( ) ;
2016-09-13 11:51:16 +02:00
$ ( "#loading_overlay" ) . addClass ( "overlay" ) ;
2016-09-06 10:14:54 +02:00
loadContentTo ( "#container_connection_lost" , "connection_lost" ) ;
initWebSocket ( ) ;
bindNavToContent ( "#load_dashboard" , "dashboard" , true ) ;
2016-09-09 18:59:58 +02:00
bindNavToContent ( "#load_remote" , "remote" , false ) ;
2016-09-06 10:14:54 +02:00
bindNavToContent ( "#load_huebridge" , "huebridge" , false ) ;
bindNavToContent ( "#load_support" , "support" , false ) ;
bindNavToContent ( "#load_confKodi" , "kodiconf" , false ) ;
bindNavToContent ( "#load_update" , "update" , false ) ;
bindNavToContent ( "#load_confGeneral" , "generalconf" , false ) ;
bindNavToContent ( "#load_confLeds" , "leds" , false ) ;
2016-09-07 20:10:37 +02:00
bindNavToContent ( "#load_confGrabber" , "grabber" , false ) ;
2016-09-06 10:14:54 +02:00
//Change all Checkboxes to Switches
$ ( "[type='checkbox']" ) . bootstrapSwitch ( ) ;
$ ( hyperion ) . on ( "cmd-serverinfo" , function ( event ) {
parsedServerInfoJSON = event . response ;
currentVersion = parsedServerInfoJSON . info . hyperion [ 0 ] . version ;
cleanCurrentVersion = currentVersion . replace ( /\./g , '' ) ;
2016-09-14 13:51:28 +02:00
if ( parsedServerInfoJSON . info . hyperion [ 0 ] . config _modified )
2016-09-15 20:42:58 +02:00
$ ( "#hyperion_reload_notify" ) . fadeIn ( "fast" ) ;
2016-09-14 13:51:28 +02:00
else
2016-09-15 20:42:58 +02:00
$ ( "#hyperion_reload_notify" ) . fadeOut ( "fast" ) ;
2016-09-14 13:51:28 +02:00
2016-09-06 10:14:54 +02:00
// get active led device
var leddevice = parsedServerInfoJSON . info . ledDevices . active ;
$ ( '#dash_leddevice' ) . html ( leddevice ) ;
// get host
var hostname = parsedServerInfoJSON . info . hostname ;
$ ( '#dash_systeminfo' ) . html ( hostname + ':' + hyperionport ) ;
2016-09-07 20:10:37 +02:00
var components = parsedServerInfoJSON . info . components ;
components _html = "" ;
for ( idx = 0 ; idx < components . length ; idx ++ )
{
components _html += '<tr><td>' + ( components [ idx ] . title ) + '</td><td><i class="fa fa-circle component-' + ( components [ idx ] . enabled ? "on" : "off" ) + '"></i></td></tr>' ;
}
$ ( "#tab_components" ) . html ( components _html ) ;
2016-09-06 10:14:54 +02:00
$ . get ( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json" , function ( data ) {
parsedUpdateJSON = JSON . parse ( data ) ;
latestVersion = parsedUpdateJSON [ 0 ] . versionnr ;
cleanLatestVersion = latestVersion . replace ( /\./g , '' ) ;
$ ( '#currentversion' ) . html ( ' V' + currentVersion ) ;
$ ( '#latestversion' ) . html ( ' V' + latestVersion ) ;
if ( cleanCurrentVersion < cleanLatestVersion )
{
$ ( '#versioninforesult' ) . html ( '<div lang="en" data-lang-token="dashboard_message_infobox_updatewarning" style="margin:0px;" class="alert alert-warning">A newer version of Hyperion is available!</div>' ) ;
}
else
{
$ ( '#versioninforesult' ) . html ( '<div lang="en" data-lang-token="dashboard_message_infobox_updatesuccess" style="margin:0px;" class="alert alert-success">You run the latest version of Hyperion.</div>' ) ;
}
} ) ;
2016-09-13 11:51:16 +02:00
$ ( "#loading_overlay" ) . removeClass ( "overlay" ) ;
2016-09-15 20:42:58 +02:00
$ ( "#main-nav" ) . show ( 'slide' , { direction : 'left' } , 1000 ) ;
$ ( "#page-content" ) . show ( 'slide' , { direction : 'down' } , 2000 ) ;
2016-09-06 10:14:54 +02:00
} ) ; // end cmd-serverinfo
2016-09-10 19:08:08 +02:00
$ ( hyperion ) . one ( "cmd-config-getschema" , function ( event ) {
parsedConfSchemaJSON = event . response . result ;
} ) ;
2016-09-06 10:14:54 +02:00
$ ( hyperion ) . on ( "error" , function ( event ) {
showErrorDialog ( "error" , event . reason ) ;
} ) ;
2016-09-10 19:08:08 +02:00
$ ( hyperion ) . on ( "open" , function ( event ) {
requestServerConfigSchema ( ) ;
requestServerInfo ( ) ;
} ) ;
2016-09-15 20:42:58 +02:00
$ ( "#btn_hyperion_reload" ) . on ( "click" , function ( ) {
$ ( hyperion ) . off ( ) ;
requestServerConfigReload ( ) ;
watchdog = 1 ;
$ ( "#wrapper" ) . fadeOut ( "slow" ) ;
cron ( ) ;
} ) ;
2016-09-06 10:14:54 +02:00
} ) ;
$ ( function ( ) {
var sidebar = $ ( '#side-menu' ) ; // cache sidebar to a variable for performance
sidebar . delegate ( 'a.inactive' , 'click' , function ( ) {
sidebar . find ( '.active' ) . toggleClass ( 'active inactive' ) ;
$ ( this ) . toggleClass ( 'active inactive' ) ;
} ) ;
} ) ;