mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Example JSON Form Example with General setting (#185)
I have created a new Category "General" with several Settings for Hyperion. For now the Submit Button only console.log's the values. Known Bug: For some reason it seems to do not load the bootstrap correctly or maybe the Lib isn't compatible with the newest version of bootstrap.
This commit is contained in:
@@ -16,39 +16,39 @@
|
||||
<script>
|
||||
|
||||
$(document).ready( function() {
|
||||
|
||||
|
||||
webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
|
||||
var serverInfo;
|
||||
|
||||
|
||||
webSocket.onerror = function(event) {
|
||||
alert(event.data);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
webSocket.onopen = function(event) {
|
||||
webSocket.send('{"command":"serverinfo"}');
|
||||
};
|
||||
|
||||
|
||||
webSocket.onmessage = function(response){
|
||||
responseJSON = JSON.parse(response.data );
|
||||
//console.log(response.data);
|
||||
for(i = 0; i < responseJSON.info.effects.length; i++) {
|
||||
//console.log(responseJSON.info.effects[i].name);
|
||||
var effectName = responseJSON.info.effects[i].name;
|
||||
|
||||
|
||||
$('#buttondiv').append('<button type="button" class="btn btn-success" onclick="playEffect(\''+effectName+'\')"><i class="fa fa-play"></i></button> '+effectName+'<br />');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$("#effect_stop").on("click", function() {
|
||||
webSocket.send('{"command":"clear", "priority":1}');
|
||||
webSocket.send('{"command":"clear", "priority":1}');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function playEffect(effectName) {
|
||||
console.log(effectName);
|
||||
webSocket.send('{"command":"effect","effect":{"name":"'+effectName+'"},"priority":1}');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user