@@ -17,7 +17,7 @@ import List from 'list.js'
17
17
18
18
import Idle from '@hackmd/idle-js'
19
19
20
- import { Spinner } from 'spin.js' ;
20
+ import { Spinner } from 'spin.js'
21
21
22
22
import {
23
23
checkLoginStateChanged ,
@@ -263,7 +263,7 @@ let visibleMD = false
263
263
let visibleLG = false
264
264
const isTouchDevice = 'ontouchstart' in document . documentElement
265
265
let currentStatus = statusType . offline
266
- let lastInfo = {
266
+ const lastInfo = {
267
267
needRestore : false ,
268
268
cursor : null ,
269
269
scroll : null ,
@@ -289,14 +289,14 @@ let lastInfo = {
289
289
let personalInfo = { }
290
290
let onlineUsers = [ ]
291
291
const fileTypes = {
292
- 'pl' : 'perl' ,
293
- ' cgi' : 'perl' ,
294
- 'js' : 'javascript' ,
295
- ' php' : 'php' ,
296
- 'sh' : 'bash' ,
297
- 'rb' : 'ruby' ,
298
- ' html' : 'html' ,
299
- 'py' : 'python'
292
+ pl : 'perl' ,
293
+ cgi : 'perl' ,
294
+ js : 'javascript' ,
295
+ php : 'php' ,
296
+ sh : 'bash' ,
297
+ rb : 'ruby' ,
298
+ html : 'html' ,
299
+ py : 'python'
300
300
}
301
301
302
302
// editor settings
@@ -956,8 +956,8 @@ ui.toolbar.export.dropbox.click(function () {
956
956
var options = {
957
957
files : [
958
958
{
959
- ' url' : noteurl + '/download' ,
960
- ' filename' : filename
959
+ url : noteurl + '/download' ,
960
+ filename : filename
961
961
}
962
962
] ,
963
963
error : function ( errorMessage ) {
@@ -1788,29 +1788,29 @@ var authorMarks = {} // temp variable
1788
1788
var addTextMarkers = [ ] // temp variable
1789
1789
function updateInfo ( data ) {
1790
1790
// console.log(data);
1791
- if ( data . hasOwnProperty ( 'createtime' ) && window . createtime !== data . createtime ) {
1791
+ if ( Object . hasOwnProperty . call ( data , 'createtime' ) && window . createtime !== data . createtime ) {
1792
1792
window . createtime = data . createtime
1793
1793
updateLastChange ( )
1794
1794
}
1795
- if ( data . hasOwnProperty ( 'updatetime' ) && window . lastchangetime !== data . updatetime ) {
1795
+ if ( Object . hasOwnProperty . call ( data , 'updatetime' ) && window . lastchangetime !== data . updatetime ) {
1796
1796
window . lastchangetime = data . updatetime
1797
1797
updateLastChange ( )
1798
1798
}
1799
- if ( data . hasOwnProperty ( 'owner' ) && window . owner !== data . owner ) {
1799
+ if ( Object . hasOwnProperty . call ( data , 'owner' ) && window . owner !== data . owner ) {
1800
1800
window . owner = data . owner
1801
1801
window . ownerprofile = data . ownerprofile
1802
1802
updateOwner ( )
1803
1803
}
1804
- if ( data . hasOwnProperty ( 'lastchangeuser' ) && window . lastchangeuser !== data . lastchangeuser ) {
1804
+ if ( Object . hasOwnProperty . call ( data , 'lastchangeuser' ) && window . lastchangeuser !== data . lastchangeuser ) {
1805
1805
window . lastchangeuser = data . lastchangeuser
1806
1806
window . lastchangeuserprofile = data . lastchangeuserprofile
1807
1807
updateLastChangeUser ( )
1808
1808
updateOwner ( )
1809
1809
}
1810
- if ( data . hasOwnProperty ( 'authors' ) && authors !== data . authors ) {
1810
+ if ( Object . hasOwnProperty . call ( data , 'authors' ) && authors !== data . authors ) {
1811
1811
authors = data . authors
1812
1812
}
1813
- if ( data . hasOwnProperty ( 'authorship' ) && authorship !== data . authorship ) {
1813
+ if ( Object . hasOwnProperty . call ( data , 'authorship' ) && authorship !== data . authorship ) {
1814
1814
authorship = data . authorship
1815
1815
updateAuthorship ( )
1816
1816
}
@@ -1855,7 +1855,7 @@ function updateAuthorshipInner () {
1855
1855
authorMarks = { }
1856
1856
for ( let i = 0 ; i < authorship . length ; i ++ ) {
1857
1857
var atom = authorship [ i ]
1858
- let author = authors [ atom [ 0 ] ]
1858
+ const author = authors [ atom [ 0 ] ]
1859
1859
if ( author ) {
1860
1860
var prePos = editor . posFromIndex ( atom [ 1 ] )
1861
1861
var preLine = editor . getLine ( prePos . line )
@@ -1873,7 +1873,7 @@ function updateAuthorshipInner () {
1873
1873
if ( prePos . ch === preLine . length ) {
1874
1874
startLine ++
1875
1875
} else if ( prePos . ch !== 0 ) {
1876
- let mark = initMarkAndCheckGutter ( authorMarks [ prePos . line ] , author , atom [ 3 ] )
1876
+ const mark = initMarkAndCheckGutter ( authorMarks [ prePos . line ] , author , atom [ 3 ] )
1877
1877
var _postPos = {
1878
1878
line : prePos . line ,
1879
1879
ch : preLine . length
@@ -1890,7 +1890,7 @@ function updateAuthorshipInner () {
1890
1890
if ( postPos . ch === 0 ) {
1891
1891
endLine --
1892
1892
} else if ( postPos . ch !== postLine . length ) {
1893
- let mark = initMarkAndCheckGutter ( authorMarks [ postPos . line ] , author , atom [ 3 ] )
1893
+ const mark = initMarkAndCheckGutter ( authorMarks [ postPos . line ] , author , atom [ 3 ] )
1894
1894
var _prePos = {
1895
1895
line : postPos . line ,
1896
1896
ch : 0
@@ -1910,7 +1910,7 @@ function updateAuthorshipInner () {
1910
1910
}
1911
1911
}
1912
1912
} else {
1913
- let mark = initMarkAndCheckGutter ( authorMarks [ prePos . line ] , author , atom [ 3 ] )
1913
+ const mark = initMarkAndCheckGutter ( authorMarks [ prePos . line ] , author , atom [ 3 ] )
1914
1914
if ( JSON . stringify ( prePos ) !== JSON . stringify ( postPos ) ) {
1915
1915
mark . textmarkers . push ( {
1916
1916
userid : author . userid ,
@@ -1923,15 +1923,15 @@ function updateAuthorshipInner () {
1923
1923
}
1924
1924
addTextMarkers = [ ]
1925
1925
editor . eachLine ( iterateLine )
1926
- var allTextMarks = editor . getAllMarks ( )
1926
+ const allTextMarks = editor . getAllMarks ( )
1927
1927
for ( let i = 0 ; i < allTextMarks . length ; i ++ ) {
1928
- let _textMarker = allTextMarks [ i ]
1929
- var pos = _textMarker . find ( )
1930
- var found = false
1928
+ const _textMarker = allTextMarks [ i ]
1929
+ const pos = _textMarker . find ( )
1930
+ let found = false
1931
1931
for ( let j = 0 ; j < addTextMarkers . length ; j ++ ) {
1932
- let textMarker = addTextMarkers [ j ]
1933
- let author = authors [ textMarker . userid ]
1934
- let className = 'authorship-inline-' + author . color . substr ( 1 )
1932
+ const textMarker = addTextMarkers [ j ]
1933
+ const author = authors [ textMarker . userid ]
1934
+ const className = 'authorship-inline-' + author . color . substr ( 1 )
1935
1935
var obj = {
1936
1936
from : textMarker . pos [ 0 ] ,
1937
1937
to : textMarker . pos [ 1 ]
@@ -1949,12 +1949,12 @@ function updateAuthorshipInner () {
1949
1949
}
1950
1950
}
1951
1951
for ( let i = 0 ; i < addTextMarkers . length ; i ++ ) {
1952
- let textMarker = addTextMarkers [ i ]
1953
- let author = authors [ textMarker . userid ]
1952
+ const textMarker = addTextMarkers [ i ]
1953
+ const author = authors [ textMarker . userid ]
1954
1954
const rgbcolor = hex2rgb ( author . color )
1955
1955
const colorString = `rgba(${ rgbcolor . red } ,${ rgbcolor . green } ,${ rgbcolor . blue } ,0.7)`
1956
1956
const styleString = `background-image: linear-gradient(to top, ${ colorString } 1px, transparent 1px);`
1957
- let className = `authorship-inline-${ author . color . substr ( 1 ) } `
1957
+ const className = `authorship-inline-${ author . color . substr ( 1 ) } `
1958
1958
const rule = `.${ className } { ${ styleString } }`
1959
1959
addStyleRule ( rule )
1960
1960
editor . markText ( textMarker . pos [ 0 ] , textMarker . pos [ 1 ] , {
@@ -1964,19 +1964,19 @@ function updateAuthorshipInner () {
1964
1964
}
1965
1965
}
1966
1966
function iterateLine ( line ) {
1967
- var lineNumber = line . lineNo ( )
1968
- var currMark = authorMarks [ lineNumber ]
1969
- var author = currMark ? authors [ currMark . gutter . userid ] : null
1967
+ const lineNumber = line . lineNo ( )
1968
+ const currMark = authorMarks [ lineNumber ]
1969
+ const author = currMark ? authors [ currMark . gutter . userid ] : null
1970
1970
if ( currMark && author ) {
1971
- let className = 'authorship-gutter-' + author . color . substr ( 1 )
1971
+ const className = 'authorship-gutter-' + author . color . substr ( 1 )
1972
1972
const gutters = line . gutterMarkers
1973
1973
if ( ! gutters || ! gutters [ 'authorship-gutters' ] ||
1974
1974
! gutters [ 'authorship-gutters' ] . className ||
1975
1975
! gutters [ 'authorship-gutters' ] . className . indexOf ( className ) < 0 ) {
1976
1976
const styleString = `border-left: 3px solid ${ author . color } ; height: ${ defaultTextHeight } px; margin-left: 3px;`
1977
1977
const rule = `.${ className } { ${ styleString } }`
1978
1978
addStyleRule ( rule )
1979
- var gutter = $ ( '<div>' , {
1979
+ const gutter = $ ( '<div>' , {
1980
1980
class : 'authorship-gutter ' + className ,
1981
1981
title : author . name
1982
1982
} )
@@ -1986,8 +1986,8 @@ function iterateLine (line) {
1986
1986
editor . setGutterMarker ( line , 'authorship-gutters' , null )
1987
1987
}
1988
1988
if ( currMark && currMark . textmarkers . length > 0 ) {
1989
- for ( var i = 0 ; i < currMark . textmarkers . length ; i ++ ) {
1990
- let textMarker = currMark . textmarkers [ i ]
1989
+ for ( let i = 0 ; i < currMark . textmarkers . length ; i ++ ) {
1990
+ const textMarker = currMark . textmarkers [ i ]
1991
1991
if ( textMarker . userid !== currMark . gutter . userid ) {
1992
1992
addTextMarkers . push ( textMarker )
1993
1993
}
@@ -1998,12 +1998,12 @@ editorInstance.on('update', function () {
1998
1998
$ ( '.authorship-gutter:not([data-original-title])' ) . tooltip ( {
1999
1999
container : '.CodeMirror-lines' ,
2000
2000
placement : 'right' ,
2001
- delay : { ' show' : 500 , ' hide' : 100 }
2001
+ delay : { show : 500 , hide : 100 }
2002
2002
} )
2003
2003
$ ( '.authorship-inline:not([data-original-title])' ) . tooltip ( {
2004
2004
container : '.CodeMirror-lines' ,
2005
2005
placement : 'bottom' ,
2006
- delay : { ' show' : 500 , ' hide' : 100 }
2006
+ delay : { show : 500 , hide : 100 }
2007
2007
} )
2008
2008
// clear tooltip which described element has been removed
2009
2009
$ ( '[id^="tooltip"]' ) . each ( function ( index , element ) {
@@ -2064,7 +2064,7 @@ var cmClient = null
2064
2064
var synchronized_ = null
2065
2065
2066
2066
function havePendingOperation ( ) {
2067
- return ! ! ( ( cmClient && cmClient . state && cmClient . state . hasOwnProperty ( 'outstanding' ) ) )
2067
+ return ! ! ( ( cmClient && cmClient . state && Object . hasOwnProperty . call ( cmClient . state , 'outstanding' ) ) )
2068
2068
}
2069
2069
2070
2070
socket . on ( 'doc' , function ( obj ) {
@@ -2224,7 +2224,7 @@ function updateOnlineStatus () {
2224
2224
break
2225
2225
}
2226
2226
}
2227
- let id = items [ i ] . values ( ) . id
2227
+ const id = items [ i ] . values ( ) . id
2228
2228
if ( found ) {
2229
2229
onlineUserList . get ( 'id' , id ) [ 0 ] . values ( _onlineUsers [ foundindex ] )
2230
2230
shortOnlineUserList . get ( 'id' , id ) [ 0 ] . values ( _onlineUsers [ foundindex ] )
@@ -2418,19 +2418,19 @@ function buildCursor (user) {
2418
2418
break
2419
2419
}
2420
2420
if ( $ ( 'div[data-clientid="' + user . id + '"]' ) . length <= 0 ) {
2421
- let cursor = $ ( '<div data-clientid="' + user . id + '" class="CodeMirror-other-cursor" style="display:none;"></div>' )
2421
+ const cursor = $ ( '<div data-clientid="' + user . id + '" class="CodeMirror-other-cursor" style="display:none;"></div>' )
2422
2422
cursor . attr ( 'data-line' , user . cursor . line )
2423
2423
cursor . attr ( 'data-ch' , user . cursor . ch )
2424
2424
cursor . attr ( 'data-offset-left' , 0 )
2425
2425
cursor . attr ( 'data-offset-top' , 0 )
2426
2426
2427
- let cursorbar = $ ( '<div class="cursorbar"> </div>' )
2427
+ const cursorbar = $ ( '<div class="cursorbar"> </div>' )
2428
2428
cursorbar [ 0 ] . style . height = defaultTextHeight + 'px'
2429
2429
cursorbar [ 0 ] . style . borderLeft = '2px solid ' + user . color
2430
2430
2431
2431
var icon = '<i class="fa ' + iconClass + '"></i>'
2432
2432
2433
- let cursortag = $ ( '<div class="cursortag">' + icon + ' <span class="name">' + user . name + '</span></div>' )
2433
+ const cursortag = $ ( '<div class="cursortag">' + icon + ' <span class="name">' + user . name + '</span></div>' )
2434
2434
// cursortag[0].style.background = color;
2435
2435
cursortag [ 0 ] . style . color = user . color
2436
2436
@@ -2486,15 +2486,15 @@ function buildCursor (user) {
2486
2486
2487
2487
checkCursorTag ( coord , cursortag )
2488
2488
} else {
2489
- let cursor = $ ( 'div[data-clientid="' + user . id + '"]' )
2489
+ const cursor = $ ( 'div[data-clientid="' + user . id + '"]' )
2490
2490
cursor . attr ( 'data-line' , user . cursor . line )
2491
2491
cursor . attr ( 'data-ch' , user . cursor . ch )
2492
2492
2493
- let cursorbar = cursor . find ( '.cursorbar' )
2493
+ const cursorbar = cursor . find ( '.cursorbar' )
2494
2494
cursorbar [ 0 ] . style . height = defaultTextHeight + 'px'
2495
2495
cursorbar [ 0 ] . style . borderLeft = '2px solid ' + user . color
2496
2496
2497
- let cursortag = cursor . find ( '.cursortag' )
2497
+ const cursortag = cursor . find ( '.cursortag' )
2498
2498
cursortag . find ( 'i' ) . removeClass ( ) . addClass ( 'fa' ) . addClass ( iconClass )
2499
2499
cursortag . find ( '.name' ) . text ( user . name )
2500
2500
@@ -2503,8 +2503,8 @@ function buildCursor (user) {
2503
2503
cursor [ 0 ] . style . top = coord . top + 'px'
2504
2504
} else {
2505
2505
cursor . animate ( {
2506
- ' left' : coord . left ,
2507
- ' top' : coord . top
2506
+ left : coord . left ,
2507
+ top : coord . top
2508
2508
} , {
2509
2509
duration : cursorAnimatePeriod ,
2510
2510
queue : false
@@ -2713,8 +2713,8 @@ function restoreInfo () {
2713
2713
$ ( window ) . scrollLeft ( lastInfo . edit . scroll . left )
2714
2714
$ ( window ) . scrollTop ( lastInfo . edit . scroll . top )
2715
2715
} else {
2716
- let left = lastInfo . edit . scroll . left
2717
- let top = lastInfo . edit . scroll . top
2716
+ const left = lastInfo . edit . scroll . left
2717
+ const top = lastInfo . edit . scroll . top
2718
2718
editor . scrollIntoView ( )
2719
2719
editor . scrollTo ( left , top )
2720
2720
}
@@ -2724,8 +2724,8 @@ function restoreInfo () {
2724
2724
$ ( window ) . scrollTop ( lastInfo . view . scroll . top )
2725
2725
break
2726
2726
case modeType . both :
2727
- let left = lastInfo . edit . scroll . left
2728
- let top = lastInfo . edit . scroll . top
2727
+ const left = lastInfo . edit . scroll . left
2728
+ const top = lastInfo . edit . scroll . top
2729
2729
editor . scrollIntoView ( )
2730
2730
editor . scrollTo ( left , top )
2731
2731
ui . area . view . scrollLeft ( lastInfo . view . scroll . left )
@@ -2847,8 +2847,8 @@ function partialUpdate (src, tar, des) {
2847
2847
for ( let i = 0 ; i < tar . length ; i ++ ) {
2848
2848
// copyAttribute(src[i], des[i], 'data-startline');
2849
2849
// copyAttribute(src[i], des[i], 'data-endline');
2850
- let rawSrc = cloneAndRemoveDataAttr ( src [ i ] )
2851
- let rawTar = cloneAndRemoveDataAttr ( tar [ i ] )
2850
+ const rawSrc = cloneAndRemoveDataAttr ( src [ i ] )
2851
+ const rawTar = cloneAndRemoveDataAttr ( tar [ i ] )
2852
2852
if ( ! rawSrc || ! rawTar || rawSrc . outerHTML !== rawTar . outerHTML ) {
2853
2853
start = i
2854
2854
break
@@ -2860,34 +2860,34 @@ function partialUpdate (src, tar, des) {
2860
2860
for ( let i = 0 ; i < src . length ; i ++ ) {
2861
2861
// copyAttribute(src[i], des[i], 'data-startline');
2862
2862
// copyAttribute(src[i], des[i], 'data-endline');
2863
- let rawSrc = cloneAndRemoveDataAttr ( src [ i ] )
2864
- let rawTar = cloneAndRemoveDataAttr ( tar [ i ] )
2863
+ const rawSrc = cloneAndRemoveDataAttr ( src [ i ] )
2864
+ const rawTar = cloneAndRemoveDataAttr ( tar [ i ] )
2865
2865
if ( ! rawSrc || ! rawTar || rawSrc . outerHTML !== rawTar . outerHTML ) {
2866
2866
start = i
2867
2867
break
2868
2868
}
2869
2869
}
2870
2870
// tar end
2871
2871
for ( let i = 1 ; i <= tar . length + 1 ; i ++ ) {
2872
- let srcLength = src . length
2873
- let tarLength = tar . length
2872
+ const srcLength = src . length
2873
+ const tarLength = tar . length
2874
2874
// copyAttribute(src[srcLength - i], des[srcLength - i], 'data-startline');
2875
2875
// copyAttribute(src[srcLength - i], des[srcLength - i], 'data-endline');
2876
- let rawSrc = cloneAndRemoveDataAttr ( src [ srcLength - i ] )
2877
- let rawTar = cloneAndRemoveDataAttr ( tar [ tarLength - i ] )
2876
+ const rawSrc = cloneAndRemoveDataAttr ( src [ srcLength - i ] )
2877
+ const rawTar = cloneAndRemoveDataAttr ( tar [ tarLength - i ] )
2878
2878
if ( ! rawSrc || ! rawTar || rawSrc . outerHTML !== rawTar . outerHTML ) {
2879
2879
tarEnd = tar . length - i
2880
2880
break
2881
2881
}
2882
2882
}
2883
2883
// src end
2884
2884
for ( let i = 1 ; i <= src . length + 1 ; i ++ ) {
2885
- let srcLength = src . length
2886
- let tarLength = tar . length
2885
+ const srcLength = src . length
2886
+ const tarLength = tar . length
2887
2887
// copyAttribute(src[srcLength - i], des[srcLength - i], 'data-startline');
2888
2888
// copyAttribute(src[srcLength - i], des[srcLength - i], 'data-endline');
2889
- let rawSrc = cloneAndRemoveDataAttr ( src [ srcLength - i ] )
2890
- let rawTar = cloneAndRemoveDataAttr ( tar [ tarLength - i ] )
2889
+ const rawSrc = cloneAndRemoveDataAttr ( src [ srcLength - i ] )
2890
+ const rawTar = cloneAndRemoveDataAttr ( tar [ tarLength - i ] )
2891
2891
if ( ! rawSrc || ! rawTar || rawSrc . outerHTML !== rawTar . outerHTML ) {
2892
2892
srcEnd = src . length - i
2893
2893
break
@@ -3318,22 +3318,22 @@ $(editor.getInputField())
3318
3318
'textComplete:show' : function ( e ) {
3319
3319
$ ( this ) . data ( 'autocompleting' , true )
3320
3320
editor . setOption ( 'extraKeys' , {
3321
- 'Up' : function ( ) {
3321
+ Up : function ( ) {
3322
3322
return false
3323
3323
} ,
3324
- ' Right' : function ( ) {
3324
+ Right : function ( ) {
3325
3325
editor . doc . cm . execCommand ( 'goCharRight' )
3326
3326
} ,
3327
- ' Down' : function ( ) {
3327
+ Down : function ( ) {
3328
3328
return false
3329
3329
} ,
3330
- ' Left' : function ( ) {
3330
+ Left : function ( ) {
3331
3331
editor . doc . cm . execCommand ( 'goCharLeft' )
3332
3332
} ,
3333
- ' Enter' : function ( ) {
3333
+ Enter : function ( ) {
3334
3334
return false
3335
3335
} ,
3336
- ' Backspace' : function ( ) {
3336
+ Backspace : function ( ) {
3337
3337
editor . doc . cm . execCommand ( 'delCharBefore' )
3338
3338
}
3339
3339
} )
0 commit comments