Merge pull request #212 from b1rdhous3/editor

New Json Editor
This commit is contained in:
redPanther 2016-08-31 18:03:53 +02:00 committed by GitHub
commit ee26abc6c4
7 changed files with 916 additions and 59 deletions

View File

@ -8,6 +8,9 @@
<hr>
<div class="col-lg-12">
<form id="generalConfForm"></form>
<div id='editor_holder'></div>
<button id='submit'>Submit (console.log)</button>
</div>
</div>
</div>
@ -38,31 +41,34 @@
udpListener = JSON.parse(response.data).result.properties.udpListener;
webConfig = JSON.parse(response.data).result.properties.webConfig;
$('form').jsonForm({
var element = document.getElementById('editor_holder');
//JSONEditor.defaults.options.theme = 'bootstrap3';
var editor = new JSONEditor(element,{
theme: 'bootstrap3',
disable_collapse: 'true',
form_name_root: 'sa',
disable_edit_json: 'true',
disable_properties: 'true',
no_additional_properties: 'true',
schema: {
logger,
jsonServer,
protoServer,
boblightServer,
udpListener,
webConfig,
},
onSubmit: function (errors, values) {
if (errors) {
console.log(errors);
}
else {
console.log(values);
title:' ',
properties: {
logger,
jsonServer,
protoServer,
boblightServer,
udpListener,
webConfig
}
}
});
document.getElementById('submit').addEventListener('click',function() {
// Get the value from the editor
console.log(editor.getValue());
});
enableFormTranslation("generalConfForm", "generalConfForm");
$("[type='checkbox']").bootstrapSwitch();

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
@ -25,8 +25,9 @@
<link href="css/bootstrap-switch.min.css" rel="stylesheet">
<!-- JSONForm -->
<script src="js/lib/underscore.js"></script>
<script src="js/lib/jsonform.js"></script>
<!--<script src="js/lib/underscore.js"></script>
<script src="js/lib/jsonform.js"></script>-->
<script src="js/lib/jsoneditor.min.js"></script>
<!--Language Support -->
<script src="js/lib/jquery-lang.js" charset="utf-8" type="text/javascript"></script>
@ -35,19 +36,14 @@
<script type="text/javascript">
// Create language switcher instance
var lang = new Lang();
lang.dynamic('de', 'lang/de.json');
lang.init({
defaultLang: 'en',
cookie: {
name: 'langCookie',
expiry: 365,
path: '/'
},
allowCookieOverride: true
});
</script>
@ -490,12 +486,10 @@
<!-- Custom Theme JavaScript -->
<script src="js/lib/sb-admin-2.js"></script>
<script>
$(document).ready( function() {
$("#load_lighttest").on("click", function() {
$("#page-wrapper").load("lighttest.html");
});
$("#load_effects").on("click", function() {
$("#page-wrapper").load("effects.html");
});
@ -503,36 +497,28 @@
$("#load_components").on("click", function() {
$("#page-wrapper").load("remote_components.html");
});
$("#load_huebridge").on("click", function() {
$("#page-wrapper").load("huebridge.html");
});
$("#load_support").on("click", function() {
$("#page-wrapper").load("support.html");
});
$("#load_confKodi").on("click", function() {
$("#page-wrapper").load("kodiconf.html");
});
$("#load_update").on("click", function() {
$("#page-wrapper").load("update.html");
});
$("#load_confGeneral").on("click", function() {
$("#page-wrapper").load("generalconf.html");
});
//Change all Checkboxes to Switches
$("[type='checkbox']").bootstrapSwitch();
loaddata();
loaddata();
});
$(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');

View File

@ -10,9 +10,9 @@
* Default language in "lang" attribute will always be "en"
* @param {String} tokenPrefix
* @param {String} formID
*/
function enableFormTranslation(tokenPrefix, formID) {
var $inputs = $("#" + formID + " :input");
var $inputs = $("#" + formID + " label");
$inputs.each(function() {
console.log("InputID: " + $(this).attr('id'));
@ -20,7 +20,7 @@ $inputs.each(function() {
$("label[for='" + $(this).attr('id') + "']").html('<span lang="en" data-lang-token="' + tokenPrefix + "_" + $(this).attr('id') + '">' + oldtext + '</span>');
});
}
*/
// global vars
var currentVersion;
var cleanCurrentVersion;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,7 @@
{
"level" :
{
"type" : "string",
"enum" : ["silent", "warn", "verbose", "debug"],
"title" : "Log-Level"
}
@ -747,6 +748,7 @@
"enable" :
{
"type" : "boolean",
"format": "checkbox",
"title" : "Activate"
},
"port" :
@ -774,6 +776,7 @@
"enable" :
{
"type" : "boolean",
"format": "checkbox",
"title" : "Activate"
},
"address" :
@ -802,6 +805,7 @@
"shared" :
{
"type" : "boolean",
"format": "checkbox",
"title" : "Shared"
}
},
@ -817,6 +821,7 @@
"enable" :
{
"type" : "boolean",
"format": "checkbox",
"title" : "Activate",
"required" : true
},
@ -829,7 +834,7 @@
"port" :
{
"type" : "integer",
"description" : "Port",
"title" : "Port",
"required" : true
}
},

View File

@ -108,7 +108,7 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
; // nothing to do. value is present so always oke
else if (attribute == "id")
; // references have already been collected
else if (attribute == "title" || attribute == "description" || attribute == "default")
else if (attribute == "title" || attribute == "description" || attribute == "default" || attribute == "format")
; // nothing to do.
else
{