Add new fix en-ru keyboard tool
This commit is contained in:
parent
91da4c34a5
commit
c9f58d1132
@ -29,6 +29,7 @@ export default {
|
||||
'home': 'Home',
|
||||
},
|
||||
'Strings': {
|
||||
'fix_run_en_keyboard': 'Fix ru-en keyboard',
|
||||
'str_to_lower': 'Str to lower',
|
||||
'str_to_upper': 'Str to upper',
|
||||
},
|
||||
|
@ -25,6 +25,11 @@ const router = createRouter({
|
||||
name: 'str_to_lower',
|
||||
component: () => import('../views/StrToLower.vue'),
|
||||
},
|
||||
{
|
||||
path: '/fix_run_en_keyboard',
|
||||
name: 'fix_run_en_keyboard',
|
||||
component: () => import('../views/FixRuEnKeyboard.vue'),
|
||||
},
|
||||
|
||||
/**
|
||||
* SQL manipulation
|
||||
|
66
src/views/FixRuEnKeyboard.vue
Normal file
66
src/views/FixRuEnKeyboard.vue
Normal file
@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<h2 class="tool-title">Fix ru-en keyboard</h2>
|
||||
<hr class="mt-5 mb-5">
|
||||
|
||||
<div class="input-group">
|
||||
<label for="data">Data</label>
|
||||
<textarea id="data" v-model="toolData.data" style="height: 150px"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label>Mode</label>
|
||||
|
||||
<div>
|
||||
<input id="keyboard_mode_en_ru" value="en-ru" name="keyboard_mode" v-model="toolData.keyboardMode" type="radio"> <label for="keyboard_mode_en_ru">en -> ru</label><br>
|
||||
<input id="keyboard_mode_ru_en" value="ru-en" name="keyboard_mode" v-model="toolData.keyboardMode" type="radio"> <label for="keyboard_mode_ru_en">ru -> en</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="mt-5 mb-5">
|
||||
|
||||
<div class="input-group">
|
||||
<label for="result">Result</label>
|
||||
<textarea id="result" v-model="toolResult" style="height: 150px"></textarea>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { unproxy } from "@/utils/unproxy";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
toolData: {
|
||||
data: '',
|
||||
keyboardMode: 'en-ru',
|
||||
},
|
||||
dictionary: {
|
||||
'en-ru': '`~!@#$%^&qwertyuiop[]asdfghjkl;\'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?',
|
||||
'ru-en': 'ёЁ!"№;%:?йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,',
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
toolResult() {
|
||||
let data = unproxy(this.toolData.data).split('');
|
||||
|
||||
const dict = this.dictionary[this.toolData.keyboardMode];
|
||||
const dictOpposite = this.dictionary[this.toolData.keyboardMode === 'en-ru' ? 'ru-en' : 'en-ru'];
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const dictPos = dict.indexOf(data[i]);
|
||||
if (dictPos === -1) continue;
|
||||
|
||||
data[i] = unproxy(dictOpposite[dictPos]);
|
||||
}
|
||||
|
||||
return data.join('');
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
@ -29,7 +29,7 @@
|
||||
|
||||
<div class="input-group">
|
||||
<label for="chunk_by">Chunk by</label>
|
||||
<input id="chunk_by" v-model="toolData.chunkBy" placeholder="900" type="number">
|
||||
<input id="chunk_by" v-model="toolData.chunkBy" placeholder="900" min="1" type="number">
|
||||
</div>
|
||||
|
||||
<hr class="mt-5 mb-5">
|
||||
@ -82,13 +82,12 @@ export default {
|
||||
data[i] = value;
|
||||
}
|
||||
|
||||
data = arrayChunk(data, this.toolData.chunkBy);
|
||||
const chunkBy = this.toolData.chunkBy > 0 ? this.toolData.chunkBy : 1;
|
||||
data = arrayChunk(data, chunkBy);
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let chunk = data[i];
|
||||
|
||||
|
||||
|
||||
data[i] = '(' + chunk.join(',') + ')';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user