mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
Merge pull request #5352 from overleaf/jpa-no-var
[misc] fix eslint violations for `no-var` GitOrigin-RevId: c52e82f3a8a993b8662cc5aa56e7b95ca3c55832
This commit is contained in:
parent
3c780c65e8
commit
a6f05109a3
115 changed files with 299 additions and 314 deletions
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
const OError = require('@overleaf/o-error')
|
||||
|
||||
let Errors
|
||||
var NotFoundError = function (message) {
|
||||
function NotFoundError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'NotFoundError'
|
||||
error.__proto__ = NotFoundError.prototype
|
||||
|
@ -15,7 +15,7 @@ var NotFoundError = function (message) {
|
|||
}
|
||||
NotFoundError.prototype.__proto__ = Error.prototype
|
||||
|
||||
var FilesOutOfSyncError = function (message) {
|
||||
function FilesOutOfSyncError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'FilesOutOfSyncError'
|
||||
error.__proto__ = FilesOutOfSyncError.prototype
|
||||
|
@ -23,7 +23,7 @@ var FilesOutOfSyncError = function (message) {
|
|||
}
|
||||
FilesOutOfSyncError.prototype.__proto__ = Error.prototype
|
||||
|
||||
var AlreadyCompilingError = function (message) {
|
||||
function AlreadyCompilingError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'AlreadyCompilingError'
|
||||
error.__proto__ = AlreadyCompilingError.prototype
|
||||
|
|
|
@ -50,7 +50,7 @@ module.exports = UrlFetcher = {
|
|||
) {
|
||||
url = `${settings.filestoreDomainOveride}${u.pathname}${u.search}`
|
||||
}
|
||||
var timeoutHandler = setTimeout(
|
||||
let timeoutHandler = setTimeout(
|
||||
function () {
|
||||
timeoutHandler = null
|
||||
logger.error({ url, filePath }, 'Timed out downloading file to cache')
|
||||
|
|
|
@ -103,7 +103,7 @@ const compareMultiplePages = function (project_id, callback) {
|
|||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
}
|
||||
var compareNext = function (page_no, callback) {
|
||||
function compareNext(page_no, callback) {
|
||||
const path = `tmp/${project_id}-source-${page_no}.png`
|
||||
return fs.stat(fixturePath(path), (error, stat) => {
|
||||
if (error != null) {
|
||||
|
|
|
@ -142,7 +142,7 @@ module.exports = Client = {
|
|||
let entities = fs.readdirSync(`${baseDirectory}/${directory}`)
|
||||
let rootResourcePath = 'main.tex'
|
||||
while (entities.length > 0) {
|
||||
var entity = entities.pop()
|
||||
const entity = entities.pop()
|
||||
const stat = fs.statSync(`${baseDirectory}/${directory}/${entity}`)
|
||||
if (stat.isDirectory()) {
|
||||
entities = entities.concat(
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
let Errors
|
||||
var NotFoundError = function (message) {
|
||||
function NotFoundError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'NotFoundError'
|
||||
error.__proto__ = NotFoundError.prototype
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -85,7 +85,7 @@ module.exports = DeleteQueueManager = {
|
|||
}
|
||||
)
|
||||
|
||||
var flushNextProject = function () {
|
||||
function flushNextProject() {
|
||||
const now = Date.now()
|
||||
if (now - startTime > options.timeout) {
|
||||
logger.debug('hit time limit on flushing old projects')
|
||||
|
@ -126,7 +126,7 @@ module.exports = DeleteQueueManager = {
|
|||
startBackgroundFlush() {
|
||||
const SHORT_DELAY = 10
|
||||
const LONG_DELAY = 1000
|
||||
var doFlush = function () {
|
||||
function doFlush() {
|
||||
if (Settings.shuttingDown) {
|
||||
logger.info('discontinuing background flush due to shutdown')
|
||||
return
|
||||
|
|
|
@ -36,7 +36,7 @@ module.exports = DispatchManager = {
|
|||
}
|
||||
|
||||
const client = redis.createClient(Settings.redis.documentupdater)
|
||||
var worker = {
|
||||
const worker = {
|
||||
client,
|
||||
_waitForUpdateThenDispatchWorker(callback) {
|
||||
if (callback == null) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
let Errors
|
||||
var NotFoundError = function (message) {
|
||||
function NotFoundError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'NotFoundError'
|
||||
error.__proto__ = NotFoundError.prototype
|
||||
|
@ -13,7 +13,7 @@ var NotFoundError = function (message) {
|
|||
}
|
||||
NotFoundError.prototype.__proto__ = Error.prototype
|
||||
|
||||
var OpRangeNotAvailableError = function (message) {
|
||||
function OpRangeNotAvailableError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'OpRangeNotAvailableError'
|
||||
error.__proto__ = OpRangeNotAvailableError.prototype
|
||||
|
@ -21,7 +21,7 @@ var OpRangeNotAvailableError = function (message) {
|
|||
}
|
||||
OpRangeNotAvailableError.prototype.__proto__ = Error.prototype
|
||||
|
||||
var ProjectStateChangedError = function (message) {
|
||||
function ProjectStateChangedError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'ProjectStateChangedError'
|
||||
error.__proto__ = ProjectStateChangedError.prototype
|
||||
|
@ -29,7 +29,7 @@ var ProjectStateChangedError = function (message) {
|
|||
}
|
||||
ProjectStateChangedError.prototype.__proto__ = Error.prototype
|
||||
|
||||
var DeleteMismatchError = function (message) {
|
||||
function DeleteMismatchError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'DeleteMismatchError'
|
||||
error.__proto__ = DeleteMismatchError.prototype
|
||||
|
|
|
@ -22,7 +22,7 @@ const ProjectManager = require('./ProjectManager')
|
|||
const _ = require('lodash')
|
||||
const logger = require('@overleaf/logger')
|
||||
|
||||
var ProjectFlusher = {
|
||||
const ProjectFlusher = {
|
||||
// iterate over keys asynchronously using redis scan (non-blocking)
|
||||
// handle all the cluster nodes or single redis server
|
||||
_getKeys(pattern, limit, callback) {
|
||||
|
@ -42,7 +42,7 @@ var ProjectFlusher = {
|
|||
const keySet = {} // use hash to avoid duplicate results
|
||||
const batchSize = limit != null ? Math.min(limit, 1000) : 1000
|
||||
// scan over all keys looking for pattern
|
||||
var doIteration = (
|
||||
const doIteration = (
|
||||
cb // avoid hitting redis too hard
|
||||
) =>
|
||||
node.scan(
|
||||
|
|
|
@ -324,7 +324,7 @@ const load = function () {
|
|||
// delete is fully after comment, nothing to do
|
||||
} else {
|
||||
// delete and comment overlap
|
||||
var remaining_after, remaining_before
|
||||
let remaining_after, remaining_before
|
||||
if (op_start <= comment_start) {
|
||||
remaining_before = ''
|
||||
} else {
|
||||
|
@ -402,7 +402,7 @@ const load = function () {
|
|||
}
|
||||
}
|
||||
} else if (change.op.i != null) {
|
||||
var offset
|
||||
let offset
|
||||
const change_end = change_start + change.op.i.length
|
||||
const is_change_overlapping =
|
||||
op_start >= change_start && op_start <= change_end
|
||||
|
@ -537,7 +537,7 @@ const load = function () {
|
|||
// offset indexes as we go.
|
||||
const op_modifications = []
|
||||
for (change of Array.from(this.changes)) {
|
||||
var change_start
|
||||
let change_start
|
||||
if (change.op.i != null) {
|
||||
change_start = change.op.p
|
||||
const change_end = change_start + change.op.i.length
|
||||
|
@ -551,7 +551,7 @@ const load = function () {
|
|||
// When the new delete overlaps an insert, we should remove the part of the insert that
|
||||
// is now deleted, and also remove the part of the new delete that overlapped. I.e.
|
||||
// the two cancel out where they overlap.
|
||||
var delete_remaining_after,
|
||||
let delete_remaining_after,
|
||||
delete_remaining_before,
|
||||
insert_remaining_after,
|
||||
insert_remaining_before
|
||||
|
|
|
@ -50,7 +50,7 @@ module.exports = RealTimeRedisManager = {
|
|||
}
|
||||
const updates = []
|
||||
for (jsonUpdate of Array.from(jsonUpdates)) {
|
||||
var update
|
||||
let update
|
||||
try {
|
||||
update = JSON.parse(jsonUpdate)
|
||||
} catch (e) {
|
||||
|
|
|
@ -165,7 +165,7 @@ module.exports = UpdateManager = {
|
|||
return _callback(error)
|
||||
}
|
||||
|
||||
var profile = new Profiler('applyUpdate', { project_id, doc_id })
|
||||
const profile = new Profiler('applyUpdate', { project_id, doc_id })
|
||||
UpdateManager._sanitizeUpdate(update)
|
||||
profile.log('sanitizeUpdate', { sync: true })
|
||||
return DocumentManager.getDoc(
|
||||
|
|
|
@ -46,7 +46,7 @@ exports._bt = bootstrapTransform = function (
|
|||
|
||||
let k = 0
|
||||
while (k < leftOp.length) {
|
||||
var l
|
||||
let l
|
||||
const nextC = []
|
||||
transformComponentX(leftOp[k], rightComponent, newLeftOp, nextC)
|
||||
k++
|
||||
|
|
|
@ -226,12 +226,12 @@ json.api = {
|
|||
return (() => {
|
||||
const result = []
|
||||
for (const c of Array.from(op)) {
|
||||
var i
|
||||
let i
|
||||
if (c.na !== undefined || c.si !== undefined || c.sd !== undefined) {
|
||||
// no change to structure
|
||||
continue
|
||||
}
|
||||
var to_remove = []
|
||||
const to_remove = []
|
||||
for (i = 0; i < this._listeners.length; i++) {
|
||||
// Transform a dummy op by the incoming op to work out what
|
||||
// should happen to the listener.
|
||||
|
@ -267,14 +267,14 @@ json.api = {
|
|||
return this.on('remoteop', function (op) {
|
||||
return (() => {
|
||||
const result = []
|
||||
for (var c of Array.from(op)) {
|
||||
var match_path =
|
||||
for (const c of Array.from(op)) {
|
||||
const match_path =
|
||||
c.na === undefined ? c.p.slice(0, c.p.length - 1) : c.p
|
||||
result.push(
|
||||
(() => {
|
||||
const result1 = []
|
||||
for (const { path, event, cb } of Array.from(this._listeners)) {
|
||||
var common
|
||||
let common
|
||||
if (pathEquals(path, match_path)) {
|
||||
switch (event) {
|
||||
case 'insert':
|
||||
|
|
|
@ -264,7 +264,7 @@ json.normalize = function (op) {
|
|||
// hax, copied from test/types/json. Apparently this is still the fastest way to deep clone an object, assuming
|
||||
// we have browser support for JSON.
|
||||
// http://jsperf.com/cloning-an-object/12
|
||||
var clone = o => JSON.parse(JSON.stringify(o))
|
||||
const clone = o => JSON.parse(JSON.stringify(o))
|
||||
|
||||
json.commonPath = function (p1, p2) {
|
||||
p1 = p1.slice()
|
||||
|
|
|
@ -421,7 +421,7 @@ module.exports = Model = function (db, options) {
|
|||
// Documents are stored so long as either:
|
||||
// - They have been accessed within the past #{PERIOD}
|
||||
// - At least one client has the document open
|
||||
var refreshReapingTimeout = function (docName) {
|
||||
function refreshReapingTimeout(docName) {
|
||||
const doc = docs[docName]
|
||||
if (!doc) {
|
||||
return
|
||||
|
@ -461,7 +461,7 @@ module.exports = Model = function (db, options) {
|
|||
})
|
||||
}
|
||||
|
||||
var tryWriteSnapshot = function (docName, callback) {
|
||||
function tryWriteSnapshot(docName, callback) {
|
||||
if (!db) {
|
||||
return typeof callback === 'function' ? callback() : undefined
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ module.exports = Model = function (db, options) {
|
|||
return (() => {
|
||||
const result = []
|
||||
for (const op of Array.from(data)) {
|
||||
var needle
|
||||
let needle
|
||||
listener(op)
|
||||
|
||||
// The listener may well remove itself during the catchup phase. If this happens, break early.
|
||||
|
|
|
@ -434,7 +434,7 @@ module.exports = Model = function (db, options) {
|
|||
// Documents are stored so long as either:
|
||||
// - They have been accessed within the past #{PERIOD}
|
||||
// - At least one client has the document open
|
||||
var refreshReapingTimeout = function (docName) {
|
||||
function refreshReapingTimeout(docName) {
|
||||
const doc = docs[docName]
|
||||
if (!doc) {
|
||||
return
|
||||
|
@ -474,7 +474,7 @@ module.exports = Model = function (db, options) {
|
|||
})
|
||||
}
|
||||
|
||||
var tryWriteSnapshot = function (docName, callback) {
|
||||
function tryWriteSnapshot(docName, callback) {
|
||||
if (!db) {
|
||||
return typeof callback === 'function' ? callback() : undefined
|
||||
}
|
||||
|
@ -797,7 +797,7 @@ module.exports = Model = function (db, options) {
|
|||
return (() => {
|
||||
const result = []
|
||||
for (const op of Array.from(data)) {
|
||||
var needle
|
||||
let needle
|
||||
listener(op)
|
||||
|
||||
// The listener may well remove itself during the catchup phase. If this happens, break early.
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = function (process) {
|
|||
|
||||
enqueue.busy = false
|
||||
|
||||
var flush = function () {
|
||||
function flush() {
|
||||
if (enqueue.busy || queue.length === 0) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = function (process) {
|
|||
|
||||
enqueue.busy = false
|
||||
|
||||
var flush = function () {
|
||||
function flush() {
|
||||
if (enqueue.busy || queue.length === 0) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ exports.transform = function (op, otherOp, side) {
|
|||
const [take, peek] = Array.from(makeTake(op))
|
||||
|
||||
for (component of Array.from(otherOp)) {
|
||||
var chunk, length
|
||||
let chunk, length
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
length = component
|
||||
|
@ -306,7 +306,7 @@ exports.compose = function (op1, op2) {
|
|||
const [take, _] = Array.from(makeTake(op1))
|
||||
|
||||
for (component of Array.from(op2)) {
|
||||
var chunk, length
|
||||
let chunk, length
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
length = component
|
||||
|
|
|
@ -99,7 +99,7 @@ type.api = {
|
|||
const docPos = { index: 0, offset: 0 }
|
||||
|
||||
for (const component of Array.from(op)) {
|
||||
var part, remainder
|
||||
let part, remainder
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
remainder = component
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
// would be represented by a document snapshot of ['Hello ', 5, 'world']
|
||||
|
||||
let append, appendDoc, takeDoc
|
||||
var type = {
|
||||
const type = {
|
||||
name: 'text-tp2',
|
||||
tp2: true,
|
||||
create() {
|
||||
|
@ -183,7 +183,7 @@ type.apply = function (doc, op) {
|
|||
const position = { index: 0, offset: 0 }
|
||||
|
||||
for (const component of Array.from(op)) {
|
||||
var part, remainder
|
||||
let part, remainder
|
||||
if (typeof component === 'number') {
|
||||
remainder = component
|
||||
while (remainder > 0) {
|
||||
|
@ -337,7 +337,7 @@ const transformer = function (op, otherOp, goForwards, side) {
|
|||
const [take, peek] = Array.from(makeTake(op))
|
||||
|
||||
for (component of Array.from(otherOp)) {
|
||||
var chunk
|
||||
let chunk
|
||||
let length = componentLength(component)
|
||||
|
||||
if (component.i !== undefined) {
|
||||
|
@ -431,7 +431,7 @@ type.compose = function (op1, op2) {
|
|||
const [take, _] = Array.from(makeTake(op1))
|
||||
|
||||
for (component of Array.from(op2)) {
|
||||
var chunk, length
|
||||
let chunk, length
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
// Just copy from op1.
|
||||
|
|
|
@ -46,7 +46,7 @@ exports._bt = bootstrapTransform = function (
|
|||
|
||||
let k = 0
|
||||
while (k < leftOp.length) {
|
||||
var l
|
||||
let l
|
||||
const nextC = []
|
||||
transformComponentX(leftOp[k], rightComponent, newLeftOp, nextC)
|
||||
k++
|
||||
|
|
|
@ -226,12 +226,12 @@ json.api = {
|
|||
return (() => {
|
||||
const result = []
|
||||
for (const c of Array.from(op)) {
|
||||
var i
|
||||
let i
|
||||
if (c.na !== undefined || c.si !== undefined || c.sd !== undefined) {
|
||||
// no change to structure
|
||||
continue
|
||||
}
|
||||
var to_remove = []
|
||||
const to_remove = []
|
||||
for (i = 0; i < this._listeners.length; i++) {
|
||||
// Transform a dummy op by the incoming op to work out what
|
||||
// should happen to the listener.
|
||||
|
@ -267,14 +267,14 @@ json.api = {
|
|||
return this.on('remoteop', function (op) {
|
||||
return (() => {
|
||||
const result = []
|
||||
for (var c of Array.from(op)) {
|
||||
var match_path =
|
||||
for (const c of Array.from(op)) {
|
||||
const match_path =
|
||||
c.na === undefined ? c.p.slice(0, c.p.length - 1) : c.p
|
||||
result.push(
|
||||
(() => {
|
||||
const result1 = []
|
||||
for (const { path, event, cb } of Array.from(this._listeners)) {
|
||||
var common
|
||||
let common
|
||||
if (pathEquals(path, match_path)) {
|
||||
switch (event) {
|
||||
case 'insert':
|
||||
|
|
|
@ -264,7 +264,7 @@ json.normalize = function (op) {
|
|||
// hax, copied from test/types/json. Apparently this is still the fastest way to deep clone an object, assuming
|
||||
// we have browser support for JSON.
|
||||
// http://jsperf.com/cloning-an-object/12
|
||||
var clone = o => JSON.parse(JSON.stringify(o))
|
||||
const clone = o => JSON.parse(JSON.stringify(o))
|
||||
|
||||
json.commonPath = function (p1, p2) {
|
||||
p1 = p1.slice()
|
||||
|
|
|
@ -421,7 +421,7 @@ module.exports = Model = function (db, options) {
|
|||
// Documents are stored so long as either:
|
||||
// - They have been accessed within the past #{PERIOD}
|
||||
// - At least one client has the document open
|
||||
var refreshReapingTimeout = function (docName) {
|
||||
function refreshReapingTimeout(docName) {
|
||||
const doc = docs[docName]
|
||||
if (!doc) {
|
||||
return
|
||||
|
@ -461,7 +461,7 @@ module.exports = Model = function (db, options) {
|
|||
})
|
||||
}
|
||||
|
||||
var tryWriteSnapshot = function (docName, callback) {
|
||||
function tryWriteSnapshot(docName, callback) {
|
||||
if (!db) {
|
||||
return typeof callback === 'function' ? callback() : undefined
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ module.exports = Model = function (db, options) {
|
|||
return (() => {
|
||||
const result = []
|
||||
for (const op of Array.from(data)) {
|
||||
var needle
|
||||
let needle
|
||||
listener(op)
|
||||
|
||||
// The listener may well remove itself during the catchup phase. If this happens, break early.
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = function (process) {
|
|||
|
||||
enqueue.busy = false
|
||||
|
||||
var flush = function () {
|
||||
function flush() {
|
||||
if (enqueue.busy || queue.length === 0) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ moduleExport.transform = function (op, otherOp, side) {
|
|||
const [take, peek] = Array.from(makeTake(op))
|
||||
|
||||
for (component of Array.from(otherOp)) {
|
||||
var chunk, length
|
||||
let chunk, length
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
length = component
|
||||
|
@ -305,7 +305,7 @@ moduleExport.compose = function (op1, op2) {
|
|||
const [take, _] = Array.from(makeTake(op1))
|
||||
|
||||
for (component of Array.from(op2)) {
|
||||
var chunk, length
|
||||
let chunk, length
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
length = component
|
||||
|
|
|
@ -99,7 +99,7 @@ type.api = {
|
|||
const docPos = { index: 0, offset: 0 }
|
||||
|
||||
for (const component of Array.from(op)) {
|
||||
var part, remainder
|
||||
let part, remainder
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
remainder = component
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
// would be represented by a document snapshot of ['Hello ', 5, 'world']
|
||||
|
||||
let append, appendDoc, takeDoc
|
||||
var type = {
|
||||
const type = {
|
||||
name: 'text-tp2',
|
||||
tp2: true,
|
||||
create() {
|
||||
|
@ -183,7 +183,7 @@ type.apply = function (doc, op) {
|
|||
const position = { index: 0, offset: 0 }
|
||||
|
||||
for (const component of Array.from(op)) {
|
||||
var part, remainder
|
||||
let part, remainder
|
||||
if (typeof component === 'number') {
|
||||
remainder = component
|
||||
while (remainder > 0) {
|
||||
|
@ -337,7 +337,7 @@ const transformer = function (op, otherOp, goForwards, side) {
|
|||
const [take, peek] = Array.from(makeTake(op))
|
||||
|
||||
for (component of Array.from(otherOp)) {
|
||||
var chunk
|
||||
let chunk
|
||||
let length = componentLength(component)
|
||||
|
||||
if (component.i !== undefined) {
|
||||
|
@ -431,7 +431,7 @@ type.compose = function (op1, op2) {
|
|||
const [take, _] = Array.from(makeTake(op1))
|
||||
|
||||
for (component of Array.from(op2)) {
|
||||
var chunk, length
|
||||
let chunk, length
|
||||
if (typeof component === 'number') {
|
||||
// Skip
|
||||
// Just copy from op1.
|
||||
|
|
|
@ -180,7 +180,7 @@ describe('DispatchManager', function () {
|
|||
|
||||
this.worker.run()
|
||||
|
||||
var checkStatus = () => {
|
||||
const checkStatus = () => {
|
||||
if (!this.settings.shuttingDown) {
|
||||
// retry until shutdown
|
||||
setTimeout(checkStatus, 100)
|
||||
|
|
|
@ -350,7 +350,7 @@ describe('ShareJS text type', function () {
|
|||
asc1 ? p <= end1 : p >= end1;
|
||||
asc1 ? p++ : p--
|
||||
) {
|
||||
var asc2, end2
|
||||
let asc2, end2
|
||||
for (
|
||||
length = 1, end2 = SNAPSHOT.length - p, asc2 = end2 >= 1;
|
||||
asc2 ? length <= end2 : length >= end2;
|
||||
|
@ -364,7 +364,7 @@ describe('ShareJS text type', function () {
|
|||
asc3 ? p <= end3 : p >= end3;
|
||||
asc3 ? p++ : p--
|
||||
) {
|
||||
var asc4, end4
|
||||
let asc4, end4
|
||||
for (
|
||||
length = 1, end4 = SNAPSHOT.length - p, asc4 = end4 >= 1;
|
||||
asc4 ? length <= end4 : length >= end4;
|
||||
|
@ -376,7 +376,7 @@ describe('ShareJS text type', function () {
|
|||
|
||||
return (() => {
|
||||
const result = []
|
||||
for (var op1 of Array.from(OPS)) {
|
||||
for (const op1 of Array.from(OPS)) {
|
||||
result.push(
|
||||
(() => {
|
||||
const result1 = []
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = Router = {
|
|||
attrs.method = method
|
||||
if (Joi.isError(error)) {
|
||||
logger.info(attrs, 'validation error')
|
||||
var message = 'invalid'
|
||||
let message = 'invalid'
|
||||
try {
|
||||
message = error.details[0].message
|
||||
} catch (e) {
|
||||
|
|
|
@ -557,7 +557,7 @@ exports.XMLHttpRequest = function () {
|
|||
*
|
||||
* @param int state New state
|
||||
*/
|
||||
var setState = function (state) {
|
||||
function setState(state) {
|
||||
if (self.readyState !== state) {
|
||||
self.readyState = state
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -112,7 +112,7 @@ class ASpellRunner {
|
|||
const lines = output.split('\n')
|
||||
const suggestions = {}
|
||||
for (const line of Array.from(lines)) {
|
||||
var parts, word
|
||||
let parts, word
|
||||
if (line[0] === '&') {
|
||||
// Suggestions found
|
||||
parts = line.split(' ')
|
||||
|
@ -187,5 +187,5 @@ ASpell.promises = promises
|
|||
|
||||
module.exports = ASpell
|
||||
|
||||
var WorkerPool = new ASpellWorkerPool()
|
||||
const WorkerPool = new ASpellWorkerPool()
|
||||
module.exports.cacheDump = cacheDump
|
||||
|
|
|
@ -112,7 +112,7 @@ class ASpellWorker {
|
|||
})
|
||||
|
||||
this.pipe.stdout.setEncoding('utf8') // ensure utf8 output is handled correctly
|
||||
var output = ''
|
||||
let output = ''
|
||||
const endMarkerRegex = new RegExp('^[a-z][a-z]', 'gm')
|
||||
this.pipe.stdout.on('data', data => {
|
||||
// We receive the language code from Aspell as the end of data marker in
|
||||
|
@ -143,7 +143,7 @@ class ASpellWorker {
|
|||
}
|
||||
})
|
||||
|
||||
var error = ''
|
||||
let error = ''
|
||||
this.pipe.stderr.on('data', chunk => {
|
||||
return (error = error + chunk)
|
||||
})
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// START of temporary overrides
|
||||
"array-callback-return": "off",
|
||||
"no-dupe-else-if": "off",
|
||||
"no-var": "off",
|
||||
"no-empty": "off",
|
||||
"node/handle-callback-err": "off",
|
||||
"no-loss-of-precision": "off",
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
let DiffGenerator
|
||||
var ConsistencyError = function (message) {
|
||||
function ConsistencyError(message) {
|
||||
const error = new Error(message)
|
||||
error.name = 'ConsistencyError'
|
||||
error.__proto__ = ConsistencyError.prototype
|
||||
|
|
|
@ -93,7 +93,7 @@ module.exports = RedisManager = {
|
|||
let cursor = 0 // redis iterator
|
||||
const keySet = {} // use hash to avoid duplicate results
|
||||
// scan over all keys looking for pattern
|
||||
var doIteration = cb =>
|
||||
const doIteration = cb =>
|
||||
node.scan(
|
||||
cursor,
|
||||
'MATCH',
|
||||
|
|
|
@ -142,7 +142,7 @@ module.exports = UpdatesManager = {
|
|||
// some old large ops in redis need to be rejected, they predate
|
||||
// the size limit that now prevents them going through the system
|
||||
const REJECT_LARGE_OP_SIZE = 4 * 1024 * 1024
|
||||
for (var rawUpdate of Array.from(rawUpdates)) {
|
||||
for (const rawUpdate of Array.from(rawUpdates)) {
|
||||
const opSizes = (() => {
|
||||
const result = []
|
||||
for (op of Array.from(
|
||||
|
@ -801,7 +801,7 @@ module.exports = UpdatesManager = {
|
|||
const summarizedUpdates = existingSummarizedUpdates.slice()
|
||||
let previousUpdateWasBigDelete = false
|
||||
for (const update of Array.from(updates)) {
|
||||
var doc_id
|
||||
let doc_id
|
||||
const earliestUpdate = summarizedUpdates[summarizedUpdates.length - 1]
|
||||
let shouldConcat = false
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
}
|
||||
},
|
||||
"rules": {
|
||||
// Disable some rules after upgrading ESLint
|
||||
// TODO: re-enable and fix
|
||||
"no-var": "off",
|
||||
|
||||
// do not allow importing of implicit dependencies.
|
||||
"import/no-extraneous-dependencies": "error"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var RefererParser = require('referer-parser')
|
||||
const RefererParser = require('referer-parser')
|
||||
const { URL } = require('url')
|
||||
const AnalyticsManager = require('./AnalyticsManager')
|
||||
|
||||
|
@ -18,7 +18,7 @@ const UTM_KEYS = [
|
|||
]
|
||||
|
||||
function parseUtm(query) {
|
||||
var utmValues = {}
|
||||
const utmValues = {}
|
||||
for (const utmKey of UTM_KEYS) {
|
||||
if (query[utmKey]) {
|
||||
utmValues[utmKey] = query[utmKey]
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = DocumentHelper = {
|
|||
for (const line of Array.from(
|
||||
DocumentHelper._getLinesFromContent(content, maxContentToScan)
|
||||
)) {
|
||||
var match
|
||||
let match
|
||||
if (
|
||||
(match =
|
||||
line.match(TITLE_WITH_CURLY_BRACES) ||
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = EditorRealTimeController = {
|
|||
emitToRoom(room_id, message, ...payload) {
|
||||
// create a unique message id using a counter
|
||||
const message_id = `web:${HOST}:${RND}-${COUNT++}`
|
||||
var channel
|
||||
let channel
|
||||
if (room_id === 'all' || !Settings.publishOnIndividualChannels) {
|
||||
channel = 'editor-events'
|
||||
} else {
|
||||
|
|
|
@ -273,7 +273,7 @@ templates.projectInvite = ctaTemplate({
|
|||
},
|
||||
message(opts, isPlainText) {
|
||||
// build message depending on spam-safe variables
|
||||
var message = [`You have been invited to an ${settings.appName} project.`]
|
||||
const message = [`You have been invited to an ${settings.appName} project.`]
|
||||
|
||||
if (SpamSafe.isSafeProjectName(opts.project.name)) {
|
||||
message.push('<br/> Project:')
|
||||
|
|
|
@ -204,7 +204,7 @@ const InstitutionsAPI = {
|
|||
},
|
||||
}
|
||||
|
||||
var makeAffiliationRequest = function (requestOptions, callback) {
|
||||
function makeAffiliationRequest(requestOptions, callback) {
|
||||
if (!settings.apis.v1.url) {
|
||||
return callback(null)
|
||||
} // service is not configured
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
},
|
||||
}
|
||||
|
||||
var affiliateUsers = function (hostname, callback) {
|
||||
function affiliateUsers(hostname, callback) {
|
||||
const reversedHostname = hostname.trim().split('').reverse().join('')
|
||||
UserGetter.getUsersByHostname(hostname, { _id: 1 }, function (error, users) {
|
||||
if (error) {
|
||||
|
@ -40,11 +40,7 @@ var affiliateUsers = function (hostname, callback) {
|
|||
})
|
||||
}
|
||||
|
||||
var affiliateUserByReversedHostname = function (
|
||||
user,
|
||||
reversedHostname,
|
||||
callback
|
||||
) {
|
||||
function affiliateUserByReversedHostname(user, reversedHostname, callback) {
|
||||
const matchingEmails = user.emails.filter(
|
||||
email => email.reversedHostname === reversedHostname
|
||||
)
|
||||
|
|
|
@ -254,7 +254,7 @@ const InstitutionsManager = {
|
|||
},
|
||||
}
|
||||
|
||||
var fetchInstitutionAndAffiliations = (institutionId, callback) =>
|
||||
const fetchInstitutionAndAffiliations = (institutionId, callback) =>
|
||||
async.waterfall(
|
||||
[
|
||||
cb =>
|
||||
|
@ -271,12 +271,12 @@ var fetchInstitutionAndAffiliations = (institutionId, callback) =>
|
|||
callback
|
||||
)
|
||||
|
||||
var refreshFeatures = function (affiliation, callback) {
|
||||
function refreshFeatures(affiliation, callback) {
|
||||
const userId = ObjectId(affiliation.user_id)
|
||||
FeaturesUpdater.refreshFeatures(userId, 'refresh-institution-users', callback)
|
||||
}
|
||||
|
||||
var refreshFeaturesAndNotify = function (affiliation, callback) {
|
||||
function refreshFeaturesAndNotify(affiliation, callback) {
|
||||
const userId = ObjectId(affiliation.user_id)
|
||||
async.waterfall(
|
||||
[
|
||||
|
@ -297,7 +297,7 @@ var refreshFeaturesAndNotify = function (affiliation, callback) {
|
|||
)
|
||||
}
|
||||
|
||||
var getUserInfo = (userId, callback) =>
|
||||
const getUserInfo = (userId, callback) =>
|
||||
async.waterfall(
|
||||
[
|
||||
cb => UserGetter.getUser(userId, cb),
|
||||
|
@ -309,7 +309,13 @@ var getUserInfo = (userId, callback) =>
|
|||
callback
|
||||
)
|
||||
|
||||
var notifyUser = (user, affiliation, subscription, featuresChanged, callback) =>
|
||||
const notifyUser = (
|
||||
user,
|
||||
affiliation,
|
||||
subscription,
|
||||
featuresChanged,
|
||||
callback
|
||||
) =>
|
||||
async.parallel(
|
||||
[
|
||||
function (cb) {
|
||||
|
|
|
@ -86,10 +86,10 @@ module.exports = MetaHandler = {
|
|||
const package_re = MetaHandler.usepackageRegex()
|
||||
const req_package_re = MetaHandler.ReqPackageRegex()
|
||||
for (const line of Array.from(lines)) {
|
||||
var labelMatch
|
||||
var clean, messy, packageMatch
|
||||
let labelMatch
|
||||
let clean, messy, packageMatch
|
||||
while ((labelMatch = label_re.exec(line))) {
|
||||
var label
|
||||
let label
|
||||
if ((label = labelMatch[1])) {
|
||||
docMeta.labels.push(label)
|
||||
}
|
||||
|
|
|
@ -1065,7 +1065,7 @@ const ProjectController = {
|
|||
},
|
||||
}
|
||||
|
||||
var defaultSettingsForAnonymousUser = userId => ({
|
||||
const defaultSettingsForAnonymousUser = userId => ({
|
||||
id: userId,
|
||||
ace: {
|
||||
mode: 'none',
|
||||
|
@ -1088,7 +1088,7 @@ var defaultSettingsForAnonymousUser = userId => ({
|
|||
betaProgram: false,
|
||||
})
|
||||
|
||||
var THEME_LIST = []
|
||||
const THEME_LIST = []
|
||||
function generateThemeList() {
|
||||
const files = fs.readdirSync(
|
||||
Path.join(__dirname, '/../../../../node_modules/ace-builds/src-noconflict')
|
||||
|
|
|
@ -42,7 +42,7 @@ module.exports = ReferencesHandler = {
|
|||
|
||||
_findBibFileIds(project) {
|
||||
const ids = []
|
||||
var _process = function (folder) {
|
||||
function _process(folder) {
|
||||
_.each(folder.fileRefs || [], function (file) {
|
||||
if (
|
||||
__guard__(file != null ? file.name : undefined, x1 =>
|
||||
|
@ -60,7 +60,7 @@ module.exports = ReferencesHandler = {
|
|||
|
||||
_findBibDocIds(project) {
|
||||
const ids = []
|
||||
var _process = function (folder) {
|
||||
function _process(folder) {
|
||||
_.each(folder.docs || [], function (doc) {
|
||||
if (
|
||||
__guard__(doc != null ? doc.name : undefined, x1 =>
|
||||
|
|
|
@ -27,7 +27,7 @@ const SystemMessageManager = require('../SystemMessages/SystemMessageManager')
|
|||
|
||||
const oneMinInMs = 60 * 1000
|
||||
|
||||
var updateOpenConnetionsMetrics = function () {
|
||||
function updateOpenConnetionsMetrics() {
|
||||
metrics.gauge(
|
||||
'open_connections.socketio',
|
||||
__guard__(
|
||||
|
|
|
@ -556,7 +556,7 @@ const RecurlyWrapper = {
|
|||
getPaginatedEndpoint(resource, queryParams, callback) {
|
||||
queryParams.per_page = queryParams.per_page || 200
|
||||
let allItems = []
|
||||
var getPage = (cursor = null) => {
|
||||
const getPage = (cursor = null) => {
|
||||
const opts = {
|
||||
url: resource,
|
||||
qs: queryParams,
|
||||
|
@ -950,7 +950,7 @@ const RecurlyWrapper = {
|
|||
},
|
||||
|
||||
_parseXml(xml, callback) {
|
||||
var convertDataTypes = function (data) {
|
||||
function convertDataTypes(data) {
|
||||
let key, value
|
||||
if (data != null && data.$ != null) {
|
||||
if (data.$.nil === 'nil') {
|
||||
|
|
|
@ -106,7 +106,7 @@ const SubscriptionGroupHandler = {
|
|||
},
|
||||
}
|
||||
|
||||
var replaceInArray = function (model, property, oldValue, newValue, callback) {
|
||||
function replaceInArray(model, property, oldValue, newValue, callback) {
|
||||
// Mongo won't let us pull and addToSet in the same query, so do it in
|
||||
// two. Note we need to add first, since the query is based on the old user.
|
||||
const query = {}
|
||||
|
|
|
@ -129,7 +129,7 @@ module.exports = TeamInvitesHandler = {
|
|||
},
|
||||
}
|
||||
|
||||
var createInvite = function (subscription, email, inviter, callback) {
|
||||
function createInvite(subscription, email, inviter, callback) {
|
||||
checkIfInviteIsPossible(
|
||||
subscription,
|
||||
email,
|
||||
|
@ -205,7 +205,7 @@ var createInvite = function (subscription, email, inviter, callback) {
|
|||
)
|
||||
}
|
||||
|
||||
var removeInviteFromTeam = function (subscriptionId, email, callback) {
|
||||
function removeInviteFromTeam(subscriptionId, email, callback) {
|
||||
const searchConditions = { _id: new ObjectId(subscriptionId.toString()) }
|
||||
const removeInvite = { $pull: { teamInvites: { email } } }
|
||||
|
||||
|
@ -218,7 +218,7 @@ var removeInviteFromTeam = function (subscriptionId, email, callback) {
|
|||
)
|
||||
}
|
||||
|
||||
var removeLegacyInvite = (subscriptionId, email, callback) =>
|
||||
const removeLegacyInvite = (subscriptionId, email, callback) =>
|
||||
Subscription.updateOne(
|
||||
{
|
||||
_id: new ObjectId(subscriptionId.toString()),
|
||||
|
@ -231,7 +231,7 @@ var removeLegacyInvite = (subscriptionId, email, callback) =>
|
|||
callback
|
||||
)
|
||||
|
||||
var checkIfInviteIsPossible = function (subscription, email, callback) {
|
||||
function checkIfInviteIsPossible(subscription, email, callback) {
|
||||
if (!subscription.groupPlan) {
|
||||
logger.log(
|
||||
{ subscriptionId: subscription.id },
|
||||
|
@ -272,7 +272,7 @@ var checkIfInviteIsPossible = function (subscription, email, callback) {
|
|||
})
|
||||
}
|
||||
|
||||
var getInviterName = function (inviter) {
|
||||
function getInviterName(inviter) {
|
||||
let inviterName
|
||||
if (inviter.first_name && inviter.last_name) {
|
||||
inviterName = `${inviter.first_name} ${inviter.last_name} (${inviter.email})`
|
||||
|
|
|
@ -59,7 +59,7 @@ module.exports = UpdateMerger = {
|
|||
if (err != null) {
|
||||
return callback(err)
|
||||
}
|
||||
var existingFileType = null
|
||||
let existingFileType = null
|
||||
if (_.some(files, f => f.path === path)) {
|
||||
existingFileType = 'file'
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ const UserGetter = {
|
|||
},
|
||||
}
|
||||
|
||||
var decorateFullEmails = (
|
||||
const decorateFullEmails = (
|
||||
defaultEmail,
|
||||
emailsData,
|
||||
affiliationsData,
|
||||
|
|
|
@ -91,7 +91,7 @@ const UserMembershipHandler = {
|
|||
UserMembershipHandler.promises = promisifyAll(UserMembershipHandler)
|
||||
module.exports = UserMembershipHandler
|
||||
|
||||
var getPopulatedListOfMembers = function (entity, attributes, callback) {
|
||||
function getPopulatedListOfMembers(entity, attributes, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error, users) {}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ var getPopulatedListOfMembers = function (entity, attributes, callback) {
|
|||
return async.map(userObjects, UserMembershipViewModel.buildAsync, callback)
|
||||
}
|
||||
|
||||
var addUserToEntity = function (entity, attribute, user, callback) {
|
||||
function addUserToEntity(entity, attribute, user, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ var addUserToEntity = function (entity, attribute, user, callback) {
|
|||
return entity.updateOne({ $addToSet: fieldUpdate }, callback)
|
||||
}
|
||||
|
||||
var removeUserFromEntity = function (entity, attribute, userId, callback) {
|
||||
function removeUserFromEntity(entity, attribute, userId, callback) {
|
||||
if (callback == null) {
|
||||
callback = function (error) {}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ var removeUserFromEntity = function (entity, attribute, userId, callback) {
|
|||
return entity.updateOne({ $pull: fieldUpdate }, callback)
|
||||
}
|
||||
|
||||
var buildEntityQuery = function (entityId, entityConfig, loggedInUser) {
|
||||
function buildEntityQuery(entityId, entityConfig, loggedInUser) {
|
||||
if (ObjectId.isValid(entityId.toString())) {
|
||||
entityId = ObjectId(entityId)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ module.exports = UserMembershipViewModel = {
|
|||
},
|
||||
}
|
||||
|
||||
var buildUserViewModel = function (user, isInvite) {
|
||||
function buildUserViewModel(user, isInvite) {
|
||||
if (isInvite == null) {
|
||||
isInvite = false
|
||||
}
|
||||
|
@ -62,6 +62,6 @@ var buildUserViewModel = function (user, isInvite) {
|
|||
}
|
||||
}
|
||||
|
||||
var buildUserViewModelWithEmail = email => buildUserViewModel({ email }, true)
|
||||
const buildUserViewModelWithEmail = email => buildUserViewModel({ email }, true)
|
||||
|
||||
var buildUserViewModelWithId = id => buildUserViewModel({ _id: id }, false)
|
||||
const buildUserViewModelWithId = id => buildUserViewModel({ _id: id }, false)
|
||||
|
|
|
@ -106,7 +106,7 @@ function linkedFileAgentsIncludes() {
|
|||
}
|
||||
|
||||
function attachHooks() {
|
||||
for (var module of _modules) {
|
||||
for (const module of _modules) {
|
||||
if (module.hooks != null) {
|
||||
for (const hook in module.hooks) {
|
||||
const method = module.hooks[hook]
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = ProxyManager = {
|
|||
apply(publicApiRouter) {
|
||||
return (() => {
|
||||
const result = []
|
||||
for (var proxyUrl in settings.proxyUrls) {
|
||||
for (const proxyUrl in settings.proxyUrls) {
|
||||
const target = settings.proxyUrls[proxyUrl]
|
||||
result.push(
|
||||
(function (target) {
|
||||
|
@ -67,7 +67,7 @@ module.exports = ProxyManager = {
|
|||
|
||||
// make a URL from a proxy target.
|
||||
// if the query is specified, set/replace the target's query with the given query
|
||||
var makeTargetUrl = function (target, req) {
|
||||
function makeTargetUrl(target, req) {
|
||||
const targetUrl = new URL(parseSettingUrl(target, req))
|
||||
if (req.query != null && Object.keys(req.query).length > 0) {
|
||||
targetUrl.search = new URLSearchParams(req.query).toString()
|
||||
|
@ -75,7 +75,7 @@ var makeTargetUrl = function (target, req) {
|
|||
return targetUrl.href
|
||||
}
|
||||
|
||||
var parseSettingUrl = function (target, { params }) {
|
||||
function parseSettingUrl(target, { params }) {
|
||||
let path
|
||||
if (typeof target === 'string') {
|
||||
return target
|
||||
|
|
|
@ -20,8 +20,8 @@ module.exports = RedirectManager = {
|
|||
apply(webRouter) {
|
||||
return (() => {
|
||||
const result = []
|
||||
for (var redirectUrl in settings.redirects) {
|
||||
var target = settings.redirects[redirectUrl]
|
||||
for (const redirectUrl in settings.redirects) {
|
||||
const target = settings.redirects[redirectUrl]
|
||||
result.push(
|
||||
Array.from(target.methods || ['get']).map(method =>
|
||||
webRouter[method](
|
||||
|
@ -73,7 +73,7 @@ module.exports = RedirectManager = {
|
|||
// Naively get the query params string. Stringifying the req.query object may
|
||||
// have differences between Express and Rails, so safer to just pass the raw
|
||||
// string
|
||||
var getQueryString = function (req) {
|
||||
function getQueryString(req) {
|
||||
const { search } = new URL(req.originalUrl, settings.siteUrl)
|
||||
if (search) {
|
||||
return search
|
||||
|
|
|
@ -1067,7 +1067,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
|||
ClsiCookieManager.clearServerId(projectId)
|
||||
}) // force every compile to a new server
|
||||
// set a timeout
|
||||
var handler = setTimeout(function () {
|
||||
let handler = setTimeout(function () {
|
||||
sendRes(500, 'Compiler timed out')
|
||||
handler = null
|
||||
}, 10000)
|
||||
|
|
|
@ -91,7 +91,7 @@ function PreviewLogEntryHeader({
|
|||
</Tooltip>
|
||||
) : null
|
||||
|
||||
var headerTitleText = logType ? `${logType} ${headerTitle}` : headerTitle
|
||||
const headerTitleText = logType ? `${logType} ${headerTitle}` : headerTitle
|
||||
|
||||
return (
|
||||
<header className={logEntryHeaderClasses}>
|
||||
|
|
|
@ -135,7 +135,7 @@ export default App.directive('layout', ($parse, $compile, ide) => ({
|
|||
}
|
||||
|
||||
// Someone moved the resizer
|
||||
var onInternalResize = function () {
|
||||
function onInternalResize() {
|
||||
state = element.layout().readState()
|
||||
scope.$broadcast(`layout:${name}:resize`, state)
|
||||
repositionControls()
|
||||
|
@ -212,7 +212,7 @@ ng-click=\"handleClick()\">\
|
|||
element.append(customTogglerEl)
|
||||
}
|
||||
|
||||
var onPaneOpen = function (pane) {
|
||||
function onPaneOpen(pane) {
|
||||
if (!hasCustomToggler && pane !== customTogglerPane) {
|
||||
return
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ ng-click=\"handleClick()\">\
|
|||
.$applyAsync(() => (customTogglerEl.scope().isOpen = true))
|
||||
}
|
||||
|
||||
var onPaneClose = function (pane) {
|
||||
function onPaneClose(pane) {
|
||||
if (!hasCustomToggler && pane !== customTogglerPane) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ export default Document = (function () {
|
|||
const orig = char
|
||||
let copy = null
|
||||
let pos = 0
|
||||
var timer = () => {
|
||||
const timer = () => {
|
||||
if (copy == null || !copy.length) {
|
||||
copy = orig.slice() + ' ' + new Date() + '\n'
|
||||
line += Math.random() > 0.1 ? 1 : -2
|
||||
|
@ -751,11 +751,11 @@ export default Document = (function () {
|
|||
this.ranges.changes = changes
|
||||
this.ranges.comments = comments
|
||||
this.ranges.track_changes = this.doc.track_changes
|
||||
for (var op of Array.from(this.doc.getInflightOp() || [])) {
|
||||
for (const op of Array.from(this.doc.getInflightOp() || [])) {
|
||||
this.ranges.setIdSeed(this.doc.track_changes_id_seeds.inflight)
|
||||
this.ranges.applyOp(op, { user_id: this.track_changes_as })
|
||||
}
|
||||
for (op of Array.from(this.doc.getPendingOp() || [])) {
|
||||
for (const op of Array.from(this.doc.getPendingOp() || [])) {
|
||||
this.ranges.setIdSeed(this.doc.track_changes_id_seeds.pending)
|
||||
this.ranges.applyOp(op, { user_id: this.track_changes_as })
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ export default ShareJsDoc = (function () {
|
|||
this._pushOntoQueue(message)
|
||||
return // defer processing this update for now
|
||||
}
|
||||
var error = this.processUpdateFromServer(message)
|
||||
const error = this.processUpdateFromServer(message)
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.message === 'Invalid version from server'
|
||||
|
@ -383,7 +383,7 @@ export default ShareJsDoc = (function () {
|
|||
|
||||
_startInflightOpTimeout(update) {
|
||||
this._startFatalTimeoutTimer(update)
|
||||
var retryOp = () => {
|
||||
const retryOp = () => {
|
||||
// Only send the update again if inflightOp is still populated
|
||||
// This can be cleared when hard reloading the document in which
|
||||
// case we don't want to keep trying to send it.
|
||||
|
|
|
@ -29,7 +29,7 @@ export default App.controller(
|
|||
const MAX_UNSAVED_SECONDS = 15 // lock the editor after this time if unsaved
|
||||
|
||||
$scope.docSavingStatus = {}
|
||||
var pollSavedStatus = function () {
|
||||
function pollSavedStatus() {
|
||||
let t
|
||||
const oldStatus = $scope.docSavingStatus
|
||||
const oldUnsavedCount = $scope.docSavingStatusCount
|
||||
|
|
|
@ -450,7 +450,7 @@ App.directive(
|
|||
return setScrollMargins(marginTop, marginBottom)
|
||||
})
|
||||
|
||||
var setScrollMargins = function (marginTop, marginBottom) {
|
||||
function setScrollMargins(marginTop, marginBottom) {
|
||||
let marginChanged = false
|
||||
if (editor.renderer.scrollMargin.top !== marginTop) {
|
||||
editor.renderer.scrollMargin.top = marginTop
|
||||
|
@ -744,7 +744,7 @@ App.directive(
|
|||
scope.$broadcast('editorInit')
|
||||
)
|
||||
|
||||
var attachToAce = function (sharejs_doc) {
|
||||
function attachToAce(sharejs_doc) {
|
||||
let mode
|
||||
const lines = sharejs_doc.getSnapshot().split('\n')
|
||||
let session = editor.getSession()
|
||||
|
@ -862,7 +862,7 @@ App.directive(
|
|||
return editor.focus()
|
||||
}
|
||||
|
||||
var detachFromAce = function (sharejs_doc) {
|
||||
function detachFromAce(sharejs_doc) {
|
||||
tearDownSpellCheck()
|
||||
tearDownTrackChanges()
|
||||
tearDownUndo()
|
||||
|
|
|
@ -146,7 +146,7 @@ export default CommandManager = class CommandManager {
|
|||
|
||||
getCompletions(editor, session, pos, prefix, callback) {
|
||||
const commandNames = {}
|
||||
for (var snippet of Array.from(topHundred)) {
|
||||
for (const snippet of Array.from(topHundred)) {
|
||||
commandNames[snippet.caption.match(/\w+/)[0]] = true
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ export default CommandManager = class CommandManager {
|
|||
const packageCommands = []
|
||||
for (const pkg in packages) {
|
||||
const snippets = packages[pkg]
|
||||
for (snippet of Array.from(snippets)) {
|
||||
for (const snippet of Array.from(snippets)) {
|
||||
packageCommands.push(snippet)
|
||||
commandNames[snippet.caption.match(/\w+/)[0]] = true
|
||||
}
|
||||
|
@ -168,8 +168,8 @@ export default CommandManager = class CommandManager {
|
|||
if (!commandNames[command[0]]) {
|
||||
let caption = `\\${command[0]}`
|
||||
const score = caption === prefix ? 99 : 50
|
||||
snippet = caption
|
||||
var i = 1
|
||||
let snippet = caption
|
||||
let i = 1
|
||||
_.times(command[1], function () {
|
||||
snippet += `[\${${i}}]`
|
||||
caption += '[]'
|
||||
|
|
|
@ -15,7 +15,7 @@ import 'ace/ace'
|
|||
import 'ace/ext-language_tools'
|
||||
const { Range } = ace.require('ace/range')
|
||||
|
||||
var Helpers = {
|
||||
const Helpers = {
|
||||
getLastCommandFragment(lineUpToCursor) {
|
||||
let index
|
||||
if ((index = Helpers.getLastCommandFragmentIndex(lineUpToCursor)) > -1) {
|
||||
|
|
|
@ -362,7 +362,7 @@ class SpellCheckManager {
|
|||
let line = lines[row]
|
||||
const rowIdx = rowNumsToCheck[row]
|
||||
line = this.blankOutBlacklistedCommands(line)
|
||||
var result
|
||||
let result
|
||||
WORD_REGEX.lastIndex = 0 // reset global stateful regexp for this usage
|
||||
while ((result = WORD_REGEX.exec(line))) {
|
||||
let word = result[0]
|
||||
|
|
|
@ -203,7 +203,7 @@ class TrackChangesManager {
|
|||
|
||||
let updateMarkers = false
|
||||
|
||||
for (var id in dirty.change.added) {
|
||||
for (const id in dirty.change.added) {
|
||||
change = dirty.change.added[id]
|
||||
if (change.op.i != null) {
|
||||
this.adapter.onInsertAdded(change)
|
||||
|
@ -211,7 +211,7 @@ class TrackChangesManager {
|
|||
this.adapter.onDeleteAdded(change)
|
||||
}
|
||||
}
|
||||
for (id in dirty.change.removed) {
|
||||
for (const id in dirty.change.removed) {
|
||||
change = dirty.change.removed[id]
|
||||
if (change.op.i != null) {
|
||||
this.adapter.onInsertRemoved(change)
|
||||
|
@ -219,25 +219,25 @@ class TrackChangesManager {
|
|||
this.adapter.onDeleteRemoved(change)
|
||||
}
|
||||
}
|
||||
for (id in dirty.change.moved) {
|
||||
for (const id in dirty.change.moved) {
|
||||
change = dirty.change.moved[id]
|
||||
updateMarkers = true
|
||||
this.adapter.onChangeMoved(change)
|
||||
}
|
||||
|
||||
for (id in dirty.comment.added) {
|
||||
for (const id in dirty.comment.added) {
|
||||
comment = dirty.comment.added[id]
|
||||
if (!this.isCommentResolved(comment)) {
|
||||
this.adapter.onCommentAdded(comment)
|
||||
}
|
||||
}
|
||||
for (id in dirty.comment.removed) {
|
||||
for (const id in dirty.comment.removed) {
|
||||
comment = dirty.comment.removed[id]
|
||||
if (!this.isCommentResolved(comment)) {
|
||||
this.adapter.onCommentRemoved(comment)
|
||||
}
|
||||
}
|
||||
for (id in dirty.comment.moved) {
|
||||
for (const id in dirty.comment.moved) {
|
||||
comment = dirty.comment.moved[id]
|
||||
if (this.adapter.onCommentMoved && !this.isCommentResolved(comment)) {
|
||||
updateMarkers = true
|
||||
|
@ -487,13 +487,13 @@ class TrackChangesManager {
|
|||
// Make a copy of session.getMarkers() so we can modify it
|
||||
const markers = {}
|
||||
const object = session.getMarkers()
|
||||
for (var marker_id in object) {
|
||||
for (const marker_id in object) {
|
||||
marker = object[marker_id]
|
||||
markers[marker_id] = marker
|
||||
}
|
||||
|
||||
const expected_markers = []
|
||||
for (var change of Array.from(this.rangesTracker.changes)) {
|
||||
for (const change of Array.from(this.rangesTracker.changes)) {
|
||||
if (this.adapter.changeIdToMarkerIdMap[change.id] != null) {
|
||||
;({ op } = change)
|
||||
;({
|
||||
|
@ -542,7 +542,7 @@ class TrackChangesManager {
|
|||
}
|
||||
}
|
||||
|
||||
for ({ marker_id, start, end } of Array.from(expected_markers)) {
|
||||
for (const { marker_id, start, end } of Array.from(expected_markers)) {
|
||||
marker = markers[marker_id]
|
||||
delete markers[marker_id]
|
||||
if (
|
||||
|
@ -552,7 +552,6 @@ class TrackChangesManager {
|
|||
marker.range.end.column !== end.column
|
||||
) {
|
||||
console.error("Change doesn't match marker anymore", {
|
||||
change,
|
||||
marker,
|
||||
start,
|
||||
end,
|
||||
|
@ -562,7 +561,7 @@ class TrackChangesManager {
|
|||
|
||||
return (() => {
|
||||
const result = []
|
||||
for (marker_id in markers) {
|
||||
for (const marker_id in markers) {
|
||||
marker = markers[marker_id]
|
||||
if (/track-changes/.test(marker.clazz)) {
|
||||
result.push(console.error('Orphaned ace marker', marker))
|
||||
|
|
|
@ -180,12 +180,12 @@ export default FileTreeManager = class FileTreeManager {
|
|||
// problems with reserved Object properties
|
||||
const entities = this.getMultiSelectedEntities()
|
||||
const paths = {}
|
||||
for (var entity of Array.from(entities)) {
|
||||
for (const entity of Array.from(entities)) {
|
||||
paths['/' + this.getEntityPath(entity)] = entity
|
||||
}
|
||||
const prefixes = {}
|
||||
for (var path in paths) {
|
||||
entity = paths[path]
|
||||
for (const path in paths) {
|
||||
const entity = paths[path]
|
||||
const parts = path.split('/')
|
||||
if (parts.length <= 2) {
|
||||
continue
|
||||
|
@ -201,10 +201,10 @@ export default FileTreeManager = class FileTreeManager {
|
|||
}
|
||||
}
|
||||
const child_entities = []
|
||||
for (path in paths) {
|
||||
for (const path in paths) {
|
||||
// If the path is in the prefixes, then it's a parent folder and
|
||||
// should be ignore
|
||||
entity = paths[path]
|
||||
const entity = paths[path]
|
||||
if (prefixes[path] == null) {
|
||||
child_entities.push(entity)
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ export default FileTreeManager = class FileTreeManager {
|
|||
return (() => {
|
||||
const result = []
|
||||
for (const entity of Array.from(folder.children || [])) {
|
||||
var childPath
|
||||
let childPath
|
||||
if (path != null) {
|
||||
childPath = path + '/' + entity.name
|
||||
} else {
|
||||
|
|
|
@ -208,7 +208,7 @@ export default HistoryManager = (function () {
|
|||
let text = ''
|
||||
const iterable = diff.diff || []
|
||||
for (let i = 0; i < iterable.length; i++) {
|
||||
var endColumn, endRow
|
||||
let endColumn, endRow
|
||||
const entry = iterable[i]
|
||||
let content = entry.u || entry.i || entry.d
|
||||
if (!content) {
|
||||
|
|
|
@ -839,7 +839,7 @@ export default HistoryManager = (function () {
|
|||
let text = ''
|
||||
const iterable = diff || []
|
||||
for (let i = 0; i < iterable.length; i++) {
|
||||
var endColumn, endRow
|
||||
let endColumn, endRow
|
||||
const entry = iterable[i]
|
||||
let content = entry.u || entry.i || entry.d
|
||||
if (!content) {
|
||||
|
|
|
@ -40,8 +40,9 @@ const historyFileEntityController = function ($scope, $element, $attrs) {
|
|||
const path1Parts = path1.split('/')
|
||||
const path2Parts = path2.split('/')
|
||||
const maxIterations = Math.min(path1Parts.length, path2Parts.length) - 1
|
||||
let commonPartIndex
|
||||
for (
|
||||
var commonPartIndex = 0;
|
||||
commonPartIndex = 0;
|
||||
commonPartIndex < maxIterations;
|
||||
commonPartIndex++
|
||||
) {
|
||||
|
@ -61,7 +62,7 @@ const historyFileEntityController = function ($scope, $element, $attrs) {
|
|||
|
||||
const _handleFileClick = () =>
|
||||
ctrl.historyFileTreeController.handleEntityClick(ctrl.fileEntity)
|
||||
var _getFolderIcon = function () {
|
||||
function _getFolderIcon() {
|
||||
if (ctrl.isOpen) {
|
||||
return 'fa-folder-open'
|
||||
} else {
|
||||
|
|
|
@ -23,8 +23,8 @@ const historyFileTreeController = function ($scope, $element, $attrs) {
|
|||
const filePathParts = fileObject.pathname.split('/')
|
||||
let currentFileTreeLocation = currentFileTree
|
||||
for (let index = 0; index < filePathParts.length; index++) {
|
||||
var fileTreeEntity
|
||||
var pathPart = filePathParts[index]
|
||||
let fileTreeEntity
|
||||
const pathPart = filePathParts[index]
|
||||
const isFile = index === filePathParts.length - 1
|
||||
if (isFile) {
|
||||
fileTreeEntity = _.clone(fileObject)
|
||||
|
|
|
@ -62,7 +62,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) {
|
|||
return (() => {
|
||||
const result = []
|
||||
for (const update of Array.from($scope.history.updates)) {
|
||||
var inSelection
|
||||
let inSelection
|
||||
if (update.selectedTo) {
|
||||
inSelection = true
|
||||
beforeSelection = false
|
||||
|
@ -91,7 +91,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) {
|
|||
let inHoverSelection
|
||||
let hoverSelectedFrom = false
|
||||
let hoverSelectedTo = false
|
||||
for (var update of Array.from($scope.history.updates)) {
|
||||
for (const update of Array.from($scope.history.updates)) {
|
||||
// Figure out whether the to or from selector is hovered over
|
||||
if (update.hoverSelectedFrom) {
|
||||
hoverSelectedFrom = true
|
||||
|
@ -104,7 +104,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) {
|
|||
if (hoverSelectedFrom) {
|
||||
// We want to 'hover select' everything between hoverSelectedFrom and selectedTo
|
||||
inHoverSelection = false
|
||||
for (update of Array.from($scope.history.updates)) {
|
||||
for (const update of Array.from($scope.history.updates)) {
|
||||
if (update.selectedTo) {
|
||||
update.hoverSelectedTo = true
|
||||
inHoverSelection = true
|
||||
|
@ -120,7 +120,7 @@ App.controller('HistoryListController', function ($scope, $modal, ide) {
|
|||
inHoverSelection = false
|
||||
return (() => {
|
||||
const result = []
|
||||
for (update of Array.from($scope.history.updates)) {
|
||||
for (const update of Array.from($scope.history.updates)) {
|
||||
if (update.hoverSelectedTo) {
|
||||
inHoverSelection = true
|
||||
}
|
||||
|
|
|
@ -24,15 +24,15 @@ export default App.directive('infiniteScroll', () => ({
|
|||
}
|
||||
}
|
||||
|
||||
var atTopOfListView = () => element.scrollTop() < 30
|
||||
const atTopOfListView = () => element.scrollTop() < 30
|
||||
|
||||
var atBottomOfListView = () =>
|
||||
const atBottomOfListView = () =>
|
||||
element.scrollTop() + element.height() >= innerElement.height() - 30
|
||||
|
||||
const listShorterThanContainer = () =>
|
||||
element.height() > innerElement.height()
|
||||
|
||||
var loadUntilFull = function () {
|
||||
function loadUntilFull() {
|
||||
if (
|
||||
(listShorterThanContainer() || atEndOfListView()) &&
|
||||
!scope.$eval(attrs.infiniteScrollDisabled)
|
||||
|
|
|
@ -25,7 +25,7 @@ export default {
|
|||
const ruleDetails = _getRule(entry.message)
|
||||
|
||||
if (ruleDetails != null) {
|
||||
var type
|
||||
let type
|
||||
if (ruleDetails.ruleId != null) {
|
||||
entry.ruleId = ruleDetails.ruleId
|
||||
} else if (ruleDetails.regexToMatch != null) {
|
||||
|
|
|
@ -28,9 +28,9 @@ const parserReducer = function (accumulator, parser) {
|
|||
|
||||
// Too many log entries can cause browser crashes
|
||||
// Construct a too many files error from the last match
|
||||
var maxErrors = 100
|
||||
const maxErrors = 100
|
||||
if (iterationCount >= maxErrors) {
|
||||
var level = newEntry.level + 's'
|
||||
const level = newEntry.level + 's'
|
||||
newEntry.message = [
|
||||
'Over',
|
||||
maxErrors,
|
||||
|
|
|
@ -92,7 +92,7 @@ export default OnlineUsersManager = (function () {
|
|||
refreshOnlineUsers() {
|
||||
this.$scope.onlineUsersArray = []
|
||||
|
||||
for (var client_id in this.$scope.onlineUsers) {
|
||||
for (const client_id in this.$scope.onlineUsers) {
|
||||
const user = this.$scope.onlineUsers[client_id]
|
||||
if (user.doc_id != null) {
|
||||
user.doc = this.ide.fileTreeManager.findEntityById(user.doc_id)
|
||||
|
@ -120,7 +120,7 @@ export default OnlineUsersManager = (function () {
|
|||
this.$scope.onlineUsersCount = this.$scope.onlineUsersArray.length
|
||||
|
||||
this.$scope.onlineUserCursorHighlights = {}
|
||||
for (client_id in this.$scope.onlineUsers) {
|
||||
for (const client_id in this.$scope.onlineUsers) {
|
||||
const client = this.$scope.onlineUsers[client_id]
|
||||
const { doc_id } = client
|
||||
if (doc_id == null || client.row == null || client.column == null) {
|
||||
|
|
|
@ -615,7 +615,7 @@ App.controller(
|
|||
const errors = []
|
||||
const warnings = []
|
||||
for (const line of log.split('\n')) {
|
||||
var m
|
||||
let m
|
||||
if ((m = line.match(/^(\S+):(\d+):(\d+): (Error|Warning): (.*)/))) {
|
||||
const result = {
|
||||
file: m[1],
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
* to customise the loader's options. However the rest of the file is identical
|
||||
* to the one provided by PDF.js.
|
||||
*/
|
||||
var pdfjs = require('../../../vendor/libs/pdfjs-dist/build/pdf.js')
|
||||
var PdfjsWorker = require('../../../vendor/libs/pdfjs-dist/build/pdf.worker.js')
|
||||
const pdfjs = require('../../../vendor/libs/pdfjs-dist/build/pdf.js')
|
||||
const PdfjsWorker = require('../../../vendor/libs/pdfjs-dist/build/pdf.worker.js')
|
||||
|
||||
if (typeof window !== 'undefined' && 'Worker' in window) {
|
||||
pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker()
|
||||
|
|
|
@ -61,7 +61,7 @@ export default App.directive(
|
|||
} else {
|
||||
// shouldn't get here - the default page size should now
|
||||
// always be set before redraw is called
|
||||
var handler = scope.$watch(
|
||||
const handler = scope.$watch(
|
||||
'defaultPageSize',
|
||||
function (defaultPageSize) {
|
||||
if (defaultPageSize == null) {
|
||||
|
|
|
@ -230,7 +230,7 @@ export default App.factory(
|
|||
startIndicators() {
|
||||
// make an array of the pages in the queue
|
||||
this.queuedPages = []
|
||||
for (var page of Array.from(this.renderQueue)) {
|
||||
for (const page of Array.from(this.renderQueue)) {
|
||||
this.queuedPages[page.pagenum] = true
|
||||
}
|
||||
// clear any unfinished spinner timers on pages that aren't in the queue any more
|
||||
|
@ -243,7 +243,7 @@ export default App.factory(
|
|||
// add indicators for any new pages in the current queue
|
||||
return (() => {
|
||||
const result = []
|
||||
for (page of Array.from(this.renderQueue)) {
|
||||
for (const page of Array.from(this.renderQueue)) {
|
||||
if (
|
||||
!this.spinTimer[page.pagenum] &&
|
||||
!this.spinTimerDone[page.pagenum]
|
||||
|
@ -348,7 +348,7 @@ export default App.factory(
|
|||
: undefined
|
||||
}, this.PAGE_LOAD_TIMEOUT)
|
||||
|
||||
var loadTask = this.getPage(pagenum)
|
||||
const loadTask = this.getPage(pagenum)
|
||||
|
||||
loadTask.cancel = function () {
|
||||
return (this.cancelled = true)
|
||||
|
|
|
@ -360,7 +360,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
return scope.document.renderPages(pages)
|
||||
}
|
||||
|
||||
var getVisiblePages = function () {
|
||||
function getVisiblePages() {
|
||||
const top = element[0].scrollTop
|
||||
const bottom = top + element[0].clientHeight
|
||||
const visiblePages = _.filter(scope.pages, function (page) {
|
||||
|
@ -376,7 +376,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
return visiblePages
|
||||
}
|
||||
|
||||
var getExtraPages = function (visiblePages) {
|
||||
function getExtraPages(visiblePages) {
|
||||
const extra = []
|
||||
if (visiblePages.length > 0) {
|
||||
const firstVisiblePage = visiblePages[0].pageNum
|
||||
|
@ -417,7 +417,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
}
|
||||
|
||||
let spinnerTimer = null
|
||||
var doRescale = function (scale) {
|
||||
function doRescale(scale) {
|
||||
// console.log 'doRescale', scale
|
||||
if (scale == null) {
|
||||
return
|
||||
|
@ -455,8 +455,8 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
})
|
||||
}
|
||||
|
||||
var elementTimer = null
|
||||
var updateLayout = function () {
|
||||
let elementTimer = null
|
||||
function updateLayout() {
|
||||
// if element is zero-sized keep checking until it is ready
|
||||
// console.log 'checking element ready', element.height(), element.width()
|
||||
if (element.height() === 0 || element.width() === 0) {
|
||||
|
@ -477,7 +477,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
}
|
||||
}
|
||||
|
||||
var layoutTimer = null
|
||||
let layoutTimer = null
|
||||
const queueLayout = function () {
|
||||
// console.log 'call to queue layout'
|
||||
if (layoutTimer != null) {
|
||||
|
@ -571,7 +571,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
|
||||
let mouseUpHandler = null // keep track of the handler to avoid adding multiple times
|
||||
|
||||
var _setMouseUpHandler = function () {
|
||||
function _setMouseUpHandler() {
|
||||
if (mouseUpHandler == null) {
|
||||
return (mouseUpHandler = $(document.body).one(
|
||||
'mouseup',
|
||||
|
@ -580,7 +580,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
}
|
||||
}
|
||||
|
||||
var _handleSelectionMouseUp = function () {
|
||||
function _handleSelectionMouseUp() {
|
||||
mouseUpHandler = null // reset handler, has now fired
|
||||
window.setTimeout(function () {
|
||||
const removedClass = _removeClassIfNoSelection()
|
||||
|
@ -592,7 +592,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
return true
|
||||
}
|
||||
|
||||
var _removeClassIfNoSelection = function () {
|
||||
function _removeClassIfNoSelection() {
|
||||
if (_hasSelection()) {
|
||||
return false // didn't remove the text layer
|
||||
} else {
|
||||
|
@ -601,7 +601,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
}
|
||||
}
|
||||
|
||||
var _hasSelection = function () {
|
||||
function _hasSelection() {
|
||||
const selection =
|
||||
typeof window.getSelection === 'function'
|
||||
? window.getSelection()
|
||||
|
@ -616,7 +616,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
)
|
||||
}
|
||||
|
||||
var _isSelectionWithinPDF = function (selection) {
|
||||
function _isSelectionWithinPDF(selection) {
|
||||
if (selection.rangeCount === 0) {
|
||||
return false
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ export default App.directive('pdfViewer', ($q, $timeout, pdfSpinner) => ({
|
|||
return (scope.scrollHandlerTimeout = setTimeout(scrollHandler, 25))
|
||||
})
|
||||
|
||||
var scrollHandler = function () {
|
||||
function scrollHandler() {
|
||||
renderVisiblePages()
|
||||
const newPosition = ctrl.getPdfPosition()
|
||||
if (newPosition != null) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
import App from '../../../base'
|
||||
|
||||
export default App.factory('preamble', function (ide) {
|
||||
var Preamble = {
|
||||
const Preamble = {
|
||||
getPreambleText() {
|
||||
const text = ide.editorManager.getCurrentDocValue().slice(0, 5000)
|
||||
const preamble =
|
||||
|
|
|
@ -324,7 +324,7 @@ export default RangesTracker = class RangesTracker {
|
|||
// delete is fully after comment, nothing to do
|
||||
} else {
|
||||
// delete and comment overlap
|
||||
var remaining_after, remaining_before
|
||||
let remaining_after, remaining_before
|
||||
if (op_start <= comment_start) {
|
||||
remaining_before = ''
|
||||
} else {
|
||||
|
@ -402,7 +402,7 @@ export default RangesTracker = class RangesTracker {
|
|||
}
|
||||
}
|
||||
} else if (change.op.i != null) {
|
||||
var offset
|
||||
let offset
|
||||
const change_end = change_start + change.op.i.length
|
||||
const is_change_overlapping =
|
||||
op_start >= change_start && op_start <= change_end
|
||||
|
@ -535,8 +535,8 @@ export default RangesTracker = class RangesTracker {
|
|||
// all the modifications after looping through the existing changes, so as not to mess up the
|
||||
// offset indexes as we go.
|
||||
const op_modifications = []
|
||||
for (var change of Array.from(this.changes)) {
|
||||
var change_start
|
||||
for (const change of Array.from(this.changes)) {
|
||||
let change_start
|
||||
if (change.op.i != null) {
|
||||
change_start = change.op.p
|
||||
const change_end = change_start + change.op.i.length
|
||||
|
@ -550,7 +550,7 @@ export default RangesTracker = class RangesTracker {
|
|||
// When the new delete overlaps an insert, we should remove the part of the insert that
|
||||
// is now deleted, and also remove the part of the new delete that overlapped. I.e.
|
||||
// the two cancel out where they overlap.
|
||||
var delete_remaining_after,
|
||||
let delete_remaining_after,
|
||||
delete_remaining_before,
|
||||
insert_remaining_after,
|
||||
insert_remaining_before
|
||||
|
@ -645,7 +645,7 @@ export default RangesTracker = class RangesTracker {
|
|||
d: this._applyOpModifications(op.d, op_modifications),
|
||||
}
|
||||
|
||||
for (change of Array.from(remove_changes)) {
|
||||
for (const change of Array.from(remove_changes)) {
|
||||
// This is a bit of hack to avoid removing one delete and replacing it with another.
|
||||
// If we don't do this, it causes the UI to flicker
|
||||
if (
|
||||
|
@ -675,7 +675,7 @@ export default RangesTracker = class RangesTracker {
|
|||
// We need to merge these together again
|
||||
const results = this._scanAndMergeAdjacentUpdates()
|
||||
moved_changes = moved_changes.concat(results.moved_changes)
|
||||
for (change of Array.from(results.remove_changes)) {
|
||||
for (const change of Array.from(results.remove_changes)) {
|
||||
this._removeChange(change)
|
||||
moved_changes = moved_changes.filter(c => c !== change)
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ export default RangesTracker = class RangesTracker {
|
|||
|
||||
return (() => {
|
||||
const result = []
|
||||
for (change of Array.from(moved_changes)) {
|
||||
for (const change of Array.from(moved_changes)) {
|
||||
result.push(this._markAsDirty(change, 'change', 'moved'))
|
||||
}
|
||||
return result
|
||||
|
|
|
@ -247,14 +247,14 @@ export default App.controller(
|
|||
return $scope.reviewPanel.resolvedComments[doc_id]
|
||||
}
|
||||
|
||||
var getThread = function (thread_id) {
|
||||
function getThread(thread_id) {
|
||||
if ($scope.reviewPanel.commentThreads[thread_id] == null) {
|
||||
$scope.reviewPanel.commentThreads[thread_id] = { messages: [] }
|
||||
}
|
||||
return $scope.reviewPanel.commentThreads[thread_id]
|
||||
}
|
||||
|
||||
var getChangeTracker = function (doc_id) {
|
||||
function getChangeTracker(doc_id) {
|
||||
if (rangesTrackers[doc_id] == null) {
|
||||
rangesTrackers[doc_id] = new RangesTracker()
|
||||
rangesTrackers[doc_id].resolvedThreadIds =
|
||||
|
@ -272,7 +272,7 @@ export default App.controller(
|
|||
}
|
||||
)
|
||||
|
||||
var updateScrollbar = function () {
|
||||
function updateScrollbar() {
|
||||
if (
|
||||
scrollbar.isVisible &&
|
||||
$scope.reviewPanel.subView === $scope.SubViews.CUR_FILE &&
|
||||
|
@ -360,7 +360,7 @@ export default App.controller(
|
|||
nEntries > 0 && $scope.project.features.trackChangesVisible)
|
||||
)
|
||||
|
||||
var regenerateTrackChangesId = function (doc) {
|
||||
function regenerateTrackChangesId(doc) {
|
||||
const old_id = getChangeTracker(doc.doc_id).getIdSeed()
|
||||
const new_id = RangesTracker.generateIdSeed()
|
||||
getChangeTracker(doc.doc_id).setIdSeed(new_id)
|
||||
|
@ -394,7 +394,7 @@ export default App.controller(
|
|||
})()
|
||||
})
|
||||
|
||||
var refreshOverviewPanel = function () {
|
||||
function refreshOverviewPanel() {
|
||||
$scope.reviewPanel.overview.loading = true
|
||||
return refreshRanges()
|
||||
.then(() => ($scope.reviewPanel.overview.loading = false))
|
||||
|
@ -409,8 +409,7 @@ export default App.controller(
|
|||
return q
|
||||
}
|
||||
|
||||
var updateEntries = function (doc_id) {
|
||||
let change, entry_id, key, new_entry, value
|
||||
function updateEntries(doc_id) {
|
||||
const rangesTracker = getChangeTracker(doc_id)
|
||||
const entries = getDocEntries(doc_id)
|
||||
const resolvedComments = getDocResolvedComments(doc_id)
|
||||
|
@ -419,17 +418,17 @@ export default App.controller(
|
|||
|
||||
// Assume we'll delete everything until we see it, then we'll remove it from this object
|
||||
const delete_changes = {}
|
||||
for (var id in entries) {
|
||||
change = entries[id]
|
||||
for (const id in entries) {
|
||||
const change = entries[id]
|
||||
if (!['add-comment', 'bulk-actions'].includes(id)) {
|
||||
for (entry_id of Array.from(change.entry_ids)) {
|
||||
for (const entry_id of Array.from(change.entry_ids)) {
|
||||
delete_changes[entry_id] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
for (id in resolvedComments) {
|
||||
change = resolvedComments[id]
|
||||
for (entry_id of Array.from(change.entry_ids)) {
|
||||
for (const id in resolvedComments) {
|
||||
const change = resolvedComments[id]
|
||||
for (const entry_id of Array.from(change.entry_ids)) {
|
||||
delete_changes[entry_id] = true
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +436,7 @@ export default App.controller(
|
|||
let potential_aggregate = false
|
||||
let prev_insertion = null
|
||||
|
||||
for (change of Array.from(rangesTracker.changes)) {
|
||||
for (const change of Array.from(rangesTracker.changes)) {
|
||||
changed = true
|
||||
|
||||
if (
|
||||
|
@ -455,16 +454,15 @@ export default App.controller(
|
|||
entries[change.id] = {}
|
||||
}
|
||||
delete delete_changes[change.id]
|
||||
new_entry = {
|
||||
const new_entry = {
|
||||
type: change.op.i ? 'insert' : 'delete',
|
||||
entry_ids: [change.id],
|
||||
content: change.op.i || change.op.d,
|
||||
offset: change.op.p,
|
||||
metadata: change.metadata,
|
||||
}
|
||||
for (key in new_entry) {
|
||||
value = new_entry[key]
|
||||
entries[change.id][key] = value
|
||||
for (const key in new_entry) {
|
||||
entries[change.id][key] = new_entry[key]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,7 +484,7 @@ export default App.controller(
|
|||
}
|
||||
|
||||
for (const comment of Array.from(rangesTracker.comments)) {
|
||||
var new_comment
|
||||
let new_comment
|
||||
changed = true
|
||||
delete delete_changes[comment.id]
|
||||
if ($scope.reviewPanel.resolvedThreadIds[comment.op.t]) {
|
||||
|
@ -502,16 +500,15 @@ export default App.controller(
|
|||
: (entries[comment.id] = {})
|
||||
delete resolvedComments[comment.id]
|
||||
}
|
||||
new_entry = {
|
||||
const new_entry = {
|
||||
type: 'comment',
|
||||
thread_id: comment.op.t,
|
||||
entry_ids: [comment.id],
|
||||
content: comment.op.c,
|
||||
offset: comment.op.p,
|
||||
}
|
||||
for (key in new_entry) {
|
||||
value = new_entry[key]
|
||||
new_comment[key] = value
|
||||
for (const key in new_entry) {
|
||||
new_comment[key] = new_entry[key]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -630,7 +627,7 @@ export default App.controller(
|
|||
})
|
||||
}
|
||||
|
||||
var _doAcceptChanges = function (change_ids) {
|
||||
function _doAcceptChanges(change_ids) {
|
||||
$http.post(
|
||||
`/project/${$scope.project_id}/doc/${$scope.editor.open_doc_id}/changes/accept`,
|
||||
{ change_ids, _csrf: window.csrfToken }
|
||||
|
@ -638,7 +635,7 @@ export default App.controller(
|
|||
return $scope.$broadcast('changes:accept', change_ids)
|
||||
}
|
||||
|
||||
var _doRejectChanges = change_ids =>
|
||||
const _doRejectChanges = change_ids =>
|
||||
$scope.$broadcast('changes:reject', change_ids)
|
||||
|
||||
const bulkAccept = function () {
|
||||
|
@ -661,7 +658,7 @@ export default App.controller(
|
|||
|
||||
$scope.showBulkRejectDialog = () => showBulkActionsDialog(false)
|
||||
|
||||
var showBulkActionsDialog = isAccept =>
|
||||
const showBulkActionsDialog = isAccept =>
|
||||
$modal
|
||||
.open({
|
||||
templateUrl: 'bulkActionsModalTemplate',
|
||||
|
@ -806,7 +803,7 @@ export default App.controller(
|
|||
eventTracking.sendMB('rp-comment-reopen')
|
||||
}
|
||||
|
||||
var _onCommentResolved = function (thread_id, user) {
|
||||
function _onCommentResolved(thread_id, user) {
|
||||
const thread = getThread(thread_id)
|
||||
if (thread == null) {
|
||||
return
|
||||
|
@ -818,7 +815,7 @@ export default App.controller(
|
|||
return $scope.$broadcast('comment:resolve_threads', [thread_id])
|
||||
}
|
||||
|
||||
var _onCommentReopened = function (thread_id) {
|
||||
function _onCommentReopened(thread_id) {
|
||||
const thread = getThread(thread_id)
|
||||
if (thread == null) {
|
||||
return
|
||||
|
@ -830,13 +827,13 @@ export default App.controller(
|
|||
return $scope.$broadcast('comment:unresolve_thread', thread_id)
|
||||
}
|
||||
|
||||
var _onThreadDeleted = function (thread_id) {
|
||||
function _onThreadDeleted(thread_id) {
|
||||
delete $scope.reviewPanel.resolvedThreadIds[thread_id]
|
||||
delete $scope.reviewPanel.commentThreads[thread_id]
|
||||
return $scope.$broadcast('comment:remove', thread_id)
|
||||
}
|
||||
|
||||
var _onCommentEdited = function (thread_id, comment_id, content) {
|
||||
function _onCommentEdited(thread_id, comment_id, content) {
|
||||
const thread = getThread(thread_id)
|
||||
if (thread == null) {
|
||||
return
|
||||
|
@ -849,7 +846,7 @@ export default App.controller(
|
|||
return updateEntries()
|
||||
}
|
||||
|
||||
var _onCommentDeleted = function (thread_id, comment_id) {
|
||||
function _onCommentDeleted(thread_id, comment_id) {
|
||||
const thread = getThread(thread_id)
|
||||
if (thread == null) {
|
||||
return
|
||||
|
@ -965,7 +962,7 @@ export default App.controller(
|
|||
return _setUserTCState(project.owner._id, newValue, isLocal)
|
||||
}
|
||||
|
||||
var _setGuestsTCState = function (newValue, isLocal) {
|
||||
function _setGuestsTCState(newValue, isLocal) {
|
||||
if (isLocal == null) {
|
||||
isLocal = false
|
||||
}
|
||||
|
@ -1103,7 +1100,7 @@ export default App.controller(
|
|||
|
||||
let _refreshingRangeUsers = false
|
||||
const _refreshedForUserIds = {}
|
||||
var refreshChangeUsers = function (refresh_for_user_id) {
|
||||
function refreshChangeUsers(refresh_for_user_id) {
|
||||
if (refresh_for_user_id != null) {
|
||||
if (_refreshedForUserIds[refresh_for_user_id] != null) {
|
||||
// We've already tried to refresh to get this user id, so stop it looping
|
||||
|
@ -1147,7 +1144,7 @@ export default App.controller(
|
|||
}
|
||||
|
||||
let _threadsLoaded = false
|
||||
var ensureThreadsAreLoaded = function () {
|
||||
function ensureThreadsAreLoaded() {
|
||||
if (_threadsLoaded) {
|
||||
// We get any updates in real time so only need to load them once.
|
||||
return
|
||||
|
@ -1159,11 +1156,11 @@ export default App.controller(
|
|||
.then(function (response) {
|
||||
const threads = response.data
|
||||
$scope.reviewPanel.loadingThreads = false
|
||||
for (var thread_id in $scope.reviewPanel.resolvedThreadIds) {
|
||||
for (const thread_id in $scope.reviewPanel.resolvedThreadIds) {
|
||||
const _ = $scope.reviewPanel.resolvedThreadIds[thread_id]
|
||||
delete $scope.reviewPanel.resolvedThreadIds[thread_id]
|
||||
}
|
||||
for (thread_id in threads) {
|
||||
for (const thread_id in threads) {
|
||||
const thread = threads[thread_id]
|
||||
for (const comment of Array.from(thread.messages)) {
|
||||
formatComment(comment)
|
||||
|
@ -1179,13 +1176,13 @@ export default App.controller(
|
|||
})
|
||||
}
|
||||
|
||||
var formatComment = function (comment) {
|
||||
function formatComment(comment) {
|
||||
comment.user = formatUser(comment.user)
|
||||
comment.timestamp = new Date(comment.timestamp)
|
||||
return comment
|
||||
}
|
||||
|
||||
var formatUser = function (user) {
|
||||
function formatUser(user) {
|
||||
let isSelf, name
|
||||
const id =
|
||||
(user != null ? user._id : undefined) ||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue