init repo
This commit is contained in:
224
OfficeWeb/apps/api/documents/index.html
Normal file
224
OfficeWeb/apps/api/documents/index.html
Normal file
@@ -0,0 +1,224 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>ONLYOFFICE Documents</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8"/>
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-touch-fullscreen" content="yes">
|
||||
|
||||
<style type="text/css">
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#wrap {
|
||||
position:absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrap">
|
||||
<div id="placeholder"></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="api.js"></script>
|
||||
<script>
|
||||
(function() {
|
||||
|
||||
// Url parameters
|
||||
|
||||
var urlParams = getUrlParams(),
|
||||
cfg = getEditorConfig(urlParams),
|
||||
doc = getDocumentData(urlParams);
|
||||
|
||||
|
||||
// Document Editor
|
||||
|
||||
var docEditor = new DocsAPI.DocEditor('placeholder', {
|
||||
type: urlParams['type'],
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
documentType: urlParams['doctype'],
|
||||
document: doc,
|
||||
editorConfig: cfg,
|
||||
events: {
|
||||
'onReady': onDocEditorReady,
|
||||
'onBack': onBack,
|
||||
'onDocumentStateChange': onDocumentStateChange,
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
'onSave': onDocumentSave,
|
||||
'onError': onError
|
||||
}
|
||||
});
|
||||
|
||||
// Document Editor event handlers
|
||||
|
||||
function onDocEditorReady(event) {
|
||||
if (event.target) {
|
||||
//console.log('Ready! Editor: ', event.target);
|
||||
}
|
||||
}
|
||||
|
||||
function onBack(event) {
|
||||
//console.log('Go back!');
|
||||
}
|
||||
|
||||
function onDocumentStateChange(event) {
|
||||
var isModified = event.data;
|
||||
//console.log(isModified);
|
||||
}
|
||||
|
||||
function onRequestEditRights(event) {
|
||||
// occurs whenever the user tryes to enter edit mode
|
||||
docEditor.applyEditRights(true, "Someone is editing this document right now. Please try again later.");
|
||||
}
|
||||
|
||||
function onDocumentSave(event) {
|
||||
var url = event.data;
|
||||
// if you want to async save process return false
|
||||
// and call api.processSaveResult when ready
|
||||
}
|
||||
|
||||
function onError(event) {
|
||||
// critical error happened
|
||||
// examine event.data.errorCode and event.data.errorDescription for details
|
||||
}
|
||||
|
||||
|
||||
// helpers
|
||||
|
||||
function getUrlParams() {
|
||||
var e,
|
||||
a = /\+/g, // Regex for replacing addition symbol with a space
|
||||
r = /([^&=]+)=?([^&]*)/g,
|
||||
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
|
||||
q = window.location.search.substring(1),
|
||||
urlParams = {};
|
||||
|
||||
while (e = r.exec(q))
|
||||
urlParams[d(e[1])] = d(e[2]);
|
||||
|
||||
return urlParams;
|
||||
}
|
||||
|
||||
function getDocumentData(urlParams) {
|
||||
return {
|
||||
key: urlParams["key"],
|
||||
url: urlParams["url"],
|
||||
title: urlParams["title"],
|
||||
fileType: urlParams["filetype"],
|
||||
vkey: urlParams["vkey"],
|
||||
permissions: {
|
||||
edit: true,
|
||||
download: true,
|
||||
reader: true
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getEditorConfig(urlParams) {
|
||||
return {
|
||||
mode : urlParams["mode"] || 'edit',
|
||||
lang : urlParams["lang"] || 'en',
|
||||
canCoAuthoring : true,
|
||||
canBackToFolder : true,
|
||||
canCreateNew : true,
|
||||
createUrl : 'http://www.example.com/create',
|
||||
|
||||
user: {
|
||||
id: urlParams["userid"] || 'uid-901', name: urlParams["username"] || 'Hamish Mitchell'
|
||||
},
|
||||
recent : [
|
||||
{title: 'Memory.docx', url: 'http://onlyoffice.com', folder: 'Document Editor'},
|
||||
{title: 'Description.doc', url: 'http://onlyoffice.com', folder: 'Document Editor'},
|
||||
{title: 'DocEditor_right.xsl', url: 'http://onlyoffice.com', folder: 'Spreadsheet Editor'},
|
||||
{title: 'api.rtf', url: 'http://onlyoffice.com', folder: 'Unnamed folder'}
|
||||
],
|
||||
templates : [
|
||||
{name: 'Contracts', icon: '../../api/documents/resources/templates/contracts.png'},
|
||||
{name: 'Letter', icon: '../../api/documents/resources/templates/letter.png'},
|
||||
{name: 'List', icon: '../../api/documents/resources/templates/list.png'},
|
||||
{name: 'Plan', icon: '../../api/documents/resources/templates/plan.png'}
|
||||
],
|
||||
embedded : {
|
||||
embedUrl : 'http://onlyoffice.com/embed',
|
||||
fullscreenUrl : 'http://onlyoffice.com/fullscreen',
|
||||
saveUrl : 'http://onlyoffice.com/download',
|
||||
shareUrl : 'http://tl.com/72b4la97',
|
||||
toolbarDocked : 'top'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Mobile version
|
||||
|
||||
function isMobile(){
|
||||
var prefixes = {
|
||||
ios: 'i(?:Pad|Phone|Pod)(?:.*)CPU(?: iPhone)? OS ',
|
||||
android: '(Android |HTC_|Silk/)',
|
||||
blackberry: 'BlackBerry(?:.*)Version\/',
|
||||
rimTablet: 'RIM Tablet OS ',
|
||||
webos: '(?:webOS|hpwOS)\/',
|
||||
bada: 'Bada\/'
|
||||
},
|
||||
i, prefix, match;
|
||||
|
||||
for (i in prefixes){
|
||||
if (prefixes.hasOwnProperty(i)) {
|
||||
prefix = prefixes[i];
|
||||
|
||||
if (navigator.userAgent.match(new RegExp('(?:'+prefix+')([^\\s;]+)')))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var fixSize = function() {
|
||||
var wrapEl = document.getElementById('wrap');
|
||||
if (wrapEl){
|
||||
wrapEl.style.height = screen.availHeight + 'px';
|
||||
window.scrollTo(0, -1);
|
||||
wrapEl.style.height = window.innerHeight + 'px';
|
||||
}
|
||||
};
|
||||
|
||||
var fixIpadLandscapeIos7 = function() {
|
||||
if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {
|
||||
var wrapEl = document.getElementById('wrap');
|
||||
if (wrapEl){
|
||||
wrapEl.style.position = "fixed";
|
||||
wrapEl.style.bottom = 0;
|
||||
wrapEl.style.width = "100%";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (isMobile()){
|
||||
window.addEventListener('load', fixSize);
|
||||
window.addEventListener('resize', fixSize);
|
||||
|
||||
fixIpadLandscapeIos7();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user