summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
authorWu Cheng-Han2017-03-22 17:48:26 +0800
committerWu Cheng-Han2017-03-22 17:48:26 +0800
commitcac618eca88e62fbbf262846506c5e7cfeabbe2e (patch)
tree2b7d5f4079a19fd19dacc145ddeffd487291f326 /public/js
parent802ed406e65072fc83aee402a5aa86523c530b4d (diff)
Fix front-end index.js code styles
Diffstat (limited to 'public/js')
-rw-r--r--public/js/index.js58
1 files changed, 34 insertions, 24 deletions
diff --git a/public/js/index.js b/public/js/index.js
index e5142f29..7d17d0fc 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -333,7 +333,7 @@ function updateStatusBar () {
var end = head.line >= anchor.line ? head : anchor
var selectionText = ' — Selected '
var selectionCharCount = Math.abs(head.ch - anchor.ch)
- // borrow from brackets EditorStatusBar.js
+ // borrow from brackets EditorStatusBar.js
if (start.line !== end.line) {
var lines = end.line - start.line + 1
if (end.ch === 0) {
@@ -649,7 +649,7 @@ function checkEditorStyle () {
},
stop: function (e) {
lastEditorWidth = ui.area.edit.width()
- // workaround that scroll event bindings
+ // workaround that scroll event bindings
window.preventSyncScrollToView = 2
window.preventSyncScrollToEdit = true
editor.setOption('viewportMargin', viewportMargin)
@@ -843,19 +843,19 @@ function changeMode (type) {
ui.area.view.show()
break
}
- // save mode to url
+ // save mode to url
if (history.replaceState && window.loaded) history.replaceState(null, '', serverurl + '/' + noteid + '?' + window.currentMode.name)
if (window.currentMode === modeType.view) {
editor.getInputField().blur()
}
if (window.currentMode === modeType.edit || window.currentMode === modeType.both) {
ui.toolbar.uploadImage.fadeIn()
- // add and update status bar
+ // add and update status bar
if (!editorInstance.statusBar) {
editorInstance.addStatusBar()
updateStatusBar()
}
- // work around foldGutter might not init properly
+ // work around foldGutter might not init properly
editor.setOption('foldGutter', false)
editor.setOption('foldGutter', true)
} else {
@@ -1298,7 +1298,7 @@ function selectRevision (time) {
var currIndex = patch.start1 + bias
for (var i = 0; i < patch.diffs.length; i++) {
var diff = patch.diffs[i]
- // ignore if diff only contains line breaks
+ // ignore if diff only contains line breaks
if ((diff[1].match(/\n/g) || []).length === diff[1].length) continue
var prePos
var postPos
@@ -1987,7 +1987,10 @@ function updateAuthorshipInner () {
ch: preLine.length
}
if (JSON.stringify(prePos) !== JSON.stringify(_postPos)) {
- mark.textmarkers.push({ userid: author.userid, pos: [prePos, _postPos] })
+ mark.textmarkers.push({
+ userid: author.userid,
+ pos: [prePos, _postPos]
+ })
startLine++
}
authorMarks[prePos.line] = mark
@@ -2001,7 +2004,10 @@ function updateAuthorshipInner () {
ch: 0
}
if (JSON.stringify(_prePos) !== JSON.stringify(postPos)) {
- mark.textmarkers.push({ userid: author.userid, pos: [_prePos, postPos] })
+ mark.textmarkers.push({
+ userid: author.userid,
+ pos: [_prePos, postPos]
+ })
endLine--
}
authorMarks[postPos.line] = mark
@@ -2374,7 +2380,11 @@ function sortOnlineUserList (list) {
if (!usera.idle && userb.idle) { return -1 } else if (usera.idle && !userb.idle) { return 1 } else {
if (usera.name && userb.name && usera.name.toLowerCase() < userb.name.toLowerCase()) {
return -1
- } 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 } }
+ } 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 }
+ }
}
}
}
@@ -2410,11 +2420,11 @@ function deduplicateOnlineUsers (list) {
var found = false
for (var j = 0; j < _onlineUsers.length; j++) {
if (_onlineUsers[j].userid === user.userid) {
- // keep self color when login
+ // keep self color when login
if (user.id === window.personalInfo.id) {
_onlineUsers[j].color = user.color
}
- // keep idle state if any of self client not idle
+ // keep idle state if any of self client not idle
if (!user.idle) {
_onlineUsers[j].idle = user.idle
_onlineUsers[j].color = user.color
@@ -2458,38 +2468,38 @@ function emitUserStatus (force) {
function checkCursorTag (coord, ele) {
if (!ele) return // return if element not exists
- // set margin
+ // set margin
var tagRightMargin = 0
var tagBottomMargin = 2
- // use sizer to get the real doc size (won't count status bar and gutters)
+ // use sizer to get the real doc size (won't count status bar and gutters)
var docWidth = ui.area.codemirrorSizer.width()
- // get editor size (status bar not count in)
+ // get editor size (status bar not count in)
var editorHeight = ui.area.codemirror.height()
- // get element size
+ // get element size
var width = ele.outerWidth()
var height = ele.outerHeight()
var padding = (ele.outerWidth() - ele.width()) / 2
- // get coord position
+ // get coord position
var left = coord.left
var top = coord.top
- // get doc top offset (to workaround with viewport)
+ // get doc top offset (to workaround with viewport)
var docTopOffset = ui.area.codemirrorSizerInner.position().top
- // set offset
+ // set offset
var offsetLeft = -3
var offsetTop = defaultTextHeight
- // only do when have width and height
+ // only do when have width and height
if (width > 0 && height > 0) {
- // flip x when element right bound larger than doc width
+ // flip x when element right bound larger than doc width
if (left + width + offsetLeft + tagRightMargin > docWidth) {
offsetLeft = -(width + tagRightMargin) + padding + offsetLeft
}
- // flip y when element bottom bound larger than doc height
- // and element top position is larger than element height
+ // flip y when element bottom bound larger than doc height
+ // and element top position is larger than element height
if (top + docTopOffset + height + offsetTop + tagBottomMargin > Math.max(editor.doc.height, editorHeight) && top + docTopOffset > height + tagBottomMargin) {
offsetTop = -(height)
}
}
- // set position
+ // set position
ele[0].style.left = offsetLeft + 'px'
ele[0].style.top = offsetTop + 'px'
}
@@ -2532,7 +2542,7 @@ function buildCursor (user) {
var icon = '<i class="fa ' + iconClass + '"></i>'
let cursortag = $('<div class="cursortag">' + icon + '&nbsp;<span class="name">' + user.name + '</span></div>')
- // cursortag[0].style.background = color;
+ // cursortag[0].style.background = color;
cursortag[0].style.color = user.color
cursor.attr('data-mode', 'hover')