New editor test
This commit is contained in:
parent
73125f70ce
commit
215ffd7fc6
92
test.php
92
test.php
@ -33,11 +33,65 @@
|
|||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function foo(element){
|
function foo(element){
|
||||||
|
var id = element.attr("name").match(/\d+/)[0]
|
||||||
|
$("[name='variable["+id+"][value]']").remove();
|
||||||
|
$("[name='variable["+id+"][equaler]']").remove();
|
||||||
|
|
||||||
if (element.val() == "atDeviceValue") {
|
if (element.val() == "atDeviceValue") {
|
||||||
var input = $("<input name=''/>");
|
var arrVarOperator = [
|
||||||
|
{val : '>', text: '>'},
|
||||||
|
{val : '<', text: '<'},
|
||||||
|
];
|
||||||
|
|
||||||
|
var varOperator = $('<select name="variable['+id+'][equaler]">');
|
||||||
|
$(arrVarOperator).each(function() {
|
||||||
|
varOperator.append($('<option>').attr('value',this.val).text(this.text));
|
||||||
|
});
|
||||||
|
element.parent().append(varOperator);
|
||||||
|
|
||||||
|
|
||||||
|
var input = $("<input/>");
|
||||||
input.attr("type","text");
|
input.attr("type","text");
|
||||||
input.attr("name",element.attr("name"));
|
input.attr("name","variable["+id+"][value]");
|
||||||
element.parent().append(input);
|
element.parent().append(input);
|
||||||
|
} else if (element.val() == "time") {
|
||||||
|
var arrVarOperator = [
|
||||||
|
{val : '>', text: '>'},
|
||||||
|
{val : '<', text: '<'},
|
||||||
|
];
|
||||||
|
|
||||||
|
var varOperator = $('<select name="variable['+id+'][equaler]">');
|
||||||
|
$(arrVarOperator).each(function() {
|
||||||
|
varOperator.append($('<option>').attr('value',this.val).text(this.text));
|
||||||
|
});
|
||||||
|
element.parent().append(varOperator);
|
||||||
|
|
||||||
|
var input = $("<input/>");
|
||||||
|
input.attr("type","time");
|
||||||
|
input.attr("name","variable["+id+"][value]");
|
||||||
|
element.parent().append(input);
|
||||||
|
}else {
|
||||||
|
var arrVarOperator = [
|
||||||
|
{val : '=', text: '=='},
|
||||||
|
{val : '!=', text: '!='},
|
||||||
|
];
|
||||||
|
|
||||||
|
var varOperator = $('<select name="variable['+id+'][equaler]">');
|
||||||
|
$(arrVarOperator).each(function() {
|
||||||
|
varOperator.append($('<option>').attr('value',this.val).text(this.text));
|
||||||
|
});
|
||||||
|
element.parent().append(varOperator);
|
||||||
|
|
||||||
|
var arrVarValue = [
|
||||||
|
{val : 'true', text: 'True'},
|
||||||
|
{val : 'false', text: 'False'},
|
||||||
|
];
|
||||||
|
|
||||||
|
var varValue = $('<select name="variable['+id+'][value]">');
|
||||||
|
$(arrVarValue).each(function() {
|
||||||
|
varValue.append($('<option>').attr('value',this.val).text(this.text));
|
||||||
|
});
|
||||||
|
element.parent().append(varValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#addButton,#restartAddButton").click( function (event) {
|
$("#addButton,#restartAddButton").click( function (event) {
|
||||||
@ -55,7 +109,7 @@ $("#addButton,#restartAddButton").click( function (event) {
|
|||||||
{val : 'someOneHome', text: 'Nekdo Doma'},
|
{val : 'someOneHome', text: 'Nekdo Doma'},
|
||||||
];
|
];
|
||||||
|
|
||||||
var varSelect = $('<select name="variable['+numItems+'][]">');
|
var varSelect = $('<select name="variable['+numItems+'][what]">');
|
||||||
$(arrVarSelect).each(function() {
|
$(arrVarSelect).each(function() {
|
||||||
varSelect.append($('<option>').attr('value',this.val).text(this.text));
|
varSelect.append($('<option>').attr('value',this.val).text(this.text));
|
||||||
});
|
});
|
||||||
@ -65,35 +119,35 @@ $("#addButton,#restartAddButton").click( function (event) {
|
|||||||
console.log(this.value);
|
console.log(this.value);
|
||||||
if (this.value == 'atDeviceValue') {
|
if (this.value == 'atDeviceValue') {
|
||||||
alert("ok");
|
alert("ok");
|
||||||
}
|
}
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
var arrVarOperator = [
|
var arrVarOperator = [
|
||||||
{val : '>', text: '>'},
|
{val : '>', text: '>'},
|
||||||
{val : '<', text: '<'},
|
{val : '<', text: '<'},
|
||||||
{val : '=', text: '=='},
|
{val : '=', text: '=='},
|
||||||
{val : '!=', text: '!='},
|
{val : '!=', text: '!='},
|
||||||
];
|
];
|
||||||
|
|
||||||
var varOperator = $('<select name="variable['+numItems+'][]">');
|
var varOperator = $('<select name="variable['+numItems+'][equaler]">');
|
||||||
$(arrVarOperator).each(function() {
|
$(arrVarOperator).each(function() {
|
||||||
varOperator.append($('<option>').attr('value',this.val).text(this.text));
|
varOperator.append($('<option>').attr('value',this.val).text(this.text));
|
||||||
});
|
});
|
||||||
|
|
||||||
var arrVarValue = [
|
var arrVarValue = [
|
||||||
{val : 'true', text: 'True'},
|
{val : 'true', text: 'True'},
|
||||||
{val : 'false', text: 'False'},
|
{val : 'false', text: 'False'},
|
||||||
];
|
];
|
||||||
|
|
||||||
var varValue = $('<select name="variable['+numItems+'][]">');
|
var varValue = $('<select name="variable['+numItems+'][value]">');
|
||||||
$(arrVarValue).each(function() {
|
$(arrVarValue).each(function() {
|
||||||
varValue.append($('<option>').attr('value',this.val).text(this.text));
|
varValue.append($('<option>').attr('value',this.val).text(this.text));
|
||||||
});
|
});
|
||||||
|
|
||||||
var newDiv = $("<div class=var>").append(varSelect);
|
var newDiv = $("<div class=var>").append(varSelect);
|
||||||
newDiv = newDiv.append(varOperator);
|
newDiv = newDiv.append(varOperator);
|
||||||
newDiv = newDiv.append(varValue);
|
newDiv = newDiv.append(varValue);
|
||||||
$(this).parent().append(newDiv);
|
$(this).parent().append(newDiv);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user