Use the file name as initial title

pull/1/head
yflory 8 years ago
parent 20b08a7847
commit c72bbd4c37

@ -564,6 +564,11 @@ define([
editor.setValue(newDoc || '');
if (Cryptpad.initialName && document.title === defaultName) {
updateTitle(Cryptpad.initialName);
onLocal();
}
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
if (yes) { unnotify(); }

@ -214,15 +214,6 @@ define([
secret.keys = Crypto.createEditCryptor();
secret.key = Crypto.createEditCryptor().editKeyStr;
};
// If we have a hash in the URL specifying a path, it means the document was created from
// the drive and should be stored at the selected path.
if (/[?&]path=/.test(window.location.hash)) {
var patharr = window.location.hash.match(/[?&]path=([^&]+)/);
var namearr = window.location.hash.match(/[?&]name=([^&]+)/);
common.initialPath = patharr[1] || undefined;
common.initialName = namearr && namearr[1] ? decodeURIComponent(namearr[1]) : undefined;
window.location.hash = '';
}
if (!secretHash && !/#/.test(window.location.href)) {
generate();
return secret;
@ -698,6 +689,9 @@ define([
});
};
var newPadNameKey = common.newPadNameKey = "newPadName";
var newPadPathKey = common.newPadPathKey = "newPadPath";
// local name?
common.ready = function (f) {
var state = 0;
@ -708,6 +702,15 @@ define([
f(void 0, env);
};
if (sessionStorage[newPadNameKey]) {
common.initialName = sessionStorage[newPadNameKey];
delete sessionStorage[newPadNameKey];
}
if (sessionStorage[newPadPathKey]) {
common.initialPath = sessionStorage[newPadPathKey];
delete sessionStorage[newPadPathKey];
}
Store.ready(function (err, storeObj) {
store = common.store = env.store = storeObj;

@ -897,8 +897,11 @@ define([
}
var onNamed = function (name) {
if (!name) { return; }
// TODO
var path = '/#?name=' + encodeURIComponent(name) + '&path=' + encodeURIComponent(currentPath);
window.open('/' + type + path);
sessionStorage[Cryptpad.newPadNameKey] = name;
sessionStorage[Cryptpad.newPadPathKey] = currentPath;
window.open('/' + type + '/');
};
Cryptpad.prompt(Messages.fm_nameFile, Cryptpad.getDefaultName({type: type}), onNamed);
};

@ -372,6 +372,8 @@ define([
};
if (!initializing) {
hjson[3].metadata.title = document.title;
} else if (Cryptpad.initialName) {
hjson[3].metadata.title = Cryptpad.initialName;
}
return stringify(hjson);
};

@ -567,7 +567,11 @@ define([
} else {
APP.proxy.info.defaultTitle = defaultName;
}
updateTitle(APP.proxy.info.title || defaultName);
if (Cryptpad.initialName && !APP.proxy.info.title) {
updateTitle(Cryptpad.initialName);
} else {
updateTitle(APP.proxy.info.title || defaultName);
}
// Description
var resize = function () {

@ -638,6 +638,11 @@ define([
editor.setValue(newDoc || '');
Slide.update(newDoc);
if (Cryptpad.initialName && APP.title === defaultName) {
updateTitle(Cryptpad.initialName);
onLocal();
}
if (Visible.isSupported()) {
Visible.onChange(function (yes) {
if (yes) { unnotify(); }

Loading…
Cancel
Save