TC 수정건 적용 (디자인 및 기능)

This commit is contained in:
kimre
2022-07-18 19:34:34 +09:00
parent 2bfa07c17f
commit a6c6db6f22
40 changed files with 1783 additions and 1170 deletions

View File

@@ -14,7 +14,7 @@
<tr>
<th>차단문구</th>
<td class="input_add">
<input v-model="word" ref="_word">
<input v-model="word" ref="_word" maxlength="10" @input="msgLimitByte()">
<button type="button" class="button white add" @click="doAdd"></button>
</td>
</tr>
@@ -292,7 +292,40 @@ export default {
this.$refs.ValidationConfirmPopup.msgConfirmDeleteOpen();
}
},
// 바이트길이 구하기
getByteLength: function (decimal) {
return (decimal >> 7) || (this.LINE_FEED === decimal) ? 2 : 1
},
getByte: function (str) {
return str
.split('')
.map((s) => s.charCodeAt(0))
.reduce((prev, unicodeDecimalValue) => prev + this.getByteLength(unicodeDecimalValue), 0)
},
getLimitedByteText: function (inputText, maxByte) {
const characters = inputText.split('')
let validText = ''
let totalByte = 0
for (let i = 0; i < characters.length; i += 1) {
const character = characters[i]
const decimal = character.charCodeAt(0)
const byte = this.getByteLength(decimal) // 글자 한 개가 몇 바이트 길이인지 구해주기
// console.log(byte)
// 현재까지의 바이트 길이와 더해 최대 바이트 길이를 넘지 않으면
if (totalByte + byte <= maxByte) {
totalByte += byte // 바이트 길이 값을 더해 현재까지의 총 바이트 길이 값을 구함
validText += character // 글자를 더해 현재까지의 총 문자열 값을 구함
} else { // 최대 바이트 길이를 넘으면
break // for 루프 종료
}
}
return validText
},
msgLimitByte(){
this.word = this.getLimitedByteText(this.word, 10);
}
},