MCPcopy Create free account
hub / github.com/cryptii/cryptii / update

Method update

src/View/Encoder.js:87–128  ·  view source on GitHub ↗

* Updates view on model change. * @return {View} Fluent interface

()

Source from the content-addressed store, hash-verified

85 * @return {View} Fluent interface
86 */
87 update () {
88 // Update action
89 const reverse = this.getModel().isReverse()
90
91 if (reverse) {
92 this._$encodeAction.classList.remove('brick__action--active')
93 this._$decodeAction &&
94 this._$decodeAction.classList.add('brick__action--active')
95 } else {
96 this._$encodeAction.classList.add('brick__action--active')
97 this._$decodeAction &&
98 this._$decodeAction.classList.remove('brick__action--active')
99 }
100
101 // Update status
102 const error = this.getModel().getLastError()
103 const translation = this.getModel().getLastTranslationMeta()
104
105 if (translation !== null) {
106 const status = translation.isEncode ? 'forward' : 'backward'
107 let message =
108 `${translation.isEncode !== reverse ? 'Encoded' : 'Decoded'} `
109
110 if (translation.charCount !== null) {
111 message +=
112 `${translation.charCount} ` +
113 `${translation.charCount === 1 ? 'char' : 'chars'}`
114 } else {
115 message +=
116 `${translation.byteCount} ` +
117 `${translation.byteCount === 1 ? 'byte' : 'bytes'}`
118 }
119
120 return this.updateStatus(status, message)
121 }
122
123 if (error !== null) {
124 return this.updateStatus('error', error.message)
125 }
126
127 return this
128 }
129}

Callers

nothing calls this directly

Calls 5

isReverseMethod · 0.80
getLastErrorMethod · 0.80
updateStatusMethod · 0.80
getModelMethod · 0.45

Tested by

no test coverage detected