+ var insertNode = function(insertion) {
+ var doc = canvas.wlxmlDocument,
+ node, metadata, creator, currentDate, dt;
+
+ var pad = function(number) {
+ if(number < 10) {
+ number = '0' + number;
+ }
+ return number;
+ };
+
+ doc.startTransaction();
+ node = insertion();
+ if(node.getTagName() === 'aside' && node.getClass() === 'comment') {
+ if(user) {
+ creator = user.name;
+ if(user.email) {
+ creator += ' (' + user.email + ')';
+ }
+ } else {
+ creator = 'anonymous';
+ }
+
+ currentDate = new Date();
+ dt = pad(currentDate.getDate()) + '-' +
+ pad((currentDate.getMonth() + 1)) + '-' +
+ pad(currentDate.getFullYear()) + ' ' +
+ pad(currentDate.getHours()) + ':' +
+ pad(currentDate.getMinutes()) + ':' +
+ pad(currentDate.getSeconds());
+
+ metadata = node.getMetadata();
+ metadata.add({key: 'creator', value: creator});
+ metadata.add({key: 'date', value: dt});
+ }
+ doc.endTransaction();
+ return node;
+ };
+
+