From 31c23fbf49e848964eab131b7277c0240cbd2ea7 Mon Sep 17 00:00:00 2001 From: Andrey Panov Date: Tue, 3 Sep 2019 13:30:41 +0300 Subject: [PATCH] csharp: user and lang selectors --- .../csharp/App_Themes/stylesheet.css | 20 ++++++++ .../csharp/Default.aspx | 48 ++++++++++++++++++- .../csharp/DocEditor.aspx.cs | 7 +-- .../csharp/script/jscript.js | 30 ++++++++++++ 4 files changed, 101 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/csharp/App_Themes/stylesheet.css b/web/documentserver-example/csharp/App_Themes/stylesheet.css index 1387a84b..51a7b53c 100644 --- a/web/documentserver-example/csharp/App_Themes/stylesheet.css +++ b/web/documentserver-example/csharp/App_Themes/stylesheet.css @@ -395,3 +395,23 @@ label .checkbox { clear: both; visibility: hidden; } + +/*Icon table*/ +.select-user { + margin-left: 15px; +} + +.user-block-table { + height: 100%; + width: 100%; +} + + .user-block-table td { + background-color: #F4F4F4; + border-bottom: 1px solid white; + padding: 12px 0; + } + +#user, #language { + width: 130px; +} diff --git a/web/documentserver-example/csharp/Default.aspx b/web/documentserver-example/csharp/Default.aspx index c90a7aa0..0f0f5713 100644 --- a/web/documentserver-example/csharp/Default.aspx +++ b/web/documentserver-example/csharp/Default.aspx @@ -46,7 +46,53 @@ ONLYOFFICE Document Editors

- 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;