gui compare support
This commit is contained in:
@ -91,8 +91,7 @@ def next(data, state: StrategyState):
|
||||
def is_defensive_mode():
|
||||
akt_pozic = int(state.positions)
|
||||
max_pozic = int(state.vars.maxpozic)
|
||||
def_mode_from = safe_get(state.vars, "def_mode_from")
|
||||
if def_mode_from == None: def_mode_from = max_pozic/2
|
||||
def_mode_from = safe_get(state.vars, "def_mode_from",max_pozic/2)
|
||||
if akt_pozic >= int(def_mode_from):
|
||||
state.ilog(e=f"DEFENSIVE mode ACTIVE {state.vars.def_mode_from=}", msg=state.positions)
|
||||
return True
|
||||
@ -101,8 +100,7 @@ def next(data, state: StrategyState):
|
||||
return False
|
||||
|
||||
def get_limitka_price():
|
||||
def_profit = safe_get(state.vars, "def_profit")
|
||||
if def_profit == None: def_profit = state.vars.profit
|
||||
def_profit = safe_get(state.vars, "def_profit",state.vars.profit)
|
||||
cena = float(state.avgp)
|
||||
if is_defensive_mode():
|
||||
return price2dec(cena+get_tick(cena,float(def_profit)))
|
||||
@ -312,9 +310,8 @@ def next(data, state: StrategyState):
|
||||
#RSI14 INDICATOR
|
||||
try:
|
||||
##mame v atributech nastaveni?
|
||||
rsi_dont_buy_above = safe_get(state.vars, "rsi_dont_buy_above")
|
||||
if rsi_dont_buy_above == None:
|
||||
rsi_dont_buy_above = 50
|
||||
rsi_dont_buy_above = safe_get(state.vars, "rsi_dont_buy_above",50)
|
||||
rsi_buy_signal_conf = safe_get(state.vars, "rsi_buy_signal_below",40)
|
||||
rsi_buy_signal = False
|
||||
rsi_dont_buy = False
|
||||
rsi_length = 14
|
||||
@ -323,7 +320,7 @@ def next(data, state: StrategyState):
|
||||
rsi_value = trunc(rsi_res[-1],3)
|
||||
state.indicators.RSI14.append(rsi_value)
|
||||
rsi_dont_buy = rsi_value > rsi_dont_buy_above
|
||||
rsi_buy_signal = rsi_value < 40
|
||||
rsi_buy_signal = rsi_value < rsi_buy_signal_conf
|
||||
state.ilog(e=f"RSI {rsi_length=} {rsi_value=} {rsi_dont_buy=} {rsi_buy_signal=}", rsi_indicator=state.indicators.RSI14[-5:])
|
||||
except Exception as e:
|
||||
state.ilog(e=f"RSI {rsi_length=} ukladame 0", message=str(e)+format_exc())
|
||||
|
||||
@ -100,8 +100,7 @@ def next(data, state: StrategyState):
|
||||
def is_defensive_mode():
|
||||
akt_pozic = int(state.positions)
|
||||
max_pozic = int(state.vars.maxpozic)
|
||||
def_mode_from = safe_get(state.vars, "def_mode_from")
|
||||
if def_mode_from == None: def_mode_from = max_pozic/2
|
||||
def_mode_from = safe_get(state.vars, "def_mode_from",max_pozic/2)
|
||||
if akt_pozic >= int(def_mode_from):
|
||||
state.ilog(e=f"DEFENSIVE mode ACTIVE {state.vars.def_mode_from=}", msg=state.positions)
|
||||
return True
|
||||
@ -110,8 +109,7 @@ def next(data, state: StrategyState):
|
||||
return False
|
||||
|
||||
def get_limitka_price():
|
||||
def_profit = safe_get(state.vars, "def_profit")
|
||||
if def_profit == None: def_profit = state.vars.profit
|
||||
def_profit = safe_get(state.vars, "def_profit",state.vars.profit)
|
||||
if is_defensive_mode():
|
||||
return price2dec(float(state.avgp)+float(def_profit))
|
||||
else:
|
||||
@ -267,7 +265,7 @@ def next(data, state: StrategyState):
|
||||
##prvni se vyklada na aktualni cenu, další jdou podle krivky, nula v krivce zvyšuje množství pro následující iteraci
|
||||
|
||||
##VAR - na zaklade conf. muzeme jako prvni posilat MARKET order
|
||||
if safe_get(state.vars, "first_buy_market") == True:
|
||||
if safe_get(state.vars, "first_buy_market", False) == True:
|
||||
#pri defenzivnim rezimu pouzivame vzdy LIMIT order
|
||||
if is_defensive_mode():
|
||||
state.ilog(e="DEF mode on, odesilame jako prvni limitku")
|
||||
|
||||
@ -16,13 +16,14 @@
|
||||
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/dataTables.bootstrap5.min.css">
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.5.1.js"></script> -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.js" integrity="sha256-a9jBBRygX1Bh5lt8GZjXDzyOB+bWve9EiO7tROUtj/E=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="https://cdn.datatables.net/select/1.6.2/js/dataTables.select.min.js"></script>
|
||||
|
||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||
@ -30,11 +31,13 @@
|
||||
<link href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css" rel="stylesheet">
|
||||
<script src="/static/js/jquery.dataTables.min.js"></script> -->
|
||||
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.5.1.js"></script> -->
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/static/main.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.4.6/mousetrap.min.js"></script>
|
||||
<!-- <script src="https://cdn.datatables.net/select/1.6.2/js/dataTables.select.min.js"></script> -->
|
||||
<script src="/static/js/fast-toml.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main" class="mainConteiner flex-container content">
|
||||
@ -165,6 +168,7 @@
|
||||
<button id="button_delete_arch" class="btn btn-outline-success btn-sm">Delete</button>
|
||||
<button id="button_show_arch" class="btn btn-outline-success btn-sm">Show</button>
|
||||
<button id="button_refresh" class="refresh btn btn-outline-success btn-sm">Refresh</button>
|
||||
<button id="button_compare_arch" class="refresh btn btn-outline-success btn-sm">Compare</button>
|
||||
<!-- <button id="button_stopall" class="btn btn-outline-success btn-sm">Stop All</button>
|
||||
<button id="button_refresh" class="btn btn-outline-success btn-sm">Refresh</button> -->
|
||||
</div>
|
||||
@ -257,14 +261,17 @@
|
||||
<h4>Strategies</h4>
|
||||
</label>
|
||||
<div id="stratin-table-inner" class="collapse show" style="width:70%">
|
||||
<button id="button_add" class="btn btn-outline-success btn-sm">Add</button>
|
||||
<button id="button_add_json" class="btn btn-outline-success btn-sm">Add JSON</button>
|
||||
<button id="button_edit" class="btn btn-outline-success btn-sm">Edit</button>
|
||||
<button id="button_dup" class="btn btn-outline-success btn-sm">Duplicate</button>
|
||||
<button id="button_copy" class="btn btn-outline-success btn-sm">Copy JSON</button>
|
||||
<button id="button_delete" class="btn btn-outline-success btn-sm">Delete</button>
|
||||
<button id="button_run" class="btn btn-outline-success btn-sm">Run Strategy</button>
|
||||
<button id="button_refresh" class="refresh btn btn-outline-success btn-sm">Refresh</button>
|
||||
<div id="controlsStratin">
|
||||
<button id="button_add" class="btn btn-outline-success btn-sm">Add</button>
|
||||
<button id="button_add_json" class="btn btn-outline-success btn-sm">Add JSON</button>
|
||||
<button id="button_edit" class="btn btn-outline-success btn-sm">Edit</button>
|
||||
<button id="button_dup" class="btn btn-outline-success btn-sm">Duplicate</button>
|
||||
<button id="button_copy" class="btn btn-outline-success btn-sm">Copy JSON</button>
|
||||
<button id="button_delete" class="btn btn-outline-success btn-sm">Delete</button>
|
||||
<button id="button_compare" class="btn btn-outline-success btn-sm">Compare</button>
|
||||
<button id="button_run" class="btn btn-outline-success btn-sm">Run Strategy</button>
|
||||
<button id="button_refresh" class="refresh btn btn-outline-success btn-sm">Refresh</button>
|
||||
</div>
|
||||
<table id="stratinTable" class="table-striped table dataTable" style="width:100%; border-color: #dce1dc;">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -399,6 +406,32 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="diffModal" class="modal fade" style="--bs-modal-width: 900px;">
|
||||
<div class="modal-dialog">
|
||||
<form method="post" id="diffForm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title_dif"><i class="fa fa-plus"></i> Diff</h4>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="diff_content"></div>
|
||||
<div class="form-group" style="float: left;">
|
||||
<label id="diff_first" for="first" class="form-label">First</label>
|
||||
<div id="first" name="first"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label id="diff_second" for="second" class="form-label">Second</label>
|
||||
<div id="second" name="second"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="runModal" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<form method="post" id="runForm">
|
||||
|
||||
@ -11,23 +11,82 @@ $(document).ready(function () {
|
||||
$('#button_show_arch').attr('disabled','disabled');
|
||||
$('#button_delete_arch').attr('disabled','disabled');
|
||||
$('#button_edit_arch').attr('disabled','disabled');
|
||||
$('#button_compare_arch').attr('disabled','disabled');
|
||||
|
||||
//selectable rows in archive table
|
||||
$('#archiveTable tbody').on('click', 'tr', function () {
|
||||
if ($(this).hasClass('selected')) {
|
||||
$(this).removeClass('selected');
|
||||
//$(this).removeClass('selected');
|
||||
$('#button_show_arch').attr('disabled','disabled');
|
||||
$('#button_delete_arch').attr('disabled','disabled');
|
||||
$('#button_edit_arch').attr('disabled','disabled');
|
||||
$('#button_compare_arch').attr('disabled','disabled');
|
||||
} else {
|
||||
stratinRecords.$('tr.selected').removeClass('selected');
|
||||
//archiveRecords.$('tr.selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
$('#button_show_arch').attr('disabled',false);
|
||||
$('#button_delete_arch').attr('disabled',false);
|
||||
$('#button_edit_arch').attr('disabled',false);
|
||||
$('#button_compare_arch').attr('disabled',false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//button compare arch
|
||||
$('#button_compare_arch').click(function () {
|
||||
window.$('#diffModal').modal('show');
|
||||
rows = archiveRecords.rows('.selected').data();
|
||||
var record1 = new Object()
|
||||
//console.log(JSON.stringify(rows))
|
||||
record1 = JSON.parse(rows[0].strat_json)
|
||||
//record1.json = rows[0].json
|
||||
//record1.id = rows[0].id;
|
||||
// record1.id2 = parseInt(rows[0].id2);
|
||||
//record1.name = rows[0].name;
|
||||
// record1.symbol = rows[0].symbol;
|
||||
// record1.class_name = rows[0].class_name;
|
||||
// record1.script = rows[0].script;
|
||||
// record1.open_rush = rows[0].open_rush;
|
||||
// record1.close_rush = rows[0].close_rush;
|
||||
record1.stratvars_conf = TOML.parse(record1.stratvars_conf);
|
||||
record1.add_data_conf = TOML.parse(record1.add_data_conf);
|
||||
// record1.note = rows[0].note;
|
||||
// record1.history = "";
|
||||
//jsonString1 = JSON.stringify(record1, null, 2);
|
||||
|
||||
var record2 = new Object()
|
||||
record2 = JSON.parse(rows[1].strat_json)
|
||||
|
||||
// record2.id = rows[1].id;
|
||||
// record2.id2 = parseInt(rows[1].id2);
|
||||
//record2.name = rows[1].name;
|
||||
// record2.symbol = rows[1].symbol;
|
||||
// record2.class_name = rows[1].class_name;
|
||||
// record2.script = rows[1].script;
|
||||
// record2.open_rush = rows[1].open_rush;
|
||||
// record2.close_rush = rows[1].close_rush;
|
||||
record2.stratvars_conf = TOML.parse(record2.stratvars_conf);
|
||||
record2.add_data_conf = TOML.parse(record2.add_data_conf);
|
||||
// record2.note = rows[1].note;
|
||||
// record2.history = "";
|
||||
//jsonString2 = JSON.stringify(record2, null, 2);
|
||||
|
||||
|
||||
document.getElementById('first').innerHTML = '<pre>'+JSON.stringify(record1, null, 2)+'</pre>'
|
||||
$('#diff_first').text(record1.name);
|
||||
$('#diff_second').text(record2.name);
|
||||
|
||||
//mozna parse?
|
||||
|
||||
var delta = compareObjects(record1, record2)
|
||||
const htmlMarkup1 = `<pre>{\n${generateHTML(record2, delta)}}\n</pre>`;
|
||||
document.getElementById('second').innerHTML = htmlMarkup1;
|
||||
|
||||
event.preventDefault();
|
||||
//$('#button_compare').attr('disabled','disabled');
|
||||
});
|
||||
|
||||
|
||||
//delete button
|
||||
$('#button_delete_arch').click(function () {
|
||||
row = archiveRecords.row('.selected').data();
|
||||
@ -263,6 +322,10 @@ var archiveRecords =
|
||||
}
|
||||
],
|
||||
order: [[6, 'desc']],
|
||||
select: {
|
||||
style: 'multi',
|
||||
selector: 'td'
|
||||
},
|
||||
// paging: true,
|
||||
// lengthChange: false,
|
||||
// select: true,
|
||||
|
||||
1
v2realbot/static/js/fast-toml.js
Normal file
1
v2realbot/static/js/fast-toml.js
Normal file
File diff suppressed because one or more lines are too long
@ -64,14 +64,14 @@ $(document).ready(function () {
|
||||
//selectable rows in stratin table
|
||||
$('#stratinTable tbody').on('click', 'tr', function () {
|
||||
if ($(this).hasClass('selected')) {
|
||||
$(this).removeClass('selected');
|
||||
//$(this).removeClass('selected');
|
||||
$('#button_dup').attr('disabled','disabled');
|
||||
$('#button_copy').attr('disabled','disabled');
|
||||
$('#button_edit').attr('disabled','disabled');
|
||||
$('#button_delete').attr('disabled','disabled');
|
||||
$('#button_run').attr('disabled','disabled');
|
||||
} else {
|
||||
stratinRecords.$('tr.selected').removeClass('selected');
|
||||
//stratinRecords.$('tr.selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
$('#button_dup').attr('disabled',false);
|
||||
$('#button_copy').attr('disabled',false);
|
||||
@ -277,6 +277,53 @@ $(document).ready(function () {
|
||||
})
|
||||
});
|
||||
|
||||
//button compare stratin
|
||||
$('#button_compare').click(function () {
|
||||
window.$('#diffModal').modal('show');
|
||||
rows = stratinRecords.rows('.selected').data();
|
||||
const rec1 = new Object()
|
||||
rec1.id = rows[0].id;
|
||||
rec1.id2 = parseInt(rows[0].id2);
|
||||
rec1.name = rows[0].name;
|
||||
rec1.symbol = rows[0].symbol;
|
||||
rec1.class_name = rows[0].class_name;
|
||||
rec1.script = rows[0].script;
|
||||
rec1.open_rush = rows[0].open_rush;
|
||||
rec1.close_rush = rows[0].close_rush;
|
||||
rec1.stratvars_conf = TOML.parse(rows[0].stratvars_conf);
|
||||
rec1.add_data_conf = TOML.parse(rows[0].add_data_conf);
|
||||
rec1.note = rows[0].note;
|
||||
rec1.history = "";
|
||||
//jsonString1 = JSON.stringify(rec1, null, 2);
|
||||
|
||||
const rec2 = new Object()
|
||||
rec2.id = rows[1].id;
|
||||
rec2.id2 = parseInt(rows[1].id2);
|
||||
rec2.name = rows[1].name;
|
||||
rec2.symbol = rows[1].symbol;
|
||||
rec2.class_name = rows[1].class_name;
|
||||
rec2.script = rows[1].script;
|
||||
rec2.open_rush = rows[1].open_rush;
|
||||
rec2.close_rush = rows[1].close_rush;
|
||||
rec2.stratvars_conf = TOML.parse(rows[1].stratvars_conf);
|
||||
rec2.add_data_conf = TOML.parse(rows[1].add_data_conf);
|
||||
rec2.note = rows[1].note;
|
||||
rec2.history = "";
|
||||
//jsonString2 = JSON.stringify(rec2, null, 2);
|
||||
|
||||
|
||||
document.getElementById('first').innerHTML = '<pre>'+JSON.stringify(rec1, null, 2)+'</pre>'
|
||||
$('#diff_first').text(rec1.name);
|
||||
$('#diff_second').text(rec2.name);
|
||||
|
||||
var delta = compareObjects(rec1, rec2)
|
||||
const htmlMarkup = `<pre>{\n${generateHTML(rec2, delta)}}\n</pre>`;
|
||||
document.getElementById('second').innerHTML = htmlMarkup;
|
||||
|
||||
event.preventDefault();
|
||||
//$('#button_compare').attr('disabled','disabled');
|
||||
});
|
||||
|
||||
//button connect
|
||||
$('#button_connect').click(function () {
|
||||
row = runnerRecords.row('.selected').data();
|
||||
@ -436,6 +483,8 @@ var stratinRecords =
|
||||
{data: 'history', visible: false},
|
||||
{data: 'id', visible: true},
|
||||
],
|
||||
paging: false,
|
||||
processing: false,
|
||||
columnDefs: [{
|
||||
targets: 12,
|
||||
render: function ( data, type, row ) {
|
||||
@ -451,11 +500,10 @@ var stratinRecords =
|
||||
},
|
||||
],
|
||||
order: [[1, 'asc']],
|
||||
paging: false,
|
||||
// select: {
|
||||
// style: 'multi'
|
||||
// },
|
||||
processing: false
|
||||
select: {
|
||||
style: 'multi',
|
||||
selector: 'td'
|
||||
},
|
||||
// createdRow: function( row, data, dataIndex){
|
||||
// if (is_running(data.id) ){
|
||||
// alert("runner");
|
||||
|
||||
@ -370,4 +370,137 @@ Mousetrap.bind('j', function() {
|
||||
});
|
||||
Mousetrap.bind('x', function() {
|
||||
$( "#button_delete" ).trigger( "click" );
|
||||
});
|
||||
});
|
||||
|
||||
// function compareObjects(obj1, obj2) {
|
||||
// const diff = {};
|
||||
|
||||
// for (let key in obj1) {
|
||||
// if (typeof obj1[key] === 'object' && typeof obj2[key] === 'object') {
|
||||
// const nestedDiff = compareObjects(obj1[key], obj2[key]);
|
||||
// if (Object.keys(nestedDiff).length > 0) {
|
||||
// diff[key] = nestedDiff;
|
||||
// }
|
||||
// } else if (obj1[key] !== obj2[key]) {
|
||||
// diff[key] = obj2[key];
|
||||
// }
|
||||
// }
|
||||
|
||||
// return diff;
|
||||
// }
|
||||
|
||||
// function generateHTML(obj, diff, indent = '') {
|
||||
// let html = '';
|
||||
|
||||
// for (let key in obj) {
|
||||
// const value = obj[key];
|
||||
|
||||
// if (typeof value === 'object' && value !== null) {
|
||||
// const nestedDiff = diff[key] || {};
|
||||
// const nestedIndent = indent + ' ';
|
||||
// html += `${indent}"${key}": {\n${generateHTML(value, nestedDiff, nestedIndent)}${indent}},\n`;
|
||||
// } else {
|
||||
// if (key in diff) {
|
||||
// html += `${indent}"${key}": <span class="highlighted">${JSON.stringify(value)}</span>,\n`;
|
||||
// } else {
|
||||
// html += `${indent}"${key}": ${JSON.stringify(value)},\n`;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return html;
|
||||
// }
|
||||
|
||||
|
||||
function compareObjects(obj1, obj2) {
|
||||
const diff = {};
|
||||
|
||||
for (let key in obj1) {
|
||||
if (typeof obj1[key] === 'object' && typeof obj2[key] === 'object') {
|
||||
if (Array.isArray(obj1[key]) && Array.isArray(obj2[key])) {
|
||||
if (!arraysAreEqual(obj1[key], obj2[key])) {
|
||||
diff[key] = obj2[key];
|
||||
}
|
||||
} else {
|
||||
const nestedDiff = compareObjects(obj1[key], obj2[key]);
|
||||
if (Object.keys(nestedDiff).length > 0) {
|
||||
diff[key] = nestedDiff;
|
||||
}
|
||||
}
|
||||
} else if (obj1[key] !== obj2[key]) {
|
||||
diff[key] = obj2[key];
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
function arraysAreEqual(arr1, arr2) {
|
||||
if (arr1.length !== arr2.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < arr1.length; i++) {
|
||||
if (typeof arr1[i] === 'object' && typeof arr2[i] === 'object') {
|
||||
const nestedDiff = compareObjects(arr1[i], arr2[i]);
|
||||
if (Object.keys(nestedDiff).length > 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (arr1[i] !== arr2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function generateHTML(obj, diff, indent = '') {
|
||||
let html = '';
|
||||
|
||||
for (let key in obj) {
|
||||
const value = obj[key];
|
||||
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
const nestedDiff = diff[key] || {};
|
||||
const nestedIndent = indent + ' ';
|
||||
if (Array.isArray(value)) {
|
||||
html += `${indent}"${key}": [\n${generateHTMLArray(value, nestedDiff, nestedIndent)}${indent}],\n`;
|
||||
} else {
|
||||
html += `${indent}"${key}": {\n${generateHTML(value, nestedDiff, nestedIndent)}${indent}},\n`;
|
||||
}
|
||||
} else {
|
||||
if (key in diff) {
|
||||
html += `${indent}"${key}": <span style="background-color: yellow;">${JSON.stringify(value)}</span>,\n`;
|
||||
} else {
|
||||
html += `${indent}"${key}": ${JSON.stringify(value)},\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function generateHTMLArray(arr, diff, indent) {
|
||||
let html = '';
|
||||
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const value = arr[i];
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
const nestedDiff = diff[i] || {};
|
||||
const nestedIndent = indent + ' ';
|
||||
if (Array.isArray(value)) {
|
||||
html += `${indent}[\n${generateHTMLArray(value, nestedDiff, nestedIndent)}${indent}],\n`;
|
||||
} else {
|
||||
html += `${indent}{\n${generateHTML(value, nestedDiff, nestedIndent)}${indent}},\n`;
|
||||
}
|
||||
} else {
|
||||
if (i in diff) {
|
||||
html += `${indent}<span style="background-color: yellow;">${JSON.stringify(value)}</span>,\n`;
|
||||
} else {
|
||||
html += `${indent}${JSON.stringify(value)},\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
@ -122,6 +122,10 @@ table.dataTable thead>tr>th.sorting_asc:before, table.dataTable thead>tr>th.sort
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: table-cell;
|
||||
}
|
||||
|
||||
.secondary-bg {
|
||||
--bs-bg-opacity: 1;
|
||||
background-color: #414749;
|
||||
@ -285,6 +289,8 @@ pre {
|
||||
/* background-color: #f5f5f5; */
|
||||
/* border: 1px solid #ccc; */
|
||||
border-radius: 4px;
|
||||
overflow-x: clip;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.pidi {
|
||||
@ -315,6 +321,8 @@ pre {
|
||||
|
||||
.highlighted {
|
||||
color: var(--bs-emphasis-color);
|
||||
background-color: var(--bs-gray-900);
|
||||
/* color: var(--bs-dark-text-emphasis); */
|
||||
}
|
||||
|
||||
.switcher {
|
||||
|
||||
Reference in New Issue
Block a user