Fix: publishing the right element as current text element on selecting node element
[fnpeditor.git] / modules / metadataEditor / transformations.js
1 define(['libs/jquery-1.9.1.min'], function($) {
2
3     'use strict';
4
5     return {
6         getMetadata: function(xml) {
7             var toret = {};
8             $(xml).find('metadata').children().each(function() {
9                 var node = $(this);
10                 toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();
11             });
12             return toret;
13         },
14         getXML: function(metadata) {
15             var meta = $('<metadata></metadata>\n');
16             _.each(_.keys(metadata), function(key) {
17                 meta.append('\n\t<dc:'+key+'>' + metadata[key] + '</dc:'+key+'>');
18             });
19             meta.append('\n');
20             return vkbeautify.xml(meta.html());
21         }
22     };
23
24 });