X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4e9af76312159043dfa1c15a56945e232ccfaed3..0214643f72c6aaa8e85eaba2ad27f2ca03ca6401:/modules/metadataEditor/transformations.js diff --git a/modules/metadataEditor/transformations.js b/modules/metadataEditor/transformations.js new file mode 100644 index 0000000..a6fea3f --- /dev/null +++ b/modules/metadataEditor/transformations.js @@ -0,0 +1,22 @@ +define(['libs/jquery-1.9.1.min'], function($) { + + return { + getMetadata: function(xml) { + var toret = {}; + $(xml).find('metadata').children().each(function() { + var node = $(this); + toret[this.nodeName.split(':')[1].toLowerCase()] = node.text(); + }) + return toret; + }, + getXML: function(metadata) { + var meta = $('\n'); + _.each(_.keys(metadata), function(key) { + meta.append('\n\t' + metadata[key] + ''); + }); + meta.append('\n'); + return vkbeautify.xml(meta.html()); + } + } + +}); \ No newline at end of file