This commit is contained in:
Michael Wain 2024-03-13 18:26:12 +03:00
parent 68be0c79ac
commit 3bebf92599
2 changed files with 15 additions and 17 deletions

View File

@ -105,7 +105,7 @@ public class DatabaseController {
} }
private void saveAction(Map<String, String> params) { private void saveAction(Map<String, String> params) {
String scriptBody = new CrockfordBase32().decodeToString(params.get("action_body_text")); String scriptBody = params.get("action_body_text");
String name_text = new String(HashUtils.decodeHexString(params.get("action_name_text"))); String name_text = new String(HashUtils.decodeHexString(params.get("action_name_text")));
TextDataVal t1 = textDataValService.save(new TextDataVal(name_text)); TextDataVal t1 = textDataValService.save(new TextDataVal(name_text));

View File

@ -9,25 +9,21 @@ function str_toHex(s) {
} }
function grab_form() { function grab_form() {
let arr = []; let arr = {};
$("form#entryForm :input").each(function() { $("form#entryForm :input").each(function() {
var input = $(this); var input = $(this);
let query = "";
if(input.attr("type") == "checkbox") { if(input.attr("type") == "checkbox") {
query = input.attr('id') + "=" + input.is(':checked'); arr[input.attr('id')] = "" + input.is(':checked');
} else if(input.attr("type") == "text") { } else if(input.attr("type") == "text") {
var vv = str_toHex(input.val()); arr[input.attr('id')] = str_toHex(input.val());
query = input.attr('id') + "=" + vv;
} else if(input.attr("id") == "action_body_text") { } else if(input.attr("id") == "action_body_text") {
var vv = base32.encode(input.val()); arr[input.attr('id')] = input.val();
query = input.attr('id') + "=" + vv;
} else { } else {
query = input.attr('id') + "=" + input.val(); arr[input.attr('id')] = input.val();
} }
arr.push(query);
}); });
arr.push("section=" + new URL(window.location.href).searchParams.get("section")); arr["section"] = new URL(window.location.href).searchParams.get("section") + "";
return arr.join("&"); return arr;
} }
function add_entry_modal() { function add_entry_modal() {
@ -148,9 +144,7 @@ function show_modal_edit(jobj, oid) {
function edit_submit_entry(obj) { function edit_submit_entry(obj) {
$.post("/api/remove_entry", "section="+new URL(window.location.href).searchParams.get("section")+"&entry_id="+($(obj).attr("data-entry-id")), function(data, status) { $.post("/api/remove_entry", "section="+new URL(window.location.href).searchParams.get("section")+"&entry_id="+($(obj).attr("data-entry-id")), function(data, status) {
$.post("/api/add_entry", grab_form(), function(data, status) { add_entry();
window.location.reload();
});
}); });
} }
@ -174,7 +168,11 @@ function remove_entry(obj) {
} }
function add_entry() { function add_entry() {
$.post("/api/add_entry", grab_form(), function(data, status) { $.ajax({
url: "/api/add_entry",
type: "POST",
data: grab_form()
}).done(function() {
window.location.reload(); window.location.reload();
}); });
} }