mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 06:40:20 +03:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6cfaf63502 | ||
|
|
6db5c32bcd | ||
|
|
9bf1b93b07 | ||
|
|
7a4310ad90 | ||
|
|
c434a5f3f0 | ||
|
|
1b1be10762 |
No files matched your search
Vendored
-3
@@ -141,8 +141,6 @@ declare module '@vue/runtime-core' {
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NRadio: typeof import('naive-ui')['NRadio']
|
||||
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NTable: typeof import('naive-ui')['NTable']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
@@ -166,7 +164,6 @@ declare module '@vue/runtime-core' {
|
||||
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
|
||||
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
|
||||
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
|
||||
StacktracePrettier: typeof import('./src/tools/stacktrace-prettier/stacktrace-prettier.vue')['default']
|
||||
StringObfuscator: typeof import('./src/tools/string-obfuscator/string-obfuscator.vue')['default']
|
||||
SvgPlaceholderGenerator: typeof import('./src/tools/svg-placeholder-generator/svg-placeholder-generator.vue')['default']
|
||||
TemperatureConverter: typeof import('./src/tools/temperature-converter/temperature-converter.vue')['default']
|
||||
|
||||
+1
-5
@@ -58,7 +58,6 @@
|
||||
"cronstrue": "^2.26.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"date-fns": "^2.29.3",
|
||||
"dom-to-image-more": "^3.4.5",
|
||||
"dompurify": "^3.0.6",
|
||||
"email-normalizer": "^1.0.0",
|
||||
"emojilib": "^3.0.10",
|
||||
@@ -68,11 +67,10 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"javastack.js": "^1.0.2",
|
||||
"js-base64": "^3.7.6",
|
||||
"json5": "^2.2.3",
|
||||
"jsstack.js": "^2.0.0",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"korean-unpacker": "^1.0.3",
|
||||
"libphonenumber-js": "^1.10.28",
|
||||
"lodash": "^4.17.21",
|
||||
"markdown-it": "^14.0.0",
|
||||
@@ -82,13 +80,11 @@
|
||||
"monaco-editor": "^0.43.0",
|
||||
"naive-ui": "^2.35.0",
|
||||
"netmask": "^2.0.2",
|
||||
"netstack.js": "^2.0.0",
|
||||
"node-forge": "^1.3.1",
|
||||
"oui-data": "^1.0.10",
|
||||
"pdf-signature-reader": "^1.4.2",
|
||||
"pinia": "^2.0.34",
|
||||
"plausible-tracker": "^0.3.8",
|
||||
"pythonstack.js": "^1.0.2",
|
||||
"qrcode": "^1.5.1",
|
||||
"randexp": "^0.5.3",
|
||||
"sql-formatter": "^13.0.0",
|
||||
|
||||
Generated
+24
-656
File diff suppressed because it is too large.
Load diff
@@ -2,7 +2,6 @@ import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
import { tool as stacktracePrettier } from './stacktrace-prettier';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
@@ -161,7 +160,6 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
emailNormalizer,
|
||||
regexTester,
|
||||
regexMemo,
|
||||
stacktracePrettier,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
declare module "dom-to-image-more" {
|
||||
export function toPng(el: HTMLElement | undefined, options?: { bgcolor: string }) : Promise<string>;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Stack } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Stacktrace prettier',
|
||||
path: '/stacktrace-prettier',
|
||||
description: 'Highlight .Net and JS stacktraces',
|
||||
keywords: ['stacktrace', 'prettier', 'highlighter'],
|
||||
component: () => import('./stacktrace-prettier.vue'),
|
||||
icon: Stack,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -1,3 +0,0 @@
|
||||
declare module "javastack.js" {
|
||||
export default function javastack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
declare module "jsstack.js" {
|
||||
export default function jsstack(selector: string) : void;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
declare module "netstack.js" {
|
||||
export default class netstack {
|
||||
constructor(el: HTMLElement | undefined, options: { prettyprint: boolean })
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
declare module "pythonstack.js" {
|
||||
export default function pythonstack(selector: string, options: { prettyprint: boolean }) : void;
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import JSStack from 'jsstack.js';
|
||||
import JavaStack from 'javastack.js';
|
||||
import PythonStack from 'pythonstack.js';
|
||||
import NetStack from 'netstack.js';
|
||||
import domtoimage from 'dom-to-image-more';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useStyleStore } from '@/stores/style.store';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const styleStore = useStyleStore();
|
||||
|
||||
const stackType = useQueryParamOrStorage<'net' | 'js' | 'java' | 'python'>({ name: 'type', storageName: 'stackfmt:type', defaultValue: 'net' });
|
||||
const stackTrace = ref('');
|
||||
const formatedStackTrace = ref<HTMLElement>();
|
||||
|
||||
const stackTraceText = ref('');
|
||||
watchEffect(() => {
|
||||
if (!formatedStackTrace.value) {
|
||||
return;
|
||||
}
|
||||
let cleanedStackTrace;
|
||||
try {
|
||||
cleanedStackTrace = JSON.parse(stackTrace.value);
|
||||
}
|
||||
catch (_) {
|
||||
cleanedStackTrace = stackTrace.value.replace(/(\\r)?\\n/g, '\n').replace(/(?:^['"])|(?:['"]$)/, '');
|
||||
};
|
||||
try {
|
||||
if (stackType.value === 'js') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JSStack('.stacktrace');
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
JavaStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
formatedStackTrace.value.textContent = cleanedStackTrace;
|
||||
PythonStack('.stacktrace', { prettyprint: true });
|
||||
}
|
||||
else if (stackType.value === 'net') {
|
||||
formatedStackTrace.value.innerText = cleanedStackTrace;
|
||||
const _ = new NetStack(formatedStackTrace.value, { prettyprint: true });
|
||||
}
|
||||
stackTraceText.value = formatedStackTrace.value.innerText;
|
||||
}
|
||||
catch {}
|
||||
});
|
||||
|
||||
const stackTraceMarkdown = computed(() => {
|
||||
let lang;
|
||||
if (stackType.value === 'net') {
|
||||
lang = 'csharp';
|
||||
}
|
||||
else if (stackType.value === 'js') {
|
||||
lang = 'javascript';
|
||||
}
|
||||
else if (stackType.value === 'java') {
|
||||
lang = 'java';
|
||||
}
|
||||
else if (stackType.value === 'python') {
|
||||
lang = 'python';
|
||||
}
|
||||
return `\`\`\`${lang}\n${formatedStackTrace.value?.innerText}\n\`\`\``;
|
||||
});
|
||||
|
||||
const { copy: copyText } = useCopy({ source: stackTraceText, text: 'Formatted stacktrace copied to the clipboard' });
|
||||
const { copy: copyMarkdown } = useCopy({ source: stackTraceMarkdown, text: 'Markdown Formatted stacktrace copied to the clipboard' });
|
||||
|
||||
async function downloadAsPNG() {
|
||||
const dataUrl = await domtoimage.toPng(formatedStackTrace.value, { bgcolor: styleStore.isDarkTheme ? '#333' : '#fff' });
|
||||
const link = document.createElement('a');
|
||||
link.download = 'stacktrace.png';
|
||||
link.href = dataUrl;
|
||||
link.click();
|
||||
}
|
||||
|
||||
const wrap = ref(true);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div max-w-600px>
|
||||
<n-radio-group v-model:value="stackType" name="radiogroup" mb-2 flex justify-center>
|
||||
<n-space>
|
||||
<n-radio
|
||||
value="net"
|
||||
label=".Net"
|
||||
/>
|
||||
<n-radio
|
||||
value="js"
|
||||
label="Javascript"
|
||||
/>
|
||||
<n-radio
|
||||
value="python"
|
||||
label="Python"
|
||||
/>
|
||||
<n-radio
|
||||
value="java"
|
||||
label="Java"
|
||||
/>
|
||||
</n-space>
|
||||
</n-radio-group>
|
||||
|
||||
<div mb-2 flex justify-center>
|
||||
<n-checkbox v-model:checked="wrap">
|
||||
Wrap lines?
|
||||
</n-checkbox>
|
||||
</div>
|
||||
<c-input-text
|
||||
v-model:value="stackTrace"
|
||||
label="Stacktrace"
|
||||
placeholder="Paste your stacktrace here.."
|
||||
multiline
|
||||
rows="5"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<pre ref="formatedStackTrace" class="stacktrace" :style="{ padding: '20px', whiteSpace: wrap ? 'pre-wrap' : 'pre', overflowX: 'auto', wordBreak: 'break-all' }" />
|
||||
|
||||
<div v-if="stackTraceText" flex justify-center gap-1>
|
||||
<c-button @click="copyText()">
|
||||
Copy Formatted (Text)
|
||||
</c-button>
|
||||
<c-button @click="copyMarkdown()">
|
||||
Copy Formatted (Markdown)
|
||||
</c-button>
|
||||
<c-button @click="downloadAsPNG()">
|
||||
Download as PNG
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
::v-deep(.stacktrace) {
|
||||
pre, code {background-color:#333 !important; color: #fff !important;}
|
||||
.st-type {color: #0a8472; font-weight: bolder;}
|
||||
.st-method {color: #70c9ba; font-weight: bolder;}
|
||||
.st-frame-params {color: #ffffff; font-weight: normal;}
|
||||
.st-param-type {color: #0a8472;}
|
||||
.st-param-name {color: #ffffff;}
|
||||
.st-file {color:#f8b068;}
|
||||
.st-line {color:#ff4f68;}
|
||||
.st-methodName {color: #70c9ba;font-weight: bolder;}
|
||||
.st-column {color: #f8b068;}
|
||||
.st-lineNumber {color: #ff4f68;}
|
||||
.st-fileName {color: #85dbff;}
|
||||
.st-intro {color: #0044dd;}
|
||||
.st-exception {color: #e40000;}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,3 @@
|
||||
declare module 'korean-unpacker' {
|
||||
function unpack(text: string): string;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,137 @@
|
||||
[
|
||||
{
|
||||
"lang": "(International)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "TANGO echo sierra YANKEE WHISKEY (SPACE) ONE TWO THREE (SPACE) (?) (SPACE) (=) (SPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(France)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THÉRÈSE eugène suzanne YVONNE WILLIAM (ESPACE) UN DEUX TROIS (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Belgium)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "TELEFOON emiel sofie YVONNE WATERLOO (ESPACE) (1) (2) (3) (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Switzerland)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THÉRÈSE émile suzanne (Y) WILLIAM (ESPACE) (1) (2) (3) (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Québec)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THOMAS édouard samuel (Y) WILLIAM (ESPACE) (1) (2) (3) (ESPACE) (?) (ESPACE) (=) (ESPACE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Germany, 2022)",
|
||||
"input": "TesYü 123 ? = !@",
|
||||
"output": "TÜBINGEN essen salzwedel YPSILON umlaut-unna (LEERZEICHEN) (1) (2) (3) (LEERZEICHEN) (?) (LEERZEICHEN) (=) (LEERZEICHEN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Austria)",
|
||||
"input": "TesYW 123 ? = !@",
|
||||
"output": "THEODOR emil samuel/siegfried YPSILON WILHELM (LEERZEICHEN) (1) (2) (3) (LEERZEICHEN) (?) (LEERZEICHEN) (=) (LEERZEICHEN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Germany, informal, 2022)",
|
||||
"input": "TesYü 123 ? = !@",
|
||||
"output": "THEODOR emil samuel YPSILON überfluss (LEERZEICHEN) (1) (2) (3) (LEERZEICHEN) (?) (LEERZEICHEN) (=) (LEERZEICHEN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Netherlands)",
|
||||
"input": "TesY huis rij 123 ? = !@",
|
||||
"output": "THEODOR eduard simon YPSILON (SPATIE) hendrik utrecht izaak simon (SPATIE) richard/rudolf ijmuiden/ijsbrand (SPATIE) (1) (2) (3) (SPATIE) (?) (SPATIE) (=) (SPATIE) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Italian",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TORINO empoli savona YORK, YOGURT jolly/juventus (SPAZIO) (1) (2) (3) (SPAZIO) (?) (SPAZIO) (=) (SPAZIO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Spanish",
|
||||
"input": "TesYñj 123 ? = !@",
|
||||
"output": "TOLEDO españa sábado YOLANDA ñoño josé (ESPACIO) (1) (2) (3) (ESPACIO) (?) (ESPACIO) (=) (ESPACIO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Brazil)",
|
||||
"input": "TesYÇj 123 ? = !@",
|
||||
"output": "TATU estrela saci YOLANDA (Ç) josé (ESPAÇO) (1) (2) (3) (ESPAÇO) (?) (ESPAÇO) (=) (ESPAÇO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "(Portugal)",
|
||||
"input": "TesYúj 123 ? = !@",
|
||||
"output": "TAVIRA évora setúbal YORK (ú) josé (ESPAÇO) (1) (2) (3) (ESPAÇO) (?) (ESPAÇO) (=) (ESPAÇO) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Swedish",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TORE erik sigurd YNGVE johan (UTRYMME) (1) (2) (3) (UTRYMME) (?) (UTRYMME) (=) (UTRYMME) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Danish",
|
||||
"input": "TesÆYj 123 ? = !@",
|
||||
"output": "THEODOR erik søren ÆGIR YRSA johan (MELLEMRUMSTEGN) (1) (2) (3) (MELLEMRUMSTEGN) (?) (MELLEMRUMSTEGN) (=) (MELLEMRUMSTEGN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Norwegian",
|
||||
"input": "TesYÅj 123 ? = !@",
|
||||
"output": "TEODOR edith sigrid YNGLING ÅSE johan (MELLOMROMSTEGN) (1) (2) (3) (MELLOMROMSTEGN) (?) (MELLOMROMSTEGN) (=) (MELLOMROMSTEGN) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Finnish",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TYYNE eemeli sakari YRJÖ jussi (VÄLILYÖNTI) (1) (2) (3) (VÄLILYÖNTI) (?) (VÄLILYÖNTI) (=) (VÄLILYÖNTI) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Turkish",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TOKAT edirne sinop YOZGAT jandarma (BOŞLUK) (1) (2) (3) (BOŞLUK) (?) (BOŞLUK) (=) (BOŞLUK) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Romanian",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TUDOR elena sandu I-GREC jean (SPAȚIU) (1) (2) (3) (SPAȚIU) (?) (SPAȚIU) (=) (SPAȚIU) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Czech",
|
||||
"input": "TesYj 123 ? = !@",
|
||||
"output": "TOMÁŠ emil svatopluk YPSILON josef (PROSTOROVÝ) (1) (2) (3) (PROSTOROVÝ) (?) (PROSTOROVÝ) (=) (PROSTOROVÝ) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Yugoslav",
|
||||
"input": "TesYČj 123 ? = !@",
|
||||
"output": "TUZLA evropa skopje IPSILON ČAČAK jadran (PRIESTOROVÝ) (1) (2) (3) (PRIESTOROVÝ) (?) (PRIESTOROVÝ) (=) (PRIESTOROVÝ) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Serbian",
|
||||
"input": "TesYČj 123 ? = !@",
|
||||
"output": "TIMOK evropa sava IPSILON ČAČAK jadran (PROSTORNI) (1) (2) (3) (PROSTORNI) (?) (PROSTORNI) (=) (PROSTORNI) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Slovene",
|
||||
"input": "TesYČj 123 ? = !@",
|
||||
"output": "TRIGLAV evropa soča IPSILON ČATEŽ jadran (PRESLEDKA) (1) (2) (3) (PRESLEDKA) (?) (PRESLEDKA) (=) (PRESLEDKA) (!) (@)"
|
||||
},
|
||||
{
|
||||
"lang": "Russian",
|
||||
"input": "Зинаида !.?",
|
||||
"output": "ЗИНАИДА иван николай анна иван дмитрий анна ( ) (!) (.) (?)"
|
||||
},
|
||||
{
|
||||
"lang": "Korean",
|
||||
"input": "안녕하세요 여러분",
|
||||
"output": "잉어 아버지 나폴리 나폴리 연못 잉어 한강 아버지 서울 엑스레이 잉어 요지경 ( ) 잉어 연못 로마 어머니 바가지 우편 나폴리"
|
||||
},
|
||||
{
|
||||
"lang": "Greek",
|
||||
"input": "τίγρης !?",
|
||||
"output": "τίγρης (ί) γαλή ρήγας ηρώ σοφός ( ) (!) (?)"
|
||||
},
|
||||
{
|
||||
"lang": "Japanese",
|
||||
"input": "数字のひと おしまいのン ?:",
|
||||
"output": "(数) (字) 野原のノ 飛行機のヒ 東京のト ( ) 大阪のオ 新聞のシ マッチのマ いろはのイ 野原のノ おしまいのン ( ) (?) (:)"
|
||||
}
|
||||
]
|
||||
@@ -1,28 +1,29 @@
|
||||
export const natoAlphabet = [
|
||||
'Alpha',
|
||||
'Bravo',
|
||||
'Charlie',
|
||||
'Delta',
|
||||
'Echo',
|
||||
'Foxtrot',
|
||||
'Golf',
|
||||
'Hotel',
|
||||
'India',
|
||||
'Juliet',
|
||||
'Kilo',
|
||||
'Lima',
|
||||
'Mike',
|
||||
'November',
|
||||
'Oscar',
|
||||
'Papa',
|
||||
'Quebec',
|
||||
'Romeo',
|
||||
'Sierra',
|
||||
'Tango',
|
||||
'Uniform',
|
||||
'Victor',
|
||||
'Whiskey',
|
||||
'X-ray',
|
||||
'Yankee',
|
||||
'Zulu',
|
||||
export const allLanguagesAndCountries = [
|
||||
'(International)',
|
||||
'(France)',
|
||||
'(Belgium)',
|
||||
'(Switzerland)',
|
||||
'(Québec)',
|
||||
'(Germany, 2022)',
|
||||
'(Austria)',
|
||||
'(Germany, informal, 2022)',
|
||||
'(Netherlands)',
|
||||
'Italian',
|
||||
'Spanish',
|
||||
'(Brazil)',
|
||||
'(Portugal)',
|
||||
'Swedish',
|
||||
'Danish',
|
||||
'Norwegian',
|
||||
'Finnish',
|
||||
'Turkish',
|
||||
'Romanian',
|
||||
'Czech',
|
||||
'Yugoslav',
|
||||
'Serbian',
|
||||
'Slovene',
|
||||
'Russian',
|
||||
'Korean',
|
||||
'Greek',
|
||||
'Japanese',
|
||||
];
|
||||
@@ -0,0 +1,160 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { textToNatoAlphabet } from './text-to-nato-alphabet.service';
|
||||
|
||||
const TestCase_TestYW = 'TesYW 123 ? = !@';
|
||||
const TestCase_TestYJ = 'TesYj 123 ? = !@';
|
||||
const natoTests = [
|
||||
{
|
||||
lang: '(International)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'TANGO echo sierra YANKEE WHISKEY (SPACE) (digit 1) (digit 2) (digit 3) (SPACE) (punctuation ?) (SPACE) (punctuation =) (SPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(France)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THÉRÈSE eugène suzanne YVONNE WILLIAM (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Belgium)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'TELEFOON emiel sofie YVONNE WATERLOO (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Switzerland)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THÉRÈSE émile suzanne (Y) WILLIAM (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Québec)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THOMAS édouard samuel (Y) WILLIAM (ESPACE) (digit 1) (digit 2) (digit 3) (ESPACE) (punctuation ?) (ESPACE) (punctuation =) (ESPACE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Germany, 2022)',
|
||||
input: 'TesYü 123 ? = !@',
|
||||
output: 'TÜBINGEN essen salzwedel YPSILON umlaut-unna (LEERZEICHEN) (digit 1) (digit 2) (digit 3) (LEERZEICHEN) (punctuation ?) (LEERZEICHEN) (punctuation =) (LEERZEICHEN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Austria)',
|
||||
input: TestCase_TestYW,
|
||||
output: 'THEODOR emil samuel/siegfried YPSILON WILHELM (LEERZEICHEN) (digit 1) (digit 2) (digit 3) (LEERZEICHEN) (punctuation ?) (LEERZEICHEN) (punctuation =) (LEERZEICHEN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Germany, informal, 2022)',
|
||||
input: 'TesYü 123 ? = !@',
|
||||
output: 'THEODOR emil samuel YPSILON überfluss (LEERZEICHEN) (digit 1) (digit 2) (digit 3) (LEERZEICHEN) (punctuation ?) (LEERZEICHEN) (punctuation =) (LEERZEICHEN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Netherlands)',
|
||||
input: 'TesY huis rij 123 ? = !@',
|
||||
output: 'THEODOR eduard simon YPSILON (SPATIE) hendrik utrecht izaak simon (SPATIE) richard/rudolf ijmuiden/ijsbrand (SPATIE) (digit 1) (digit 2) (digit 3) (SPATIE) (punctuation ?) (SPATIE) (punctuation =) (SPATIE) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Italian',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TORINO empoli savona YORK, YOGURT jolly/juventus (SPAZIO) (digit 1) (digit 2) (digit 3) (SPAZIO) (punctuation ?) (SPAZIO) (punctuation =) (SPAZIO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Spanish',
|
||||
input: 'TesYñj 123 ? = !@',
|
||||
output: 'TOLEDO españa sábado YOLANDA ñoño josé (ESPACIO) (digit 1) (digit 2) (digit 3) (ESPACIO) (punctuation ?) (ESPACIO) (punctuation =) (ESPACIO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Brazil)',
|
||||
input: 'TesYÇj 123 ? = !@',
|
||||
output: 'TATU estrela saci YOLANDA (Ç) josé (ESPAÇO) (digit 1) (digit 2) (digit 3) (ESPAÇO) (punctuation ?) (ESPAÇO) (punctuation =) (ESPAÇO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: '(Portugal)',
|
||||
input: 'TesYúj 123 ? = !@',
|
||||
output: 'TAVIRA évora setúbal YORK (ú) josé (ESPAÇO) (digit 1) (digit 2) (digit 3) (ESPAÇO) (punctuation ?) (ESPAÇO) (punctuation =) (ESPAÇO) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Swedish',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TORE erik sigurd YNGVE johan (UTRYMME) (digit 1) (digit 2) (digit 3) (UTRYMME) (punctuation ?) (UTRYMME) (punctuation =) (UTRYMME) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Danish',
|
||||
input: 'TesÆYj 123 ? = !@',
|
||||
output: 'THEODOR erik søren ÆGIR YRSA johan (MELLEMRUMSTEGN) (digit 1) (digit 2) (digit 3) (MELLEMRUMSTEGN) (punctuation ?) (MELLEMRUMSTEGN) (punctuation =) (MELLEMRUMSTEGN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Norwegian',
|
||||
input: 'TesYÅj 123 ? = !@',
|
||||
output: 'TEODOR edith sigrid YNGLING ÅSE johan (MELLOMROMSTEGN) (digit 1) (digit 2) (digit 3) (MELLOMROMSTEGN) (punctuation ?) (MELLOMROMSTEGN) (punctuation =) (MELLOMROMSTEGN) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Finnish',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TYYNE eemeli sakari YRJÖ jussi (VÄLILYÖNTI) (digit 1) (digit 2) (digit 3) (VÄLILYÖNTI) (punctuation ?) (VÄLILYÖNTI) (punctuation =) (VÄLILYÖNTI) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Turkish',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TOKAT edirne sinop YOZGAT jandarma (BOŞLUK) (digit 1) (digit 2) (digit 3) (BOŞLUK) (punctuation ?) (BOŞLUK) (punctuation =) (BOŞLUK) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Romanian',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TUDOR elena sandu I-GREC jean (SPAȚIU) (digit 1) (digit 2) (digit 3) (SPAȚIU) (punctuation ?) (SPAȚIU) (punctuation =) (SPAȚIU) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Czech',
|
||||
input: TestCase_TestYJ,
|
||||
output: 'TOMÁŠ emil svatopluk YPSILON josef (PROSTOROVÝ) (digit 1) (digit 2) (digit 3) (PROSTOROVÝ) (punctuation ?) (PROSTOROVÝ) (punctuation =) (PROSTOROVÝ) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Yugoslav',
|
||||
input: 'TesYČj 123 ? = !@',
|
||||
output: 'TUZLA evropa skopje IPSILON ČAČAK jadran (PRIESTOROVÝ) (digit 1) (digit 2) (digit 3) (PRIESTOROVÝ) (punctuation ?) (PRIESTOROVÝ) (punctuation =) (PRIESTOROVÝ) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Serbian',
|
||||
input: 'TesYČj 123 ? = !@',
|
||||
output: 'TIMOK evropa sava IPSILON ČAČAK jadran (PROSTORNI) (digit 1) (digit 2) (digit 3) (PROSTORNI) (punctuation ?) (PROSTORNI) (punctuation =) (PROSTORNI) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Slovene',
|
||||
input: 'TesYČj 123 ? = !@',
|
||||
output: 'TRIGLAV evropa soča IPSILON ČATEŽ jadran (PRESLEDKA) (digit 1) (digit 2) (digit 3) (PRESLEDKA) (punctuation ?) (PRESLEDKA) (punctuation =) (PRESLEDKA) (punctuation !) (punctuation @)',
|
||||
},
|
||||
{
|
||||
lang: 'Russian',
|
||||
input: 'Зинаида !.?',
|
||||
output: 'ЗИНАИДА иван николай анна иван дмитрий анна ( ) (punctuation !) (punctuation .) (punctuation ?)',
|
||||
},
|
||||
{
|
||||
lang: 'Korean',
|
||||
input: '안녕하세요 여러분',
|
||||
output: '잉어 아버지 나폴리 나폴리 연못 잉어 한강 아버지 서울 엑스레이 잉어 요지경 ( ) 잉어 연못 로마 어머니 바가지 우편 나폴리',
|
||||
},
|
||||
{
|
||||
lang: 'Greek',
|
||||
input: 'τίγρης !?',
|
||||
output: 'τίγρης (ί) γαλή ρήγας ηρώ σοφός ( ) (punctuation !) (punctuation ?)',
|
||||
},
|
||||
{
|
||||
lang: 'Japanese',
|
||||
input: '数字のひと おしまいのン ?:',
|
||||
output: '(数) (字) 野原のノ 飛行機のヒ 東京のト ( ) 大阪のオ 新聞のシ マッチのマ いろはのイ 野原のノ おしまいのン ( ) (punctuation ?) (punctuation :)',
|
||||
},
|
||||
];
|
||||
|
||||
describe('text-to-nato', () => {
|
||||
it('Convert text to NATO', async () => {
|
||||
for (const nato of natoTests) {
|
||||
const { lang, input, output } = nato;
|
||||
expect(textToNatoAlphabet({ text: input, langOrCountry: lang })).to.equal(output);
|
||||
}
|
||||
});
|
||||
|
||||
it('Convert text to NATO (includes punctuations and digits names)', async () => {
|
||||
expect(textToNatoAlphabet({ text: 'a 1 2 3 ! % ? ;', langOrCountry: '(France)', useDigitsNames: true, usePunctuationsNames: true })).to.equal(
|
||||
'anatole (ESPACE) {digit 1 => un} (ESPACE) {digit 2 => deux} (ESPACE) {digit 3 => trois} (ESPACE) {punctuation ! => point d\'exclamation} (ESPACE) {punctuation % => pour cent} (ESPACE) {punctuation ? => point d\'interrogation} (ESPACE) {punctuation ; => point-virgule}');
|
||||
expect(textToNatoAlphabet({ text: 'и 1 2 3 ! % ? ;', langOrCountry: 'Russian', useDigitsNames: true, usePunctuationsNames: true })).to.equal(
|
||||
'иван ( ) {digit 1 => один (odin)} ( ) {digit 2 => два (dva)} ( ) {digit 3 => три (tri)} ( ) {punctuation ! => восклицательный знак (vosklitsatel\'nyy znak)} ( ) {punctuation % => процент (protsent)} ( ) {punctuation ? => вопросительный знак (voprositel\'nyy znak)} ( ) {punctuation ; => точка с запятой (tochka s zapyatoy)}');
|
||||
expect(textToNatoAlphabet({ text: 'TesYj 1 2 3 ! % ? ;', langOrCountry: 'Swedish', useDigitsNames: true, usePunctuationsNames: true })).to.equal(
|
||||
'TORE erik sigurd YNGVE johan (UTRYMME) {digit 1 => ett} (UTRYMME) {digit 2 => två} (UTRYMME) {digit 3 => tre} (UTRYMME) {punctuation ! => utropstecken} (UTRYMME) {punctuation % => procent} (UTRYMME) {punctuation ? => frågetecken} (UTRYMME) {punctuation ; => semikolon}');
|
||||
});
|
||||
});
|
||||
@@ -1,19 +1,80 @@
|
||||
import { natoAlphabet } from './text-to-nato-alphabet.constants';
|
||||
import hangul from 'korean-unpacker';
|
||||
import allAlphabets from './nato.alphabets.json';
|
||||
|
||||
type AllAlphabetsKeys = keyof typeof allAlphabets[0];
|
||||
|
||||
export { textToNatoAlphabet };
|
||||
|
||||
function getLetterPositionInAlphabet({ letter }: { letter: string }) {
|
||||
return letter.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0);
|
||||
function isPunctuation(char: string) {
|
||||
const punctuations = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
|
||||
return punctuations.includes(char);
|
||||
}
|
||||
function isDigit(char: string) {
|
||||
const digits = '0123456789';
|
||||
return digits.includes(char);
|
||||
}
|
||||
|
||||
function textToNatoAlphabet({ text }: { text: string }) {
|
||||
return text
|
||||
.split('')
|
||||
.map((character) => {
|
||||
const alphabetIndex = getLetterPositionInAlphabet({ letter: character });
|
||||
const natoWord = natoAlphabet[alphabetIndex];
|
||||
|
||||
return natoWord ?? character;
|
||||
})
|
||||
.join(' ');
|
||||
function escapeRegExp(string: string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
}
|
||||
|
||||
function textToNatoAlphabet({
|
||||
text, langOrCountry = '(International)',
|
||||
useDigitsNames = false, usePunctuationsNames = false,
|
||||
}: {
|
||||
text: string
|
||||
langOrCountry: string
|
||||
useDigitsNames?: boolean
|
||||
usePunctuationsNames?: boolean
|
||||
}) {
|
||||
const getNatoWord = (searchChar: string) => {
|
||||
const alphabetLetter = allAlphabets.find(letter => letter.Letter === searchChar);
|
||||
if (alphabetLetter && alphabetLetter[langOrCountry as AllAlphabetsKeys]) {
|
||||
return alphabetLetter[langOrCountry as AllAlphabetsKeys] || '';
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const charRegex = new RegExp(
|
||||
`(${
|
||||
allAlphabets
|
||||
.sort((a, b) => b.Letter.length - a.Letter.length)
|
||||
.filter(a => a[langOrCountry as AllAlphabetsKeys])
|
||||
.map(a => escapeRegExp(a.Letter))
|
||||
.join('|')
|
||||
}|.)`,
|
||||
'gi');
|
||||
return hangul.unpack(text)
|
||||
.replace(/\s+/g, ' ')
|
||||
.replace(
|
||||
charRegex,
|
||||
(character) => {
|
||||
const searchChar = character.toUpperCase();
|
||||
const isUpper = character[0].toUpperCase() === character[0];
|
||||
const natoWord = getNatoWord(searchChar);
|
||||
|
||||
if (isDigit(searchChar)) {
|
||||
if (useDigitsNames) {
|
||||
return ` {digit ${searchChar} => ${natoWord}}`;
|
||||
}
|
||||
else {
|
||||
return ` (digit ${character})`;
|
||||
}
|
||||
}
|
||||
if (isPunctuation(searchChar)) {
|
||||
if (usePunctuationsNames) {
|
||||
return ` {punctuation ${searchChar} => ${natoWord}}`;
|
||||
}
|
||||
else {
|
||||
return ` (punctuation ${character})`;
|
||||
}
|
||||
}
|
||||
|
||||
if (natoWord) {
|
||||
return ` ${isUpper ? natoWord.toUpperCase() : natoWord.toLowerCase()}`;
|
||||
}
|
||||
|
||||
return ` (${character})`;
|
||||
})
|
||||
.trim();
|
||||
}
|
||||
@@ -1,14 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { textToNatoAlphabet } from './text-to-nato-alphabet.service';
|
||||
import { allLanguagesAndCountries } from './text-to-nato-alphabet.constants';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const lang = useStorage('text-to-nato:lang', '(International)');
|
||||
const input = ref('');
|
||||
const natoText = computed(() => textToNatoAlphabet({ text: input.value }));
|
||||
const useDigitsNames = useStorage('text-to-nato:digits', false);
|
||||
const usePunctuationsNames = useStorage('text-to-nato:puncts', false);
|
||||
const natoText = computed(() => textToNatoAlphabet({ text: input.value, langOrCountry: lang.value }));
|
||||
const { copy } = useCopy({ source: natoText, text: 'NATO alphabet string copied.' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-select
|
||||
v-model:value="lang"
|
||||
:options="allLanguagesAndCountries"
|
||||
searchable
|
||||
/>
|
||||
|
||||
<div flex justify-center>
|
||||
<n-form-item label="Use digits pronunciation">
|
||||
<n-checkbox v-model:checked="usePunctuationsNames" />
|
||||
</n-form-item>
|
||||
<n-form-item label="Use punctuations pronunciation">
|
||||
<n-checkbox v-model:checked="useDigitsNames" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="input"
|
||||
label="Your text to convert to NATO phonetic alphabet"
|
||||
@@ -19,7 +38,7 @@ const { copy } = useCopy({ source: natoText, text: 'NATO alphabet string copied.
|
||||
|
||||
<div v-if="natoText">
|
||||
<div mb-2>
|
||||
Your text in NATO phonetic alphabet
|
||||
Your text in NATO phonetic alphabet ({{ lang }})
|
||||
</div>
|
||||
<c-card>
|
||||
{{ natoText }}
|
||||
|
||||
Reference in new issue
Block a user