From e03e917292152f4a726a4eea2a57da8d234fb683 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Sun, 23 Mar 2014 19:47:18 +0100 Subject: [PATCH] editor: refactoring --- src/editor/modules/documentCanvas/commands.js | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/editor/modules/documentCanvas/commands.js b/src/editor/modules/documentCanvas/commands.js index 11a874a..7302df3 100644 --- a/src/editor/modules/documentCanvas/commands.js +++ b/src/editor/modules/documentCanvas/commands.js @@ -1,6 +1,7 @@ define([ -'./canvas/utils' -], function(utils) { +'./canvas/utils', +'fnpjs/datetime' +], function(utils, datetime) { 'use strict'; @@ -108,14 +109,7 @@ commands.register('newNodeRequested', function(canvas, params, user) { 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; - }; + node, metadata, creator; doc.startTransaction(); node = insertion(); @@ -129,17 +123,9 @@ commands.register('newNodeRequested', function(canvas, params, user) { 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}); + metadata.add({key: 'date', value: datetime.currentStrfmt()}); } doc.endTransaction(); return node; -- 2.20.1