Skip to content

Commit cac618e

Browse files
committed
Fix front-end index.js code styles
1 parent 802ed40 commit cac618e

1 file changed

Lines changed: 34 additions & 24 deletions

File tree

public/js/index.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function updateStatusBar () {
333333
var end = head.line >= anchor.line ? head : anchor
334334
var selectionText = ' — Selected '
335335
var selectionCharCount = Math.abs(head.ch - anchor.ch)
336-
// borrow from brackets EditorStatusBar.js
336+
// borrow from brackets EditorStatusBar.js
337337
if (start.line !== end.line) {
338338
var lines = end.line - start.line + 1
339339
if (end.ch === 0) {
@@ -649,7 +649,7 @@ function checkEditorStyle () {
649649
},
650650
stop: function (e) {
651651
lastEditorWidth = ui.area.edit.width()
652-
// workaround that scroll event bindings
652+
// workaround that scroll event bindings
653653
window.preventSyncScrollToView = 2
654654
window.preventSyncScrollToEdit = true
655655
editor.setOption('viewportMargin', viewportMargin)
@@ -843,19 +843,19 @@ function changeMode (type) {
843843
ui.area.view.show()
844844
break
845845
}
846-
// save mode to url
846+
// save mode to url
847847
if (history.replaceState && window.loaded) history.replaceState(null, '', serverurl + '/' + noteid + '?' + window.currentMode.name)
848848
if (window.currentMode === modeType.view) {
849849
editor.getInputField().blur()
850850
}
851851
if (window.currentMode === modeType.edit || window.currentMode === modeType.both) {
852852
ui.toolbar.uploadImage.fadeIn()
853-
// add and update status bar
853+
// add and update status bar
854854
if (!editorInstance.statusBar) {
855855
editorInstance.addStatusBar()
856856
updateStatusBar()
857857
}
858-
// work around foldGutter might not init properly
858+
// work around foldGutter might not init properly
859859
editor.setOption('foldGutter', false)
860860
editor.setOption('foldGutter', true)
861861
} else {
@@ -1298,7 +1298,7 @@ function selectRevision (time) {
12981298
var currIndex = patch.start1 + bias
12991299
for (var i = 0; i < patch.diffs.length; i++) {
13001300
var diff = patch.diffs[i]
1301-
// ignore if diff only contains line breaks
1301+
// ignore if diff only contains line breaks
13021302
if ((diff[1].match(/\n/g) || []).length === diff[1].length) continue
13031303
var prePos
13041304
var postPos
@@ -1987,7 +1987,10 @@ function updateAuthorshipInner () {
19871987
ch: preLine.length
19881988
}
19891989
if (JSON.stringify(prePos) !== JSON.stringify(_postPos)) {
1990-
mark.textmarkers.push({ userid: author.userid, pos: [prePos, _postPos] })
1990+
mark.textmarkers.push({
1991+
userid: author.userid,
1992+
pos: [prePos, _postPos]
1993+
})
19911994
startLine++
19921995
}
19931996
authorMarks[prePos.line] = mark
@@ -2001,7 +2004,10 @@ function updateAuthorshipInner () {
20012004
ch: 0
20022005
}
20032006
if (JSON.stringify(_prePos) !== JSON.stringify(postPos)) {
2004-
mark.textmarkers.push({ userid: author.userid, pos: [_prePos, postPos] })
2007+
mark.textmarkers.push({
2008+
userid: author.userid,
2009+
pos: [_prePos, postPos]
2010+
})
20052011
endLine--
20062012
}
20072013
authorMarks[postPos.line] = mark
@@ -2374,7 +2380,11 @@ function sortOnlineUserList (list) {
23742380
if (!usera.idle && userb.idle) { return -1 } else if (usera.idle && !userb.idle) { return 1 } else {
23752381
if (usera.name && userb.name && usera.name.toLowerCase() < userb.name.toLowerCase()) {
23762382
return -1
2377-
} else if (usera.name && userb.name && usera.name.toLowerCase() > userb.name.toLowerCase()) { return 1 } else { if (usera.color && userb.color && usera.color.toLowerCase() < userb.color.toLowerCase()) { return -1 } else if (usera.color && userb.color && usera.color.toLowerCase() > userb.color.toLowerCase()) { return 1 } else { return 0 } }
2383+
} else if (usera.name && userb.name && usera.name.toLowerCase() > userb.name.toLowerCase()) {
2384+
return 1
2385+
} else {
2386+
if (usera.color && userb.color && usera.color.toLowerCase() < userb.color.toLowerCase()) { return -1 } else if (usera.color && userb.color && usera.color.toLowerCase() > userb.color.toLowerCase()) { return 1 } else { return 0 }
2387+
}
23782388
}
23792389
}
23802390
}
@@ -2410,11 +2420,11 @@ function deduplicateOnlineUsers (list) {
24102420
var found = false
24112421
for (var j = 0; j < _onlineUsers.length; j++) {
24122422
if (_onlineUsers[j].userid === user.userid) {
2413-
// keep self color when login
2423+
// keep self color when login
24142424
if (user.id === window.personalInfo.id) {
24152425
_onlineUsers[j].color = user.color
24162426
}
2417-
// keep idle state if any of self client not idle
2427+
// keep idle state if any of self client not idle
24182428
if (!user.idle) {
24192429
_onlineUsers[j].idle = user.idle
24202430
_onlineUsers[j].color = user.color
@@ -2458,38 +2468,38 @@ function emitUserStatus (force) {
24582468

24592469
function checkCursorTag (coord, ele) {
24602470
if (!ele) return // return if element not exists
2461-
// set margin
2471+
// set margin
24622472
var tagRightMargin = 0
24632473
var tagBottomMargin = 2
2464-
// use sizer to get the real doc size (won't count status bar and gutters)
2474+
// use sizer to get the real doc size (won't count status bar and gutters)
24652475
var docWidth = ui.area.codemirrorSizer.width()
2466-
// get editor size (status bar not count in)
2476+
// get editor size (status bar not count in)
24672477
var editorHeight = ui.area.codemirror.height()
2468-
// get element size
2478+
// get element size
24692479
var width = ele.outerWidth()
24702480
var height = ele.outerHeight()
24712481
var padding = (ele.outerWidth() - ele.width()) / 2
2472-
// get coord position
2482+
// get coord position
24732483
var left = coord.left
24742484
var top = coord.top
2475-
// get doc top offset (to workaround with viewport)
2485+
// get doc top offset (to workaround with viewport)
24762486
var docTopOffset = ui.area.codemirrorSizerInner.position().top
2477-
// set offset
2487+
// set offset
24782488
var offsetLeft = -3
24792489
var offsetTop = defaultTextHeight
2480-
// only do when have width and height
2490+
// only do when have width and height
24812491
if (width > 0 && height > 0) {
2482-
// flip x when element right bound larger than doc width
2492+
// flip x when element right bound larger than doc width
24832493
if (left + width + offsetLeft + tagRightMargin > docWidth) {
24842494
offsetLeft = -(width + tagRightMargin) + padding + offsetLeft
24852495
}
2486-
// flip y when element bottom bound larger than doc height
2487-
// and element top position is larger than element height
2496+
// flip y when element bottom bound larger than doc height
2497+
// and element top position is larger than element height
24882498
if (top + docTopOffset + height + offsetTop + tagBottomMargin > Math.max(editor.doc.height, editorHeight) && top + docTopOffset > height + tagBottomMargin) {
24892499
offsetTop = -(height)
24902500
}
24912501
}
2492-
// set position
2502+
// set position
24932503
ele[0].style.left = offsetLeft + 'px'
24942504
ele[0].style.top = offsetTop + 'px'
24952505
}
@@ -2532,7 +2542,7 @@ function buildCursor (user) {
25322542
var icon = '<i class="fa ' + iconClass + '"></i>'
25332543

25342544
let cursortag = $('<div class="cursortag">' + icon + '&nbsp;<span class="name">' + user.name + '</span></div>')
2535-
// cursortag[0].style.background = color;
2545+
// cursortag[0].style.background = color;
25362546
cursortag[0].style.color = user.color
25372547

25382548
cursor.attr('data-mode', 'hover')

0 commit comments

Comments
 (0)