#12 Add table to mediawiki table tool #13

Merged
stuzer05 merged 1 commits from stuzer05/random-web-tools#12 into master 2024-03-30 10:45:03 +02:00
3 changed files with 65 additions and 0 deletions

@ -28,6 +28,7 @@ export default {
'General': { 'General': {
'home': 'Home', 'home': 'Home',
'explain_crontab': 'Explain crontab', 'explain_crontab': 'Explain crontab',
'table_to_mediawiki_table': 'Table to Mediawiki table',
}, },
'Strings': { 'Strings': {
'fix_ru_en_keyboard': 'Fix ru-en keyboard', 'fix_ru_en_keyboard': 'Fix ru-en keyboard',

@ -16,6 +16,11 @@ const router = createRouter({
name: 'explain_crontab', name: 'explain_crontab',
component: () => import('../views/ExplainCrontab.vue'), component: () => import('../views/ExplainCrontab.vue'),
}, },
{
path: '/table_to_mediawiki_table',
name: 'table_to_mediawiki_table',
component: () => import('../views/TableToMediawikiTable.vue'),
},
/** /**
* String manipulation * String manipulation

@ -0,0 +1,59 @@
<template>
<h2 class="tool-title">Fix ru-en keyboard</h2>
<hr class="mt-5 mb-5">
<div class="input-group">
<label for="data">Data (paste from excel)</label>
<textarea id="data" v-model="toolData.data" v-on:keyup="result"></textarea>
</div>
<hr class="mt-5 mb-5">
<div class="input-group">
<label for="result">Result</label>
<MonacoEditor name="result" language="text" :value="toolResult"></MonacoEditor>
</div>
</template>
<script>
import { unproxy } from "@/utils/unproxy";
import MonacoEditor from "@/components/MonacoEditor.vue";
export default {
components: {
MonacoEditor
},
data() {
return {
toolData: {
data: '',
},
toolResult: '',
};
},
methods: {
result() {
let output = '{| class="wikitable"\n';
const rows = unproxy(this.toolData.data).split('\n');
for (let i = 0; i < rows.length; i++) {
const cells = rows[i].split('\t');
output += '|-\n';
for (let j = 0; j < cells.length; j++) {
output += i === 0 ? '! ' : '| ';
output += cells[j].trim() + '\n';
}
}
output += '|}';
this.toolResult = output;
},
},
}
</script>
<style lang="scss">
</style>