web-apps/apps/api/documents/index.html.desktop

185 lines
6 KiB
Desktop File
Raw Normal View History

2016-03-11 00:48:53 +00:00
<!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'] || 'word',
2016-03-11 00:48:53 +00:00
document: doc,
editorConfig: cfg,
events: {
onInternalMessage: onInternalMessage,
2018-11-02 12:17:45 +00:00
onRequestClose: e => {return 0;}
}
2016-03-11 00:48:53 +00:00
});
// 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) {
2020-10-22 07:14:20 +00:00
let docparams = {
2016-03-11 00:48:53 +00:00
key: urlParams["key"],
url: urlParams["url"] || '_offline_',
title: urlParams["title"],
fileType: urlParams["filetype"],
vkey: urlParams["vkey"],
permissions: {
edit: true,
download: true
}
};
2020-10-22 07:14:20 +00:00
if (urlParams['mode'] == 'review')
docparams.permissions.edit = !(docparams.permissions.review = true);
return docparams;
2016-03-11 00:48:53 +00:00
}
function getEditorConfig(urlParams) {
return {
2018-01-25 08:22:47 +00:00
customization : {
2018-02-21 23:23:32 +00:00
goback: { url: "onlyoffice.com" }
2018-01-25 08:22:47 +00:00
},
2016-03-11 00:48:53 +00:00
mode : urlParams["mode"] || 'edit',
lang : urlParams["lang"] || 'en',
user: {
2019-06-28 12:08:15 +00:00
id: urlParams["userid"] || urlParams["username"] || 'uid-901', name: urlParams["username"] || 'Chuk.Gek'
2016-03-11 00:48:53 +00:00
}
};
}
// 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%";
}
}
};
function onInternalMessage(event) {
let info = event.data;
if ( info.type == 'goback' ) {
if ( window.AscDesktopEditor ) {
window.AscDesktopEditor.execCommand('go:folder', info.data.status);
}
}
};
function onDocumentReady() {
if ( window.AscDesktopEditor ) {
window.AscDesktopEditor.execCommand('doc:onready', '');
}
}
2016-03-11 00:48:53 +00:00
if (isMobile()){
window.addEventListener('load', fixSize);
window.addEventListener('resize', fixSize);
fixIpadLandscapeIos7();
}
})();
</script>
</body>
</html>