Commit 5a5952e4 authored by agolybev's avatar agolybev

Added example.

parent 9fa5abd6
This diff is collapsed.
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
http://www.onlyoffice.com
*/
html {
height: 100%;
width: 100%;
}
body {
background: #fff;
color: #333;
font-family: 'Open Sans', sans-serif;
font-size: 12px;
font-weight: normal;
height: 100%;
margin: 0;
padding: 0;
text-decoration: none;
}
form {
height: 100%;
}
div {
margin: 0;
padding: 0;
}
a, a:hover, a:visited {
color: #333;
}
.top-panel {
background: url("images/logo.png") no-repeat 30px center #3D4A6B;
height: 80px;
width: 100%;
}
.main-panel {
margin: 80px auto;
width: 600px;
}
.portal-name {
font-size: 20px;
}
.portal-descr {
display: inline-block;
line-height: 20px;
margin-bottom: 24px;
width: 600px;
}
.save-original {
color: #929597;
line-height: 20px;
margin-left: 16px;
white-space: nowrap;
width: 272px;
}
.question {
background: url("images/question_small.png") no-repeat center center transparent;
cursor: pointer;
display: inline-block;
height: 16px;
width: 16px;
}
#hint {
background-color: #FFFFFF;
border: 1px solid #8E908F;
display: none;
margin: 4px 0 0 -32px;
max-width: 415px;
padding: 10px 15px 15px;
word-wrap: break-word;
z-index: 255;
}
.corner {
background: url("images/corner.png") no-repeat scroll 0 0 transparent;
height: 6px;
left: 35px;
margin-top: -15px;
position: absolute;
width: 9px;
z-index: 261;
}
.try-descr {
font-size: 16px;
white-space : nowrap;
}
.try-editor-list {
list-style: none;
margin: 0;
padding: 0;
}
.try-editor-list li {
float: left;
margin: 25px;
}
.try-editor {
background-color: transparent;
background-position: center 0;
background-repeat: no-repeat;
display: block;
font-size: 14px;
font-weight: bold;
height: 30px;
padding-top: 100px;
text-decoration: none;
}
.try-editor.document {
background-image: url("images/file_doct.png");
}
.try-editor.spreadsheet {
background-image: url("images/file_xlst.png");
}
.try-editor.presentation {
background-image: url("images/file_pptt.png");
}
.button, .button:visited, .button:hover, .button:active {
display: inline-block;
font-weight: normal;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor:pointer;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
touch-callout: none;
-o-touch-callout: none;
-moz-touch-callout: none;
-webkit-touch-callout: none;
user-select: none;
-o-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
font-size: 12px;
line-height: 16px;
margin-right: 3px;
padding: 2px 12px;
color: #fff;
background: #3D96C6;
background: linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -o-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -moz-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -webkit-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#59B1E2', EndColorStr='#1A76a6')";
border-width: 1px;
border-style: solid;
border-color: #4da9dc #4098c9 #2d7399 #4098c9;
}
.button.disable {
cursor: default;
background: #BADDEF;
background: linear-gradient(top, #CEE9F6, #BADDEF 50%, #BADDEF 51%, #ABD4EA);
background: -o-linear-gradient(top, #CEE9F6, #BADDEF 50%, #BADDEF 51%, #ABD4EA);
background: -moz-linear-gradient(top, #CEE9F6, #BADDEF 50%, #BADDEF 51%, #ABD4EA);
background: -webkit-linear-gradient(top, #CEE9F6, #BADDEF 50%, #BADDEF 51%, #ABD4EA);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#CEE9F6', EndColorStr='#ABD4EA')";
border: 1px solid #BCDCED;
}
.button.gray {
color: #666;
background: #E9EAEA;
background: linear-gradient(top, #F3F3F3, #E9EAEA 50%, #E8E9E9 51%, #DEDEDE);
background: -o-linear-gradient(top, #F3F3F3, #E9EAEA 50%, #E8E9E9 51%, #DEDEDE);
background: -moz-linear-gradient(top, #F3F3F3, #E9EAEA 50%, #E8E9E9 51%, #DEDEDE);
background: -webkit-linear-gradient(top, #F3F3F3, #E9EAEA 50%, #E8E9E9 51%, #DEDEDE);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#F3F3F3', EndColorStr='#DEDEDE')";
border: 1px solid #BFBFBF;
}
.file-upload {
cursor: pointer;
margin-bottom: 8px;
padding: 0 !important;
overflow: hidden;
position: relative;
}
.file-upload span {
line-height: 21px;
margin: 2px 12px;
}
.file-upload input {
cursor: pointer;
font-size: 23px;
opacity: 0;
position: absolute;
right: 0;
top: 0;
transform: translate(-300px, 0) scale(4);
}
#mainProgress {
color: #979b9f;
display: none;
margin: 15px;
}
#mainProgress #embeddedView {
display: none;
}
#mainProgress.embedded #embeddedView {
display: block;
}
#mainProgress.embedded #uploadSteps {
display: none;
}
.error-message {
background: url("images/alert.png") no-repeat scroll 4px 10px #FFECE3;
color: #666668 !important;
display: none;
font-size: 13px;
font-weight: normal;
margin: 5px 0;
padding: 10px 10px 10px 30px;
vertical-align: middle;
}
#mainProgress .error-message a {
color: #666668;
}
.step {
background-repeat: no-repeat;
background-position: left center;
background-color: transparent;
color: #979B9F;
font-size: 14px;
line-height: 30px;
padding-left: 25px;
}
.current {
background-image: url("images/loader16.gif");
color: #333;
}
.done {
background-image: url("images/done.png");
color: #333;
}
.error {
background-image: url("images/alert.png");
}
.step-descr {
display: block;
margin-left: 45px;
}
#mainProgress .step-descr a {
color: #979B9F;
}
.progress-descr {
color: #333;
}
#loadScripts {
display: none;
}
#iframeScripts {
position: absolute;
visibility: hidden;
}
.bottom-panel {
bottom: 0;
position: fixed;
text-align: right;
width: 100%;
}
.help-block span {
font-size: 16px;
line-height: 26px;
}
.button.sample {
color: #333;
font-weight: bold;
}
.blockTitle {
background-color: #E2E2E2 !important;
border: none !important;
border-radius: 0 !important;
-moz-border-radius: 0 !important;
-webkit-border-radius: 0 !important;
color: #333 !important;
font-size: 16px !important;
font-weight: normal !important;
padding: 15px 25px !important;
}
.dialog-close {
background: url("images/close.png") no-repeat scroll left top #E2E2E2;
cursor: pointer;
float: right;
font-size: 1px;
height: 12px;
line-height: 1px;
margin-top: 4px;
width: 12px;
}
.blockPage {
border: none !important;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.5);
padding: 0 !important;
}
\ No newline at end of file
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OnlineEditorsExample._Default" Title="ONLYOFFICE™" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ONLYOFFICE™</title>
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:900,800,700,600,500,400,300&subset=latin,cyrillic-ext,cyrillic,latin-ext" />
<link rel="stylesheet" type="text/css" href="app_themes/stylesheet.css" />
<link rel="stylesheet" type="text/css" href="app_themes/jquery-ui.css" />
<script language="javascript" type="text/javascript" src="script/jquery-1.9.0.min.js"></script>
<script language="javascript" type="text/javascript" src="script/jquery-ui.min.js"></script>
<script language="javascript" type="text/javascript" src="script/jquery.blockUI.js"></script>
<script language="javascript" type="text/javascript" src="script/jquery.iframe-transport.js"></script>
<script language="javascript" type="text/javascript" src="script/jquery.fileupload.js"></script>
<script language="javascript" type="text/javascript" src="script/jquery.dropdownToggle.js"></script>
<script language="javascript" type="text/javascript" src="script/jscript.js"></script>
<script language="javascript" type="text/javascript">
var ConverExtList = '<%= string.Join(",", ConvertExts.ToArray()) %>';
var EditedExtList = '<%= string.Join(",", EditedExts.ToArray()) %>';
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="top-panel"></div>
<div class="main-panel">
<span class="portal-name">ONLYOFFICE™ Online Editors</span>
<br />
<br />
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Online 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>
<div class="file-upload button gray">
<span>Choose file</span>
<input type="file" id="fileupload" name="files[]" data-url="webeditor.ashx?type=upload" />
</div>
<label class="save-original">
<input type="checkbox" id="checkOriginalFormat" />Save document in original format
</label>
<span class="question"></span>
<br />
<br />
<br />
<span class="try-descr">You are also enabled to view and edit documents pre-uploaded to the portal.</span>
<ul class="try-editor-list">
<li><a class="try-editor document" href="doceditor.aspx?type=document" target="_blank">Sample Document</a></li>
<li><a class="try-editor spreadsheet" href="doceditor.aspx?type=spreadsheet" target="_blank">Sample Spreadsheet</a></li>
<li><a class="try-editor presentation" href="doceditor.aspx?type=presentation" target="_blank">Sample Presentation</a></li>
</ul>
<br />
<br />
<br />
<div class="help-block">
<span>Want to learn how it works?</span>
<% if (File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExample.zip")
|| File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleMVC.zip")
|| File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleJS.zip")
|| File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleJava.zip")
|| File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleNodeJS.zip")
|| File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExamplePHP.zip"))
{ %>
<br />
Download the code for the sample of ONLYOFFICE™ Online Editors to find out the details.
<br />
<br />
<% if (File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExample.zip"))
{ %>
<a class="sample button gray" href="app_data/OnlineEditorsExample.zip">C#</a>
<% } %>
<% if (File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleMVC.zip"))
{ %>
<a class="sample button gray" href="app_data/OnlineEditorsExampleMVC.zip">C# MVC</a>
<% } %>
<% if (File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleJS.zip"))
{ %>
<a class="sample button gray" href="app_data/OnlineEditorsExampleJS.zip">JavaScript</a>
<% } %>
<% if (File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleJava.zip"))
{ %>
<a class="sample button gray" href="app_data/OnlineEditorsExampleJava.zip">Java</a>
<% } %>
<% if (File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExampleNodeJS.zip"))
{ %>
<a class="sample button gray" href="app_data/OnlineEditorsExampleNodeJS.zip">Node.js</a>
<% } %>
<% if (File.Exists(HttpRuntime.AppDomainAppPath + "App_Data\\OnlineEditorsExamplePHP.zip"))
{ %>
<a class="sample button gray" href="app_data/OnlineEditorsExamplePHP.zip">PHP</a>
<% } %>
<br />
<br />
<% } %>
<br />
Read the editor <a href="http://api.onlyoffice.com/editors/howitworks">API Documentation</a>
</div>
<br />
<br />
<br />
<div class="help-block">
<span>Any questions?</span>
<br />
Please, <a href="mailto:sales@onlyoffice.com">submit your request</a> and we'll help you shortly.
</div>
</div>
<div id="hint">
<div class="corner"></div>
If you check this option the file will be saved both in the original and converted into Office Open XML format for faster viewing and editing. In other case the document will be overwritten by its copy in Office Open XML format.
</div>
<div id="mainProgress">
<div id="uploadSteps">
<span id="step1" class="step">1. Loading the file</span>
<span class="step-descr">The file loading process will take some time depending on the file size, presence or absence of additional elements in it (macros, etc.) and the connection speed.</span>
<br />
<span id="step2" class="step">2. File conversion</span>
<span class="step-descr">The file is being converted into Office Open XML format for the document faster viewing and editing.</span>
<br />
<span id="step3" class="step">3. Loading editor scripts</span>
<span class="step-descr">The scripts for the editor are loaded only once and are will be cached on your computer in future. It might take some time depending on the connection speed.</span>
<input type="hidden" name="hiddenFileName" id="hiddenFileName" />
<br />
<br />
<span class="progress-descr">Please note, that the speed of all operations greatly depends on the server and the client locations. In case they differ or are located in differernt countries/continents, there might be lack of speed and greater wait time. The best results are achieved when the server and client computers are located in one and the same place (city).</span>
<br />
<br />
<div class="error-message">
<span></span>
<br />
Please select another file and try again. If you have questions please <a href="mailto:sales@onlyoffice.com">contact us.</a>
</div>
</div>
<iframe id="embeddedView" src="" height="345px" width="600px" frameborder="0" scrolling="no" allowtransparency></iframe>
<br />
<div id="beginEmbedded" class="button disable">Embedded view</div>
<div id="beginView" class="button disable">View</div>
<% if (EditMode)
{ %>
<div id="beginEdit" class="button disable">Edit</div>
<% } %>
<div id="cancelEdit" class="button gray">Cancel</div>
</div>
<span id="loadScripts" data-docs="<%= UrlPreloadScripts %>"></span>
<div class="bottom-panel">&copy; Ascensio System SIA <%=DateTime.Now.Year.ToString()%>. All rights reserved.</div>
</form>
</body>
</html>
This diff is collapsed.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OnlineEditorsExample {
public partial class _Default {
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DocEditor.aspx.cs" Inherits="OnlineEditorsExample.DocEditor" Title="ONLYOFFICE™" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="OnlineEditorsExample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
<title>ONLYOFFICE™</title>
<style>
html {
height: 100%;
width: 100%;
}
body {
background: #fff;
color: #333;
font-family: Arial, Tahoma,sans-serif;
font-size: 12px;
font-weight: normal;
height: 100%;
margin: 0;
overflow-y: hidden;
padding: 0;
text-decoration: none;
}
form {
height: 100%;
}
div {
margin: 0;
padding: 0;
}
</style>
<script language="javascript" type="text/javascript" src="<%= DocServiceApiUri %>"></script>
<script type="text/javascript" language="javascript">
var docEditor;
var fileName = "<%= FileName %>";
var fileType = "<%= Path.GetExtension(FileName).Trim('.') %>";
var innerAlert = function (message) {
if (console && console.log)
console.log(message);
;
};
var onReady = function () {
innerAlert("Document editor ready");
};
var onBack = function () {
location.href = "default.aspx";
};
var onDocumentStateChange = function (event) {
var title = document.title.replace(/\*$/g, "");
document.title = title + (event.data ? "*" : "");
};
var onRequestEditRights = function () {
if (typeof DocsAPI.DocEditor.version == "function") {
var version = DocsAPI.DocEditor.version();
if ((parseFloat(version) || 0) >= 3) {
location.href = location.href.replace(RegExp("action=view\&?", "i"), "");
return;
}
}
docEditor.applyEditRights(true);
};
var onDocumentSave = function (event) {
SaveFileRequest(fileName, fileType, event.data);
};
var onError = function (event) {
if (console && console.log && event)
console.log(event.data);
};
var сonnectEditor = function () {
docEditor = new DocsAPI.DocEditor("iframeEditor",
{
width: "100%",
height: "100%",
type: '<%= Request["action"] != "embedded" ? "desktop" : "embedded" %>',
documentType: "<%= DocumentType %>",
document: {
title: fileName,
url: "<%= FileUri %>",
fileType: fileType,
key: "<%= Key %>",
vkey: "<%= ValidateKey %>",
info: {
author: "Me",
created: "<%= DateTime.Now.ToShortDateString() %>"
},
permissions: {
edit: "<%= _Default.EditedExts.Contains(Path.GetExtension(FileName)) %>" == "True",
download: true
}
},
editorConfig: {
mode: '<%= _Default.EditMode && _Default.EditedExts.Contains(Path.GetExtension(FileName)) && Request["action"] != "view" ? "edit" : "view" %>',
lang: "en",
callbackUrl: "<%= CallbackUrl %>",
user : {
id: "<%= _Default.CurUserHostAddress(null) %>",
name: "User"
},
embedded: {
saveUrl: "<%= FileUri %>",
embedUrl: "<%= FileUri %>",
shareUrl: "<%= FileUri %>",
toolbarDocked: "top"
}
},
events: {
'onReady': onReady,
'onBack': <%= Request["action"] != "embedded" ? "onBack" : "undefined" %>,
'onDocumentStateChange': onDocumentStateChange,
'onRequestEditRights': onRequestEditRights,
'onSave': onDocumentSave,
'onError': onError
}
});
};
if (window.addEventListener) {
window.addEventListener("load", сonnectEditor);
} else if (window.attachEvent) {
window.attachEvent("load", сonnectEditor);
}
function getXmlHttp() {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (ex) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function SaveFileRequest(fileName, fileType, fileUri) {
var req = getXmlHttp();
if (console && console.log) {
req.onreadystatechange = function () {
if (req.readyState == 4) {
console.log(req.statusText);
if (req.status == 200) {
console.log(req.responseText);
}
}
};
}
var requestAddress = "webeditor.ashx"
+ "?type=save"
+ "&filename=" + encodeURIComponent(fileName)
+ "&filetype=" + encodeURIComponent(fileType)
+ "&fileuri=" + encodeURIComponent(fileUri);
req.open('get', requestAddress, true);
req.send(fileUri);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="iframeEditor">
</div>
</form>
</body>
</html>
using System;
using System.IO;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using ASC.Api.DocumentConverter;
namespace OnlineEditorsExample
{
public partial class DocEditor : Page
{
public static string FileName;
public static string FileUri
{
get { return _Default.FileUri(FileName); }
}
protected string Key
{
get { return ServiceConverter.GenerateRevisionId(_Default.CurUserHostAddress(null) + "/" + Path.GetFileName(FileUri)); }
}
protected string ValidateKey
{
get { return ServiceConverter.GenerateValidateKey(Key); }
}
protected string DocServiceApiUri
{
get { return WebConfigurationManager.AppSettings["files.docservice.url.api"] ?? string.Empty; }
}
public static string CallbackUrl
{
get
{
var callbackUrl = new UriBuilder(HttpContext.Current.Request.Url)
{
Path =
HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx",
Query = "type=track"
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
+ "&fileName=" + HttpUtility.UrlEncode(FileName)
};
return callbackUrl.ToString();
}
}
protected string DocumentType
{
get
{
var ext = Path.GetExtension(FileName).ToLower();
if (FileType.ExtsDocument.Contains(ext)) return "text";
if (FileType.ExtsSpreadsheet.Contains(ext)) return "spreadsheet";
if (FileType.ExtsPresentation.Contains(ext)) return "presentation";
return string.Empty;
}
}
protected void Page_Load(object sender, EventArgs e)
{
var externalUrl = Request["fileUrl"];
if (!string.IsNullOrEmpty(externalUrl))
{
FileName = _Default.DoUpload(externalUrl);
}
else
{
FileName = Request["fileID"];
}
var type = Request["type"];
if (!string.IsNullOrEmpty(type))
{
Try(type);
Response.Redirect("doceditor.aspx?fileID=" + HttpUtility.UrlEncode(FileName));
}
}
private static void Try(string type)
{
string ext;
switch (type)
{
case "document":
ext = ".docx";
break;
case "spreadsheet":
ext = ".xlsx";
break;
case "presentation":
ext = ".pptx";
break;
default:
return;
}
var demoName = "demo" + ext;
FileName = _Default.GetCorrectName(demoName);
File.Copy(HttpRuntime.AppDomainAppPath + "app_data/" + demoName, _Default.StoragePath(FileName, null));
}
}
}
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OnlineEditorsExample {
public partial class DocEditor {
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
}
}
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3270EDBC-C0AB-4138-AE26-8A26D426D348}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineEditorsExample</RootNamespace>
<AssemblyName>OnlineEditorsExample</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<UseIISExpress>false</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.Mobile" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="DocEditor.aspx.cs">
<DependentUpon>DocEditor.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="DocEditor.aspx.designer.cs">
<DependentUpon>DocEditor.aspx</DependentUpon>
</Compile>
<Compile Include="DocumentConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="WebEditor.ashx.cs">
<DependentUpon>WebEditor.ashx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="favicon.ico" />
<Content Include="settings.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Default.aspx" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Themes\images\alert.png" />
<Content Include="App_Themes\images\close.png" />
<Content Include="App_Themes\images\corner.png" />
<Content Include="App_Themes\images\done.png" />
<Content Include="App_Themes\images\file_doct.png" />
<Content Include="App_Themes\images\file_pptt.png" />
<Content Include="App_Themes\images\file_xlst.png" />
<Content Include="App_Themes\images\loader16.gif" />
<Content Include="App_Themes\images\logo.png" />
<Content Include="App_Themes\images\question_small.png" />
<Content Include="App_Themes\jquery-ui.css" />
<Content Include="App_Themes\stylesheet.css" />
<Content Include="DocEditor.aspx" />
<Content Include="script\jquery-1.9.0.min.js" />
<Content Include="script\jquery-ui.min.js" />
<Content Include="script\jquery.blockUI.js" />
<Content Include="script\jquery.dropdownToggle.js" />
<Content Include="script\jquery.fileupload.js" />
<Content Include="script\jquery.iframe-transport.js" />
<Content Include="script\jscript.js" />
<Content Include="WebEditor.ashx" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>55594</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
</Project>
\ No newline at end of file
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>ONLYOFFICE™</title>
<link href="stylesheet.css" type="text/css" rel="stylesheet">
<!--Change the address on installed ONLYOFFICE™ Online Editors-->
<script id="scriptApi" type="text/javascript" src="https://doc.onlyoffice.com/OfficeWeb/apps/api/documents/api.js"></script>
<script type="text/javascript" src="sha256.js"></script>
<script type="text/javascript" src="init.js"></script>
</head>
<body>
<div id="page">
<div class="top-panel"></div>
<div id="mainPanel" class="main-panel">
<span class="portal-name">ONLYOFFICE™ Online Editors</span>
<br />
<br />
<span class="portal-descr">Get started with a demo-sample of ONLYOFFICE™ Online Editors, the first html5-based editors. You may enter url your own document for testing.</span>
<textarea id="documentUrl" class="document-url">http://onlyo.co/1x5REbq?demo.docx</textarea>
<br />
<br />
<div class="button" onclick="document.getElementById('mainPanel').style.display ='none';document.getElementById('placeholder').parentNode.setAttribute('class', 'embedded');initEditor(null, null, null, 'embedded')">Embedded view</div>
<div class="button" onclick="document.getElementById('page').style.display ='none';initEditor()">View</div>
<div class="button" onclick="document.getElementById('page').style.display ='none';initEditor(null, null, 'edit')">Edit</div>
</div>
</div>
<div>
<div id="placeholder"></div>
</div>
</body>
</html>
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
http://www.onlyoffice.com
*/
function initEditor(docKey, docVkey, mode, type) {
//mode for editor
window.mode = window.mode || mode || "view";
mode = window.mode;
//mode for editor
window.type = window.type || type || "desktop";
type = window.type;
//url for document
window.docUrl = document.getElementById("documentUrl").value;
//key for chaching and collaborate editing
window.docKey = window.docKey || docKey || key(docUrl);
docKey = window.docKey;
//vkey parameter is necessary if you use our SaaS based editors only.
if (document.getElementById("scriptApi").getAttribute("src").indexOf("doc.onlyoffice.com") != -1
&& !docVkey) {
if (typeof vkey !== "function") {
var script = document.createElement("script")
script.setAttribute("src", "vkey.js")
document.getElementsByTagName("head")[0].appendChild(script);
return;
} else {
docVkey = vkey(docKey);
}
}
//type for document
var docType = docUrl.substring(docUrl.lastIndexOf(".") + 1).trim().toLowerCase();
//type for editor
var documentType = getDocumentType(docType);
//creating object editing
new DocsAPI.DocEditor("placeholder",
{
type: type,
width: (type == "desktop" ? "100%" : undefined),
height: (type == "desktop" ? "100%" : undefined),
documentType: documentType,
document: {
title: docUrl,
url: docUrl,
fileType: docType,
key: docKey,
vkey: docVkey,
permissions: {
edit: true
}
},
editorConfig: {
mode: mode,
},
events: {
"onSave": function (event) { alert("You can get changed document by url: " + event.data); }
}
});
}
function key(k) {
var result = k.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_") + (new Date()).getTime();
return result.substring(result.length - Math.min(result.length, 20));
};
var getDocumentType = function (ext) {
if (".docx.doc.odt.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
if (".xls.xlsx.ods.csv".indexOf(ext) != -1) return "spreadsheet";
if (".pps.ppsx.ppt.pptx.odp".indexOf(ext) != -1) return "presentation";
return null;
};
\ No newline at end of file
/*
A JavaScript implementation of the SHA family of hashes, as
defined in FIPS PUB 180-2 as well as the corresponding HMAC implementation
as defined in FIPS PUB 198a
Copyright Brian Turek 2008-2014
Distributed under the BSD License
See http://caligatio.github.com/jsSHA/ for more information
Several functions taken from Paul Johnston
*/
'use strict';(function(D){function r(a,d,b){var c=0,f=[0],g="",h=null,g=b||"UTF8";if("UTF8"!==g&&"UTF16"!==g)throw"encoding must be UTF8 or UTF16";if("HEX"===d){if(0!==a.length%2)throw"srcString of HEX type must be in byte increments";h=u(a);c=h.binLen;f=h.value}else if("TEXT"===d)h=v(a,g),c=h.binLen,f=h.value;else if("B64"===d)h=w(a),c=h.binLen,f=h.value;else if("BYTES"===d)h=x(a),c=h.binLen,f=h.value;else throw"inputFormat must be HEX, TEXT, B64, or BYTES";this.getHash=function(a,d,b,g){var h=null,
e=f.slice(),m=c,k;3===arguments.length?"number"!==typeof b&&(g=b,b=1):2===arguments.length&&(b=1);if(b!==parseInt(b,10)||1>b)throw"numRounds must a integer >= 1";switch(d){case "HEX":h=y;break;case "B64":h=z;break;case "BYTES":h=A;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-224"===a)for(k=0;k<b;k+=1)e=q(e,m,a),m=224;else if("SHA-256"===a)for(k=0;k<b;k+=1)e=q(e,m,a),m=256;else throw"Chosen SHA variant is not supported";return h(e,B(g))};this.getHMAC=function(a,b,d,h,l){var e,m,
k,n,C=[],s=[];e=null;switch(h){case "HEX":h=y;break;case "B64":h=z;break;case "BYTES":h=A;break;default:throw"outputFormat must be HEX, B64, or BYTES";}if("SHA-224"===d)m=64,n=224;else if("SHA-256"===d)m=64,n=256;else throw"Chosen SHA variant is not supported";if("HEX"===b)e=u(a),k=e.binLen,e=e.value;else if("TEXT"===b)e=v(a,g),k=e.binLen,e=e.value;else if("B64"===b)e=w(a),k=e.binLen,e=e.value;else if("BYTES"===b)e=x(a),k=e.binLen,e=e.value;else throw"inputFormat must be HEX, TEXT, B64, or BYTES";
a=8*m;b=m/4-1;m<k/8?(e=q(e,k,d),e[b]&=4294967040):m>k/8&&(e[b]&=4294967040);for(m=0;m<=b;m+=1)C[m]=e[m]^909522486,s[m]=e[m]^1549556828;d=q(s.concat(q(C.concat(f),a+c,d)),a+n,d);return h(d,B(l))}}function v(a,d){var b=[],c,f=[],g=0,h;if("UTF8"===d)for(h=0;h<a.length;h+=1)for(c=a.charCodeAt(h),f=[],128>c?f.push(c):2048>c?(f.push(192|c>>>6),f.push(128|c&63)):55296>c||57344<=c?f.push(224|c>>>12,128|c>>>6&63,128|c&63):(h+=1,c=65536+((c&1023)<<10|a.charCodeAt(h)&1023),f.push(240|c>>>18,128|c>>>12&63,128|
c>>>6&63,128|c&63)),c=0;c<f.length;c+=1)(g>>>2)+1>b.length&&b.push(0),b[g>>>2]|=f[c]<<24-g%4*8,g+=1;else if("UTF16"===d)for(h=0;h<a.length;h+=1)(g>>>2)+1>b.length&&b.push(0),b[g>>>2]|=a.charCodeAt(h)<<16-g%4*8,g+=2;return{value:b,binLen:8*g}}function u(a){var d=[],b=a.length,c,f;if(0!==b%2)throw"String of HEX type must be in byte increments";for(c=0;c<b;c+=2){f=parseInt(a.substr(c,2),16);if(isNaN(f))throw"String of HEX type contains invalid characters";d[c>>>3]|=f<<24-c%8*4}return{value:d,binLen:4*
b}}function x(a){var d=[],b,c;for(c=0;c<a.length;c+=1)b=a.charCodeAt(c),(c>>>2)+1>d.length&&d.push(0),d[c>>>2]|=b<<24-c%4*8;return{value:d,binLen:8*a.length}}function w(a){var d=[],b=0,c,f,g,h,l;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string";c=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==c&&c<a.length)throw"Invalid '=' found in base-64 string";for(f=0;f<a.length;f+=4){l=a.substr(f,4);for(g=h=0;g<l.length;g+=1)c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(l[g]),
h|=c<<18-6*g;for(g=0;g<l.length-1;g+=1)d[b>>2]|=(h>>>16-8*g&255)<<24-b%4*8,b+=1}return{value:d,binLen:8*b}}function y(a,d){var b="",c=4*a.length,f,g;for(f=0;f<c;f+=1)g=a[f>>>2]>>>8*(3-f%4),b+="0123456789abcdef".charAt(g>>>4&15)+"0123456789abcdef".charAt(g&15);return d.outputUpper?b.toUpperCase():b}function z(a,d){var b="",c=4*a.length,f,g,h;for(f=0;f<c;f+=3)for(h=(a[f>>>2]>>>8*(3-f%4)&255)<<16|(a[f+1>>>2]>>>8*(3-(f+1)%4)&255)<<8|a[f+2>>>2]>>>8*(3-(f+2)%4)&255,g=0;4>g;g+=1)b=8*f+6*g<=32*a.length?b+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(h>>>6*(3-g)&63):b+d.b64Pad;return b}function A(a){var d="",b=4*a.length,c,f;for(c=0;c<b;c+=1)f=a[c>>>2]>>>8*(3-c%4)&255,d+=String.fromCharCode(f);return d}function B(a){var d={outputUpper:!1,b64Pad:"="};try{a.hasOwnProperty("outputUpper")&&(d.outputUpper=a.outputUpper),a.hasOwnProperty("b64Pad")&&(d.b64Pad=a.b64Pad)}catch(b){}if("boolean"!==typeof d.outputUpper)throw"Invalid outputUpper formatting option";if("string"!==typeof d.b64Pad)throw"Invalid b64Pad formatting option";
return d}function l(a,d){return a>>>d|a<<32-d}function I(a,d,b){return a&d^~a&b}function J(a,d,b){return a&d^a&b^d&b}function K(a){return l(a,2)^l(a,13)^l(a,22)}function L(a){return l(a,6)^l(a,11)^l(a,25)}function M(a){return l(a,7)^l(a,18)^a>>>3}function N(a){return l(a,17)^l(a,19)^a>>>10}function O(a,d){var b=(a&65535)+(d&65535);return((a>>>16)+(d>>>16)+(b>>>16)&65535)<<16|b&65535}function P(a,d,b,c){var f=(a&65535)+(d&65535)+(b&65535)+(c&65535);return((a>>>16)+(d>>>16)+(b>>>16)+(c>>>16)+(f>>>16)&
65535)<<16|f&65535}function Q(a,d,b,c,f){var g=(a&65535)+(d&65535)+(b&65535)+(c&65535)+(f&65535);return((a>>>16)+(d>>>16)+(b>>>16)+(c>>>16)+(f>>>16)+(g>>>16)&65535)<<16|g&65535}function q(a,d,b){var c,f,g,h,l,q,r,E,u,e,m,k,n,C,s,p,v,w,x,y,z,A,B,F,G,t=[],H,D=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,
1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];e=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,
1694076839,3204075428];c=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];if("SHA-224"===b||"SHA-256"===b)m=64,C=16,s=1,G=Number,p=O,v=P,w=Q,x=M,y=N,z=K,A=L,F=J,B=I,e="SHA-224"===b?e:c;else throw"Unexpected error in SHA-2 implementation";a[d>>>5]|=128<<24-d%32;a[(d+65>>>9<<4)+15]=d;H=a.length;for(k=0;k<H;k+=C){d=e[0];c=e[1];f=e[2];g=e[3];h=e[4];l=e[5];q=e[6];r=e[7];for(n=0;n<m;n+=1)t[n]=16>n?new G(a[n*s+k],a[n*s+k+1]):v(y(t[n-2]),t[n-7],x(t[n-15]),t[n-16]),
E=w(r,A(h),B(h,l,q),D[n],t[n]),u=p(z(d),F(d,c,f)),r=q,q=l,l=h,h=p(g,E),g=f,f=c,c=d,d=p(E,u);e[0]=p(d,e[0]);e[1]=p(c,e[1]);e[2]=p(f,e[2]);e[3]=p(g,e[3]);e[4]=p(h,e[4]);e[5]=p(l,e[5]);e[6]=p(q,e[6]);e[7]=p(r,e[7])}if("SHA-224"===b)a=[e[0],e[1],e[2],e[3],e[4],e[5],e[6]];else if("SHA-256"===b)a=e;else throw"Unexpected error in SHA-2 implementation";return a}"function"===typeof define&&define.amd?define(function(){return r}):"undefined"!==typeof exports?"undefined"!==typeof module&&module.exports?module.exports=
exports=r:exports=r:D.jsSHA=r})(this);
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
http://www.onlyoffice.com
*/
html {
height: 100%;
width: 100%;
}
body {
background: #fff;
color: #333;
font-family: Arial, Tahoma,sans-serif;
font-size: 12px;
font-weight: normal;
height: 100%;
margin: 0;
padding: 0;
text-decoration: none;
}
form {
height: 100%;
}
div {
margin: 0;
padding: 0;
}
.top-panel {
background: url("logo.png") no-repeat 30px center #3D4A6B;
height: 80px;
width: 100%;
}
.main-panel {
margin: 105px auto 0;
width: 350px;
}
.portal-name {
color: #3D4A6B;
font-size: 20px;
}
.portal-descr {
display: inline-block;
line-height: 20px;
margin-bottom: 24px;
width: 480px;
}
.document-url {
height: 65px;
resize: vertical;
width: 350px;
}
.embedded {
margin: 105px auto 0;
width: 640px;
}
.button, .button:visited, .button:hover, .button:active {
display: inline-block;
font-weight: normal;
text-align: center;
text-decoration: none;
vertical-align: middle;
cursor:pointer;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
touch-callout: none;
-o-touch-callout: none;
-moz-touch-callout: none;
-webkit-touch-callout: none;
user-select: none;
-o-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
font-size: 12px;
line-height: 16px;
padding: 2px 12px;
color: #fff;
background: #3D96C6;
background: linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -o-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -moz-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
background: -webkit-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76a6);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#59B1E2', EndColorStr='#1A76a6')";
border-width: 1px;
border-style: solid;
border-color: #4da9dc #4098c9 #2d7399 #4098c9;
}
\ No newline at end of file
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
http://www.onlyoffice.com
*/
function vkey(document_id) {
var tenant_id = "_ContactUs_";
var secret_key = "_ContactUs_";
var ms = Date.now().valueOf();
var primary_key = "{\"expire\":\"\\/Date(" + ms + ")\\/\",\"key\":\"" + document_id + "\",\"key_id\":\"" + tenant_id + "\",\"user_count\":0}";
return Create(primary_key, secret_key);
}
function Create(primary_key, secret_key) {
var secret_hash = GetHashBase64(primary_key + secret_key);
var payload = secret_hash + "?" + primary_key;
var data = Base64.encode(payload);
var cnt = 0;
while (data.indexOf('=') !== -1) {
cnt++;
data = data.replace('=', '');
}
data = (data + cnt).replace(/\+/g, '/').replace(/-/g, '_').replace(/\//g, '_');
return data;
};
function GetHashBase64(t) {
var data = new jsSHA(t, 'TEXT').getHash('SHA-256', 'B64', 1)
return data
};
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
encode_arr : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode_arr(input);
while (i < input.length) {
chr1 = input[i++];
chr2 = input[i++];
chr3 = input[i++];
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
_utf8_encode_arr : function (string) {
//string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string[n];
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
};
initEditor(docKey, vkey(docKey));
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
</properties>
<spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
<word>api</word>
<word>app</word>
<word>apps</word>
<word>Ascensio</word>
<word>ashx</word>
<word>bafa</word>
<word>bda</word>
<word>ca</word>
<word>ce</word>
<word>ContactUs</word>
<word>ConvertService</word>
<word>csv</word>
<word>djvu</word>
<word>docservice</word>
<word>docx</word>
<word>eb</word>
<word>epub</word>
<word>fb</word>
<word>filesize</word>
<word>FileUploader</word>
<word>htm</word>
<word>html</word>
<word>http</word>
<word>https</word>
<word>ISA</word>
<word>js</word>
<word>mht</word>
<word>odp</word>
<word>ods</word>
<word>odt</word>
<word>OfficeWeb</word>
<word>ONLYOFFICE</word>
<word>pdf</word>
<word>pps</word>
<word>ppsx</word>
<word>ppt</word>
<word>pptx</word>
<word>ResourceService</word>
<word>rtf</word>
<word>SIA</word>
<word>teamlab</word>
<word>txt</word>
<word>url</word>
<word>xls</word>
<word>xlsx</word>
<word>XML</word>
<word>xps</word>
</spellchecker-wordlist>
</project-shared-configuration>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>onlyoffice.com</groupId>
<artifactId>OnlineEditorsExampleJava</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>OnlineEditorsExampleJava</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package controllers;
import helpers.ConfigManager;
import helpers.DocumentManager;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import entities.FileModel;
@WebServlet(name = "EditorServlet", urlPatterns = {"/EditorServlet"})
public class EditorServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String mode = request.getParameter("mode");
String fileExt = request.getParameter("fileExt");
String fileName = request.getParameter("fileName");
DocumentManager.Init(request, response);
if(fileExt != null)
{
try
{
fileName = DocumentManager.CreateDemo(fileExt);
}
catch (Exception ex)
{
response.getWriter().write("Error: " + ex.getMessage());
}
}
Boolean desktopMode = !"embedded".equals(mode);
FileModel file = new FileModel();
file.SetTypeDesktop(desktopMode);
file.SetFileName(fileName);
request.setAttribute("file", file);
request.setAttribute("mode", mode);
request.setAttribute("type", desktopMode ? "desktop" : "embedded");
request.setAttribute("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.api"));
request.getRequestDispatcher("editor.jsp").forward(request, response);
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
}
package controllers;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class GlobalServletContextListener implements ServletContextListener{
@Override
public void contextDestroyed(ServletContextEvent arg0) {
System.out.println("ServletContextListener destroyed");
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers()
{
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType)
{
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType)
{
}
}
};
SSLContext sc;
try
{
sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
catch (NoSuchAlgorithmException | KeyManagementException ex)
{
}
HostnameVerifier allHostsValid = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
System.out.println("ServletContextListener started");
}
}
\ No newline at end of file
package entities;
import helpers.DocumentManager;
import helpers.ServiceConverter;
import helpers.FileUtility;
public class FileModel
{
private String FileName;
private Boolean TypeDesktop;
public String GetFileName()
{
return FileName;
}
public void SetFileName(String fileName)
{
this.FileName = fileName;
}
public Boolean GetTypeDesktop()
{
return TypeDesktop;
}
public void SetTypeDesktop(Boolean typeDesktop)
{
this.TypeDesktop = typeDesktop;
}
public String GetFileUri() throws Exception
{
return DocumentManager.GetFileUri(FileName);
}
public String GetDocumentType()
{
return FileUtility.GetFileType(FileName).toString().toLowerCase();
}
public String GetKey()
{
return ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + "/" + FileName);
}
public String GetValidateKey()
{
return ServiceConverter.GenerateValidateKey(GetKey());
}
public String GetCallbackUrl()
{
return DocumentManager.GetCallback(FileName);
}
}
package entities;
public enum FileType {
Text,
Spreadsheet,
Presentation
}
\ No newline at end of file
package entities;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date;
import org.json.simple.JSONObject;
public class Signature {
static {}
public static String Create(Date expire, String key, Object key_id, int user_count, String ip, String secret)
{
try
{
JSONObject jsonObj = new JSONObject();
jsonObj.put("expire", "/Date("+ expire.getTime() +")/");
jsonObj.put("key", key);
jsonObj.put("key_id", key_id);
jsonObj.put("user_count", user_count);
jsonObj.put("ip", ip == null ? "" : ip);
String str = jsonObj.toString();
String payload = GetHashBase64(str + secret) + "?" + str;
return UrlTokenEncode(payload.getBytes("UTF-8"));
}
catch(Exception ex)
{
return null;
}
}
private static String GetHashBase64(String str)
{
try
{
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(str.getBytes("UTF-8"));
return Base64.getEncoder().encodeToString(md.digest());
}
catch (NoSuchAlgorithmException | UnsupportedEncodingException ex)
{
return null;
}
}
private static String UrlTokenEncode(byte [] input)
{
if (input == null)
return null;
if (input.length < 1)
return "";
String base64Str = null;
int endPos = 0;
char[] base64Chars = null;
// Step 1: Do a Base64 encoding
base64Str = Base64.getEncoder().encodeToString(input);
if (base64Str == null)
return null;
// Step 2: Find how many padding chars are present in the end
for (endPos = base64Str.length(); endPos > 0; endPos--)
{
if (base64Str.charAt(endPos - 1) != '=') // Found a non-padding char!
{
break; // Stop here
}
}
// Step 3: Create char array to store all non-padding chars,
// plus a char to indicate how many padding chars are needed
base64Chars = new char[endPos + 1];
base64Chars[endPos] = (char)((int)'0' + base64Str.length() - endPos); // Store a char at the end, to indicate how many padding chars are needed
// Step 3: Copy in the other chars. Transform the "+" to "-", and "/" to "_"
for (int iter = 0; iter < endPos; iter++)
{
char c = base64Str.charAt(iter);
switch (c)
{
case '+':
base64Chars[iter] = '-';
break;
case '/':
base64Chars[iter] = '_';
break;
case '=':
base64Chars[iter] = c;
break;
default:
base64Chars[iter] = c;
break;
}
}
return new String(base64Chars);
}
}
package helpers;
import java.io.InputStream;
import java.util.Properties;
public class ConfigManager {
private static Properties properties;
static
{
Init();
}
private static void Init()
{
try
{
properties = new Properties();
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("settings.properties");
properties.load(stream);
}
catch (Exception ex)
{
properties = null;
}
}
public static String GetProperty(String name){
if(properties == null)
return "";
String property = properties.getProperty(name);
return property == null ? "" : property;
}
}
\ No newline at end of file
package helpers;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javafx.util.Pair;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import entities.FileType;
public class DocumentManager
{
private static HttpServletRequest request;
private static HttpServletResponse response;
private static final Map<String, String> CacheMap = new HashMap<>();
private static final String ExternalIPCacheKey = "ExternalIPCacheKey";
public static void Init(HttpServletRequest req, HttpServletResponse resp){
request = req;
response = resp;
}
public static long GetMaxFileSize()
{
long size;
try
{
size = Long.parseLong(ConfigManager.GetProperty("filesize-max"));
}
catch(Exception ex)
{
size = 0;
}
return size > 0 ? size : 5 * 1024 * 1024;
}
public static List<String> GetFileExts()
{
List<String> res = new ArrayList<>();
res.addAll(GetViewedExts());
res.addAll(GetEditedExts());
res.addAll(GetConvertExts());
return res;
}
public static List<String> GetViewedExts()
{
String exts = ConfigManager.GetProperty("files.docservice.viewed-docs");
return Arrays.asList(exts.split("\\|"));
}
public static List<String> GetEditedExts()
{
String exts = ConfigManager.GetProperty("files.docservice.edited-docs");
return Arrays.asList(exts.split("\\|"));
}
public static List<String> GetConvertExts()
{
String exts = ConfigManager.GetProperty("files.docservice.convert-docs");
return Arrays.asList(exts.split("\\|"));
}
public static String CurUserHostAddress(String userAddress)
{
if(userAddress == null)
{
try
{
userAddress = InetAddress.getLocalHost().getHostAddress();
}
catch(Exception ex)
{
userAddress = "";
}
}
return userAddress.replaceAll("[^0-9a-zA-Z.=]", "_");
}
public static String StoragePath(String fileName, String userAddress)
{
String serverPath = request.getSession().getServletContext().getRealPath("");
String storagePath = ConfigManager.GetProperty("storage-folder");
String hostAddress = CurUserHostAddress(userAddress);
String directory = serverPath + "\\" + storagePath + "\\";
File file = new File(directory);
if (!file.exists())
{
file.mkdir();
}
directory = directory + hostAddress + "\\";
file = new File(directory);
if (!file.exists())
{
file.mkdir();
}
return directory + fileName;
}
public static String GetCorrectName(String fileName)
{
String baseName = FileUtility.GetFileNameWithoutExtension(fileName);
String ext = FileUtility.GetFileExtension(fileName);
String name = baseName + ext;
File file = new File(StoragePath(name, null));
for (int i = 1; file.exists(); i++)
{
name = baseName + " (" + i + ")" + ext;
file = new File(StoragePath(name, null));
}
return name;
}
public static String CreateDemo(String fileExt) throws Exception
{
String demoName = "sample." + fileExt;
String fileName = GetCorrectName(demoName);
try
{
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(demoName);
File file = new File(StoragePath(fileName, null));
try (FileOutputStream out = new FileOutputStream(file)) {
int read;
final byte[] bytes = new byte[1024];
while ((read = stream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
}
}
catch(Exception ex)
{
throw ex;
}
return fileName;
}
public static String GetFileUri(String fileName) throws Exception
{
try
{
String serverPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
String storagePath = ConfigManager.GetProperty("storage-folder");
String hostAddress = CurUserHostAddress(null);
String filePath = serverPath + "/" + storagePath + "/" + hostAddress + "/" + URLEncoder.encode(fileName);
if (HaveExternalIP(filePath))
{
return filePath;
}
return GetExternalUri(filePath);
}
catch(Exception ex)
{
throw ex;
}
}
public static String GetCallback(String fileName)
{
String serverPath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
String hostAddress = CurUserHostAddress(null);
String query = "?type=track&userAddress=" + URLEncoder.encode(hostAddress) + "&fileName=" + URLEncoder.encode(fileName);
return serverPath + "/IndexServlet" + query;
}
public static Boolean HaveExternalIP(String filePath)
{
if(CacheMap.containsKey(ExternalIPCacheKey))
return Boolean.parseBoolean(CacheMap.get(ExternalIPCacheKey));
Boolean haveExternalIP = false;
try
{
String extension = FileUtility.GetFileExtension(filePath);
String internalExtension = GetInternalExtension(FileUtility.GetFileType(filePath));
Pair<Integer, String> res = ServiceConverter.GetConvertedUri(filePath, extension, internalExtension, UUID.randomUUID().toString(), false);
if(res != null)
{
haveExternalIP = true;
}
}
catch (Exception ex)
{
haveExternalIP = false;
}
CacheMap.put(ExternalIPCacheKey, haveExternalIP.toString());
return haveExternalIP;
}
public static String GetExternalUri(String localUri) throws Exception
{
String documentRevisionId = ServiceConverter.GenerateRevisionId(localUri);
if(CacheMap.containsKey(documentRevisionId))
return CacheMap.get(documentRevisionId);
try
{
URL url = new URL(localUri);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
InputStream inputStream = connection.getInputStream();
String contentType = connection.getContentType();
String externalUri = ServiceConverter.GetExternalUri(inputStream, inputStream.available(), contentType, documentRevisionId);
connection.disconnect();
CacheMap.put(documentRevisionId, externalUri);
return externalUri;
}
catch (Exception ex)
{
throw ex;
}
}
public static String GetInternalExtension(FileType fileType)
{
if(fileType.equals(FileType.Text))
return ".docx";
if(fileType.equals(FileType.Spreadsheet))
return ".xlsx";
if(fileType.equals(FileType.Presentation))
return ".pptx";
return ".docx";
}
}
\ No newline at end of file
package helpers;
import entities.FileType;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FileUtility
{
static {}
public static FileType GetFileType(String fileName)
{
String ext = GetFileExtension(fileName).toLowerCase();
if (ExtsDocument.contains(ext))
return FileType.Text;
if (ExtsSpreadsheet.contains(ext))
return FileType.Spreadsheet;
if (ExtsPresentation.contains(ext))
return FileType.Presentation;
return FileType.Text;
}
public static List<String> ExtsDocument = Arrays.asList
(
".docx", ".doc", ".odt", ".rtf", ".txt",
".html", ".htm", ".mht", ".pdf", ".djvu",
".fb2", ".epub", ".xps"
);
public static List<String> ExtsSpreadsheet = Arrays.asList
(
".xls", ".xlsx", ".ods", ".csv"
);
public static List<String> ExtsPresentation = Arrays.asList
(
".ppt", ".pptx",".odp"
);
public static String GetFileName (String url)
{
if(url == null) return null;
//for external file url
String tempstorage = ConfigManager.GetProperty("files.docservice.url.tempstorage");
if(!tempstorage.isEmpty() && url.startsWith(tempstorage))
{
Map<String, String> params = GetUrlParams(url);
return params == null ? null : params.get("filename");
}
String fileName = url.substring(url.lastIndexOf('/')+1, url.length());
return fileName;
}
public static String GetFileNameWithoutExtension (String url)
{
String fileName = GetFileName(url);
if(fileName == null) return null;
String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf('.'));
return fileNameWithoutExt;
}
public static String GetFileExtension (String url)
{
String fileName = GetFileName(url);
if(fileName == null) return null;
String fileExt = fileName.substring(fileName.lastIndexOf("."));
return fileExt.toLowerCase();
}
public static Map<String, String> GetUrlParams (String url)
{
try
{
String query = new URL(url).getQuery();
String[] params = query.split("&");
Map<String, String> map = new HashMap<>();
for (String param : params)
{
String name = param.split("=")[0];
String value = param.split("=")[1];
map.put(name, value);
}
return map;
}
catch (Exception ex)
{
return null;
}
}
}
filesize-max=5242880
storage-folder=app_data
files.docservice.viewed-docs=.ppt|.pps|.odp|.pdf|.djvu|.fb2|.epub|.xps
files.docservice.edited-docs=.docx|.doc|.odt|.xlsx|.xls|.ods|.csv|.pptx|.ppsx|.rtf|.txt|.mht|.html|.htm
files.docservice.convert-docs=.doc|.odt|.xls|.ods|.ppt|.pps|.odp|.rtf|.mht|.html|.htm|.fb2|.epub
files.docservice.timeout=120000
files.docservice.tenantid=ContactUs
files.docservice.key=ContactUs
files.docservice.url.storage=https://doc.onlyoffice.com/FileUploader.ashx
files.docservice.url.converter=https://doc.onlyoffice.com/ConvertService.ashx
files.docservice.url.tempstorage=https://doc.onlyoffice.com/ResourceService.ashx
files.docservice.url.api=https://doc.onlyoffice.com/OfficeWeb/apps/api/documents/api.js?_dc=2014-12-19
files.docservice.url.preloader=https://doc.onlyoffice.com/OfficeWeb/apps/api/documents/cache-scripts.html?_dc=2014-12-19
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<listener>
<listener-class>
controllers.GlobalServletContextListener
</listener-class>
</listener>
</web-app>
\ No newline at end of file
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
http://www.onlyoffice.com
*/
html {
height: 100%;
width: 100%;
}
body {
background: #fff;
color: #333;
font-family: Arial, Tahoma,sans-serif;
font-size: 12px;
font-weight: normal;
height: 100%;
margin: 0;
overflow-y: hidden;
padding: 0;
text-decoration: none;
}
.form {
height: 100%;
}
div {
margin: 0;
padding: 0;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
using System.Web.Optimization;
namespace OnlineEditorsExampleMVC
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui.js",
"~/Scripts/jquery.blockUI.js",
"~/Scripts/jquery.iframe-transport.js",
"~/Scripts/jquery.fileupload.js",
"~/Scripts/jquery.dropdownToggle.js"
));
bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
"~/Scripts/jscript.js"
));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/stylesheet.css",
"~/Content/jquery-ui.css"
));
bundles.Add(new StyleBundle("~/Content/editor").Include(
"~/Content/editor.css"
));
}
}
}
\ No newline at end of file
using System.Web.Mvc;
namespace OnlineEditorsExampleMVC
{
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
}
}
\ No newline at end of file
using System.Web.Mvc;
using System.Web.Routing;
namespace OnlineEditorsExampleMVC
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{action}",
defaults: new { controller = "Home", action = "Index" }
);
}
}
}
\ No newline at end of file
using System.Web.Http;
namespace OnlineEditorsExampleMVC
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
}
}
}
/*
Copyright (c) Ascensio System SIA 2014. All rights reserved.
http://www.onlyoffice.com
*/
html {
height: 100%;
width: 100%;
}
body {
background: #fff;
color: #333;
font-family: Arial, Tahoma,sans-serif;
font-size: 12px;
font-weight: normal;
height: 100%;
margin: 0;
overflow-y: hidden;
padding: 0;
text-decoration: none;
}
.form {
height: 100%;
}
div {
margin: 0;
padding: 0;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment