Merge pull request #266 from ONLYOFFICE/feature/renaming-files

Feature/renaming files
This commit is contained in:
Sergey Linnik
2022-03-18 10:31:19 +03:00
committed by GitHub
28 changed files with 476 additions and 64 deletions

View File

@ -38,6 +38,7 @@
<script type="text/javascript" language="javascript">
var docEditor;
var config;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -56,10 +57,14 @@
};
var onMetaChange = function (event) { // the meta information of the document is changed via the meta command
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
if (event.data.favorite) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
}
innerAlert("onMetaChange: " + JSON.stringify(event.data));
};
var onRequestEditRights = function () { // the user is trying to switch the document from the viewing into the editing mode
@ -155,7 +160,7 @@
}
let xhr = new XMLHttpRequest();
xhr.open("POST", "create");
xhr.setRequestHeader( 'Content-Type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
@ -163,7 +168,24 @@
}
}
var config = {<%- include("config") %>,
var onRequestRename = function(event) { // the user is trying to rename file by clicking Rename... button
innerAlert("onRequestRename: " + JSON.stringify(event.data));
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);
}
};
config = {<%- include("config") %>,
events: {
"onAppReady": onAppReady,
"onDocumentStateChange": onDocumentStateChange,
@ -178,6 +200,7 @@
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
"onRequestRename": onRequestRename
}
};