LH_Jzs
2021-04-26 dcf5a87de927e683d4bbfad3978c3d608c06e48c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
 
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>demo</title>
    <script id="scriptApi" type="text/javascript" src="https://www.51jianxie.com/ds-vpath/web-apps/apps/api/documents/api.js"></script>
</head>
 
<body>
    <div  id="placeholder"></div>
    <script type="text/javascript">
        window.onload=function(){
            initEditor("","http://sdk.51changxie.com/demo/TravelList.xlsx",true,true,true,true,"a8a62dd9-dbef-4840-b610-791d666bb92f","edit","",{"comment":false,"download":true,"edit":true,"print":true,"review":false})
        }
        function initEditor(username,docUrl, titlebarFlag, rightPanelFlag, leftPanelFlag, toobarFlag, docKey, mode, type, permission) {
            //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;
            window.docUrl = docUrl;
            //key for chaching and collaborate editing
            window.docKey = docKey;
 
            //type for document
            var docType = docUrl.substring(docUrl.lastIndexOf(".") + 1).trim().toLowerCase();
            //type for editor
            var documentType = getDocumentType(docType);
 
 
            window.permission = permission;
            window.user = username;
 
            window.user = window.user || "测试"
            var id = window.user + "-4"
            //CXO_API.CXEditor
            //creating object editing
            var onDocumentReady = function() {
                //editor.destroyEditor();
 
            }
            var onAppReady = function() {
 
            }
 
            var editor = new CXO_API.CXEditor("placeholder", {
                type: type,
                width: (type == "desktop" ? "100%" : undefined),
                height: (type == "desktop" ? "900px" : undefined),
                documentType: documentType,
                token: "eyJ0eXBlIjoiMSIsImFsZyI6IkhTNTEyIn0.e30.RgxbmTaMyvL4cYnOg2DH03JghyUeIlLTiFDZrxqM4Ai_8XGv0K1qw0DB2r9EDRmiLb9ROxzzg36J62V-2IvaXA",
                document: {
                    title: docUrl,
                    url: docUrl,
                    fileType: docType,
                    key: docKey + 2,
                    permissions: window.permission
                },
                editorConfig: {
                    mode: mode,
                    user: {
                        "id": id,
                        "name": window.user
                    },
                    customization: {
                        about: true,
                        chat: false,
                        comments: true,
                        zoom: 50,
                        leftMenu: leftPanelFlag,
                        rightMenu: rightPanelFlag,
                toolbar: toobarFlag,
                displayTitle:titlebarFlag,
                        header: true,
                        statusBar: true,
                autosave: false,
                    forcesave: false
                    },
                },
                events: {
                    'onDocumentReady': onDocumentReady,
                    'onAppReady': onAppReady
                }
            });
        }
 
        function key(k) {
            // var result = k.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_") + (new Date()).getTime();
            var result = k.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_");
            return result.substring(result.length - Math.min(result.length, 20));
        };
        var getDocumentType = function(ext) {
            if (".doc.docx.docm.dot.dotx.dotm.odt.fodt.ott.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
            if (".xls.xlsx.xlsm.xlt.xltx.xltm.ods.fods.ots.csv".indexOf(ext) != -1) return "spreadsheet";
            if (".pps.ppsx.ppsm.ppt.pptx.pptm.pot.potx.potm.odp.fodp.otp".indexOf(ext) != -1) return "presentation";
            return null;
        };
    </script>
</body>
 
</html>