smartxml: allow objects set with setData to clone themselves on node cloning
[fnpeditor.git] / src / editor / modules / metadataEditor / transformations.js
1 define(['libs/jquery', 'libs/underscore'], 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             /* globals vkbeautify */
21             return vkbeautify.xml(meta.html());
22         }
23     };
24
25 });