console
$(function () {
var docEditor;
var innerAlert = function (message) {
if (console && console.log)
console.log(message);
};
var onAppReady = function () {
innerAlert("文档已就绪~");
var about = $("#left-btn-about")
debugger
console.log(about.css("display"))
};
var onDocumentStateChange = function (event) {
var title = document.title.replace(/\*$/g, "");
document.title = title + (event.data ? "*" : "");
};
var onRequestEditRights = function () {
location.href = location.href.replace(RegExp("mode=view\&?", "i"), "");
};
var onError = function (event) {
if (event)
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
var getUrlParam = function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return decodeURI(r[2]);
}
return null;
};
var getDocument = function () {
var fileName = getUrlParam('file');
!fileName && (fileName = "doc.doc");
var ext = fileName.substr(fileName.lastIndexOf(".") + 1);
return {
"document": {
"fileType": ext,
"key": "sherlocky_oss_office_" + new Date().getMilliseconds() + "_" + fileName,
"title": "测试文档" + fileName,
"url": "http://sherlocky.oss.sherlocky.com/office/" + fileName,
"info": {
"author": "John Smith",
"created": "2010-07-07 3:46 PM",
"folder": "Example Files",
"sharingSettings": [
{
"permissions": "Full Access",
"user": "John Smith"
},
{
"permissions": "Read Only",
"user": "Kate Cage"
},]
},
"permissions": {
"comment": true,
"download": true,
"edit": true,
"fillForms": true,
"print": true,
"review": true
},
}
};
};
var сonnectEditor = function () {
var config = getDocument();
config.width = "100%";
config.height = "100%";
config.events = {
"onAppReady": onAppReady,
"onDocumentStateChange": onDocumentStateChange,
"onError": onError,
"onOutdatedVersion": onOutdatedVersion
};
config.editorConfig = {
"callbackUrl": "http:/127.0.0.1:8080/api/callback",
"lang": "zh-CN",
"mode": "view",
"recent": [
],
"user": {
"id": "123456",
"name": "Sherlock"
}
,
"customization": {
"chat": false,
"commentAuthorOnly": true,
"comments": false,
"compactHeader": false,
"compactToolbar": false,
"feedback": {
"visible": false
},
"customer": {
"address": "My City, 123a-45",
"info": "Some additional information",
"logo": "https://example.com/logo-big.png",
"mail": "john@example.com",
"name": "John Smith and Co.",
"www": "example.com"
},
"forcesave": false,
"goback": false,
"plugins": false,
"hideLeftMenu": false,
"help": false,
"hideRightMenu": false,
"showReviewChanges": false,
"toolbarNoTabs": false,
"zoom": 100
}
};
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
};
сonnectEditor();
});
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
<head>
<title>OnlyOffice预览测试demo</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script type="text/javascript" src="http://120.77.151.83:88/web-apps/apps/api/documents/api.js" ></script>
</head>
<body>
<div class="form">
<div id="iframeEditor"></div>
</div>
</body>
</html>
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%;
}
.tool-menu-btns {
display: none !important;
width: 40px;
height: 100%;
position: absolute;
padding-top: 15px;
}
div {
margin: 0;
padding: 0;
}