move 'getDefaultName' out of 'common-hash'

This commit is contained in:
ansuz
2019-09-05 12:22:30 +02:00
parent d7906f9132
commit 096b0fb44a
6 changed files with 26 additions and 22 deletions

View File

@@ -1,9 +1,8 @@
define([
'/common/common-util.js',
'/customize/messages.js',
'/bower_components/chainpad-crypto/crypto.js',
'/bower_components/tweetnacl/nacl-fast.min.js'
], function (Util, Messages, Crypto) {
], function (Util, Crypto) {
var Nacl = window.nacl;
var Hash = window.CryptPad_Hash = {};
@@ -515,20 +514,6 @@ Version 1
'/' + curvePublic.replace(/\//g, '-') + '/';
};
// Create untitled documents when no name is given
var getLocaleDate = function () {
if (window.Intl && window.Intl.DateTimeFormat) {
var options = {weekday: "short", year: "numeric", month: "long", day: "numeric"};
return new window.Intl.DateTimeFormat(undefined, options).format(new Date());
}
return new Date().toString().split(' ').slice(0,4).join(' ');
};
Hash.getDefaultName = function (parsed) {
var type = parsed.type;
var name = (Messages.type)[type] + ' - ' + getLocaleDate();
return name;
};
Hash.isValidHref = function (href) {
// Non-empty href?
if (!href) { return; }