- Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may upload your own documents for testing using the "Choose file" button and selecting the necessary files on your PC.
+ Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors. You may upload your own documents for testing using the "Upload file" button and selecting the necessary files on your PC.
+
+
+
+
+
+ Username:
+
+
+
Select user name before opening the document; you can open the same document using different users in different Web browser sessions, so you can check out multi-user editing functions.
+
+
+
+
+
+
Choose the language for ONLYOFFICEâ„¢ editors interface.
+
+
+
+
+
Upload your file or create new file
diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs
index e86b6cf8..4df9c11b 100644
--- a/web/documentserver-example/csharp/DocEditor.aspx.cs
+++ b/web/documentserver-example/csharp/DocEditor.aspx.cs
@@ -97,6 +97,7 @@ namespace OnlineEditorsExample
}
var ext = Path.GetExtension(FileName);
+
var config = new Dictionary
{
{ "type", Request["action"] != "embedded" ? "desktop" : "embedded" },
@@ -128,13 +129,13 @@ namespace OnlineEditorsExample
"editorConfig", new Dictionary
{
{ "mode", _Default.EditMode && _Default.EditedExts.Contains(ext) && Request["action"] != "view" ? "edit" : "view" },
- { "lang", "en" },
+ { "lang", Request.Cookies["ulang"]?.Value ?? "en" },
{ "callbackUrl", CallbackUrl },
{
"user", new Dictionary
{
- { "id", _Default.CurUserHostAddress(null) },
- { "name", "John Smith" }
+ { "id", Request.Cookies["uid"]?.Value ?? "uid-1" },
+ { "name", Request.Cookies["uname"]?.Value ?? "John Smith" }
}
},
{
diff --git a/web/documentserver-example/csharp/script/jscript.js b/web/documentserver-example/csharp/script/jscript.js
index 8334cac5..041183c1 100644
--- a/web/documentserver-example/csharp/script/jscript.js
+++ b/web/documentserver-example/csharp/script/jscript.js
@@ -70,6 +70,8 @@ if (typeof jQuery != "undefined") {
checkConvert();
}
});
+
+ initSelectors();
});
var timer = null;
@@ -158,6 +160,34 @@ if (typeof jQuery != "undefined") {
}
};
+ var initSelectors = function () {
+ var userSel = jq("#user");
+ var langSel = jq("#language");
+
+ function getCookie(name) {
+ let matches = document.cookie.match(new RegExp(
+ "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
+ ));
+ return matches ? decodeURIComponent(matches[1]) : null;
+ }
+ function setCookie(name, value) {
+ document.cookie = name + "=" + value + "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 7).toUTCString(); //week
+ }
+
+ var userId = getCookie("uid");
+ if (userId) userSel.val(userId);
+ var langId = getCookie("ulang");
+ if (langId) langSel.val(langId);
+
+ userSel.on("change", function () {
+ setCookie("uid", userSel.val());
+ setCookie("uname", userSel.find("option:selected").text())
+ });
+ langSel.on("change", function () {
+ setCookie("ulang", langSel.val());
+ });
+ };
+
jq(document).on("click", "#beginEdit:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
var url = "doceditor.aspx?fileID=" + fileId;