diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-03-07 10:48:56 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-03-07 10:48:56 -0500 |
commit | ba64f34df19d446cbe5b8ec2e367d4f6a4d1061f (patch) | |
tree | e3ffd0298e919191d6e84c102f90297d7715c7bf /ext/bg | |
parent | 93aa275d827816c624f30548ac635b4fea1d23eb (diff) |
Mark fields as private
Diffstat (limited to 'ext/bg')
-rw-r--r-- | ext/bg/js/clipboard-monitor.js | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/ext/bg/js/clipboard-monitor.js b/ext/bg/js/clipboard-monitor.js index 2ba6d487..a6d73c79 100644 --- a/ext/bg/js/clipboard-monitor.js +++ b/ext/bg/js/clipboard-monitor.js @@ -21,59 +21,59 @@ class ClipboardMonitor extends EventDispatcher { constructor({getClipboard}) { super(); - this.timerId = null; - this.timerToken = null; - this.interval = 250; - this.previousText = null; - this.getClipboard = getClipboard; + this._timerId = null; + this._timerToken = null; + this._interval = 250; + this._previousText = null; + this._getClipboard = getClipboard; } start() { this.stop(); // The token below is used as a unique identifier to ensure that a new clipboard monitor - // hasn't been started during the await call. The check below the await this.getClipboard() + // hasn't been started during the await call. The check below the await this._getClipboard() // call will exit early if the reference has changed. const token = {}; const intervalCallback = async () => { - this.timerId = null; + this._timerId = null; let text = null; try { - text = await this.getClipboard(); + text = await this._getClipboard(); } catch (e) { // NOP } - if (this.timerToken !== token) { return; } + if (this._timerToken !== token) { return; } if ( typeof text === 'string' && (text = text.trim()).length > 0 && - text !== this.previousText + text !== this._previousText ) { - this.previousText = text; + this._previousText = text; if (jpIsStringPartiallyJapanese(text)) { this.trigger('change', {text}); } } - this.timerId = setTimeout(intervalCallback, this.interval); + this._timerId = setTimeout(intervalCallback, this._interval); }; - this.timerToken = token; + this._timerToken = token; intervalCallback(); } stop() { - this.timerToken = null; - if (this.timerId !== null) { - clearTimeout(this.timerId); - this.timerId = null; + this._timerToken = null; + if (this._timerId !== null) { + clearTimeout(this._timerId); + this._timerId = null; } } setPreviousText(text) { - this.previousText = text; + this._previousText = text; } } |