From 046f790d23651c5afd7e9568b1fe4e0e53d3b1ff Mon Sep 17 00:00:00 2001 From: Mirjan Hoffmann Date: Thu, 23 Nov 2023 06:50:43 +0100 Subject: [PATCH] added json output Ref https://gitlab.com/oersi/metadata-form/-/issues/6 --- metadata-generator.html | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/metadata-generator.html b/metadata-generator.html index 7f57b8d..9a331a3 100644 --- a/metadata-generator.html +++ b/metadata-generator.html @@ -248,13 +248,28 @@ - -
- - + +
+
+ +
+
+ + +
+
+ + +
+
@@ -664,11 +679,11 @@ return creators; } - function copy_generated_output() { + function copy_generated_output(text_element_id) { if (!navigator.clipboard) { return; } - navigator.clipboard.writeText(document.getElementById("comment").value).then(function() { + navigator.clipboard.writeText(document.getElementById(text_element_id).value).then(function() { $("#copied_to_clipboard_toast").toast("show"); }, function(err) { console.error('Async: Could not copy text: ', err); @@ -720,9 +735,11 @@ + ('0' + datePublished.getDate()).slice(-2); meta.datePublished = dateString; } - document.getElementById("comment").value = jsyaml.dump(meta); + document.getElementById("yaml_output").value = jsyaml.dump(meta); + document.getElementById("json_output").value = JSON.stringify(meta, null, 2); if (navigator.clipboard) { - document.getElementById("button_copy_generated_output").disabled = false + document.getElementById("button_copy_generated_output_yaml").disabled = false + document.getElementById("button_copy_generated_output_json").disabled = false } }