mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
csharp: user and lang selectors
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
@ -46,7 +46,53 @@
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
<br />
|
||||
<span class="portal-descr">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.</span>
|
||||
<span class="portal-descr">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.</span>
|
||||
|
||||
<table class="user-block-table" cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="30%" valign="middle">
|
||||
<span class="select-user">Username:</span>
|
||||
<select class="select-user" id="user">
|
||||
<option value="uid-1">Jonn Smith</option>
|
||||
<option value="uid-2">Mark Pottato</option>
|
||||
<option value="uid-3">Hamish Mitchell</option>
|
||||
</select>
|
||||
</td>
|
||||
<td width="70%" valign="middle">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.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="30%" valign="middle">
|
||||
<select class="select-user" id="language">
|
||||
<option value="en">English</option>
|
||||
<option value="bg">Bulgarian</option>
|
||||
<option value="zh">Chinese</option>
|
||||
<option value="cs">Czech</option>
|
||||
<option value="nl">Dutch</option>
|
||||
<option value="fr">French</option>
|
||||
<option value="de">German</option>
|
||||
<option value="hu">Hungarian</option>
|
||||
<option value="it">Italian</option>
|
||||
<option value="ja">Japanese</option>
|
||||
<option value="ko">Korean</option>
|
||||
<option value="lv">Latvian</option>
|
||||
<option value="pl">Polish</option>
|
||||
<option value="pt">Portuguese</option>
|
||||
<option value="ru">Russian</option>
|
||||
<option value="sk">Slovak</option>
|
||||
<option value="sl">Slovenian</option>
|
||||
<option value="es">Spanish</option>
|
||||
<option value="tr">Turkish</option>
|
||||
<option value="uk">Ukrainian</option>
|
||||
<option value="vi">Vietnamese</option>
|
||||
</select>
|
||||
</td>
|
||||
<td width="70%" valign="middle">Choose the language for ONLYOFFICE™ editors interface.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="help-block">
|
||||
<span class="try-descr">Upload your file or create new file</span>
|
||||
|
||||
@ -97,6 +97,7 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(FileName);
|
||||
|
||||
var config = new Dictionary<string, object>
|
||||
{
|
||||
{ "type", Request["action"] != "embedded" ? "desktop" : "embedded" },
|
||||
@ -128,13 +129,13 @@ namespace OnlineEditorsExample
|
||||
"editorConfig", new Dictionary<string, object>
|
||||
{
|
||||
{ "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<string, object>
|
||||
{
|
||||
{ "id", _Default.CurUserHostAddress(null) },
|
||||
{ "name", "John Smith" }
|
||||
{ "id", Request.Cookies["uid"]?.Value ?? "uid-1" },
|
||||
{ "name", Request.Cookies["uname"]?.Value ?? "John Smith" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user