formatting and lint compliance

pull/1/head
ansuz 7 years ago
parent 480b499d7b
commit 118ceef2f2

@ -9,6 +9,7 @@ www/scratch
www/common/toolbar.js www/common/toolbar.js
www/common/hyperscript.js www/common/hyperscript.js
www/common/tippy.min.js www/common/tippy.min.js
www/common/onlyoffice/*
www/pad/wysiwygarea-plugin.js www/pad/wysiwygarea-plugin.js
www/pad/mediatag-plugin.js www/pad/mediatag-plugin.js
@ -17,3 +18,4 @@ www/pad/mediatag-plugin-dialog.js
www/common/media-tag-nacl.min.js www/common/media-tag-nacl.min.js
customize/ customize/

@ -1,6 +1,7 @@
/* jshint esversion: 6 */
const sockjs = require('sockjs'); const sockjs = require('sockjs');
const co = require('co'); var config;
try { try {
config = require('./config'); config = require('./config');
} catch (e) { } catch (e) {
@ -9,109 +10,107 @@ try {
} }
var origin = config.httpUnsafeOrigin || 'http://localhost:3000/'; var origin = config.httpUnsafeOrigin || 'http://localhost:3000/';
exports.install = function(server, callbackFunction) { module.exports.install = function(server, callbackFunction) {
var sockjs_opts = {sockjs_url: ""}, var sockjs_opts = {sockjs_url: ""},
sockjs_echo = sockjs.createServer(sockjs_opts), sockjs_echo = sockjs.createServer(sockjs_opts);
urlParse = new RegExp("^/common/onlyoffice/doc/([0-9-.a-zA-Z_=]*)/c.+", 'i'); //urlParse = new RegExp("^/common/onlyoffice/doc/([0-9-.a-zA-Z_=]*)/c.+", 'i');
console.log("Start ooserver"); console.log("Start ooserver");
console.log("Port " + sockjs_echo.port); console.log("Port " + sockjs_echo.port);
function getBaseUrl(protocol, hostHeader, forwardedProtoHeader, forwardedHostHeader) { function getBaseUrl(protocol, hostHeader, forwardedProtoHeader, forwardedHostHeader) {
var url = ''; var url = '';
if (forwardedProtoHeader) { if (forwardedProtoHeader) {
url += forwardedProtoHeader; url += forwardedProtoHeader;
} else if (protocol) { } else if (protocol) {
url += protocol; url += protocol;
} else { } else {
url += 'http'; url += 'http';
} }
url += '://'; url += '://';
if (forwardedHostHeader) { if (forwardedHostHeader) {
url += forwardedHostHeader; url += forwardedHostHeader;
} else if (hostHeader) { } else if (hostHeader) {
url += hostHeader; url += hostHeader;
} else { } else {
url += origin.slice(0, -1); url += origin.slice(0, -1);
} }
return url; return url;
} }
function getBaseUrlByConnection(conn) { function getBaseUrlByConnection(conn) {
return getBaseUrl('', conn.headers['host'], conn.headers['x-forwarded-proto'], conn.headers['x-forwarded-host']); return getBaseUrl('', conn.headers['host'], conn.headers['x-forwarded-proto'], conn.headers['x-forwarded-host']);
} }
function sendData(conn, data) {
conn.write(JSON.stringify(data));
}
function sendDataWarning(conn, msg) {
sendData(conn, {type: "warning", message: msg});
}
function sendDataMessage(conn, msg) {
sendData(conn, {type: "message", messages: msg});
}
sockjs_echo.on('connection', function(conn) { function sendData(conn, data) {
console.log("ooserver in connection"); conn.write(JSON.stringify(data));
if (null == conn) {
console.log("null == conn");
return;
} }
conn.baseUrl = getBaseUrlByConnection(conn); //function sendDataWarning(conn, msg) { sendData(conn, {type: "warning", message: msg}); }
console.log("BaseUrl: " + conn.baseUrl); //function sendDataMessage(conn, msg) { sendData(conn, {type: "message", messages: msg}); }
conn.sessionIsSendWarning = false;
conn.sessionTimeConnect = conn.sessionTimeLastAction = new Date().getTime(); sockjs_echo.on('connection', function(conn) {
console.log("ooserver setting handlers"); console.log("ooserver in connection");
conn.on('data', function(message) { if (null === conn) {
console.log("In data"); console.log("null == conn");
return co(function* () { return;
try {
console.log("Received: " + message);
var data = JSON.parse(message);
switch (data.type) {
case 'auth':
console.log("Response auth");
var fileUrl = origin + "oodoc/test.bin";
if (data.openCmd.format=="xlsx")
fileUrl = origin + "oocell/test.bin"
else if (data.openCmd.format=="pptx")
fileUrl = origin + "ooslide/test.bin"
sendData(conn, {"type":"auth","result":1,"sessionId":"08e77705-dc5c-477d-b73a-b1a7cbca1e9b","sessionTimeConnect":1494226099270,"participants":[]});
sendData(conn, {"type":"documentOpen","data":{"type":"open","status":"ok","data":{"Editor.bin":fileUrl}}});
break;
default:
break;
}
} catch (e) {
console.log("error receiving response: docId = %s type = %s\r\n%s", docId, (data && data.type) ? data.type : 'null', e.stack);
} }
}); conn.baseUrl = getBaseUrlByConnection(conn);
}); console.log("BaseUrl: " + conn.baseUrl);
conn.on('error', function() { conn.sessionIsSendWarning = false;
console.log("On error"); conn.sessionTimeConnect = conn.sessionTimeLastAction = new Date().getTime();
}); console.log("ooserver setting handlers");
conn.on('close', function() { conn.on('data', function(message) {
return co(function* () { console.log("In data");
console.log("On close"); var data;
}); try {
console.log("Received: " + message);
data = JSON.parse(message);
switch (data.type) {
case 'auth':
console.log("Response auth");
var fileUrl = origin + "oodoc/test.bin";
if (data.openCmd) {
if (data.openCmd.format === "xlsx") {
fileUrl = origin + "oocell/test.bin";
} else if (data.openCmd.format === "pptx") {
fileUrl = origin + "ooslide/test.bin";
}
}
sendData(conn, {"type":"auth","result":1,"sessionId":"08e77705-dc5c-477d-b73a-b1a7cbca1e9b","sessionTimeConnect":1494226099270,"participants":[]});
sendData(conn, {"type":"documentOpen","data":{"type":"open","status":"ok","data":{"Editor.bin":fileUrl}}});
break;
default:
break;
}
} catch (e) {
console.error(e);
//console.log("error receiving response: docId = %s type = %s\r\n%s", docId, (data && data.type) ? data.type : 'null', e.stack);
}
});
conn.on('error', function() {
console.log("On error");
});
conn.on('close', function() {
console.log("On close");
});
console.log("ooserver sending welcome message");
sendData(conn, {
type: 'license',
license: {
type: 3,
light: false,
trial: false,
rights: 1,
buildVersion: "4.3.3",
buildNumber: 4,
branding: false
}
});
}); });
console.log("ooserver sending welcome message");
sendData(conn, {
type: 'license',
license: {
type: 3,
light: false,
trial: false,
rights: 1,
buildVersion: "4.3.3",
buildNumber: 4,
branding: false
}
});
});
sockjs_echo.installHandlers(server, {prefix: '/common/onlyoffice/doc/[0-9-.a-zA-Z_=]*/c', log: function(severity, message) { sockjs_echo.installHandlers(server, {prefix: '/common/onlyoffice/doc/[0-9-.a-zA-Z_=]*/c', log: function(severity, message) {
console.log(message); console.log(message);
}}); }});
callbackFunction(); callbackFunction();
}; };

@ -12,7 +12,6 @@
"stream-to-pull-stream": "^1.7.2", "stream-to-pull-stream": "^1.7.2",
"tweetnacl": "~0.12.2", "tweetnacl": "~0.12.2",
"ws": "^1.0.1", "ws": "^1.0.1",
"co": "^4.6.0",
"sockjs": "^0.3.18" "sockjs": "^0.3.18"
}, },
"devDependencies": { "devDependencies": {

@ -1,4 +1,5 @@
config = { /* globals DocsAPI */
window.config = {
"document": { "document": {
"fileType": "xlsx", "fileType": "xlsx",
"key": "Khirz6zTPdfd7", "key": "Khirz6zTPdfd7",
@ -26,8 +27,8 @@ config = {
} }
console.log("in change (remote)"); console.log("in change (remote)");
}, },
"onReady": function(evt) { console.log("in onReady"); }, "onReady": function(/*evt*/) { console.log("in onReady"); },
"onAppReady": function(evt) { console.log("in onAppReady"); }, "onAppReady": function(/*evt*/) { console.log("in onAppReady"); },
} }
}; };
window.onbeforeunload = function () { window.onbeforeunload = function () {
@ -35,6 +36,5 @@ window.onbeforeunload = function () {
if (ifr) { ifr.remove(); } if (ifr) { ifr.remove(); }
}; };
window.docEditor = new DocsAPI.DocEditor("placeholder", window.config);
var docEditor = new DocsAPI.DocEditor("placeholder", config);

@ -1,4 +1,5 @@
config = { /* globals DocsAPI */
window.config = {
"document": { "document": {
"fileType": "docx", "fileType": "docx",
"key": "Khirz6zTPdfd7", "key": "Khirz6zTPdfd7",
@ -13,12 +14,11 @@ config = {
} }
}, },
"events": { "events": {
"onDocumentStateChange": function(evt) { console.log("in change"); }, "onDocumentStateChange": function (/* evt */) { console.log("in change"); },
"onReady": function(evt) { console.log("in onReady"); } "onReady": function (/* evt */) { console.log("in onReady"); }
} }
}; };
window.onbeforeunload = null; window.onbeforeunload = null;
window.docEditor = new DocsAPI.DocEditor("placeholder", window.config);
var docEditor = new DocsAPI.DocEditor("placeholder", config);

@ -1,4 +1,5 @@
config = { /* globals DocsAPI */
window.config = {
"document": { "document": {
"fileType": "pptx", "fileType": "pptx",
"key": "Khirz6zTPdfd7", "key": "Khirz6zTPdfd7",
@ -13,12 +14,12 @@ config = {
} }
}, },
"events": { "events": {
"onDocumentStateChange": function(evt) { console.log("in change"); }, "onDocumentStateChange": function (/* evt */) { console.log("in change"); },
"onReady": function(evt) { console.log("in onReady"); } "onReady": function (/* evt */) { console.log("in onReady"); }
} }
}; };
window.onbeforeunload = null; window.onbeforeunload = null;
var docEditor = new DocsAPI.DocEditor("placeholder", config); window.docEditor = new DocsAPI.DocEditor("placeholder", window.config);

Loading…
Cancel
Save