move 'getDefaultName' out of 'common-hash'
parent
d7906f9132
commit
096b0fb44a
|
@ -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; }
|
||||
|
|
|
@ -648,7 +648,6 @@ define([
|
|||
data.href = parsed.getUrl({present: parsed.present});
|
||||
|
||||
if (typeof (data.title) !== "string") { return cb('Missing title'); }
|
||||
if (data.title.trim() === "") { data.title = Hash.getDefaultName(parsed); }
|
||||
|
||||
if (common.initialPath) {
|
||||
if (!data.path) {
|
||||
|
|
|
@ -507,7 +507,7 @@ define([
|
|||
roHref: roHref,
|
||||
atime: now,
|
||||
ctime: now,
|
||||
title: title || Hash.getDefaultName(Hash.parsePadUrl(href)),
|
||||
title: title || UserObject.getDefaultName(Hash.parsePadUrl(href)),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -805,6 +805,8 @@ define([
|
|||
var p = Hash.parsePadUrl(href);
|
||||
var h = p.hashData;
|
||||
|
||||
if (title.trim() === "") { title = UserObject.getDefaultName(p); }
|
||||
|
||||
if (AppConfig.disableAnonymousStore && !store.loggedIn) { return void cb(); }
|
||||
if (p.type === "debug") { return void cb(); }
|
||||
|
||||
|
|
|
@ -694,7 +694,7 @@ define([
|
|||
// Fix creation time
|
||||
if (!el.ctime) { el.ctime = el.atime; }
|
||||
// Fix title
|
||||
if (!el.title) { el.title = Hash.getDefaultName(parsed); }
|
||||
if (!el.title) { el.title = exp.getDefaultName(parsed); }
|
||||
// Fix channel
|
||||
if (!el.channel) {
|
||||
try {
|
||||
|
|
|
@ -50,9 +50,10 @@ define([
|
|||
'/common/outer/local-store.js',
|
||||
'/customize/application_config.js',
|
||||
'/common/test.js',
|
||||
'/common/userObject.js',
|
||||
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel,
|
||||
_FilePicker, _Share, _Messaging, _Notifier, _Hash, _Util, _Realtime,
|
||||
_Constants, _Feedback, _LocalStore, _AppConfig, _Test) {
|
||||
_Constants, _Feedback, _LocalStore, _AppConfig, _Test, _UserObject) {
|
||||
CpNfOuter = _CpNfOuter;
|
||||
Cryptpad = _Cryptpad;
|
||||
Crypto = Utils.Crypto = _Crypto;
|
||||
|
@ -68,6 +69,7 @@ define([
|
|||
Utils.Constants = _Constants;
|
||||
Utils.Feedback = _Feedback;
|
||||
Utils.LocalStore = _LocalStore;
|
||||
Utils.UserObject = _UserObject;
|
||||
AppConfig = _AppConfig;
|
||||
Test = _Test;
|
||||
|
||||
|
@ -271,7 +273,7 @@ define([
|
|||
Utils.crypto = Utils.Crypto.createEncryptor(Utils.secret.keys);
|
||||
var parsed = Utils.Hash.parsePadUrl(window.location.href);
|
||||
if (!parsed.type) { throw new Error(); }
|
||||
var defaultTitle = Utils.Hash.getDefaultName(parsed);
|
||||
var defaultTitle = Utils.UserObject.getDefaultName(parsed);
|
||||
var edPublic, curvePublic, notifications, isTemplate;
|
||||
var forceCreationScreen = cfg.useCreationScreen &&
|
||||
sessionStorage[Utils.Constants.displayPadCreationScreen];
|
||||
|
@ -1176,7 +1178,7 @@ define([
|
|||
|
||||
// Update metadata values and send new metadata inside
|
||||
parsed = Utils.Hash.parsePadUrl(window.location.href);
|
||||
defaultTitle = Utils.Hash.getDefaultName(parsed);
|
||||
defaultTitle = Utils.UserObject.getDefaultName(parsed);
|
||||
hashes = Utils.Hash.getHashes(secret);
|
||||
readOnly = false;
|
||||
updateMeta();
|
||||
|
|
|
@ -15,8 +15,24 @@ define([
|
|||
var TEMPLATE = module.TEMPLATE = "template";
|
||||
var SHARED_FOLDERS = module.SHARED_FOLDERS = "sharedFolders";
|
||||
|
||||
// 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(' ');
|
||||
};
|
||||
module.getDefaultName = function (parsed) {
|
||||
var type = parsed.type;
|
||||
var name = (Messages.type)[type] + ' - ' + getLocaleDate();
|
||||
return name;
|
||||
};
|
||||
|
||||
module.init = function (files, config) {
|
||||
var exp = {};
|
||||
exp.getDefaultName = module.getDefaultName;
|
||||
|
||||
var sframeChan = config.sframeChan;
|
||||
|
||||
var FILES_DATA = module.FILES_DATA = exp.FILES_DATA = Constants.storageKey;
|
||||
|
|
Loading…
Reference in New Issue