mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
spellcheck var -> let + const
This commit is contained in:
@ -32,19 +32,19 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var sockjs = require('sockjs'),
|
const sockjs = require('sockjs');
|
||||||
nodehun = require('nodehun'),
|
const nodehun = require('nodehun');
|
||||||
config = require('config').get('SpellChecker'),
|
const config = require('config').get('SpellChecker');
|
||||||
logger = require('./../../Common/sources/logger'),
|
const logger = require('./../../Common/sources/logger');
|
||||||
fs = require('fs'),
|
const fs = require('fs');
|
||||||
cfgSockjsUrl = require('config').get('services.CoAuthoring.server.sockjsUrl');
|
const cfgSockjsUrl = require('config').get('services.CoAuthoring.server.sockjsUrl');
|
||||||
var arrDictionaries = {};
|
let arrDictionaries = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Read dictionaries
|
// Read dictionaries
|
||||||
var arrDictionariesConfig = config.get('dictionaries');
|
const arrDictionariesConfig = config.get('dictionaries');
|
||||||
var oDictTmp = null, pathTmp = '', oDictName = null;
|
let oDictTmp = null, pathTmp = '', oDictName = null;
|
||||||
for (var indexDict = 0, lengthDict = arrDictionariesConfig.length; indexDict < lengthDict; ++indexDict) {
|
for (let indexDict = 0, lengthDict = arrDictionariesConfig.length; indexDict < lengthDict; ++indexDict) {
|
||||||
oDictTmp = arrDictionariesConfig[indexDict];
|
oDictTmp = arrDictionariesConfig[indexDict];
|
||||||
oDictName = oDictTmp.name;
|
oDictName = oDictTmp.name;
|
||||||
pathTmp = __dirname + '/../dictionaries/' + oDictName + '/' + oDictName + '.';
|
pathTmp = __dirname + '/../dictionaries/' + oDictName + '/' + oDictName + '.';
|
||||||
@ -71,8 +71,8 @@ CheckDictionary(arrDictionaries[0x0409], 'color', 'calor');*/
|
|||||||
|
|
||||||
exports.install = function (server, callbackFunction) {
|
exports.install = function (server, callbackFunction) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var sockjs_opts = {sockjs_url: cfgSockjsUrl},
|
const sockjs_opts = {sockjs_url: cfgSockjsUrl};
|
||||||
sockjs_echo = sockjs.createServer(sockjs_opts);
|
const sockjs_echo = sockjs.createServer(sockjs_opts);
|
||||||
|
|
||||||
sockjs_echo.on('connection', function (conn) {
|
sockjs_echo.on('connection', function (conn) {
|
||||||
if (null == conn) {
|
if (null == conn) {
|
||||||
@ -81,7 +81,7 @@ exports.install = function (server, callbackFunction) {
|
|||||||
}
|
}
|
||||||
conn.on('data', function (message) {
|
conn.on('data', function (message) {
|
||||||
try {
|
try {
|
||||||
var data = JSON.parse(message);
|
let data = JSON.parse(message);
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'spellCheck': spellCheck(conn, data);break;
|
case 'spellCheck': spellCheck(conn, data);break;
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ exports.install = function (server, callbackFunction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function spellCheck(conn, data) {
|
function spellCheck(conn, data) {
|
||||||
var oSpellInfo;
|
let oSpellInfo;
|
||||||
function checkEnd() {
|
function checkEnd() {
|
||||||
if (0 === oSpellInfo.usrWordsLength) {
|
if (0 === oSpellInfo.usrWordsLength) {
|
||||||
sendData(conn, { type:"spellCheck", spellCheckData:JSON.stringify(data) });
|
sendData(conn, { type:"spellCheck", spellCheckData:JSON.stringify(data) });
|
||||||
@ -111,7 +111,7 @@ exports.install = function (server, callbackFunction) {
|
|||||||
function spellSuggest(index, word, lang) {
|
function spellSuggest(index, word, lang) {
|
||||||
oSpellInfo.arrTimes[index] = new Date();
|
oSpellInfo.arrTimes[index] = new Date();
|
||||||
logger.info('start %s word = %s, lang = %s', data.type, word, lang);
|
logger.info('start %s word = %s, lang = %s', data.type, word, lang);
|
||||||
var oDictionary = arrDictionaries[lang];
|
const oDictionary = arrDictionaries[lang];
|
||||||
if (!oDictionary) {
|
if (!oDictionary) {
|
||||||
data.usrCorrect[index] = true;
|
data.usrCorrect[index] = true;
|
||||||
--data.usrWordsLength;
|
--data.usrWordsLength;
|
||||||
@ -141,7 +141,7 @@ exports.install = function (server, callbackFunction) {
|
|||||||
oSpellInfo = {usrWordsLength: data.usrWords.length, arrTimes: []};
|
oSpellInfo = {usrWordsLength: data.usrWords.length, arrTimes: []};
|
||||||
|
|
||||||
//data.start = new Date();
|
//data.start = new Date();
|
||||||
for (var i = 0, length = data.usrWords.length; i < length; ++i) {
|
for (let i = 0, length = data.usrWords.length; i < length; ++i) {
|
||||||
spellSuggest(i, data.usrWords[i], data.usrLang[i]);
|
spellSuggest(i, data.usrWords[i], data.usrLang[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ exports.install = function (server, callbackFunction) {
|
|||||||
callbackFunction();
|
callbackFunction();
|
||||||
};
|
};
|
||||||
exports.spellSuggest = function (type, word, lang, callbackFunction) {
|
exports.spellSuggest = function (type, word, lang, callbackFunction) {
|
||||||
var oDictionary = arrDictionaries[lang];
|
const oDictionary = arrDictionaries[lang];
|
||||||
if (undefined === oDictionary) {
|
if (undefined === oDictionary) {
|
||||||
callbackFunction(false);
|
callbackFunction(false);
|
||||||
} else if ('spell' === type) {
|
} else if ('spell' === type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user