priorities rework, webc update (#366)

* update

* update

* tabs test

* update

* test

* ...

* fix editor

* update ui

* fix visual glitch if help is off

* fix fadecandy error and th

[skip ci]
This commit is contained in:
brindosch
2017-01-17 21:53:35 +01:00
committed by redPanther
parent 5b809743f7
commit 8d7137136b
75 changed files with 1713 additions and 1144 deletions

View File

@@ -1,15 +1,72 @@
var conf_editor = null;
var editor_color = null;
var editor_smoothing = null;
var editor_blackborder = null;
$(hyperion).one("cmd-config-getschema", function(event) {
schema = parsedConfSchemaJSON.properties;
conf_editor = createJsonEditor('editor_container', {
color : schema.color,
smoothing : schema.smoothing,
blackborderdetector: schema.blackborderdetector,
}, true);
if(showOptHelp)
{
//color
$('#conf_cont').append(createRow('conf_cont_color'))
$('#conf_cont_color').append(createOptPanel('fa-photo', $.i18n("edt_conf_color_heading_title"), 'editor_container_color', 'btn_submit_color'));
$('#conf_cont_color').append(createHelpTable(schema.color.properties, $.i18n("edt_conf_color_heading_title")));
//smoothing
$('#conf_cont').append(createRow('conf_cont_smoothing'))
$('#conf_cont_smoothing').append(createOptPanel('fa-photo', $.i18n("edt_conf_smooth_heading_title"), 'editor_container_smoothing', 'btn_submit_smoothing'));
$('#conf_cont_smoothing').append(createHelpTable(schema.smoothing.properties, $.i18n("edt_conf_smooth_heading_title")));
//blackborder
$('#conf_cont').append(createRow('conf_cont_blackborder'))
$('#conf_cont_blackborder').append(createOptPanel('fa-photo', $.i18n("edt_conf_bb_heading_title"), 'editor_container_blackborder', 'btn_submit_blackborder'));
$('#conf_cont_blackborder').append(createHelpTable(schema.blackborderdetector.properties, $.i18n("edt_conf_bb_heading_title")));
}
else
{
$('#conf_cont').addClass('row');
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_color_heading_title"), 'editor_container_color', 'btn_submit_color'));
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_smooth_heading_title"), 'editor_container_smoothing', 'btn_submit_smoothing'));
$('#conf_cont').append(createOptPanel('fa-photo', $.i18n("edt_conf_bb_heading_title"), 'editor_container_blackborder', 'btn_submit_blackborder'));
}
//color
editor_color = createJsonEditor('editor_container_color', {
color : schema.color
}, true, true);
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
editor_color.on('change',function() {
editor_color.validate().length ? $('#btn_submit_color').attr('disabled', true) : $('#btn_submit_color').attr('disabled', false);
});
$('#btn_submit_color').off().on('click',function() {
requestWriteConfig(editor_color.getValue());
});
//smoothing
editor_smoothing = createJsonEditor('editor_container_smoothing', {
smoothing : schema.smoothing
}, true, true);
editor_smoothing.on('change',function() {
editor_smoothing.validate().length ? $('#btn_submit_smoothing').attr('disabled', true) : $('#btn_submit_smoothing').attr('disabled', false);
});
$('#btn_submit_smoothing').off().on('click',function() {
requestWriteConfig(editor_smoothing.getValue());
});
//blackborder
editor_blackborder = createJsonEditor('editor_container_blackborder', {
blackborderdetector: schema.blackborderdetector
}, true, true);
editor_blackborder.on('change',function() {
editor_blackborder.validate().length ? $('#btn_submit_blackborder').attr('disabled', true) : $('#btn_submit_blackborder').attr('disabled', false);
});
$('#btn_submit_blackborder').off().on('click',function() {
requestWriteConfig(editor_blackborder.getValue());
});
});

View File

@@ -8,9 +8,51 @@ var backgroundEffect_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) {
schema = parsedConfSchemaJSON.properties;
effects_editor = createJsonEditor('editor_container_effects', {
effects : schema.effects
}, true, true);
if(showOptHelp)
{
//effect path
if(storedAccess != 'default')
{
$('#conf_cont').append(createRow('conf_cont_ef'))
$('#conf_cont_ef').append(createOptPanel('fa-spinner', $.i18n("edt_conf_effp_heading_title"), 'editor_container_effects', 'btn_submit_effects'));
$('#conf_cont_ef').append(createHelpTable(schema.effects.properties, $.i18n("edt_conf_effp_heading_title")));
}
//foreground effect
$('#conf_cont').append(createRow('conf_cont_fge'))
$('#conf_cont_fge').append(createOptPanel('fa-spinner', $.i18n("edt_conf_fge_heading_title"), 'editor_container_foregroundEffect', 'btn_submit_foregroundEffect'));
$('#conf_cont_fge').append(createHelpTable(schema.foregroundEffect.properties, $.i18n("edt_conf_fge_heading_title")));
//background effect
$('#conf_cont').append(createRow('conf_cont_bge'))
$('#conf_cont_bge').append(createOptPanel('fa-spinner', $.i18n("edt_conf_bge_heading_title"), 'editor_container_backgroundEffect', 'btn_submit_backgroundEffect'));
$('#conf_cont_bge').append(createHelpTable(schema.backgroundEffect.properties, $.i18n("edt_conf_bge_heading_title")));
}
else
{
if(storedAccess != 'default')
$('#conf_cont').append(createOptPanel('fa-spinner', $.i18n("edt_conf_effp_heading_title"), 'editor_container_effects', 'btn_submit_effects'));
$('#conf_cont').addClass('row');
$('#conf_cont').append(createOptPanel('fa-spinner', $.i18n("edt_conf_fge_heading_title"), 'editor_container_foregroundEffect', 'btn_submit_foregroundEffect'));
$('#conf_cont').append(createOptPanel('fa-spinner', $.i18n("edt_conf_bge_heading_title"), 'editor_container_backgroundEffect', 'btn_submit_backgroundEffect'));
}
if(storedAccess != 'default')
{
effects_editor = createJsonEditor('editor_container_effects', {
effects : schema.effects
}, true, true);
effects_editor.on('change',function() {
effects_editor.validate().length ? $('#btn_submit_effects').attr('disabled', true) : $('#btn_submit_effects').attr('disabled', false);
});
$('#btn_submit_effects').off().on('click',function() {
requestWriteConfig(effects_editor.getValue());
});
}
foregroundEffect_editor = createJsonEditor('editor_container_foregroundEffect', {
foregroundEffect : schema.foregroundEffect
@@ -21,11 +63,13 @@ $(hyperion).one("cmd-config-getschema", function(event) {
}, true, true);
effects_editor.on('ready',function() {
foregroundEffect_editor.on('ready',function() {
editorReady = true;
});
foregroundEffect_editor.on('change',function() {
foregroundEffect_editor.validate().length ? $('#btn_submit_foregroundEffect').attr('disabled', true) : $('#btn_submit_foregroundEffect').attr('disabled', false);
var type = foregroundEffect_editor.getEditor('root.foregroundEffect.type');
if(type.value == "color")
{
@@ -40,6 +84,8 @@ $(hyperion).one("cmd-config-getschema", function(event) {
});
backgroundEffect_editor.on('change',function() {
backgroundEffect_editor.validate().length ? $('#btn_submit_backgroundEffect').attr('disabled', true) : $('#btn_submit_backgroundEffect').attr('disabled', false);
var type = backgroundEffect_editor.getEditor('root.backgroundEffect.type');
if(type.value == "color")
{
@@ -53,10 +99,6 @@ $(hyperion).one("cmd-config-getschema", function(event) {
}
});
$('#btn_submit_effects').off().on('click',function() {
requestWriteConfig(effects_editor.getValue());
});
$('#btn_submit_foregroundEffect').off().on('click',function() {
//requestWriteConfig(foregroundEffect_editor.getValue());
console.log(foregroundEffect_editor.getValue());
@@ -66,13 +108,7 @@ $(hyperion).one("cmd-config-getschema", function(event) {
//requestWriteConfig(backgroundEffect_editor.getValue());
console.log(backgroundEffect_editor.getValue());
});
if(showOptHelp)
{
$('#opt_expl_effects').html(createHelpTable(schema.effects.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_effp_heading_title")+' '+$.i18n("conf_helptable_expl")));
$('#opt_expl_foregroundEffect').html(createHelpTable(schema.foregroundEffect.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_fge_heading_title")+' '+$.i18n("conf_helptable_expl")));
$('#opt_expl_backgroundEffect').html(createHelpTable(schema.backgroundEffect.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_bge_heading_title")+' '+$.i18n("conf_helptable_expl")));
}
});
function updateEffectlist(event){
@@ -98,11 +134,12 @@ function updateEffectlist(event){
$('#root_backgroundEffect_effect').html($('#root_foregroundEffect_effect').html());
olddEffects = newEffects;
$('#root_foregroundEffect_effect').val(confFgEff);
$('#root_foregroundEffect_effect').trigger('change');
$('#root_backgroundEffect_effect').val(confBgEff);
$('#root_backgroundEffect_effect').trigger('change');
$('#root_foregroundEffect_effect').val(confFgEff).change();
//$('select').trigger('change');
//var fgeff = foregroundEffect_editor.getEditor('root.foregroundEffect.effect').setValue(confFgEff);
//console.log(fgeff);
$('#root_backgroundEffect_effect').val(confBgEff).change();
}
}
}

View File

@@ -82,7 +82,7 @@ $(hyperion).one("cmd-config-getschema", function(event) {
if(validateEditor())
{
requestWriteEffect(effectName,effectPy,JSON.stringify(effects_editor.getValue()));
showInfoDialog('success', $.i18n('infoDialog_effconf_created_title'), $.i18n('infoDialog_effconf_created_text', effectName));
showInfoDialog('success', "", $.i18n('infoDialog_effconf_created_text', effectName));
}
});
@@ -104,7 +104,7 @@ $(hyperion).one("cmd-config-getschema", function(event) {
$('#btn_delete').off().on('click',function() {
var name = $("#effectsdellist").val();
requestDeleteEffect(name);
showInfoDialog('success', $.i18n('infoDialog_effconf_deleted_title'), $.i18n('infoDialog_effconf_deleted_text', name));
showInfoDialog('success', "", $.i18n('infoDialog_effconf_deleted_text', name));
});
$('#effectsdellist').off().on('change', function(){

View File

@@ -2,21 +2,120 @@
var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) {
schema = parsedConfSchemaJSON.properties;
$('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_gen_heading_title"), 'editor_container', 'btn_submit'));
if(showOptHelp)
{
$('#conf_cont').append(createHelpTable(schema.general.properties, $.i18n("edt_conf_gen_heading_title")));
}
else
$('#conf_imp').appendTo('#conf_cont');
conf_editor = createJsonEditor('editor_container', {
general: schema.general
}, true, true);
conf_editor.on('change',function() {
conf_editor.validate().length ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
});
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
});
if(showOptHelp)
$('#opt_expl').html(createHelpTable(schema.general.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_gen_heading_title")+' '+$.i18n("conf_helptable_expl")));
});
$(document).ready( function() {
performTranslation();
requestServerConfigSchema();
var importedConf;
var confName;
function dis_imp_btn(state)
{
state ? $('#btn_import_conf').attr('disabled', true) : $('#btn_import_conf').attr('disabled', false);
}
function readFile(evt)
{
var f = evt.target.files[0];
if (f)
{
var r = new FileReader();
r.onload = function(e)
{
var content = e.target.result;
//check file is json
var check = isJsonString(content);
if(check.length != 0)
{
showInfoDialog('error', "", $.i18n('infoDialog_import_jsonerror_text', f.name, JSON.stringify(check)));
dis_imp_btn(true);
}
else
{
content = JSON.parse(content);
//check for hyperion json
if(typeof content.leds === 'undefined' || typeof content.general === 'undefined')
{
showInfoDialog('error', "", $.i18n('infoDialog_import_hyperror_text', f.name));
dis_imp_btn(true);
}
else
{
//check config revision
if(content.general.configVersion !== parsedConfJSON.general.configVersion)
{
showInfoDialog('error', "", $.i18n('infoDialog_import_reverror_text', f.name, content.general.configVersion, parsedConfJSON.general.configVersion));
dis_imp_btn(true);
}
else
{
dis_imp_btn(false);
importedConf = content;
confName = f.name;
}
}
}
}
r.readAsText(f);
}
}
$('#btn_export_conf').off().on('click', function(){
var crev = parsedConfJSON.general.configVersion;
var name = parsedConfJSON.general.name;
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var timestamp = d.getFullYear() + '.' +
(month<10 ? '0' : '') + month + '.' +
(day<10 ? '0' : '') + day;
download(JSON.stringify(parsedConfJSON, null, "\t"), 'Hyperion-Config ('+name+') '+timestamp+'.json', "application/json");
});
$('#btn_import_conf').off().on('click', function(){
showInfoDialog('import', $.i18n('infoDialog_import_confirm_title'), $.i18n('infoDialog_import_confirm_text', confName));
$('#id_btn_import').off().on('click', function(){
requestWriteConfig(importedConf, true);
setTimeout(initRestart, 100);
});
});
$('#select_import_conf').off().on('change', function(e){
if (window.File && window.FileReader && window.FileList && window.Blob)
readFile(e);
else
showInfoDialog('error', "", $.i18n('infoDialog_import_comperror_text'));
});
});

View File

@@ -3,27 +3,52 @@ var conf_editor_v4l2 = null;
var conf_editor_fg = null;
$(hyperion).one("cmd-config-getschema", function(event) {
schema = parsedConfSchemaJSON.properties;
if(showOptHelp)
{
//fg
$('#conf_cont').append(createRow('conf_cont_fg'))
$('#conf_cont_fg').append(createOptPanel('fa-camera', $.i18n("edt_conf_fg_heading_title"), 'editor_container_fg', 'btn_submit_fg'));
$('#conf_cont_fg').append(createHelpTable(schema.framegrabber.properties, $.i18n("edt_conf_fg_heading_title")));
//v4l
$('#conf_cont').append(createRow('conf_cont_v4l'))
$('#conf_cont_v4l').append(createOptPanel('fa-camera', $.i18n("edt_conf_v4l2_heading_title"), 'editor_container_v4l2', 'btn_submit_v4l2'));
$('#conf_cont_v4l').append(createHelpTable(schema.grabberV4L2.items.properties, $.i18n("edt_conf_v4l2_heading_title")));
}
else
{
$('#conf_cont').addClass('row');
$('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_fg_heading_title"), 'editor_container_fg', 'btn_submit_fg'));
$('#conf_cont').append(createOptPanel('fa-camera', $.i18n("edt_conf_v4l2_heading_title"), 'editor_container_v4l2', 'btn_submit_v4l2'));
}
//fg
conf_editor_fg = createJsonEditor('editor_container_fg', {
framegrabber: schema.framegrabber
}, true, true);
conf_editor_fg.on('change',function() {
conf_editor_fg.validate().length ? $('#btn_submit_fg').attr('disabled', true) : $('#btn_submit_fg').attr('disabled', false);
});
$('#btn_submit_fg').off().on('click',function() {
requestWriteConfig(conf_editor_fg.getValue());
});
//vl4
conf_editor_v4l2 = createJsonEditor('editor_container_v4l2', {
grabberV4L2 : schema.grabberV4L2
}, true, true);
conf_editor_v4l2.on('change',function() {
conf_editor_v4l2.validate().length ? $('#btn_submit_v4l2').attr('disabled', true) : $('#btn_submit_v4l2').attr('disabled', false);
});
$('#btn_submit_v4l2').off().on('click',function() {
requestWriteConfig(conf_editor_v4l2.getValue());
});
if(showOptHelp)
{
$('#opt_expl_fg').html(createHelpTable(schema.framegrabber.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_fg_heading_title")+' '+$.i18n("conf_helptable_expl")));
$('#opt_expl_v4l2').html(createHelpTable(schema.grabberV4L2.items.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_v4l2_heading_title")+' '+$.i18n("conf_helptable_expl")));
}
});

View File

@@ -1,8 +1,8 @@
$(document).ready( function() {
var uiLock = false;
$("#main-nav").hide();
loadContentTo("#container_connection_lost","connection_lost");
loadContentTo("#container_restart","restart");
initWebSocket();
bindNavToContent("#load_dashboard","dashboard",true);
bindNavToContent("#load_remote","remote",false);
@@ -82,7 +82,6 @@ $(document).ready( function() {
$("#loading_overlay").removeClass("overlay");
$("#main-nav").show('slide', {direction: 'left'}, 1000);
if (!parsedServerInfoJSON.info.hyperion[0].config_writeable)
{

View File

@@ -2,22 +2,30 @@
var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) {
schema = parsedConfSchemaJSON.properties;
$('#conf_cont').append(createOptPanel('fa-play-circle-o', $.i18n("conf_kodi_label_title"), 'editor_container', 'btn_submit'));
if(showOptHelp)
{
$('#conf_cont').append(createHelpTable(schema.kodiVideoChecker.properties, $.i18n("conf_kodi_label_title")));
}
conf_editor = createJsonEditor('editor_container', {
kodiVideoChecker: schema.kodiVideoChecker
}, true, true);
conf_editor.on('change',function() {
conf_editor.validate().length ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
});
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
});
if(showOptHelp)
$('#opt_expl').html(createHelpTable(schema.kodiVideoChecker.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("conf_kodi_label_title")+' '+$.i18n("conf_helptable_expl")));
});
$(document).ready( function() {
performTranslation();
requestServerConfigSchema();
});

View File

@@ -1,6 +1,9 @@
var ledsCustomCfgInitialized = false;
var finalLedArray = [];
var IntListIds;
var StrListIds;
var BoolListIds;
function get_hue_lights(){
$.ajax({
@@ -27,6 +30,56 @@ function validateText(){
return true
}
function loadStoredValues()
{
if (storageComp() && getStorage('ip_cl_ledstop') != null)
{
IntListIds = $('.led_val_int').map(function() { return this.id; }).get();
StrListIds = $('.led_val_string').map(function() { return this.id; }).get();
BoolListIds = $('.led_val_bool').map(function() { return this.id; }).get();
for(var i = 0; i < IntListIds.length; i++)
{
$('#'+IntListIds[i]).val(parseInt(getStorage(IntListIds[i])));
}
for(var i = 0; i < BoolListIds.length; i++)
{
var vb = getStorage(BoolListIds[i]);
$('#'+BoolListIds[i]).prop('checked', vb == "true" ? true : false);
}
for(var i = 0; i < StrListIds.length; i++)
{
$('#'+StrListIds[i]).val(getStorage(StrListIds[i]));
}
return;
}
return;
}
function saveValues()
{
if(storageComp())
{
for(var i = 0; i < IntListIds.length; i++)
{
setStorage(IntListIds[i], $('#'+IntListIds[i]).val());
}
for(var i = 0; i < BoolListIds.length; i++)
{
setStorage(BoolListIds[i], $('#'+BoolListIds[i]).is(":checked"));
}
for(var i = 0; i < StrListIds.length; i++)
{
setStorage(StrListIds[i], $('#'+StrListIds[i]).val());
}
return;
}
}
function round(number) {
var factor = Math.pow(10, 4);
var tempNumber = number * factor;
@@ -37,19 +90,19 @@ function round(number) {
function createLedPreview(leds, origin){
if (origin == "classic"){
$('#previewcreator').html('<h5>'+$.i18n('conf_leds_layout_preview_originCL')+'</h5>');
$('#previewcreator').html($.i18n('conf_leds_layout_preview_originCL'));
$('#leds_preview').css("padding-top", "56.25%");
}
else if(origin == "text"){
$('#previewcreator').html('<h5>'+$.i18n('conf_leds_layout_preview_originTEXT')+'</h5>');
$('#previewcreator').html($.i18n('conf_leds_layout_preview_originTEXT'));
$('#leds_preview').css("padding-top", "56.25%");
}
else if(origin == "matrix"){
$('#previewcreator').html('<h5>'+$.i18n('conf_leds_layout_preview_originMA')+'</h5>');
$('#previewcreator').html($.i18n('conf_leds_layout_preview_originMA'));
$('#leds_preview').css("padding-top", "100%");
}
$('#previewledcount').html('<h5>'+$.i18n('conf_leds_layout_preview_totalleds', leds.length)+'</h5>');
$('#previewledcount').html($.i18n('conf_leds_layout_preview_totalleds', leds.length));
$('.st_helper').css("border", "8px solid grey");
@@ -80,27 +133,27 @@ function createLedPreview(leds, origin){
function createClassicLeds(){
//get values
var ledsTop = parseInt($("#ip_cl_ledstop").val());
var ledsBottom = parseInt($("#ip_cl_ledsbottom").val());
var ledsLeft = parseInt($("#ip_cl_ledsleft").val());
var ledsRight = parseInt($("#ip_cl_ledsright").val());
var ledsGlength = parseInt($("#ip_cl_ledsglength").val());
var ledsGPos = parseInt($("#ip_cl_ledsgpos").val());
var ledstop = parseInt($("#ip_cl_ledstop").val());
var ledsbottom = parseInt($("#ip_cl_ledsbottom").val());
var ledsleft = parseInt($("#ip_cl_ledsleft").val());
var ledsright = parseInt($("#ip_cl_ledsright").val());
var ledsglength = parseInt($("#ip_cl_ledsglength").val());
var ledsgpos = parseInt($("#ip_cl_ledsgpos").val());
var position = parseInt($("#ip_cl_position").val());
var reverse = $("#ip_cl_reverse").is(":checked");
//advanced values
var rawledsVDepth = parseInt($("#ip_cl_ledsvdepth").val());
var rawledsHDepth = parseInt($("#ip_cl_ledshdepth").val());
var rawedgeGap = parseInt($("#ip_cl_ledsedgegap").val());
var rawcornerGap = parseInt($("#ip_cl_ledscornergap").val());
var rawledsvdepth = parseInt($("#ip_cl_rawledsvdepth").val());
var rawledshdepth = parseInt($("#ip_cl_rawledshdepth").val());
var rawledsedgegap = parseInt($("#ip_cl_rawledsedgegap").val());
var rawledscornergap = parseInt($("#ip_cl_rawledscornergap").val());
//helper
var ledsVDepth = rawledsVDepth /100;
var ledsHDepth = rawledsHDepth /100;
var edgeVGap = rawedgeGap /100/2;
var ledsVDepth = rawledsvdepth /100;
var ledsHDepth = rawledshdepth /100;
var edgeVGap = rawledsedgegap /100/2;
var edgeHGap = edgeVGap/(16/9);
var cornerVGap = rawcornerGap /100/2;
var cornerVGap = rawledscornergap /100/2;
var cornerHGap = cornerVGap/(16/9);
var Vmin = 0.0 + edgeVGap;
var Vmax = 1.0 - edgeVGap;
@@ -121,7 +174,7 @@ function createClassicLeds(){
}
function validateGap(){
if (ledsGPos+ledsGlength > ledArray.length){
if (ledsgpos+ledsglength > ledArray.length){
showInfoDialog('error', $.i18n('infoDialog_leds_gap_title'), $.i18n('infoDialog_leds_gap_text'));
return false
}
@@ -153,16 +206,16 @@ function createClassicLeds(){
}
function createTopLeds(){
step=(Hmax-Hmin)/ledsTop;
step=(Hmax-Hmin)/ledstop;
hmin=Hmin
if(cornerVGap != '0'){
step=(Hmax-Hmin-(cornerHGap*2))/ledsTop;
step=(Hmax-Hmin-(cornerHGap*2))/ledstop;
hmin=Hmin+(cornerHGap);
}
vmin=Vmin
vmax=vmin+ledsHDepth;
hmax=hmin+step
for (var i = 0; i<ledsTop; i++){
for (var i = 0; i<ledstop; i++){
createLedArray(hmin, hmax, vmin, vmax);
hmin += step
hmax += step
@@ -170,16 +223,16 @@ function createClassicLeds(){
}
function createLeftLeds(){
step=(Vmax-Vmin)/ledsLeft;
step=(Vmax-Vmin)/ledsleft;
vmax=Vmax
if(cornerVGap != '0'){
step=(Vmax-Vmin-(cornerVGap*2))/ledsLeft;
step=(Vmax-Vmin-(cornerVGap*2))/ledsleft;
vmax=Vmax-(cornerVGap);
}
hmin=Hmin;
hmax=hmin+ledsVDepth;
vmin=vmax-step
for (var i = ledsLeft; i>0; i--){
for (var i = ledsleft; i>0; i--){
createLedArray(hmin, hmax, vmin, vmax);
vmin -= step
vmax -= step
@@ -187,16 +240,16 @@ function createClassicLeds(){
}
function createRightLeds(){
step=(Vmax-Vmin)/ledsRight;
step=(Vmax-Vmin)/ledsright;
vmin=Vmin
if(cornerVGap != '0'){
step=(Vmax-Vmin-(cornerVGap*2))/ledsRight;
step=(Vmax-Vmin-(cornerVGap*2))/ledsright;
vmin=Vmin+(cornerVGap);
}
hmax=Hmax;
hmin=hmax-ledsVDepth;
vmax=vmin+step
for (var i = 0; i<ledsRight; i++){
for (var i = 0; i<ledsright; i++){
createLedArray(hmin, hmax, vmin, vmax);
vmin += step
vmax += step
@@ -204,16 +257,16 @@ function createClassicLeds(){
}
function createBottomLeds(){
step=(Hmax-Hmin)/ledsBottom;
step=(Hmax-Hmin)/ledsbottom;
hmax=Hmax
if(cornerVGap != '0'){
step=(Hmax-Hmin-(cornerHGap*2))/ledsBottom;
step=(Hmax-Hmin-(cornerHGap*2))/ledsbottom;
hmax=Hmax-(cornerHGap);
}
vmax=Vmax;
vmin=vmax-ledsHDepth;
hmin=hmax-step
for (var i = ledsBottom; i>0; i--){
for (var i = ledsbottom; i>0; i--){
createLedArray(hmin, hmax, vmin, vmax);
hmin -= step;
hmax -= step;
@@ -222,8 +275,8 @@ function createClassicLeds(){
createLeftLeds(createBottomLeds(createRightLeds(createTopLeds())));
if(ledsGlength != "0" && validateGap()){
ledArray.splice(ledsGPos, ledsGlength);
if(ledsglength != "0" && validateGap()){
ledArray.splice(ledsgpos, ledsglength);
}
if (position != "0"){
@@ -241,8 +294,8 @@ function createMatrixLeds(){
// https://raw.githubusercontent.com/RanzQ/hyperion-audio-effects/master/matrix-config.js
//get values
var width = parseInt($("#ip_ma_ledshoriz").val());
var height = parseInt($("#ip_ma_ledsvert").val());
var ledshoriz = parseInt($("#ip_ma_ledshoriz").val());
var ledsvert = parseInt($("#ip_ma_ledsvert").val());
var cabling = $("#ip_ma_cabling").val();
//var order = $("#ip_ma_order").val();
var start = $("#ip_ma_start").val();
@@ -250,8 +303,8 @@ function createMatrixLeds(){
var parallel = false
var index = 0
var leds = []
var hblock = 1.0 / width
var vblock = 1.0 / height
var hblock = 1.0 / ledshoriz
var vblock = 1.0 / ledsvert
if (cabling == "parallel"){
parallel = true
@@ -288,10 +341,10 @@ function createMatrixLeds(){
}
var startYX = start.split('-')
var startX = startYX[1] === 'right' ? width - 1 : 0
var startY = startYX[0] === 'bottom' ? height - 1 : 0
var endX = startX === 0 ? width - 1 : 0
var endY = startY === 0 ? height - 1 : 0
var startX = startYX[1] === 'right' ? ledshoriz - 1 : 0
var startY = startYX[0] === 'bottom' ? ledsvert - 1 : 0
var endX = startX === 0 ? ledshoriz - 1 : 0
var endY = startY === 0 ? ledsvert - 1 : 0
var forward = startX < endX
var downward = startY < endY
@@ -316,75 +369,62 @@ function createMatrixLeds(){
}
$(document).ready(function() {
// translate
performTranslation();
//-------------------------------------------------------------------
// restore values from storage
loadStoredValues();
// check access level and adjust ui
if(storedAccess == "default")
{
$('#btn_ma_generate').toggle(false);
$('#btn_cl_generate').toggle(false);
$('#texfield_panel').toggle(false);
$('#previewcreator').toggle(false);
}
else
{
$('#btn_ma_save').toggle(false);
$('#btn_cl_save').toggle(false);
}
// bind change event to all inputs
$('.ledCLconstr').bind("change", function() {
createClassicLeds();
});
// ------------------------------------------------------------------
$('.ledMAconstr').bind("change", function() {
createMatrixLeds();
});
// ------------------------------------------------------------------
// cl leds push to textfield and save values
$('#btn_cl_generate').off().on("click", function() {
if (finalLedArray != ""){
$("#ledconfig").text(JSON.stringify(finalLedArray, null, "\t"));
$('#collapse1').collapse('hide')
$('#collapse1').collapse('hide');
$('#collapse4').collapse('show');
saveValues();
}
});
// ------------------------------------------------------------------
// ma leds push to textfield and save values
$('#btn_ma_generate').off().on("click", function() {
if (finalLedArray != ""){
$("#ledconfig").text(JSON.stringify(finalLedArray, null, "\t"));
$('#collapse2').collapse('hide')
$('#collapse2').collapse('hide');
$('#collapse4').collapse('show');
saveValues();
}
});
// ------------------------------------------------------------------
$(hyperion).on("cmd-ledcolors-imagestream-update",function(event){
if ($("#leddevices").length == 0)
{
requestLedImageStop();
}
else
{
imageData = (event.response.result.image);
$("#image_preview").attr("src", imageData);
}
// fill textfield with current led conf and copy to finalLedArray
$(hyperion).one("cmd-config-getconfig",function(event){
$("#ledconfig").text(JSON.stringify(event.response.result.leds, null, "\t"));
finalLedArray = event.response.result.leds;
});
// ------------------------------------------------------------------
$(hyperion).on("cmd-ledcolors-ledstream-update",function(event){
if ($("#leddevices").length == 0)
{
requestLedColorsStop();
}
else
{
ledColors = (event.response.result.leds);
for(var idx=0; idx<ledColors.length; idx++)
{
led = ledColors[idx]
$("#led_"+led.index).css("background","rgb("+led.red+","+led.green+","+led.blue+")");
}
}
});
// ------------------------------------------------------------------
$(hyperion).on("cmd-ledcolors-ledstream-stop",function(event){
led_count = $(".led").length;
for(var idx=0; idx<led_count; idx++)
{
$('#led_'+idx).css("background-color","hsl("+(idx*360/led_count)+",100%,50%)");
}
});
// ------------------------------------------------------------------
// create led device selection
$(hyperion).one("cmd-serverinfo",function(event){
server = event.response;
ledDevices = server.info.ledDevices.available
@@ -428,93 +468,32 @@ $(document).ready(function() {
$("#leddevices").trigger("change");
});
// ------------------------------------------------------------------
$(hyperion).on("cmd-config-getconfig",function(event){
parsedConfJSON = event.response.result;
leds = parsedConfJSON.leds;
$("#ledconfig").text(JSON.stringify(leds, null, "\t"));
canvas_height = $('#leds_canvas').innerHeight();
canvas_width = $('#leds_canvas').innerWidth();
leds_html = '<img src="" id="image_preview" style="position:relative" />"';
for(var idx=0; idx<leds.length; idx++)
{
led = leds[idx];
led_id='led_'+led.index;
bgcolor = "background-color:hsl("+(idx*360/leds.length)+",100%,50%);";
pos = "left:"+(led.hscan.minimum * canvas_width)+"px;"+
"top:"+(led.vscan.minimum * canvas_height)+"px;"+
"width:"+((led.hscan.maximum-led.hscan.minimum) * canvas_width-1)+"px;"+
"height:"+((led.vscan.maximum-led.vscan.minimum) * canvas_height-1)+"px;";
leds_html += '<div id="'+led_id+'" class="led" style="'+bgcolor+pos+'" title="'+led.index+'"><span id="'+led_id+'_num" class="led_num">'+led.index+'</span></div>';
}
$('#leds_canvas').html(leds_html);
$('#led_0').css({"z-index":"10"});
$('#image_preview').hide();
$('#image_preview').attr("width" , $('#leds_canvas').innerWidth()-2);
$('#image_preview').attr("height", $('#leds_canvas').innerHeight()-2);
});
// ------------------------------------------------------------------
$('#leds_toggle_num').off().on("click", function() {
$('.led_num').toggle();
toggleClass('#leds_toggle_num', "btn-danger", "btn-success");
});
// ------------------------------------------------------------------
$('#leds_toggle').off().on("click", function() {
$('.led').toggle();
toggleClass('#leds_toggle', "btn-success", "btn-danger");
});
// ------------------------------------------------------------------
$('#leds_toggle_live').off().on("click", function() {
setClassByBool('#leds_toggle_live',ledStreamActive,"btn-success","btn-danger");
if ( ledStreamActive )
{
requestLedColorsStop();
}
else
{
requestLedColorsStart();
}
});
// ------------------------------------------------------------------
$('#leds_toggle_live_video').off().on("click", function() {
setClassByBool('#leds_toggle_live_video',imageStreamActive,"btn-success","btn-danger");
if ( imageStreamActive )
{
requestLedImageStop();
$('#image_preview').hide();
}
else
{
$('#image_preview').show();
requestLedImageStart();
}
});
// ------------------------------------------------------------------
// validate textfield and update preview
$("#leds_custom_updsim").off().on("click", function() {
if (validateText()){
createLedPreview(JSON.parse($("#ledconfig").val()), 'text');
}
});
// ------------------------------------------------------------------
// save led config and saveValues - passing textfield
$("#btn_ma_save, #btn_cl_save").off().on("click", function() {
requestWriteConfig(JSON.parse('{"leds" :'+finalLedArray+'}'));
saveValues();
});
// validate and save led config from textfield
$("#leds_custom_save").off().on("click", function() {
if (validateText())
requestWriteConfig(JSON.parse('{"leds" :'+$("#ledconfig").val()+'}'));
});
// ------------------------------------------------------------------
// toggle led numbers
$('#leds_prev_toggle_num').off().on("click", function() {
$('.led_prev_num').toggle();
toggleClass('#leds_prev_toggle_num', "btn-danger", "btn-success");
});
// -------------------------------------------------------------
// nav
$('#leds_cfg_nav a[data-toggle="tab"]').off().on('shown.bs.tab', function (e) {
var target = $(e.target).attr("href") // activated tab
if (target == "#menu_gencfg" && !ledsCustomCfgInitialized)
@@ -524,12 +503,11 @@ $(document).ready(function() {
}
});
// ------------------------------------------------------------------
// create and update editor
var conf_editor = null;
$("#leddevices").off().on("change", function(event) {
generalOptions = parsedConfSchemaJSON.properties.device;
specificOptions = parsedConfSchemaJSON.properties.alldevices[$(this).val()];
//$('#ledDeviceOptions').html(JSON.stringify(generalOptions)+"<br>"+JSON.stringify(specificOptions));
conf_editor = createJsonEditor('editor_container', {
generalOptions : generalOptions,
specificOptions : specificOptions,
@@ -554,10 +532,6 @@ $(document).ready(function() {
conf_editor.getEditor("root.specificOptions").setValue( values_specific );
};
$('#editor_container .well').css("background-color","white");
$('#editor_container .well').css("border","none");
$('#editor_container .well').css("box-shadow","none");
if ($(this).val() == "philipshue")
{
@@ -575,12 +549,13 @@ $(document).ready(function() {
{
$("#huebridge").hide();
}
// change save button state based on validation result
conf_editor.validate().length ? $('#btn_submit_controller').attr('disabled', true) : $('#btn_submit_controller').attr('disabled', false);
});
// ------------------------------------------------------------------
// save led device config
$("#btn_submit_controller").off().on("click", function(event) {
if (conf_editor==null)
return;
ledDevice = $("#leddevices").val();
result = {device:{}};
@@ -602,3 +577,4 @@ $(document).ready(function() {
});

View File

@@ -1,16 +1,26 @@
var conf_editor = null;
$(document).ready(function() {
performTranslation();
requestLoggingStart();
schema = parsedConfSchemaJSON.properties;
$('#conf_cont').append(createOptPanel('fa-reorder', $.i18n("edt_conf_log_heading_title"), 'editor_container', 'btn_submit'));
if(showOptHelp)
{
$('#conf_cont').append(createHelpTable(schema.logger.properties, $.i18n("edt_conf_log_heading_title")));
}
conf_editor = createJsonEditor('editor_container', {
logger : schema.logger
}, true);
$('#editor_container h3').remove();
}, true, true);
conf_editor.on('change',function() {
conf_editor.validate().length ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
});
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
@@ -20,7 +30,6 @@ $(document).ready(function() {
toggleClass('#btn_autoscroll', "btn-success", "btn-danger");
});
if (!loggingHandlerInstalled)
{
loggingHandlerInstalled = true;

View File

@@ -9,54 +9,115 @@ $(hyperion).one("cmd-config-getschema", function(event) {
schema = parsedConfSchemaJSON.properties;
if(showOptHelp)
{
//jsonserver
$('#conf_cont').append(createRow('conf_cont_json'))
$('#conf_cont_json').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_js_heading_title"), 'editor_container_jsonserver', 'btn_submit_jsonserver'));
$('#conf_cont_json').append(createHelpTable(schema.jsonServer.properties, $.i18n("edt_conf_js_heading_title")));
//protoserver
$('#conf_cont').append(createRow('conf_cont_proto'))
$('#conf_cont_proto').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_ps_heading_title"), 'editor_container_protoserver', 'btn_submit_protoserver'));
$('#conf_cont_proto').append(createHelpTable(schema.protoServer.properties, $.i18n("edt_conf_ps_heading_title")));
//boblight
$('#conf_cont').append(createRow('conf_cont_bobl'))
$('#conf_cont_bobl').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_bobls_heading_title"), 'editor_container_boblightserver', 'btn_submit_boblightserver'));
$('#conf_cont_bobl').append(createHelpTable(schema.boblightServer.properties, $.i18n("edt_conf_bobls_heading_title")));
//udplistener
$('#conf_cont').append(createRow('conf_cont_udpl'))
$('#conf_cont_udpl').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_udpl_heading_title"), 'editor_container_udplistener', 'btn_submit_udplistener'));
$('#conf_cont_udpl').append(createHelpTable(schema.udpListener.properties, $.i18n("edt_conf_udpl_heading_title")));
//forwarder
if(storedAccess != 'default')
{
$('#conf_cont').append(createRow('conf_cont_fw'))
$('#conf_cont_fw').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_fw_heading_title"), 'editor_container_forwarder', 'btn_submit_forwarder'));
$('#conf_cont_fw').append(createHelpTable(schema.forwarder.properties, $.i18n("edt_conf_fw_heading_title")));
}
}
else
{
$('#conf_cont').addClass('row');
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_js_heading_title"), 'editor_container_jsonserver', 'btn_submit_jsonserver'));
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_ps_heading_title"), 'editor_container_protoserver', 'btn_submit_protoserver'));
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_bobls_heading_title"), 'editor_container_boblightserver', 'btn_submit_boblightserver'));
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_udpl_heading_title"), 'editor_container_udplistener', 'btn_submit_udplistener'));
if(storedAccess != 'default')
$('#conf_cont').append(createOptPanel('fa-sitemap', $.i18n("edt_conf_fw_heading_title"), 'editor_container_forwarder', 'btn_submit_forwarder'));
}
//json
conf_editor_json = createJsonEditor('editor_container_jsonserver', {
jsonServer : schema.jsonServer
}, true, true);
conf_editor_json.on('change',function() {
conf_editor_json.validate().length ? $('#btn_submit_jsonserver').attr('disabled', true) : $('#btn_submit_jsonserver').attr('disabled', false);
});
$('#btn_submit_jsonserver').off().on('click',function() {
requestWriteConfig(conf_editor_json.getValue());
});
//proto
conf_editor_proto = createJsonEditor('editor_container_protoserver', {
protoServer : schema.protoServer
}, true, true);
conf_editor_proto.on('change',function() {
conf_editor_proto.validate().length ? $('#btn_submit_protoserver').attr('disabled', true) : $('#btn_submit_protoserver').attr('disabled', false);
});
$('#btn_submit_protoserver').off().on('click',function() {
requestWriteConfig(conf_editor_proto.getValue());
});
//boblight
conf_editor_bobl = createJsonEditor('editor_container_boblightserver', {
boblightServer : schema.boblightServer
}, true, true);
conf_editor_bobl.on('change',function() {
conf_editor_bobl.validate().length ? $('#btn_submit_boblightserver').attr('disabled', true) : $('#btn_submit_boblightserver').attr('disabled', false);
});
$('#btn_submit_boblightserver').off().on('click',function() {
requestWriteConfig(conf_editor_bobl.getValue());
});
//udplistener
conf_editor_udpl = createJsonEditor('editor_container_udplistener', {
udpListener : schema.udpListener
}, true, true);
conf_editor_udpl.on('change',function() {
conf_editor_udpl.validate().length ? $('#btn_submit_udplistener').attr('disabled', true) : $('#btn_submit_udplistener').attr('disabled', false);
});
$('#btn_submit_udplistener').off().on('click',function() {
requestWriteConfig(conf_editor_udpl.getValue());
});
conf_editor_forw = createJsonEditor('editor_container_forwarder', {
forwarder : schema.forwarder
}, true, true);
$('#btn_submit_forwarder').off().on('click',function() {
requestWriteConfig(conf_editor_forw.getValue());
});
if(showOptHelp)
if(storedAccess != 'default')
{
$('#opt_expl_jsonserver').html(createHelpTable(schema.jsonServer.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_js_heading_title")+' '+$.i18n("conf_helptable_expl")));
$('#opt_expl_protoserver').html(createHelpTable(schema.protoServer.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_ps_heading_title")));
$('#opt_expl_boblightserver').html(createHelpTable(schema.boblightServer.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_bobls_heading_title")+' '+$.i18n("conf_helptable_expl")));
$('#opt_expl_udplistener').html(createHelpTable(schema.udpListener.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_udpl_heading_title")+' '+$.i18n("conf_helptable_expl")));
$('#opt_expl_forwarder').html(createHelpTable(schema.forwarder.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_fw_heading_title")+' '+$.i18n("conf_helptable_expl")));
//forwarder
conf_editor_forw = createJsonEditor('editor_container_forwarder', {
forwarder : schema.forwarder
}, true, true);
conf_editor_forw.on('change',function() {
conf_editor_forw.validate().length ? $('#btn_submit_forwarder').attr('disabled', true) : $('#btn_submit_forwarder').attr('disabled', false);
});
$('#btn_submit_forwarder').off().on('click',function() {
requestWriteConfig(conf_editor_forw.getValue());
});
}
});

View File

@@ -1,25 +1,61 @@
function updateInputSelect()
{
{
$('#sstbody').html("");
var data = "";
var prios = parsedServerInfoJSON.info.priorities
var i;
for(i = 0; i < parsedServerInfoJSON.info.priorities.length; i++) {
var owner = parsedServerInfoJSON.info.priorities[i].owner;
var active = parsedServerInfoJSON.info.priorities[i].active;
var visible = parsedServerInfoJSON.info.priorities[i].visible;
var priority = parsedServerInfoJSON.info.priorities[i].priority;
for(i = 0; i < prios.length; i++)
{
var origin = "not impl";
var ip = "xxx.xxx.xxx.xxx";
var owner = prios[i].owner;
var active = prios[i].active;
var visible = prios[i].visible;
var priority = prios[i].priority;
var compId = prios[i].componentId;
var duration = prios[i].duration_ms/1000;
var btn_type = "default";
var btn_text = $.i18n('remote_input_setsource_btn');
var btn_state = "enabled";
if (active) btn_type = "warning";
if (visible) btn_type = "success";
if (visible)
{
btn_state = "disabled";
btn_type = "success";
btn_text = $.i18n('remote_input_sourceactiv_btn');
}
if(ip)
origin += '<br/><span style="font-size:80%; color:grey;">'+$.i18n('remote_input_ip')+' '+ip+'</span>';
if(compId == "10")
owner = $.i18n('remote_effects_label_effects')+' '+owner;
if(compId == "9")
owner = $.i18n('remote_colors_label_color')+' '+'<div style="width:18px; height:18px; border-radius:20px; margin-bottom:-4px; border:1px grey solid; background-color: rgb('+prios[i].value.RGB+'); display:inline-block" title="RGB: ('+prios[i].value.RGB+')"></div>';
if(compId == "7")
owner = $.i18n('general_comp_GRABBER')+': ('+owner+')';
if(compId == "8")
owner = $.i18n('general_comp_V4L')+': ('+owner+')';
if(compId == "6")
owner = $.i18n('general_comp_BOBLIGHTSERVER');
if(compId == "5")
owner = $.i18n('general_comp_UDPLISTENER');
if(duration)
owner += '<br/><span style="font-size:80%; color:grey;">'+$.i18n('remote_input_duration')+' '+duration.toFixed(0)+$.i18n('edt_append_s')+'</span>';
var btn = '<button id="srcBtn'+i+'" type="button" '+btn_state+' class="btn btn-'+btn_type+' btn_input_selection" onclick="requestSetSource('+priority+');">'+btn_text+'</button>';
if((compId == "10" || compId == "9") && priority != 254)
btn += '<button type="button" class="btn btn-sm btn-danger" style="margin-left:10px;" onclick="requestPriorityClear('+priority+');"><i class="fa fa-close"></button>';
if(btn_type != 'default')
data += '<button id="srcBtn'+i+'" type="button" class="btn btn-lg btn-'+btn_type+' btn_input_selection" style="margin:10px;min-width:200px" onclick="requestSetSource('+priority+');">'+owner+'<span style="font-size:70% !important;"> ('+priority+')</span></button><br/>';
$('#sstbody').append(createTableRow([origin, owner, priority, btn], false, true));
}
var autostate = (parsedServerInfoJSON.info.priorities_autoselect? "btn-success" : "btn-danger");
data += '<button id="srcBtn'+i+'" type="button" class="btn btn-lg '+autostate+' btn_input_selection" style="margin:10px;min-width:200px" onclick="requestSetSource(\'auto\');">'+$.i18n('remote_input_label_autoselect')+'</button><br/>';
$('#hyperion_inputs').html(data);
var btn_auto_color = (parsedServerInfoJSON.info.priorities_autoselect? "btn-success" : "btn-danger");
var btn_auto_state = (parsedServerInfoJSON.info.priorities_autoselect? "disabled" : "enabled");
var btn_auto_text = (parsedServerInfoJSON.info.priorities_autoselect? $.i18n('general_btn_on') : $.i18n('general_btn_off'));
$('#auto_btn').html('<button id="srcBtn'+i+'" type="button" '+btn_auto_state+' class="btn '+btn_auto_color+'" style="margin:10px;display:inline-block;" onclick="requestSetSource(\'auto\');">'+$.i18n('remote_input_label_autoselect')+' ('+btn_auto_text+')</button>');
var max_width=200;
var max_width=100;
$('.btn_input_selection').each(function() {
if ($(this).innerWidth() > max_width)
max_width = $(this).innerWidth();
@@ -109,11 +145,15 @@
$(document).ready(function() {
performTranslation();
createTable('ssthead', 'sstbody', 'sstcont');
$('#ssthead').html(createTableRow([$.i18n('remote_input_origin'), $.i18n('remote_input_owner'), $.i18n('remote_input_priority'), $.i18n('remote_input_status')], true, true));
// color
$(function() {
$('#cp2').colorpicker({
format: 'rgb',
customClass: 'colorpicker-2x',
color: '#B500FF',
sliders: {
saturation: {
maxLeft: 200,

View File

@@ -2,16 +2,24 @@
var conf_editor = null;
$(hyperion).one("cmd-config-getschema", function(event) {
schema = parsedConfSchemaJSON.properties;
$('#conf_cont').append(createOptPanel('fa-wrench', $.i18n("edt_conf_webc_heading_title"), 'editor_container', 'btn_submit'));
if(showOptHelp)
{
$('#conf_cont').append(createHelpTable(schema.webConfig.properties, $.i18n("edt_conf_webc_heading_title")));
}
conf_editor = createJsonEditor('editor_container', {
webConfig : schema.webConfig
}, true, true);
conf_editor.on('change',function() {
conf_editor.validate().length ? $('#btn_submit').attr('disabled', true) : $('#btn_submit').attr('disabled', false);
});
$('#btn_submit').off().on('click',function() {
requestWriteConfig(conf_editor.getValue());
});
if(showOptHelp)
$('#opt_expl_webconfig').html(createHelpTable(schema.webConfig.properties, '<i class="fa fa-info-circle fa-fw"></i>'+$.i18n("edt_conf_webc_heading_title")+' '+$.i18n("conf_helptable_expl")));
});

View File

@@ -1,5 +1,6 @@
// global vars
var webPrio = 1;
var showOptHelp = true;
var currentVersion;
var cleanCurrentVersion;
@@ -26,8 +27,7 @@ function initRestart()
$(hyperion).off();
requestServerConfigReload();
watchdog = 10;
$("#wrapper").fadeOut("slow");
connectionLostDetection();
connectionLostDetection('restart');
}
function cron()
@@ -37,15 +37,23 @@ function cron()
}
function connectionLostDetection()
function connectionLostDetection(type)
{
if ( watchdog > 1 )
{
var interval_id = window.setInterval("", 9999); // Get a reference to the last
for (var i = 1; i < interval_id; i++)
window.clearInterval(i);
$("body").html($("#container_connection_lost").html());
connectionLostAction();
if(type == 'restart')
{
$("body").html($("#container_restart").html());
restartAction();
}
else
{
$("body").html($("#container_connection_lost").html());
connectionLostAction();
}
}
else
{
@@ -200,19 +208,22 @@ function requestLedImageStop()
sendToHyperion("ledcolors", "imagestream-stop");
}
function requestPriorityClear()
function requestPriorityClear(prio)
{
sendToHyperion("clear", "", '"priority":1');
if(typeof prio !== 'number')
prio = webPrio;
sendToHyperion("clear", "", '"priority":'+prio+'');
}
function requestPlayEffect(effectName)
{
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'"},"priority":1');
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'"},"priority":'+webPrio+'');
}
function requestSetColor(r,g,b)
{
sendToHyperion("color", "", '"color":['+r+','+g+','+b+'], "priority":1');
sendToHyperion("color", "", '"color":['+r+','+g+','+b+'], "priority":'+webPrio+'');
}
function requestSetComponentState(comp, state)
@@ -229,14 +240,18 @@ function requestSetSource(prio)
sendToHyperion("sourceselect", "", '"priority":'+prio);
}
function requestWriteConfig(config)
function requestWriteConfig(config, full)
{
var complete_config = parsedConfJSON;
jQuery.each(config, function(i, val) {
complete_config[i] = val;
});
if(full === true)
parsedConfJSON = config;
else
{
jQuery.each(config, function(i, val) {
parsedConfJSON[i] = val;
});
}
var config_str = escape(encode_utf8(JSON.stringify(complete_config)));
var config_str = escape(encode_utf8(JSON.stringify(parsedConfJSON)));
$.post( "/cgi/cfg_set", { cfg: config_str })
.done(function( data ) {
@@ -255,7 +270,7 @@ function requestWriteEffect(effectName,effectPy,effectArgs)
function requestTestEffect(effectName,effectPy,effectArgs)
{
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'", "args":'+effectArgs+'},"priority":1, "pythonScript":"'+effectPy+'"}');
sendToHyperion("effect", "", '"effect":{"name":"'+effectName+'", "args":'+effectArgs+'},"priority":'+webPrio+', "pythonScript":"'+effectPy+'"}');
}
function requestDeleteEffect(effectName)

View File

@@ -0,0 +1,141 @@
$(document).ready(function() {
var modalOpened = false;
var ledsim_width = 540;
var ledsim_height = 489;
var dialog;
var leds;
$(hyperion).one("cmd-config-getconfig",function(event){
leds = event.response.result.leds;
if(storageComp() && getStorage('ledsim_width') != null)
{
ledsim_width = getStorage('ledsim_width');
ledsim_height = getStorage('ledsim_height');
}
dialog = $("#ledsim_dialog").dialog({
uiLibrary: 'bootstrap',
resizable: true,
modal: false,
minWidth: 250,
width: ledsim_width,
minHeight: 350,
height: ledsim_height,
closeOnEscape: true,
autoOpen: false,
title: $.i18n('main_ledsim_title'),
resize: function (e) {
updateLedLayout();
},
opened: function (e) {
updateLedLayout();
modalOpened = true;
requestLedColorsStart();
if($('#leds_toggle_live_video').hasClass('btn-success'))
requestLedImageStart();
},
closed: function (e) {
modalOpened = false;
},
resizeStop: function (e) {
if(storageComp())
{
setStorage("ledsim_width", $("#ledsim_dialog").outerWidth());
setStorage("ledsim_height", $("#ledsim_dialog").outerHeight());
}
}
});
});
function updateLedLayout()
{
//calculate body size
var canvas_height = $('#ledsim_dialog').outerHeight()-$('#ledsim_text').outerHeight()-$('[data-role=footer]').outerHeight()-$('[data-role=header]').outerHeight()-40;
var canvas_width = $('#ledsim_dialog').outerWidth()-30;
$('#leds_canvas').html("");
leds_html = '<img src="" id="image_preview" style="position:relative" />';
for(var idx=0; idx<leds.length; idx++)
{
led = leds[idx];
led_id='led_'+led.index;
bgcolor = "background-color:hsl("+(idx*360/leds.length)+",100%,50%);";
pos = "left:"+(led.hscan.minimum * canvas_width)+"px;"+
"top:"+(led.vscan.minimum * canvas_height)+"px;"+
"width:"+((led.hscan.maximum-led.hscan.minimum) * canvas_width-1)+"px;"+
"height:"+((led.vscan.maximum-led.vscan.minimum) * canvas_height-1)+"px;";
leds_html += '<div id="'+led_id+'" class="led" style="'+bgcolor+pos+'" title="'+led.index+'"><span id="'+led_id+'_num" class="led_num">'+led.index+'</span></div>';
}
$('#leds_canvas').html(leds_html);
if($('#leds_toggle_num').hasClass('btn-success'))
$('.led_num').toggle(true);
if($('#leds_toggle').hasClass('btn-danger'))
$('.led').toggle(false);
$('#image_preview').attr("width" , canvas_width-1);
$('#image_preview').attr("height", canvas_height-1);
}
// ------------------------------------------------------------------
$('#leds_toggle_num').off().on("click", function() {
$('.led_num').toggle();
toggleClass('#leds_toggle_num', "btn-danger", "btn-success");
});
// ------------------------------------------------------------------
$('#leds_toggle').off().on("click", function() {
$('.led').toggle();
toggleClass('#leds_toggle', "btn-success", "btn-danger");
});
// ------------------------------------------------------------------
$('#leds_toggle_live_video').off().on("click", function() {
setClassByBool('#leds_toggle_live_video',imageStreamActive,"btn-success","btn-danger");
if ( imageStreamActive )
{
requestLedImageStop();
$('#image_preview').removeAttr("src");
}
else
{
requestLedImageStart();
}
});
// ------------------------------------------------------------------
$(hyperion).on("cmd-ledcolors-ledstream-update",function(event){
if (!modalOpened)
{
requestLedColorsStop();
}
else
{
ledColors = (event.response.result.leds);
for(var idx=0; idx<ledColors.length; idx++)
{
led = ledColors[idx]
$("#led_"+led.index).css("background","rgb("+led.red+","+led.green+","+led.blue+")");
}
}
});
// ------------------------------------------------------------------
$(hyperion).on("cmd-ledcolors-imagestream-update",function(event){
if (!modalOpened)
{
requestLedImageStop();
}
else
{
imageData = (event.response.result.image);
$("#image_preview").attr("src", imageData);
}
});
$("#btn_open_ledsim").off().on("click", function(event) {
dialog.open();
});
});

1
assets/webconfig/js/lib/dialog.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
//download.js v4.2, by dandavis; 2008-2016. [CCBY2] see http://danml.com/download.html for tests/usage
(function(r,k){"function"==typeof define&&define.amd?define([],k):"object"==typeof exports?module.exports=k():r.download=k()})(this,function(){return function k(a,b,g){function q(p){var a=p.split(/[:;,]/);p=a[1];var a=("base64"==a[2]?atob:decodeURIComponent)(a.pop()),d=a.length,b=0,c=new Uint8Array(d);for(b;b<d;++b)c[b]=a.charCodeAt(b);return new f([c],{type:p})}function l(a,b){if("download"in d)return d.href=a,d.setAttribute("download",m),d.className="download-js-link",d.innerHTML="downloading...",d.style.display="none",document.body.appendChild(d),setTimeout(function(){d.click(),document.body.removeChild(d),!0===b&&setTimeout(function(){e.URL.revokeObjectURL(d.href)},250)},66),!0;if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent))return a=a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream"),!window.open(a)&&confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=document.createElement("iframe");document.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),c.src=a,setTimeout(function(){document.body.removeChild(c)},333)}var e=window,c=g||"application/octet-stream",h=!b&&!g&&a,d=document.createElement("a");g=function(a){return String(a)};var f=e.Blob||e.MozBlob||e.WebKitBlob||g,m=b||"download",f=f.call?f.bind(e):Blob;"true"===String(this)&&(a=[a,c],c=a[0],a=a[1]);if(h&&2048>h.length&&(m=h.split("/").pop().split("?")[0],d.href=h,-1!==d.href.indexOf(h))){var n=new XMLHttpRequest;return n.open("GET",h,!0),n.responseType="blob",n.onload=function(a){k(a.target.response,m,"application/octet-stream")},setTimeout(function(){n.send()},0),n}if(/^data\:[\w+\-]+\/[\w+\-]+[,;]/.test(a)){if(!(2096103.424<a.length&&f!==g))return navigator.msSaveBlob?navigator.msSaveBlob(q(a),m):l(a);a=q(a),c=a.type||"application/octet-stream"}b=a instanceof f?a:new f([a],{type:c});if(navigator.msSaveBlob)return navigator.msSaveBlob(b,m);if(e.URL)l(e.URL.createObjectURL(b),!0);else{if("string"==typeof b||b.constructor===g)try{return l("data:"+c+";base64,"+e.btoa(b))}catch(p){return l("data:"+c+","+encodeURIComponent(b))}c=new FileReader,c.onload=function(a){l(this.result)},c.readAsDataURL(b)}return!0}});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -232,6 +232,7 @@ JSONEditor.prototype = {
var theme_class = JSONEditor.defaults.themes[this.options.theme || JSONEditor.defaults.theme];
if(!theme_class) throw "Unknown theme " + (this.options.theme || JSONEditor.defaults.theme);
this.access = this.options.access;
this.schema = this.options.schema;
this.theme = new theme_class();
this.template = this.options.template;
@@ -322,7 +323,8 @@ JSONEditor.prototype = {
this.validation_results = null;
this.theme = null;
this.iconlib = null;
this.template = null;
this.access = null;
this.template = null;
this.__data = null;
this.ready = false;
this.element.innerHTML = '';
@@ -1418,7 +1420,8 @@ JSONEditor.AbstractEditor = Class.extend({
this.theme = this.jsoneditor.theme;
this.template_engine = this.jsoneditor.template;
this.iconlib = this.jsoneditor.iconlib;
this.access = this.jsoneditor.access;
this.translate = this.jsoneditor.translate || JSONEditor.defaults.translate;
this.original_schema = options.schema;
@@ -1458,13 +1461,12 @@ JSONEditor.AbstractEditor = Class.extend({
this.register();
this.onWatchedFieldChange();
//hide input field, if it didn't match the current access level
var storedAccess = localStorage.getItem("accesslevel");
//hide input fields, if they didn't match the current access level
var storedAccess = this.access
if(this.schema.access){
if(this.schema.access == 'system')
this.container.style.display = "none";
if(this.schema.access == 'expert' && storedAccess != 'expert'){
else if(this.schema.access == 'expert' && storedAccess != 'expert'){
this.container.style.display = "none";
//this.disable();
}
@@ -1725,7 +1727,7 @@ JSONEditor.AbstractEditor = Class.extend({
}
},
setValue: function(value) {
this.value = value;
this.value = value;
},
getValue: function() {
return this.value;
@@ -2150,7 +2152,7 @@ JSONEditor.defaults.editors.string = JSONEditor.AbstractEditor.extend({
if(this.format) this.input.setAttribute('data-schemaformat',this.format);
if(this.defaultValue) this.input.setAttribute('data-schemaformat',this.format);
if(this.formname)this.label.setAttribute('for',this.formname);
if(this.formname && this.label)this.label.setAttribute('for',this.formname);
this.control = this.theme.getFormControl(this.label, this.input, this.description, this.append, this.placeholder);
this.container.appendChild(this.control);
@@ -2898,7 +2900,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
else this.showEditJSON();
},
insertPropertyControlUsingPropertyOrder: function (property, control, container) {
var propertyOrder;
var propertyOrder;
if (this.schema.properties[property])
propertyOrder = this.schema.properties[property].propertyOrder;
if (typeof propertyOrder !== "number") propertyOrder = 1000;
@@ -4842,7 +4844,7 @@ JSONEditor.defaults.editors["enum"] = JSONEditor.AbstractEditor.extend({
}
},
setValue: function(val) {
if(this.value !== val) {
if(this.value !== val) {
this.value = val;
this.refreshValue();
this.onChange();
@@ -4861,16 +4863,15 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({
setValue: function(value,initial) {
value = this.typecast(value||'');
// Sanitize value before setting it
//Sanitize value before setting it
var sanitized = value;
if(this.enum_values.indexOf(sanitized) < 0) {
sanitized = this.enum_values[0];
}
if(this.value === sanitized) {
return;
return;
}
this.input.value = this.enum_options[this.enum_values.indexOf(sanitized)];
if(this.select2) this.select2.select2('val',this.input.value);
this.value = sanitized;
@@ -4909,7 +4910,7 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({
}
},
getValue: function() {
return this.value;
return this.value;
},
preBuild: function() {
var self = this;

File diff suppressed because one or more lines are too long

View File

@@ -1,120 +0,0 @@
$(document).ready( function() {
var storedLang;
var storedAccess;
var availLang = ['en','de'];
var availAccess = ['default','expert']
//$.i18n.debug = true;
function storageComp(){
if (typeof(Storage) !== "undefined")
return true;
return false;
}
function initTrans(lc){
if (lc == 'auto')
{
$.i18n().load().done(
function() {
performTranslation();
});
}
else
{
$.i18n().locale = lc;
$.i18n().load( "i18n", lc ).done(
function() {
performTranslation();
});
}
}
//i18n
if (storageComp())
{
storedLang = localStorage.getItem("langcode");
if (storedLang == null)
{
localStorage.langcode = "auto";
storedLang = 'auto';
initTrans('auto');
}
else
{
initTrans(storedLang);
}
}
else
{
showInfoDialog('warning', "Can't store settings", "Your browser doesn't support localStorage. You can't save a specific language setting (fallback to 'auto detection') and access level (fallback to 'default'). Some wizards may be hidden. You could still use the webinterface without further issues");
initTrans('auto');
$('#btn_setlang').toggle();
$('#btn_setaccess').toggle();
$('#btn_wizard_byteorder').toggle();
}
$('#btn_setlang').off().on('click',function() {
$('#modal_select').html('');
for (var lcx = 0; lcx<availLang.length; lcx++)
{
$('#modal_select').append(createSelOpt(availLang[lcx], $.i18n('general_speech_'+availLang[lcx])))
}
showInfoDialog('select', $.i18n('InfoDialog_lang_title'), $.i18n('InfoDialog_lang_text'),'btn_savelang');
if (storedLang != "auto")
$('#modal_select').val(storedLang);
$('#btn_savelang').off().on('click',function() {
var newLang = $('#modal_select').val();
if (newLang != storedLang)
{
initTrans(newLang);
localStorage.langcode = newLang;
storedLang = newLang;
}
});
});
//access
function updateVisibility(){
if(storedAccess == 'expert')
$('#load_webconfig').toggle(true);
else
$('#load_webconfig').toggle(false);
}
if (storageComp())
{
storedAccess = localStorage.getItem("accesslevel");
if (storedAccess == null)
{
localStorage.accesslevel = "default";
storedAccess = "default";
updateVisibility();
}
else
{
updateVisibility();
}
}
$('#btn_setaccess').off().on('click',function() {
$('#modal_select').html('');
for (var lcx = 0; lcx<availAccess.length; lcx++)
{
$('#modal_select').append(createSelOpt(availAccess[lcx], $.i18n('general_access_'+availAccess[lcx])))
}
showInfoDialog('select', $.i18n('InfoDialog_access_title'), $.i18n('InfoDialog_access_text'), 'btn_saveaccess');
$('#modal_select').val(storedAccess);
$('#btn_saveaccess').off().on('click',function() {
storedAccess = $('#modal_select').val();
localStorage.accesslevel = storedAccess;
updateVisibility();
});
});
});

View File

@@ -0,0 +1,121 @@
var storedAccess;
var storedLang;
var availLang = ['en','de'];
var availAccess = ['default','advanced','expert'];
//$.i18n.debug = true;
$(document).ready( function() {
//i18n
function initTrans(lc){
if (lc == 'auto')
{
$.i18n().load().done(
function() {
performTranslation();
});
}
else
{
$.i18n().locale = lc;
$.i18n().load( "i18n", lc ).done(
function() {
performTranslation();
});
}
}
if (storageComp())
{
storedLang = getStorage("langcode");
if (storedLang == null)
{
setStorage("langcode", 'auto')
storedLang = 'auto';
initTrans(storedLang);
}
else
{
initTrans(storedLang);
}
}
else
{
showInfoDialog('warning', "Can't store settings", "Your browser doesn't support localStorage. You can't save a specific language setting (fallback to 'auto detection') and access level (fallback to 'default'). Some wizards may be hidden. You could still use the webinterface without further issues");
initTrans('auto');
storedLang = 'auto';
storedAccess = "default";
$('#btn_setlang').toggle();
$('#btn_setaccess').toggle();
}
$('#btn_setlang').off().on('click',function() {
var newLang;
showInfoDialog('select', $.i18n('InfoDialog_lang_title'), $.i18n('InfoDialog_lang_text'));
for (var lcx = 0; lcx<availLang.length; lcx++)
{
$('#id_select').append(createSelOpt(availLang[lcx], $.i18n('general_speech_'+availLang[lcx])))
}
if (storedLang != "auto")
$('#id_select').val(storedLang);
$('#id_select').off().on('change',function() {
newLang = $('#id_select').val();
if (newLang == storedLang)
$('#id_btn_saveset').attr('disabled', true);
else
$('#id_btn_saveset').attr('disabled', false);
});
$('#id_btn_saveset').off().on('click',function() {
setStorage("langcode", newLang);
reload();
});
$('#id_select').trigger('change');
});
//access
if (storageComp())
{
storedAccess = getStorage("accesslevel");
if (storedAccess == null)
{
setStorage("accesslevel", "default");
storedAccess = "default";
}
}
$('#btn_setaccess').off().on('click',function() {
var newAccess;
showInfoDialog('select', $.i18n('InfoDialog_access_title'), $.i18n('InfoDialog_access_text'));
for (var lcx = 0; lcx<availAccess.length; lcx++)
{
$('#id_select').append(createSelOpt(availAccess[lcx], $.i18n('general_access_'+availAccess[lcx])));
}
$('#id_select').val(storedAccess);
$('#id_select').off().on('change',function() {
newAccess = $('#id_select').val();
if (newAccess == storedAccess)
$('#id_btn_saveset').attr('disabled', true);
else
$('#id_btn_saveset').attr('disabled', false);
});
$('#id_btn_saveset').off().on('click',function() {
setStorage("accesslevel", newAccess);
reload();
});
$('#id_select').trigger('change');
});
//hide menu elements
if (storedAccess != 'expert')
$('#load_webconfig').toggle(false);
});

View File

@@ -1,3 +1,25 @@
function reload()
{
location.reload();
}
function storageComp()
{
if (typeof(Storage) !== "undefined")
return true;
return false;
}
function getStorage(item)
{
return localStorage.getItem(item);
}
function setStorage(item, value)
{
localStorage.setItem(item, value);
return true;
}
function debugMessage(msg)
{
@@ -24,8 +46,6 @@ function loadContentTo(containerId, fileName)
$(containerId).load("/content/"+fileName+".html");
}
function toggleClass(obj,class1,class2)
{
if ( $(obj).hasClass(class1))
@@ -55,37 +75,46 @@ function setClassByBool(obj,enable,class1,class2)
}
}
function showInfoDialog(type,header,message,btnid)
{
if (type != 'select')
$('#modal_select').toggle(false);
else
$('#modal_select').toggle(true);
$('#modal_dialog .modal-bodytitle').html(header);
$('#modal_dialog .modal-bodycontent').html(message);
function showInfoDialog(type,header,message)
{
if (type=="success"){
$('#modal_dialog .modal-bodyicon').html('<i class="fa fa-check modal-icon-check">');
$('#modal_dialog .modal-footer-button').html('<button type="button" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-check modal-icon-check">');
if(header == "")
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_success_title')+'</h4>');
$('#id_footer').html('<button type="button" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
}
else if (type=="warning"){
$('#modal_dialog .modal-bodyicon').html('<i class="fa fa-warning modal-icon-warning">');
$('#modal_dialog .modal-footer-button').html('<button type="button" class="btn btn-warning" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
if(header == "")
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_warning_title')+'</h4>');
$('#id_footer').html('<button type="button" class="btn btn-warning" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
}
else if (type=="error"){
$('#modal_dialog .modal-bodyicon').html('<i class="fa fa-warning modal-icon-error">');
$('#modal_dialog .modal-footer-button').html('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-error">');
if(header == "")
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('infoDialog_general_error_title')+'</h4>');
$('#id_footer').html('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_ok')+'</button>');
}
else if (type == "select"){
$('#modal_dialog .modal-bodyicon').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
$('#modal_dialog .modal-footer-button').html('<button type="button" id="'+btnid+'" class="btn btn-success" data-dismiss="modal">'+$.i18n('general_btn_save')+'</button>');
$('#modal_dialog .modal-footer-button').append('<button type="button" class="btn btn-danger" data-dismiss="modal">'+$.i18n('general_btn_cancel')+'</button>');
$('#id_body').html('<img style="margin-bottom:20px" src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
$('#id_footer').html('<button type="button" id="id_btn_saveset" class="btn btn-success" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saveandreload')+'</button>');
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
}
else if (type == "uilock"){
$('#modal_dialog .modal-bodyicon').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
$('#modal_dialog .modal-footer-button').html('<b>'+$.i18n('InfoDialog_nowrite_foottext')+'</b>');
$('#id_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!">');
$('#id_footer').html('<b>'+$.i18n('InfoDialog_nowrite_foottext')+'</b>');
}
else if (type == "import"){
$('#id_body').html('<i style="margin-bottom:20px" class="fa fa-warning modal-icon-warning">');
$('#id_footer').html('<button type="button" id="id_btn_import" class="btn btn-warning" data-dismiss="modal"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saverestart')+'</button>');
$('#id_footer').append('<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
}
$('#id_body').append('<h4 style="font-weight:bold;text-transform:uppercase;">'+header+'</h4>');
$('#id_body').append(message);
if(type == "select")
$('#id_body').append('<select id="id_select" class="form-control" style="margin-top:10px;width:auto;"></select>');
$("#modal_dialog").modal({
backdrop : "static",
@@ -107,7 +136,6 @@ function isJsonString(str)
return "";
}
function createJsonEditor(container,schema,setconfig,usePanel)
{
$('#'+container).off();
@@ -123,6 +151,9 @@ function createJsonEditor(container,schema,setconfig,usePanel)
disable_properties: 'true',
disable_array_reorder: 'true',
no_additional_properties: 'true',
disable_array_delete_all_rows: 'true',
disable_array_delete_last_row: 'true',
access: storedAccess,
schema: {
title:'',
properties: schema
@@ -147,44 +178,100 @@ function createJsonEditor(container,schema,setconfig,usePanel)
return editor;
}
function createTableTh(th1, th2){
var elth1 = document.createElement('th');
var elth2 = document.createElement('th');
var tr = document.createElement('tr');
elth1.innerHTML = th1;
elth2.innerHTML = th2;
tr.appendChild(elth1);
tr.appendChild(elth2);
return tr;
}
function createTableTd(td1, td2){
var eltd1 = document.createElement('td');
var eltd2 = document.createElement('td');
var tr = document.createElement('tr');
eltd1.innerHTML = td1;
eltd2.innerHTML = td2;
tr.appendChild(eltd1);
tr.appendChild(eltd2);
return tr;
}
function createHelpTable(list, phead){
// Creates a table with thead and tbody ids
// @param string hid : a id for thead
// @param string bid : a id for tbody
// @param string cont : a container id to html() the table
function createTable(hid, bid, cont)
{
var table = document.createElement('table');
var thead = document.createElement('thead');
var tbody = document.createElement('tbody');
table.className = "table";
table.style.marginBottom = "0px";
thead.setAttribute("id", hid);
tbody.setAttribute("id", bid);
table.appendChild(thead);
table.appendChild(tbody);
$('#'+cont).html(table);
}
// Creates a table row <tr>
// @param array list :innerHTML content for <td>/<th>
// @param bool head :if null or false it's body
// @param bool align :if null or false no alignment
//
// @return : <tr> with <td> or <th> as child(s)
function createTableRow(list, head, align)
{
var row = document.createElement('tr');
for(var i = 0; i < list.length; i++)
{
if(head === true)
var el = document.createElement('th');
else
var el = document.createElement('td');
if(align)
el.style.verticalAlign = "middle";
el.innerHTML = list[i];
row.appendChild(el);
}
return row;
}
function createRow(id)
{
var el = document.createElement('div');
el.className = "row";
el.setAttribute('id', id);
return el;
}
function createOptPanel(phicon, phead, bodyid, footerid)
{
phead = '<i class="fa '+phicon+' fa-fw"></i>'+phead;
pfooter = document.createElement('button');
pfooter.className = "btn btn-success";
pfooter.setAttribute("id", footerid);
pfooter.innerHTML = '<i class="fa fa-fw fa-save"></i>'+$.i18n('general_button_savesettings');
return createPanel(phead, "", pfooter, "panel-default", bodyid);
}
function createHelpTable(list, phead){
var table = document.createElement('table');
var thead = document.createElement('thead');
var tbody = document.createElement('tbody');
//console.log(sortProperties(list));
phead = '<i class="fa fa-fw fa-info-circle"></i>'+phead+' '+$.i18n("conf_helptable_expl");
table.className = 'table table-hover borderless';
thead.appendChild(createTableTh($.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')));
for (key in list){
if(list[key].access != 'system'){
text = list[key].title.replace('title', 'expl');
tbody.appendChild(createTableTd($.i18n(list[key].title), $.i18n(text)));
thead.appendChild(createTableRow([$.i18n('conf_helptable_option'), $.i18n('conf_helptable_expl')], true, false));
for (key in list)
{
if(list[key].access != 'system')
{
var text = list[key].title.replace('title', 'expl');
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
if(list[key].items && list[key].items.properties)
{
var ilist = list[key].items.properties;
for (ikey in ilist)
{
var itext = ilist[ikey].title.replace('title', 'expl');
tbody.appendChild(createTableRow([$.i18n(ilist[ikey].title), $.i18n(itext)], false, false));
}
}
}
}
table.appendChild(thead);
@@ -193,12 +280,15 @@ function createHelpTable(list, phead){
return createPanel(phead, table);
}
function createPanel(head, body, footer, type){
function createPanel(head, body, footer, type, bodyid){
var cont = document.createElement('div');
var p = document.createElement('div');
var phead = document.createElement('div');
var pbody = document.createElement('div');
var pfooter = document.createElement('div');
cont.className = "col-lg-6";
if(typeof type == 'undefined')
type = 'panel-default';
@@ -209,18 +299,30 @@ function createPanel(head, body, footer, type){
phead.innerHTML = head;
if(typeof body != 'undefined')
if(typeof bodyid != 'undefined')
{
pfooter.style.textAlign = 'right';
pbody.setAttribute("id", bodyid)
}
if(typeof body != 'undefined' && body != "")
pbody.appendChild(body);
pfooter.innerHTML = footer;
if(typeof footer != 'undefined')
pfooter.appendChild(footer);
p.appendChild(phead);
p.appendChild(pbody);
if(typeof footer != 'undefined')
{
pfooter.style.textAlign = "right";
p.appendChild(pfooter);
}
return p;
cont.appendChild(p);
return cont;
}
function createSelGroup(group)

View File

@@ -1,12 +1,21 @@
$(document).ready( function() {
//clear priority if people reload the page or lost connection while a wizard was active
var wizardStatus = localStorage.getItem("wizardactive");
$(hyperion).one("cmd-config-getschema", function(event) {
if(wizardStatus)
if(getStorage("wizardactive") === 'true')
requestPriorityClear();
setStorage("wizardactive", false);
});
function resetWizard()
{
$("#wizard_modal").modal('hide');
clearInterval(colorIntveralId);
requestPriorityClear();
setStorage("wizardactive", false);
$('#wizp1').toggle(true);
$('#wizp2').toggle(false);
}
//rgb byte order wizard
var colorIntveralId;
var new_rgb_order;
@@ -29,15 +38,33 @@ $(document).ready( function() {
function startWizardRGB()
{
//create html
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>'+$.i18n('wiz_rgb_title'));
$('#wizp1_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!" style="margin-bottom:20px"><h4 style="font-weight:bold;text-transform:uppercase;">'+$.i18n('wiz_rgb_title')+'</h4><p>'+$.i18n('wiz_rgb_intro1')+'</p><p style="font-weight:bold;">'+$.i18n('wiz_rgb_intro2')+'</p>');
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont"><i class="fa fa-fw fa-check"></i>'+$.i18n('general_btn_continue')+'</button><button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>');
$('#wizp2_body').html('<img src="img/hyperion/hyperionlogo.png" alt="Redefine ambient light!" style="margin-bottom:20px"><p style="font-weight:bold">'+$.i18n('wiz_rgb_expl')+'</p>');
$('#wizp2_body').append('<div class="form-group"><label>'+$.i18n('wiz_rgb_switchevery')+'</label><div class="input-group" style="width:100px"><select id="wiz_switchtime_select" class="form-control"></select><div class="input-group-addon">'+$.i18n('edt_append_s')+'</div></div></div>');
$('#wizp2_body').append('<canvas id="wiz_canv_color" width="100" height="100" style="border-radius:60px;background-color:red; display:block; margin: 10px 0;border:4px solid grey;"></canvas><label>'+$.i18n('wiz_rgb_q')+'</label>');
$('#wizp2_body').append('<table class="table borderless" style="width:200px"><tbody><tr><td class="ltd"><label>'+$.i18n('wiz_rgb_qrend')+'</label></td><td class="itd"><select id="wiz_r_select" class="form-control wselect"></select></td></tr><tr><td class="ltd"><label>'+$.i18n('wiz_rgb_qgend')+'</label></td><td class="itd"><select id="wiz_g_select" class="form-control wselect"></select></td></tr></tbody></table>');
$('#wizp2_footer').html('<button type="button" class="btn btn-success" id="btn_wiz_save"><i class="fa fa-fw fa-save"></i>'+$.i18n('general_btn_saverestart')+'</button><button type="button" class="btn btn-primary" id="btn_wiz_checkok" style="display:none" data-dismiss="modal"><i class="fa fa-fw fa-check"></i>'+$.i18n('general_btn_ok')+'</button><button type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>'+$.i18n('general_btn_cancel')+'</button>')
//open modal
$("#wizard_modal").modal({
backdrop : "static",
keyboard: false,
show: true
});
//listen for continue
$('#btn_wiz_cont').off().on('click',function() {
beginWizardRGB();
$('#wizp1').toggle(false);
$('#wizp2').toggle(true);
});
}
function beginWizardRGB()
{
{
$("#wiz_switchtime_select").off().on('change',function() {
clearInterval(colorIntveralId);
var time = $("#wiz_switchtime_select").val();
@@ -70,10 +97,8 @@ $(document).ready( function() {
rgb_order[1] = greenS;
rgb_order[2] = blueS;
rgb_order = rgb_order.toString().replace(/,/g,"");
var old_rgb_order = parsedConfJSON.device.colorOrder;
if(old_rgb_order == rgb_order)
if(redS == "r" && greenS == "g")
{
$('#btn_wiz_save').toggle(false);
$('#btn_wiz_checkok').toggle(true);
@@ -89,54 +114,37 @@ $(document).ready( function() {
$('#btn_wiz_save').attr('disabled',true);
});
$("#wiz_switchtime_select").html('');
$("#wiz_switchtime_select").append(createSelOpt('5','5'),createSelOpt('10','10'),createSelOpt('15','15'),createSelOpt('30','30'));
$("#wiz_switchtime_select").trigger('change');
$("#wiz_r_select").html('');
$("#wiz_r_select").append(createSelOpt("null", ""),createSelOpt('r', $.i18n('general_col_red')),createSelOpt('g', $.i18n('general_col_green')),createSelOpt('b', $.i18n('general_col_blue')));
$("#wiz_g_select").html($("#wiz_r_select").html());
$("#wiz_r_select").trigger('change');
requestSetColor('255','0','0');
localStorage.wizardactive = true;
}
setTimeout(requestSetSource, 100, 'auto');
setStorage("wizardactive", true);
$('#btn_wiz_abort').off().on('click',function() {
resetWizard()
});
$('#btn_wiz_checkok').off().on('click',function() {
showInfoDialog('success', "", $.i18n('infoDialog_wizrgb_text'));
resetWizard();
});
$('#btn_wiz_save').off().on('click',function() {
resetWizard();
var devConf = parsedConfJSON.device;
devConf.colorOrder = new_rgb_order;
requestWriteConfig(devConf);
setTimeout(initRestart, 100);
});
}
$('#btn_wizard_byteorder').off().on('click',function() {
startWizardRGB();
});
$('#btn_wiz_cont').off().on('click',function() {
beginWizardRGB();
$('#wizp1').toggle(false);
$('#wizp2').toggle(true);
});
$('#btn_wiz_abort').off().on('click',function() {
$("#wizard_modal").modal('hide');
$("#wiz_canv_color").css('background-color','rgb(255, 0, 0)');
clearInterval(colorIntveralId);
requestPriorityClear();
localStorage.wizardactive = false;
$('#wizp1').toggle(true);
$('#wizp2').toggle(false);
$('#btn_wiz_save').toggle(true);
$('#btn_wiz_checkok').toggle(false);
});
$('#btn_wiz_cancel').off().on('click',function() {
$("#wizard_modal").modal('hide');
});
$('#btn_wiz_checkok').off().on('click',function() {
showInfoDialog('success', $.i18n('infoDialog_wizrgb_title'), $.i18n('infoDialog_wizrgb_text'));
});
$('#btn_wiz_save').off().on('click',function() {
var devConf = parsedConfJSON.device;
devConf.colorOrder = new_rgb_order;
requestWriteConfig(devConf);
initRestart();
startWizardRGB();
});
});