mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 16:36:15 -04:00
lint: Put opening brace on same line as function
Normally I would let `eslint --fix` do this for me, but there's a bug that causes: const x = function () { // ... }; to become: const x = () => { // ... }; which ESLint thinks is a syntax error. (It probably is; I don't know enough about the automatic semicolon insertion rules to be confident.)
This commit is contained in:
parent
cc988bd67b
commit
7df3ded66f
66 changed files with 1036 additions and 2072 deletions
|
@ -30,27 +30,23 @@ if(os.type().indexOf("Windows") > -1)
|
|||
{
|
||||
var stdoutBuffer = "";
|
||||
|
||||
doConvertTask = function(task, callback)
|
||||
{
|
||||
doConvertTask = function(task, callback) {
|
||||
//span an abiword process to perform the conversion
|
||||
var abiword = spawn(settings.abiword, ["--to=" + task.destFile, task.srcFile]);
|
||||
|
||||
//delegate the processing of stdout to another function
|
||||
abiword.stdout.on('data', function (data)
|
||||
{
|
||||
abiword.stdout.on('data', function (data) {
|
||||
//add data to buffer
|
||||
stdoutBuffer+=data.toString();
|
||||
});
|
||||
|
||||
//append error messages to the buffer
|
||||
abiword.stderr.on('data', function (data)
|
||||
{
|
||||
abiword.stderr.on('data', function (data) {
|
||||
stdoutBuffer += data.toString();
|
||||
});
|
||||
|
||||
//throw exceptions if abiword is dieing
|
||||
abiword.on('exit', function (code)
|
||||
{
|
||||
abiword.on('exit', function (code) {
|
||||
if(code != 0) {
|
||||
return callback(`Abiword died with exit code ${code}`);
|
||||
}
|
||||
|
@ -64,8 +60,7 @@ if(os.type().indexOf("Windows") > -1)
|
|||
});
|
||||
};
|
||||
|
||||
exports.convertFile = function(srcFile, destFile, type, callback)
|
||||
{
|
||||
exports.convertFile = function(srcFile, destFile, type, callback) {
|
||||
doConvertTask({"srcFile": srcFile, "destFile": destFile, "type": type}, callback);
|
||||
};
|
||||
}
|
||||
|
@ -82,21 +77,18 @@ else
|
|||
var firstPrompt = true;
|
||||
|
||||
//append error messages to the buffer
|
||||
abiword.stderr.on('data', function (data)
|
||||
{
|
||||
abiword.stderr.on('data', function (data) {
|
||||
stdoutBuffer += data.toString();
|
||||
});
|
||||
|
||||
//abiword died, let's restart abiword and return an error with the callback
|
||||
abiword.on('exit', function (code)
|
||||
{
|
||||
abiword.on('exit', function (code) {
|
||||
spawnAbiword();
|
||||
stdoutCallback(`Abiword died with exit code ${code}`);
|
||||
});
|
||||
|
||||
//delegate the processing of stdout to a other function
|
||||
abiword.stdout.on('data',function (data)
|
||||
{
|
||||
abiword.stdout.on('data',function (data) {
|
||||
//add data to buffer
|
||||
stdoutBuffer+=data.toString();
|
||||
|
||||
|
@ -123,12 +115,10 @@ else
|
|||
};
|
||||
spawnAbiword();
|
||||
|
||||
doConvertTask = function(task, callback)
|
||||
{
|
||||
doConvertTask = function(task, callback) {
|
||||
abiword.stdin.write("convert " + task.srcFile + " " + task.destFile + " " + task.type + "\n");
|
||||
//create a callback that calls the task callback and the caller callback
|
||||
stdoutCallback = function (err)
|
||||
{
|
||||
stdoutCallback = function (err) {
|
||||
callback();
|
||||
console.log("queue continue");
|
||||
try{
|
||||
|
@ -141,8 +131,7 @@ else
|
|||
|
||||
//Queue with the converts we have to do
|
||||
var queue = async.queue(doConvertTask, 1);
|
||||
exports.convertFile = function(srcFile, destFile, type, callback)
|
||||
{
|
||||
exports.convertFile = function(srcFile, destFile, type, callback) {
|
||||
queue.push({"srcFile": srcFile, "destFile": destFile, "type": type, "callback": callback});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ var eejs = require('ep_etherpad-lite/node/eejs');
|
|||
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
||||
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
||||
|
||||
async function getPadHTML(pad, revNum)
|
||||
{
|
||||
async function getPadHTML(pad, revNum) {
|
||||
let atext = pad.atext;
|
||||
|
||||
// fetch revision atext
|
||||
|
@ -39,8 +38,7 @@ async function getPadHTML(pad, revNum)
|
|||
exports.getPadHTML = getPadHTML;
|
||||
exports.getHTMLFromAtext = getHTMLFromAtext;
|
||||
|
||||
async function getHTMLFromAtext(pad, atext, authorColors)
|
||||
{
|
||||
async function getHTMLFromAtext(pad, atext, authorColors) {
|
||||
var apool = pad.apool();
|
||||
var textLines = atext.text.slice(0, -1).split('\n');
|
||||
var attribLines = Changeset.splitAttributionLines(atext.attribs, atext.text);
|
||||
|
@ -110,8 +108,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
|
||||
// iterates over all props(h1,h2,strong,...), checks if it is used in
|
||||
// this pad, and if yes puts its attrib id->props value into anumMap
|
||||
props.forEach(function (propName, i)
|
||||
{
|
||||
props.forEach(function (propName, i) {
|
||||
var attrib = [propName, true];
|
||||
if (_.isArray(propName)) {
|
||||
// propName can be in the form of ['color', 'red'],
|
||||
|
@ -125,8 +122,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
}
|
||||
});
|
||||
|
||||
function getLineHTML(text, attribs)
|
||||
{
|
||||
function getLineHTML(text, attribs) {
|
||||
// Use order of tags (b/i/u) as order of nesting, for simplicity
|
||||
// and decent nesting. For example,
|
||||
// <b>Just bold<b> <b><i>Bold and italics</i></b> <i>Just italics</i>
|
||||
|
@ -166,8 +162,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
return _.isArray(property);
|
||||
}
|
||||
|
||||
function emitOpenTag(i)
|
||||
{
|
||||
function emitOpenTag(i) {
|
||||
openTags.unshift(i);
|
||||
var spanClass = getSpanClassFor(i);
|
||||
|
||||
|
@ -183,8 +178,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
}
|
||||
|
||||
// this closes an open tag and removes its reference from openTags
|
||||
function emitCloseTag(i)
|
||||
{
|
||||
function emitCloseTag(i) {
|
||||
openTags.shift();
|
||||
var spanClass = getSpanClassFor(i);
|
||||
var spanWithData = isSpanWithData(i);
|
||||
|
@ -202,8 +196,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
|
||||
var idx = 0;
|
||||
|
||||
function processNextChars(numChars)
|
||||
{
|
||||
function processNextChars(numChars) {
|
||||
if (numChars <= 0)
|
||||
{
|
||||
return;
|
||||
|
@ -220,8 +213,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
var usedAttribs = [];
|
||||
|
||||
// mark all attribs as used
|
||||
Changeset.eachAttribNumber(o.attribs, function (a)
|
||||
{
|
||||
Changeset.eachAttribNumber(o.attribs, function (a) {
|
||||
if (a in anumMap)
|
||||
{
|
||||
usedAttribs.push(anumMap[a]); // i = 0 => bold, etc.
|
||||
|
@ -280,8 +272,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
} // end processNextChars
|
||||
if (urls)
|
||||
{
|
||||
urls.forEach(function (urlData)
|
||||
{
|
||||
urls.forEach(function (urlData) {
|
||||
var startIndex = urlData[0];
|
||||
var url = urlData[1];
|
||||
var urlLength = url.length;
|
||||
|
@ -341,8 +332,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
//To create list parent elements
|
||||
if ((!prevLine || prevLine.listLevel !== line.listLevel) || (prevLine && line.listTypeName !== prevLine.listTypeName))
|
||||
{
|
||||
var exists = _.find(openLists, function (item)
|
||||
{
|
||||
var exists = _.find(openLists, function (item) {
|
||||
return (item.level === line.listLevel && item.type === line.listTypeName);
|
||||
});
|
||||
if (!exists) {
|
||||
|
@ -445,8 +435,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
|
||||
for (var diff = nextLevel; diff < line.listLevel; diff++)
|
||||
{
|
||||
openLists = openLists.filter(function(el)
|
||||
{
|
||||
openLists = openLists.filter(function(el) {
|
||||
return el.level !== diff && el.type !== line.listTypeName;
|
||||
});
|
||||
|
||||
|
@ -485,8 +474,7 @@ async function getHTMLFromAtext(pad, atext, authorColors)
|
|||
return pieces.join('');
|
||||
}
|
||||
|
||||
exports.getPadHTMLDocument = async function (padId, revNum)
|
||||
{
|
||||
exports.getPadHTMLDocument = async function (padId, revNum) {
|
||||
let pad = await padManager.getPad(padId);
|
||||
|
||||
// Include some Styles into the Head for Export
|
||||
|
@ -518,8 +506,7 @@ var _REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|g
|
|||
// returns null if no URLs, or [[startIndex1, url1], [startIndex2, url2], ...]
|
||||
|
||||
|
||||
function _findURLs(text)
|
||||
{
|
||||
function _findURLs(text) {
|
||||
_REGEX_URL.lastIndex = 0;
|
||||
var urls = null;
|
||||
var execResult;
|
||||
|
|
|
@ -23,8 +23,7 @@ var padManager = require("../db/PadManager");
|
|||
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
||||
|
||||
// This is slightly different than the HTML method as it passes the output to getTXTFromAText
|
||||
var getPadTXT = async function(pad, revNum)
|
||||
{
|
||||
var getPadTXT = async function(pad, revNum) {
|
||||
let atext = pad.atext;
|
||||
|
||||
if (revNum != undefined) {
|
||||
|
@ -38,8 +37,7 @@ var getPadTXT = async function(pad, revNum)
|
|||
|
||||
// This is different than the functionality provided in ExportHtml as it provides formatting
|
||||
// functionality that is designed specifically for TXT exports
|
||||
function getTXTFromAtext(pad, atext, authorColors)
|
||||
{
|
||||
function getTXTFromAtext(pad, atext, authorColors) {
|
||||
var apool = pad.apool();
|
||||
var textLines = atext.text.slice(0, -1).split('\n');
|
||||
var attribLines = Changeset.splitAttributionLines(atext.attribs, atext.text);
|
||||
|
@ -259,8 +257,7 @@ function getTXTFromAtext(pad, atext, authorColors)
|
|||
|
||||
exports.getTXTFromAtext = getTXTFromAtext;
|
||||
|
||||
exports.getPadTXTDocument = async function(padId, revNum)
|
||||
{
|
||||
exports.getPadTXTDocument = async function(padId, revNum) {
|
||||
let pad = await padManager.getPad(padId);
|
||||
return getPadTXT(pad, revNum);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ var log4js = require('log4js');
|
|||
const db = require("../db/DB");
|
||||
const hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||
|
||||
exports.setPadRaw = function(padId, records)
|
||||
{
|
||||
exports.setPadRaw = function(padId, records) {
|
||||
records = JSON.parse(records);
|
||||
|
||||
Object.keys(records).forEach(async function(key) {
|
||||
|
|
|
@ -145,8 +145,7 @@ function requestURIs(locations, method, headers, callback) {
|
|||
* @param req the Express request
|
||||
* @param res the Express response
|
||||
*/
|
||||
function minify(req, res)
|
||||
{
|
||||
function minify(req, res) {
|
||||
var filename = req.params['filename'];
|
||||
|
||||
// No relative paths, especially if they may go up the file hierarchy.
|
||||
|
@ -318,22 +317,18 @@ function lastModifiedDateOfEverything(callback) {
|
|||
var folders2check = [ROOT_DIR + 'js/', ROOT_DIR + 'css/'];
|
||||
var latestModification = 0;
|
||||
//go trough this two folders
|
||||
async.forEach(folders2check, function(path, callback)
|
||||
{
|
||||
async.forEach(folders2check, function(path, callback) {
|
||||
//read the files in the folder
|
||||
fs.readdir(path, function(err, files)
|
||||
{
|
||||
fs.readdir(path, function(err, files) {
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//we wanna check the directory itself for changes too
|
||||
files.push(".");
|
||||
|
||||
//go trough all files in this folder
|
||||
async.forEach(files, function(filename, callback)
|
||||
{
|
||||
async.forEach(files, function(filename, callback) {
|
||||
//get the stat data of this file
|
||||
fs.stat(path + "/" + filename, function(err, stats)
|
||||
{
|
||||
fs.stat(path + "/" + filename, function(err, stats) {
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
//get the modification time
|
||||
|
|
|
@ -7,13 +7,11 @@ var Terser = require("terser");
|
|||
var path = require('path');
|
||||
var Threads = require('threads')
|
||||
|
||||
function compressJS(content)
|
||||
{
|
||||
function compressJS(content) {
|
||||
return Terser.minify(content);
|
||||
}
|
||||
|
||||
function compressCSS(filename, ROOT_DIR)
|
||||
{
|
||||
function compressCSS(filename, ROOT_DIR) {
|
||||
return new Promise((res, rej) => {
|
||||
try {
|
||||
const absPath = path.join(ROOT_DIR, filename);
|
||||
|
|
|
@ -381,8 +381,7 @@ exports.commitRateLimiting = {
|
|||
exports.importMaxFileSize = 50 * 1024 * 1024;
|
||||
|
||||
// checks if abiword is avaiable
|
||||
exports.abiwordAvailable = function()
|
||||
{
|
||||
exports.abiwordAvailable = function() {
|
||||
if (exports.abiword != null) {
|
||||
return os.type().indexOf("Windows") != -1 ? "withoutPDF" : "yes";
|
||||
} else {
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
*/
|
||||
var crypto = require('crypto');
|
||||
|
||||
var randomString = function(len)
|
||||
{
|
||||
var randomString = function(len) {
|
||||
return crypto.randomBytes(len).toString('hex')
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue