nodejs:meta command

This commit is contained in:
Olga Larinova
2022-03-07 22:01:03 +03:00
parent f7259409a2
commit b8eecab45f
2 changed files with 58 additions and 0 deletions

View File

@ -56,10 +56,17 @@
};
var onMetaChange = function (event) { // the meta information of the document is changed via the meta command
if(event.data.title) {
var title = event.data.title;
document.title = title;
console.log(event.data);
}
else {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
}
};
var onRequestEditRights = function () { // the user is trying to switch the document from the viewing into the editing mode
@ -163,6 +170,22 @@
}
}
var onRequestRename = function(event) { // the user is trying to rename file by clicking Rename... button
var newfilename = event.data;
var data = {
newfilename: newfilename,
dockey: config.document.key,
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "rename");
xhr.setRequestHeader( 'Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
}
};
var config = {<%- include("config") %>,
events: {
"onAppReady": onAppReady,
@ -178,6 +201,7 @@
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
"onRequestRename": onRequestRename
}
};