mirror of
https://gitlab.com/comenius-institut/foerbico/metadata-form.git
synced 2025-12-07 23:34:31 +00:00
added json output
Ref https://gitlab.com/oersi/metadata-form/-/issues/6
This commit is contained in:
parent
7454bb9431
commit
046f790d23
1 changed files with 27 additions and 10 deletions
|
|
@ -248,13 +248,28 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" onclick="generate()" class="btn btn-primary"><i class="fa fa-arrow-down"></i> <span data-i18n="LABEL_GENERATE">Generieren</span>
|
||||
</button>
|
||||
<button type="button" disabled onclick="copy_generated_output()" class="btn btn-primary" id="button_copy_generated_output"><i class="fa fa-copy"></i> <span data-i18n="LABEL_COPY">Kopieren</span>
|
||||
</button>
|
||||
<div class="form-group">
|
||||
<label for="comment" data-i18n="LABEL_YAML_METADATA">YAML Metadaten</label>
|
||||
<textarea class="form-control" rows="15" id="comment"></textarea>
|
||||
<button type="button" onclick="generate()" class="btn btn-primary"><i class="fa fa-arrow-down"></i> <span data-i18n="LABEL_GENERATE">Generieren</span></button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<ul class="nav nav-tabs" id="outputTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="yaml-tab" data-toggle="tab" data-target="#yaml" type="button" role="tab" aria-controls="yaml" aria-selected="true">YAML</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="json-tab" data-toggle="tab" data-target="#json" type="button" role="tab" aria-controls="json" aria-selected="false">JSON</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="outputTabContent">
|
||||
<div class="tab-pane fade show active" id="yaml" role="tabpanel" aria-labelledby="yaml-tab">
|
||||
<button type="button" disabled onclick="copy_generated_output('yaml_output')" class="btn btn-primary my-2" id="button_copy_generated_output_yaml"><i class="fa fa-copy"></i> YAML <span data-i18n="LABEL_COPY">Kopieren</span></button>
|
||||
<textarea class="form-control" rows="15" id="yaml_output"></textarea>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="json" role="tabpanel" aria-labelledby="json-tab">
|
||||
<button type="button" disabled onclick="copy_generated_output('json_output')" class="btn btn-primary my-2" id="button_copy_generated_output_json"><i class="fa fa-copy"></i> JSON <span data-i18n="LABEL_COPY">Kopieren</span></button>
|
||||
<textarea class="form-control" rows="15" id="json_output"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue