@@ -258,14 +258,14 @@ var defaultMode = modeType.view
258258
259259// global vars
260260window . loaded = false
261- window . needRefresh = false
262- window . isDirty = false
263- window . editShown = false
264- window . visibleXS = false
265- window . visibleSM = false
266- window . visibleMD = false
267- window . visibleLG = false
268- window . isTouchDevice = 'ontouchstart' in document . documentElement
261+ let needRefresh = false
262+ let isDirty = false
263+ let editShown = false
264+ let visibleXS = false
265+ let visibleSM = false
266+ let visibleMD = false
267+ let visibleLG = false
268+ const isTouchDevice = 'ontouchstart' in document . documentElement
269269window . currentMode = defaultMode
270270window . currentStatus = statusType . offline
271271window . lastInfo = {
@@ -393,7 +393,7 @@ function setRefreshModal (status) {
393393}
394394
395395function setNeedRefresh ( ) {
396- window . needRefresh = true
396+ needRefresh = true
397397 editor . setOption ( 'readOnly' , true )
398398 socket . disconnect ( )
399399 showStatus ( statusType . offline )
@@ -415,7 +415,7 @@ Visibility.change(function (e, state) {
415415 }
416416 } else {
417417 if ( wasFocus ) {
418- if ( ! window . visibleXS ) {
418+ if ( ! visibleXS ) {
419419 editor . focus ( )
420420 editor . refresh ( )
421421 }
@@ -432,7 +432,7 @@ $(document).ready(function () {
432432 checkResponsive ( )
433433 // if in smaller screen, we don't need advanced scrollbar
434434 var scrollbarStyle
435- if ( window . visibleXS ) {
435+ if ( visibleXS ) {
436436 scrollbarStyle = 'native'
437437 } else {
438438 scrollbarStyle = 'overlay'
@@ -443,7 +443,7 @@ $(document).ready(function () {
443443 }
444444 checkEditorStyle ( )
445445 /* we need this only on touch devices */
446- if ( window . isTouchDevice ) {
446+ if ( isTouchDevice ) {
447447 /* cache dom references */
448448 var $body = $ ( 'body' )
449449
@@ -553,12 +553,12 @@ function editorHasFocus () {
553553
554554// 768-792px have a gap
555555function checkResponsive ( ) {
556- window . visibleXS = $ ( '.visible-xs' ) . is ( ':visible' )
557- window . visibleSM = $ ( '.visible-sm' ) . is ( ':visible' )
558- window . visibleMD = $ ( '.visible-md' ) . is ( ':visible' )
559- window . visibleLG = $ ( '.visible-lg' ) . is ( ':visible' )
556+ visibleXS = $ ( '.visible-xs' ) . is ( ':visible' )
557+ visibleSM = $ ( '.visible-sm' ) . is ( ':visible' )
558+ visibleMD = $ ( '.visible-md' ) . is ( ':visible' )
559+ visibleLG = $ ( '.visible-lg' ) . is ( ':visible' )
560560
561- if ( window . visibleXS && window . currentMode === modeType . both ) {
561+ if ( visibleXS && window . currentMode === modeType . both ) {
562562 if ( editorHasFocus ( ) ) { changeMode ( modeType . edit ) } else { changeMode ( modeType . view ) }
563563 }
564564
@@ -780,9 +780,9 @@ function changeMode (type) {
780780 case modeType . edit :
781781 ui . area . edit . show ( )
782782 ui . area . view . hide ( )
783- if ( ! window . editShown ) {
783+ if ( ! editShown ) {
784784 editor . refresh ( )
785- window . editShown = true
785+ editShown = true
786786 }
787787 break
788788 case modeType . view :
@@ -1764,11 +1764,11 @@ var socket = io.connect({
17641764// overwrite original event for checking login state
17651765var on = socket . on
17661766socket . on = function ( ) {
1767- if ( ! checkLoginStateChanged ( ) && ! window . needRefresh ) { return on . apply ( socket , arguments ) }
1767+ if ( ! checkLoginStateChanged ( ) && ! needRefresh ) { return on . apply ( socket , arguments ) }
17681768}
17691769var emit = socket . emit
17701770socket . emit = function ( ) {
1771- if ( ! checkLoginStateChanged ( ) && ! window . needRefresh ) { emit . apply ( socket , arguments ) }
1771+ if ( ! checkLoginStateChanged ( ) && ! needRefresh ) { emit . apply ( socket , arguments ) }
17721772}
17731773socket . on ( 'info' , function ( data ) {
17741774 console . error ( data )
@@ -1814,7 +1814,7 @@ socket.on('disconnect', function (data) {
18141814 if ( ! editor . getOption ( 'readOnly' ) ) { editor . setOption ( 'readOnly' , true ) }
18151815 if ( ! retryTimer ) {
18161816 retryTimer = setInterval ( function ( ) {
1817- if ( ! window . needRefresh ) socket . connect ( )
1817+ if ( ! needRefresh ) socket . connect ( )
18181818 } , 1000 )
18191819 }
18201820} )
@@ -2089,15 +2089,15 @@ socket.on('refresh', function (data) {
20892089 // auto change mode if no content detected
20902090 var nocontent = editor . getValue ( ) . length <= 0
20912091 if ( nocontent ) {
2092- if ( window . visibleXS ) { window . currentMode = modeType . edit } else { window . currentMode = modeType . both }
2092+ if ( visibleXS ) { window . currentMode = modeType . edit } else { window . currentMode = modeType . both }
20932093 }
20942094 // parse mode from url
20952095 if ( window . location . search . length > 0 ) {
20962096 var urlMode = modeType [ window . location . search . substr ( 1 ) ]
20972097 if ( urlMode ) window . currentMode = urlMode
20982098 }
20992099 changeMode ( window . currentMode )
2100- if ( nocontent && ! window . visibleXS ) {
2100+ if ( nocontent && ! visibleXS ) {
21012101 editor . focus ( )
21022102 editor . refresh ( )
21032103 }
@@ -2169,20 +2169,20 @@ socket.on('doc', function (obj) {
21692169 }
21702170
21712171 if ( setDoc && bodyMismatch ) {
2172- window . isDirty = true
2172+ isDirty = true
21732173 updateView ( )
21742174 }
21752175
21762176 restoreInfo ( )
21772177} )
21782178
21792179socket . on ( 'ack' , function ( ) {
2180- window . isDirty = true
2180+ isDirty = true
21812181 updateView ( )
21822182} )
21832183
21842184socket . on ( 'operation' , function ( ) {
2185- window . isDirty = true
2185+ isDirty = true
21862186 updateView ( )
21872187} )
21882188
@@ -2395,7 +2395,7 @@ var userStatusCache = null
23952395function emitUserStatus ( force ) {
23962396 if ( ! window . loaded ) return
23972397 var type = null
2398- if ( window . visibleXS ) { type = 'xs' } else if ( window . visibleSM ) { type = 'sm' } else if ( window . visibleMD ) { type = 'md' } else if ( window . visibleLG ) { type = 'lg' }
2398+ if ( visibleXS ) { type = 'xs' } else if ( visibleSM ) { type = 'sm' } else if ( visibleMD ) { type = 'md' } else if ( visibleLG ) { type = 'lg' }
23992399
24002400 window . personalInfo [ 'idle' ] = idle . isAway
24012401 window . personalInfo [ 'type' ] = type
@@ -2800,7 +2800,7 @@ function restoreInfo () {
28002800// view actions
28012801function refreshView ( ) {
28022802 ui . area . markdown . html ( '' )
2803- window . isDirty = true
2803+ isDirty = true
28042804 updateViewInner ( )
28052805}
28062806
@@ -2812,7 +2812,7 @@ var lastResult = null
28122812var postUpdateEvent = null
28132813
28142814function updateViewInner ( ) {
2815- if ( window . currentMode === modeType . edit || ! window . isDirty ) return
2815+ if ( window . currentMode === modeType . edit || ! isDirty ) return
28162816 var value = editor . getValue ( )
28172817 var lastMeta = md . meta
28182818 md . meta = { }
@@ -2860,7 +2860,7 @@ function updateViewInner () {
28602860 generateScrollspy ( )
28612861 updateScrollspy ( )
28622862 smoothHashScroll ( )
2863- window . isDirty = false
2863+ isDirty = false
28642864 clearMap ( )
28652865 // buildMap();
28662866 updateTitleReminder ( )
0 commit comments