feat: tools default params and default language at runtime and more url parameters

Fix #1624, #1537, #906, #654
This commit is contained in:
ShareVB committed 2025-08-19 19:57:12 +02:00
1 parent 686c9fb08b
commit 63065a59e5
122 files changed
+460 -268

No files matched your search

+52
View File
@@ -4,6 +4,10 @@ Since *Docker base image* is now `nginx-unpriviledged`, docker image now listen
Docker image listen to IPv6, so it needs to be enabled: https://serverfault.com/questions/1147296/how-to-enable-ipv6-on-ubuntu-20-04. Alternatively, you can mount your own `nginx.conf` own using docker option `-v "./nginx.conf:/etc/nginx/conf.d/nginx.conf"` (with `listen [::]:8080;` removed)
## PR Welcome
Especially for UI improvements and translation. And for anything else.
## HTTPS is recommanded
Some tools like PGP encryption rely on WebCrypto API that is only available in HTTPS/SSL. Also, if you want to use PWA, HTTPS is required.
@@ -75,6 +79,54 @@ Category matches on category (English) names ; Tools matches on tools path/url.
See (docker-tools-filter-and-home-content)[https://github.com/sharevb/it-tools]
## Setting default tools parameters / default UI language at runtime
You can set default tools parameters by mounting a `tools-setting.json` in `/usr/share/nginx/html`.
It is a two level json, first level for `tool name`, second level for `parameter name`:
```json
{
"regex-tester": {
"multi": true,
"regex": "some regex",
"global": false
}
}
```
You can find `tool name` and `parameter name` in the tools source code `src/tools` subfolder :
- for pattern like `const global = useQueryParamOrStorage({ storageName: 'regex-tester:g', name: 'global', defaultValue: true });`:
```json
{
"regex-tester": {
"global": false
}
}
```
- for pattern like `const value = useQueryParam({ tool: 'barcode-gen', name: 'text', defaultValue: '123456789' });`:
```json
{
"barcode-gen": {
"text": "4356"
}
}
```
- for pattern like `const width = useITStorage('ascii-text-drawer:width', 80);`:
```json
{
"ascii-text-drawer": {
"width": 80
}
}
```
To define default UI language, add a `default_locale` key to json:
```json
{
"default_locale": "fr"
}
```
## To build using a custom default language:
```
+1
View File
@@ -0,0 +1 @@
{}
+4
View File
@@ -1,10 +1,12 @@
<script setup lang="ts">
import { RouterView, useRoute } from 'vue-router';
import { NGlobalStyle, NMessageProvider, NNotificationProvider, darkTheme } from 'naive-ui';
import { get } from '@vueuse/core';
import { darkThemeOverrides, lightThemeOverrides } from './themes';
import { layouts } from './layouts';
import { useStyleStore } from './stores/style.store';
import { useAppTheme } from './ui/theme/themes';
import { getITToolsSetting } from './composable/queryParams';
const route = useRoute();
const layout = computed(() => route?.meta?.layout ?? layouts.base);
@@ -30,6 +32,8 @@ watchEffect(() => {
});
});
locale.value = get(getITToolsSetting('default_locale', locale.value));
syncRef(
locale,
useStorage('locale', locale),
+37 -8
View File
@@ -1,8 +1,9 @@
import { useRouteQuery } from '@vueuse/router';
import { computed } from 'vue';
import { useStorage } from '@vueuse/core';
import { type MaybeRef, computed } from 'vue';
import { type RemovableRef, type StorageLike, type UseStorageOptions, get, useStorage } from '@vueuse/core';
import { getCurrentInstance } from 'vue';
export { useQueryParam, useQueryParamOrStorage };
export { useQueryParam, useQueryParamOrStorage, useITStorage, getITToolsSetting };
const transformers = {
number: {
@@ -25,11 +26,12 @@ const transformers = {
},
};
function useQueryParam<T>({ name, defaultValue }: { name: string; defaultValue: T }) {
function useQueryParam<T>({ tool, name, defaultValue }: { tool: string; name: string; defaultValue: T }): RemovableRef<T> {
const type = typeof defaultValue;
const transformer = transformers[type as keyof typeof transformers] ?? transformers.string;
const defaultValueOrSetting = getITToolsSetting(`${tool}:${name}`, defaultValue);
const proxy = useRouteQuery(name, transformer.toQuery(defaultValue as never));
const proxy = useRouteQuery(name, transformer.toQuery(defaultValueOrSetting as never));
return computed<T>({
get() {
@@ -45,11 +47,13 @@ function useQueryParamOrStorage<T>({ name, storageName, defaultValue }: { name:
const type = typeof defaultValue;
const transformer = transformers[type as keyof typeof transformers] ?? transformers.string;
const storageRef = useStorage(storageName, defaultValue);
const proxyDefaultValue = transformer.toQuery(defaultValue as never);
const defaultValueOrSetting = getITToolsSetting(`${storageName.split(':')[0]}:${name}`, defaultValue);
const storageRef = useStorage(storageName, defaultValueOrSetting);
const proxyDefaultValue = transformer.toQuery(defaultValueOrSetting as never);
const proxy = useRouteQuery(name, proxyDefaultValue);
const r = ref(defaultValue);
const r = isRef(defaultValueOrSetting) ? defaultValueOrSetting as Ref<T> : ref(get(defaultValueOrSetting));
watch(r,
(value) => {
@@ -64,3 +68,28 @@ function useQueryParamOrStorage<T>({ name, storageName, defaultValue }: { name:
return r;
}
function useITStorage<T>(key: string, defaults: MaybeRef<T>, storage?: StorageLike, options?: UseStorageOptions<T>): RemovableRef<T> {
const defaultValueOrSetting = getITToolsSetting(key, defaults);
return useStorage<T>(key, defaultValueOrSetting, storage, options);
}
function getITToolsSetting<T>(key: string, defaultValue: MaybeRef<T>) {
const itToolsSettings = useITToolsSettings();
if (key.includes(':')) {
const [tool, subkey] = key.split(':');
return (itToolsSettings[tool] || {})[subkey] as T ?? defaultValue;
}
else {
return (itToolsSettings)[key] as T ?? defaultValue;
}
}
let itToolsSettings: Record<string, Record<string, any> | any>;
function useITToolsSettings(): Record<string, Record<string, any>> {
if (!itToolsSettings) {
const vm = getCurrentInstance();
itToolsSettings = vm?.appContext.config.globalProperties.$itToolsSettings as Record<string, Record<string, any>>;
}
return itToolsSettings;
}
+11
View File
@@ -32,6 +32,17 @@ registerSW();
const app = createApp(App);
const base = import.meta.env.BASE_URL ?? '/';
let toolsSettings: Record<string, Record<string, any> | any> = {};
try {
const remoteSettingsResponse = await fetch(`${base}tools-settings.json`);
if (remoteSettingsResponse.ok) {
toolsSettings = (await remoteSettingsResponse.json()) as Record<string, Record<string, any> | any>;
}
}
catch {}
app.config.globalProperties.$itToolsSettings = toolsSettings;
app.use(LoadingPlugin);
app.use(createPinia());
app.use(createHead());
+3 -2
View File
@@ -1,13 +1,14 @@
import { useDark, useMediaQuery, useStorage, useToggle } from '@vueuse/core';
import { useDark, useMediaQuery, useToggle } from '@vueuse/core';
import { defineStore } from 'pinia';
import { type Ref, watch } from 'vue';
import { useITStorage } from '@/composable/queryParams';
export const useStyleStore = defineStore('style', {
state: () => {
const isDarkTheme = useDark();
const toggleDark = useToggle(isDarkTheme);
const isSmallScreen = useMediaQuery('(max-width: 700px)');
const isMenuCollapsed = useStorage('isMenuCollapsed', isSmallScreen.value) as Ref<boolean>;
const isMenuCollapsed = useITStorage('isMenuCollapsed', isSmallScreen.value) as Ref<boolean>;
watch(isSmallScreen, v => (isMenuCollapsed.value = v));
@@ -2,11 +2,12 @@
import { useI18n } from 'vue-i18n';
import promptSplitter from 'chatgpt-prompt-splitter';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const prompt = ref('');
const splitLength = ref(1024);
const prompt = useQueryParam({ tool: 'ai-prompt-split', name: 'prompt', defaultValue: '' });
const splitLength = useQueryParam({ tool: 'ai-prompt-split', name: 'split', defaultValue: 1024 });
const splittedPrompts = computed(() => {
try {
@@ -8,7 +8,7 @@ import { Terminal } from '@xterm/xterm';
import '@xterm/xterm/css/xterm.css';
import styles from 'ansi-styles';
import type { CSPair } from 'ansi-styles';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -77,7 +77,7 @@ onMounted(() => {
watch(outputEscapeSequence, seq => writeTermAndScrollBottom(seq), { immediate: true });
const escapeSequenceToTest = ref('');
const escapeSequenceToTest = useQueryParam({ tool: 'ansi', name: 'seq', defaultValue: '' });
</script>
<template>
@@ -2,11 +2,12 @@
import figlet from 'figlet';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { languages, printToLanguage } from '@/utils/ascii-lang-utils';
import { useITStorage } from '@/composable/queryParams';
const input = ref('Ascii ART');
const language = useStorage('ascii-text-drawer:language', 'raw');
const font = useStorage('ascii-text-drawer:font', 'Standard');
const width = useStorage('ascii-text-drawer:width', 80);
const language = useITStorage('ascii-text-drawer:language', 'raw');
const font = useITStorage('ascii-text-drawer:font', 'Standard');
const width = useITStorage('ascii-text-drawer:width', 80);
const output = ref('');
const errored = ref(false);
const processing = ref(false);
@@ -4,7 +4,7 @@ import bwipjs, { type RenderOptions } from 'bwip-js/browser';
import { Base64 } from 'js-base64';
import formats from './barcode.formats.json';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -15,7 +15,7 @@ const height = useQueryParamOrStorage({ name: 'height', storageName: 'barcode-ge
const margin = useQueryParamOrStorage({ name: 'margin', storageName: 'barcode-gen:margin', defaultValue: 10 });
const format = useQueryParamOrStorage({ name: 'format', storageName: 'barcode-gen:format', defaultValue: 'code128' });
const displayValue = useQueryParamOrStorage({ name: 'display', storageName: 'barcode-gen:display', defaultValue: true });
const value = ref('123456789');
const value = useQueryParam({ tool: 'barcode-gen', name: 'text', defaultValue: '123456789' });
const barcodeCanvas = ref<HTMLCanvasElement>();
const options = computed<RenderOptions>(() => ({
@@ -3,17 +3,18 @@ import { useI18n } from 'vue-i18n';
import { useCopy } from '@/composable/copy';
import { base64ToText, isValidBase64, textToBase64 } from '@/utils/base64';
import { withDefaultOnError } from '@/utils/defaults';
import { useITStorage, useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const encodeUrlSafe = useStorage('base64-string-converter--encode-url-safe', false);
const decodeUrlSafe = useStorage('base64-string-converter--decode-url-safe', false);
const encodeUrlSafe = useITStorage('base64-string-converter:encode-url-safe', false);
const decodeUrlSafe = useITStorage('base64-string-converter:decode-url-safe', false);
const textInput = ref('');
const textInput = useQueryParam({ tool: 'base64-string-converter', name: 'text', defaultValue: '' });
const base64Output = computed(() => textToBase64(textInput.value, { makeUrlSafe: encodeUrlSafe.value }));
const { copy: copyTextBase64 } = useCopy({ source: base64Output, text: t('tools.base64-string-converter.texts.text-base64-string-copied-to-the-clipboard') });
const base64Input = ref('');
const base64Input = useQueryParam({ tool: 'base64-string-converter', name: 'base64', defaultValue: '' });
const textOutput = computed(() =>
withDefaultOnError(() => base64ToText(base64Input.value.trim(), { makeUrlSafe: decodeUrlSafe.value }), ''),
);
@@ -1,21 +1,21 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { Plus, Trash } from '@vicons/tabler';
import { useStorage } from '@vueuse/core';
import _ from 'lodash';
import { arrayToMarkdownTable, computeAverage, computeVariance } from './benchmark-builder.models';
import DynamicValues from './dynamic-values.vue';
import { useCopy } from '@/composable/copy';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
const suites = useStorage('benchmark-builder:suites', [
const suites = useITStorage('benchmark-builder:suites', [
{ title: 'Suite 1', data: [5, 10] },
{ title: 'Suite 2', data: [8, 12] },
]);
const unit = useStorage('benchmark-builder:unit', '');
const unit = useITStorage('benchmark-builder:unit', '');
const round = (v: number) => Math.round(v * 1000) / 1000;
@@ -21,6 +21,7 @@ import { useCopy } from '@/composable/copy';
import { useValidation } from '@/composable/validation';
import { isNotThrowing } from '@/utils/boolean';
import { withDefaultOnError } from '@/utils/defaults';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -40,7 +41,8 @@ const languages = {
const entropy = ref(generateEntropy());
const passphraseInput = ref('');
const language = ref<keyof typeof languages>('English');
const language = useQueryParamOrStorage<keyof typeof languages>({ name: 'lang', storageName: 'bip39-gen:l', defaultValue: 'English' });
const passphrase = computed({
get() {
return withDefaultOnError(() => entropyToMnemonic(entropy.value, languages[language.value]), passphraseInput.value);
+2 -2
View File
@@ -14,7 +14,7 @@ import {
trainCase,
} from 'change-case';
import InputCopyable from '../../components/InputCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
import { useValidation } from '@/composable/validation';
const { t } = useI18n();
@@ -34,7 +34,7 @@ const cleaningRegexValidation = useValidation({
],
});
const input = ref('lorem ipsum dolor sit amet');
const input = useQueryParam({ tool: 'case-conv', name: 'text', defaultValue: 'lorem ipsum dolor sit amet' });
const inputCleaned = computed(() => {
if (!cleaningRegexValidation.isValid) {
return input.value;
+3 -3
View File
@@ -1,17 +1,17 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { useStorage } from '@vueuse/core';
import { Check as CheckIcon, LetterX as CrossIcon } from '@vicons/tabler';
import { getMatch } from 'ip-matching';
import { cidrInCidr } from './cidr-in-cidr.service';
import { withDefaultOnError } from '@/utils/defaults';
import { isNotThrowing } from '@/utils/boolean';
import SpanCopyable from '@/components/SpanCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const baseRange = useStorage('cidr-in-cidr:range', '192.168.0.1/24'); // NOSONAR
const ipOrRangeToTest = useStorage('cidr-in-cidr:ip', '192.168.0.1'); // NOSONAR
const baseRange = useQueryParamOrStorage({ name: 'range', storageName: 'cidr-in-cidr:range', defaultValue: '192.168.0.1/24' }); // NOSONAR
const ipOrRangeToTest = useQueryParamOrStorage({ name: 'ip', storageName: 'cidr-in-cidr:ip', defaultValue: '192.168.0.1' }); // NOSONAR
const matchResult = computed(() => withDefaultOnError(
() => cidrInCidr({ baseRange: baseRange.value, ipOrRangeToTest: ipOrRangeToTest.value }),
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import * as service from './cli-command-editor.service';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const inputCommand = ref('');
const inputCommand = useQueryParam({ tool: 'cli-cmd-editor', name: 'cmd', defaultValue: '' });
const options = computed(() => service.extractOptions(inputCommand.value));
const optionsObject = computed(() => service.buildOptionsObject(options.value));
const optionsInput = ref<{ [k: string]: string }>(optionsObject.value);
@@ -5,8 +5,8 @@ import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const forecolor = useQueryParam({ name: 'fg', defaultValue: '#000' });
const backcolor = useQueryParam({ name: 'bg', defaultValue: '#fff' });
const forecolor = useQueryParam({ tool: 'color-constrast-checker', name: 'fg', defaultValue: '#000' });
const backcolor = useQueryParam({ tool: 'color-constrast-checker', name: 'bg', defaultValue: '#fff' });
const levels = [
{ score: 3, text: t('tools.color-contrast-checker.texts.text-very-poor'), bg: '#fbd0da', fg: '#5f071c', stars: 1 },
+3 -1
View File
@@ -7,12 +7,14 @@ import { computed, ref, watch } from 'vue';
import { useDebounce } from '@vueuse/core';
import type { Harmony, HarmonyType } from 'vue-color-wheel';
import { VueColorWheel } from 'vue-color-wheel';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
extend([a11yPlugin]);
const wheelColor = useDebounce(ref('#40ffff')); // { hue: 0, saturation: 0.68, value: 1 }
const inputColor = useQueryParam({ tool: 'color-wheel', name: 'col', defaultValue: '#40ffff' });
const wheelColor = useDebounce(inputColor); // { hue: 0, saturation: 0.68, value: 1 }
const colors = ref<Array<Harmony>>([]);
const currentType = ref<HarmonyType>('analogous');
const isColorReadable = ref(false);
+1 -1
View File
@@ -5,7 +5,7 @@ import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const cookieHeader = useQueryParam({ name: 'cookies', defaultValue: '' });
const cookieHeader = useQueryParam({ tool: 'cookies-parser', name: 'cookies', defaultValue: '' });
const parsedCookies = computed(() => {
return (cookieHeader.value || '').replace(/^Cookie:\s*/, '').split('; ').map((cookie) => {
+4 -4
View File
@@ -22,10 +22,10 @@ function getCountDownHref(c: CountDown) {
return parsedUrl.toString();
}
const days = useQueryParam({ name: 'd', defaultValue: 0 });
const hours = useQueryParam({ name: 'h', defaultValue: 0 });
const minutes = useQueryParam({ name: 'm', defaultValue: 0 });
const seconds = useQueryParam({ name: 's', defaultValue: 0 });
const days = useQueryParam({ tool: 'countdown', name: 'd', defaultValue: 0 });
const hours = useQueryParam({ tool: 'countdown', name: 'h', defaultValue: 0 });
const minutes = useQueryParam({ tool: 'countdown', name: 'm', defaultValue: 0 });
const seconds = useQueryParam({ tool: 'countdown', name: 's', defaultValue: 0 });
const history = useStorage<CountDown[]>('countdown:hst', []);
const status = ref<'stopped' | 'ended' | 'running'>('stopped');
+2 -2
View File
@@ -8,8 +8,8 @@ import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const allDays = '0,1,2,3,4,5,6';
const alarmAt = useQueryParam({ name: 'at', defaultValue: '17:30:00' });
const alarmDays = useQueryParam({ name: 'days', defaultValue: allDays });
const alarmAt = useQueryParam({ tool: 'cronalarm', name: 'at', defaultValue: '17:30:00' });
const alarmDays = useQueryParam({ tool: 'cronalarm', name: 'days', defaultValue: allDays });
const history = useStorage<{ days: string; at: string }[]>('cronalarm:hst', []);
function getTimeHref(at: string, days: string) {
@@ -5,13 +5,13 @@ import ctz from 'countries-and-timezones';
import getTimezoneOffset from 'get-timezone-offset';
import { type CronType, getLastExecutionTimes, isCronValid } from './crontab-generator.service';
import { useStyleStore } from '@/stores/style.store';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const styleStore = useStyleStore();
const cron = ref('40 * * * *');
const cron = useQueryParam({ tool: 'crontab-gen', name: 'expr', defaultValue: '40 * * * *' });
const cronstrueConfig = reactive({
verbose: true,
dayOfWeekStartIndexZero: true,
+8 -7
View File
@@ -5,10 +5,11 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { withDefaultOnErrorAsync } from '@/utils/defaults';
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const commonName = ref('test.com');
const commonName = useQueryParam({ tool: 'csr-gen', name: 'cn', defaultValue: 'test.com' });
const commonNameValidation = useValidation({
source: commonName,
rules: [
@@ -19,13 +20,13 @@ const commonNameValidation = useValidation({
],
});
const organizationName = ref('Test');
const organizationalUnit = ref('');
const organizationName = useQueryParam({ tool: 'csr-gen', name: 'org', defaultValue: 'Test' });
const organizationalUnit = useQueryParam({ tool: 'csr-gen', name: 'ou', defaultValue: '' });
const password = ref('');
const city = ref('Paris');
const state = ref('FR');
const country = ref('France');
const contactEmail = ref('');
const city = useQueryParam({ tool: 'csr-gen', name: 'city', defaultValue: 'Paris' });
const state = useQueryParam({ tool: 'csr-gen', name: 'state', defaultValue: 'FR' });
const country = useQueryParam({ tool: 'csr-gen', name: 'country', defaultValue: 'France' });
const contactEmail = useQueryParam({ tool: 'csr-gen', name: 'email', defaultValue: '' });
const subjectAlternativeNames = ref('');
const emptyCSR = { csrPem: '', privateKeyPem: '', publicKeyPem: '' };
@@ -3,10 +3,11 @@ import { useI18n } from 'vue-i18n';
import xPathToCss from 'xpath-to-css';
import cssToXpath from 'csstoxpath';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const cssInput = ref('');
const cssInput = useQueryParam({ tool: 'css-xpath-conv', name: 'css', defaultValue: '' });
const xpathOutput = computed(
() => {
try {
@@ -18,7 +19,7 @@ const xpathOutput = computed(
},
);
const xpathInput = ref('');
const xpathInput = useQueryParam({ tool: 'css-xpath-conv', name: 'xpath', defaultValue: '' });
const cssOutput = computed(
() => {
try {
+3 -2
View File
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import { convertCsvToArray } from '../csv-to-json/csv-to-json.service';
import { objectArrayToData } from '@/utils/objectarray.export';
import type { ExportFormat } from '@/utils/objectarray.export';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -13,8 +14,8 @@ const fileInput = ref() as Ref<File | null>;
const error = ref('');
const convertedData = ref<string>('');
const selectedFormat = ref<string>('json');
const tableName = ref<string>('TableName');
const selectedFormat = useQueryParamOrStorage({ name: 'fmt', storageName: 'csv-to-data:fmt', defaultValue: 'json' });
const tableName = useQueryParamOrStorage({ name: 'table', storageName: 'csv-to-data:tbl', defaultValue: 'TableName' });
const nestify = ref(false);
const typedValues = ref(false);
+2 -1
View File
@@ -16,6 +16,7 @@ import {
toWgetWarn,
} from 'curlconverter';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -85,7 +86,7 @@ const translate = {
'wget': [toWget, toWgetWarn],
};
const language = ref('python');
const language = useQueryParamOrStorage({ name: 'lang', storageName: 'curl-conv:l', defaultValue: 'python' });
const curl = ref('curl --data "hello=world" example.com');
const inlang = computed(() => {
try {
@@ -3,14 +3,14 @@ import { useI18n } from 'vue-i18n';
import { code, countries, country } from 'currency-codes-ts';
import converter from 'currency-exchanger-js';
import moneysData from './moneys.json';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const allCurrencies = Object.entries(moneysData).map(([k, v]) => ({ value: k, label: v || k }));
const otherCurrencies = useQueryParamOrStorage<{ name: string }[]>({ name: 'to', storageName: 'currency-conv:others', defaultValue: [{ name: 'usd' }] });
const currentCurrency = useQueryParamOrStorage<string>({ name: 'from', storageName: 'currency-conv:cur', defaultValue: 'eur' });
const amount = ref(1);
const amount = useQueryParam({ tool: 'currency-conv', name: 'amount', defaultValue: 1 });
const currentDatetime = ref(Date.now());
const convertedCurrencies = computedAsync<Record<string, number>>(async () => {
+1 -1
View File
@@ -28,7 +28,7 @@ const generatedData = ref<string>('');
const itemCount = useQueryParamOrStorage({ name: 'count', storageName: 'faker:c', defaultValue: 1 });
const error = ref('');
const selectedFormat = useQueryParamOrStorage({ name: 'fmt', storageName: 'faker:f', defaultValue: 'json' });
const tableName = ref<string>('TableName');
const tableName = useQueryParamOrStorage({ name: 'table', storageName: 'faker:t', defaultValue: 'TableName' });
const nestify = ref(false);
const allLocales = Object.keys(allFakers);
@@ -40,10 +40,11 @@ import {
} from './date-time-converter.models';
import { withDefaultOnError } from '@/utils/defaults';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const inputDate = ref('');
const inputDate = useQueryParam({ tool: 'date-time-converter', name: 'date', defaultValue: '' });
const toDate: ToDateMapper = date => new Date(date);
+3 -2
View File
@@ -2,11 +2,12 @@
import { useI18n } from 'vue-i18n';
import { combineTXT, query, wellknown } from 'dns-query';
import types from './dns.records.types.json';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const type = ref('A');
const name = ref('google.com');
const type = useQueryParam({ tool: 'dns-queries', name: 'type', defaultValue: 'A' });
const name = useQueryParam({ tool: 'dns-queries', name: 'domain', defaultValue: 'google.com' });
const answers = ref<string[]>([]);
async function queryDNS() {
@@ -4,6 +4,7 @@ import Composeverter from 'composeverter';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { textToBase64 } from '@/utils/base64';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -15,7 +16,7 @@ const dockerCompose = ref(
- '/var/run/docker.sock:/tmp/docker.sock:ro'
image: nginx`,
);
const indentSize = useStorage('docker-compose-converter:indent-size', 4);
const indentSize = useQueryParamOrStorage({ name: 'indent', storageName: 'docker-compose-converter:indent-size', defaultValue: 4 });
const expandVolumes = ref(
false,
@@ -23,7 +24,7 @@ const expandVolumes = ref(
const expandPorts = ref(
false,
);
const conversion = useStorage('docker-compose-converter:conversion', 'latest');
const conversion = useQueryParamOrStorage({ name: 'conv', storageName: 'docker-compose-converter:conversion', defaultValue: 'latest' });
const conversionOptions = [
{ value: 'v1ToV2x', label: t('tools.docker-compose-converter.texts.label-v1-to-v2-2-x') },
{ value: 'v1ToV3x', label: t('tools.docker-compose-converter.texts.label-v1-to-v2-3-x') },
@@ -4,18 +4,19 @@ import composerize from 'composerize';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { textToBase64 } from '@/utils/base64';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const dockerRuns = ref(
'docker run -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --restart always --log-opt max-size=1g nginx',
);
const indentSize = useStorage('docker-run-to-compose:indent-size', 4);
const indentSize = useQueryParamOrStorage({ name: 'indent', storageName: 'docker-run-to-compose:indent-size', defaultValue: 4 });
const existingDockerComposeFile = ref(
'',
);
const format = useStorage('docker-run-to-compose:format', 'latest');
const format = useQueryParamOrStorage({ name: 'fmt', storageName: 'docker-run-to-compose:format', defaultValue: 'latest' });
const formatOptions = [
{ value: 'v2x', label: t('tools.docker-run-to-docker-compose-converter.texts.label-v2-2-x') },
{ value: 'v3x', label: t('tools.docker-run-to-docker-compose-converter.texts.label-v2-3-x') },
@@ -5,20 +5,21 @@ import { generateKeyPair } from './ecdsa-key-pair-generator.service';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { withDefaultOnErrorAsync } from '@/utils/defaults';
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
const password = ref('');
const comment = ref('');
const emptyCerts = { publicKey: '', privateKey: '' };
const curve = useStorage('ecdsa-key-pair-generator:curve', 'nistp256');
const curve = useITStorage('ecdsa-key-pair-generator:curve', 'nistp256');
const curveOptions = [
{ value: 'nistp256', label: t('tools.ecdsa-key-pair-generator.texts.label-nistp256') },
{ value: 'nistp384', label: t('tools.ecdsa-key-pair-generator.texts.label-nistp384') },
{ value: 'nistp521', label: t('tools.ecdsa-key-pair-generator.texts.label-nistp521') },
];
const format = useStorage('ecdsa-key-pair-generator:format', 'ssh');
const format = useITStorage('ecdsa-key-pair-generator:format', 'ssh');
const formatOptions = [
{ value: 'pem', label: t('tools.ecdsa-key-pair-generator.texts.label-pem') },
{ value: 'pkcs8', label: t('tools.ecdsa-key-pair-generator.texts.label-pkcs-8') },
@@ -5,6 +5,7 @@ import { generateKeyPair } from './ed25519-key-pair-generator.service';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { withDefaultOnErrorAsync } from '@/utils/defaults';
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -12,7 +13,7 @@ const password = ref('');
const comment = ref('');
const emptyCerts = { publicKey: '', privateKey: '' };
const format = useStorage('ed25519-key-pair-generator:format', 'ssh');
const format = useITStorage('ed25519-key-pair-generator:format', 'ssh');
const formatOptions = [
{ value: 'pem', label: t('tools.ed25519-key-pair-generator.texts.label-pem') },
{ value: 'pkcs8', label: t('tools.ed25519-key-pair-generator.texts.label-pkcs-8') },
@@ -1,12 +1,13 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { computeCost } from './energy-computer.service';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const wattage = ref(100);
const durationHours = ref(2);
const kWhCost = ref(0.1);
const wattage = useQueryParam({ tool: 'energy-computer', name: 'wattage', defaultValue: 100 });
const durationHours = useQueryParam({ tool: 'energy-computer', name: 'hours', defaultValue: 2 });
const kWhCost = useQueryParam({ tool: 'energy-computer', name: 'cost', defaultValue: 0.1 });
const totalCost = computed(() => computeCost(wattage.value, durationHours.value, kWhCost.value));
</script>
+3 -2
View File
@@ -4,13 +4,14 @@ import { useI18n } from 'vue-i18n';
import * as XLSX from 'xlsx';
import { objectArrayToData } from '@/utils/objectarray.export';
import type { ExportFormat } from '@/utils/objectarray.export';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const workbook = ref<XLSX.WorkBook | null>(null);
const convertedData = ref<string>('');
const selectedFormat = ref<string>('json');
const tableName = ref<string>('TableName');
const selectedFormat = useQueryParamOrStorage({ name: 'fmt', storageName: 'excel-to-data:fmt', defaultValue: 'json' });
const tableName = useQueryParamOrStorage({ name: 'table', storageName: 'excel-to-data:tbl', defaultValue: 'TableName' });
const nestify = ref(false);
const sheetName = ref('');
const error = ref('');
+3 -2
View File
@@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n';
import InputCopyable from '../../components/InputCopyable.vue';
import type { Units } from './hdd-calculator.service';
import { getRealSize } from './hdd-calculator.service';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
@@ -21,8 +22,8 @@ const bin_units = [
{ value: 'pb', label: t('tools.hdd-calculator.texts.label-pib') },
];
const claimedCapacity = ref(1);
const claimedUnit = ref('tb');
const claimedCapacity = useQueryParam({ tool: 'hdd-calc', name: 'capacity', defaultValue: 1 });
const claimedUnit = useQueryParam({ tool: 'hdd-calc', name: 'unit', defaultValue: 'tb' });
</script>
<template>
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import type { Ref } from 'vue';
import { useCopy } from '@/composable/copy';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -52,9 +53,9 @@ async function ReadFileAsHex(file: File, separator: string = ' '): Promise<strin
});
}
const separator = useStorage('hex-converter:sep', ' ');
const separator = useITStorage('hex-converter:sep', ' ');
const fileInput = ref() as Ref<File>;
const prefix = useStorage('hex-converter:prefix', '');
const prefix = useITStorage('hex-converter:prefix', '');
const fileHex = computedAsync(async () => {
const file = fileInput.value;
const sep = separator.value;
@@ -1,14 +1,13 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { minify, prettify } from 'htmlfy';
import { useStorage } from '@vueuse/core';
import Editor from './editor/editor.vue';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const html = useStorage('html-wysiwyg-editor--html', '<h1>Hey!</h1><p>Welcome to this html wysiwyg editor</p>');
const html = useITStorage('html-wysiwyg-editor--html', '<h1>Hey!</h1><p>Welcome to this html wysiwyg editor</p>');
const minifyOutput = useQueryParamOrStorage({ name: 'minify', storageName: 'html-wysiwyg-editor--min', defaultValue: false });
@@ -11,10 +11,11 @@ import {
} from '@tabler/icons-vue';
import { codesByCategories } from './http-status-codes.constants';
import { useFlexSearch } from '@/composable/flexSearch';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const search = ref('');
const search = useQueryParam({ tool: 'http-status-codes', name: 's', defaultValue: '' });
const { searchResult } = useFlexSearch({
search,
@@ -3,10 +3,11 @@ import { useI18n } from 'vue-i18n';
import { extractIBAN, friendlyFormatIBAN, isQRIBAN, validateIBAN } from 'ibantools';
import { getFriendlyErrors } from './iban-validator-and-parser.service';
import type { CKeyValueListItems } from '@/ui/c-key-value-list/c-key-value-list.types';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const rawIban = ref('');
const rawIban = useQueryParam({ tool: 'iban-validator', name: 'iban', defaultValue: '' });
const ibanInfo = computed<CKeyValueListItems>(() => {
const iban = rawIban.value.toUpperCase().replace(/\s/g, '').replace(/-/g, '');
@@ -3,11 +3,12 @@ import { useI18n } from 'vue-i18n';
import { ImageToAsciiArt } from 'image-to-ascii-art';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { languages, printToLanguage } from '@/utils/ascii-lang-utils';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
const inputBase64 = ref('');
const language = useStorage('image-to-ascii-art:language', 'raw');
const language = useITStorage('image-to-ascii-art:language', 'raw');
const scale = ref(100);
const errored = ref(false);
const processing = ref(false);
@@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n';
import InputCopyable from '../../components/InputCopyable.vue';
import { convertBase, hasNumberPrefix } from './integer-base-converter.model';
import { getErrorMessageIfThrows } from '@/utils/error';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
@@ -14,9 +15,9 @@ const inputProps = {
'mb-2': '',
} as const;
const input = ref('42');
const inputBase = ref(10);
const outputBase = ref(42);
const input = useQueryParam({ tool: 'int-base-conv', name: 'num', defaultValue: '42' });
const inputBase = useQueryParam({ tool: 'int-base-conv', name: 'base', defaultValue: 10 });
const outputBase = useQueryParam({ tool: 'int-base-conv', name: 'outbase', defaultValue: 42 });
const hasInputNumberPrefix = computed(() => hasNumberPrefix(input.value));
+3 -2
View File
@@ -3,11 +3,12 @@ import { useI18n } from 'vue-i18n';
import { stringifyIp } from 'ip-bigint';
import InputCopyable from '../../components/InputCopyable.vue';
import { convertBase, hasNumberPrefix } from '../integer-base-converter/integer-base-converter.model';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const input = ref('3232235777');
const inputBase = ref(10);
const input = useQueryParam({ tool: 'int-to-ip', name: 'int', defaultValue: '3232235777' });
const inputBase = useQueryParam({ tool: 'int-to-ip', name: 'base', defaultValue: 10 });
const hasInputNumberPrefix = computed(() => hasNumberPrefix(input.value));
@@ -4,10 +4,11 @@ import isCidr from 'is-cidr';
import { expandCidr } from 'cidr-tools';
import { getIPNetworkType, parseAsCIDR } from '@/utils/ip';
import { useValidation } from '@/composable/validation';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const rawCIDR = useStorage('ip-cidr-to-range:cidr', '192.168.1.0/24'); // NOSONAR
const rawCIDR = useQueryParamOrStorage({ name: 'cidr', storageName: 'ip-cidr-to-range:cidr', defaultValue: '192.168.1.0/24' }); // NOSONAR
const result = computed(() => {
const parsedCIDR = parseAsCIDR(rawCIDR.value) || rawCIDR.value;
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import type { CKeyValueListItems } from '@/ui/c-key-value-list/c-key-value-list.types';
import { useITStorage, useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const ip = ref('8.8.8.8');
const ip = useQueryParam({ tool: 'ip-geo-loc', name: 'ip', defaultValue: '8.8.8.8' });
const errorMessage = ref('');
const fields: Array<{ field: string; name: string }> = [
@@ -24,7 +25,7 @@ const geoInfosData = ref<{
loc?: string
}>({});
const status = ref<'pending' | 'error' | 'success'>('pending');
const token = useStorage('ip-geoloc:token', '');
const token = useITStorage('ip-geoloc:token', '');
const openStreetMapUrl = computed(
() => {
@@ -1,14 +1,14 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { useStorage } from '@vueuse/core';
import { substractCIDRs } from './ip-include-exclude.service';
import SpanCopyable from '@/components/SpanCopyable.vue';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const allowedRanges = useStorage('ip-inc-exc:allow', '192.168.0.1/24'); // NOSONAR
const disallowedRanges = useStorage('ip-inc-exc:disallow', '192.168.0.6'); // NOSONAR
const allowedRanges = useQueryParamOrStorage({ name: 'allow', storageName: 'ip-inc-exc:allow', defaultValue: '192.168.0.1/24' }); // NOSONAR
const disallowedRanges = useQueryParamOrStorage({ name: 'disallow', storageName: 'ip-inc-exc:disallow', defaultValue: '192.168.0.6' }); // NOSONAR
const result = computed(() => substractCIDRs({
allowedRanges: allowedRanges.value, disallowedRanges: disallowedRanges.value,
@@ -6,11 +6,12 @@ import { isIP, isIPv6 } from 'is-ip';
import { Exchange } from '@vicons/tabler';
import { stringifyIp } from 'ip-bigint';
import { useValidation } from '@/composable/validation';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const rawStartAddress = useStorage('ip-range-to-cidr:startAddress', '192.168.1.1');
const rawEndAddress = useStorage('ip-range-to-cidr:endAddress', '192.168.6.255');
const rawStartAddress = useQueryParamOrStorage({ name: 'start', storageName: 'ip-range-to-cidr:startAddress', defaultValue: '192.168.1.1' });
const rawEndAddress = useQueryParamOrStorage({ name: 'end', storageName: 'ip-range-to-cidr:endAddress', defaultValue: '192.168.6.255' });
const isReversed = ref<boolean>(false);
const isNotSameVersion = ref<boolean>(false);
@@ -6,10 +6,11 @@ import { ipv4ToInt, ipv4ToIpv6, isValidIpv4 } from './ipv4-address-converter.ser
import { getIPNetworkType, to6to4Prefix, toARPA, toIPv4MappedAddressDecimal } from '@/utils/ip';
import { useValidation } from '@/composable/validation';
import { withDefaultOnError } from '@/utils/defaults';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const rawIpAddress = useStorage('ipv4-converter:ip', '192.168.1.1'); // NOSONAR
const rawIpAddress = useQueryParamOrStorage({ name: 'ip', storageName: 'ipv4-converter:ip', defaultValue: '192.168.1.1' }); // NOSONAR
const convertedSections = computed(() => withDefaultOnError(() => {
const ipInDecimal = ipv4ToInt({ ip: rawIpAddress.value });
@@ -6,11 +6,12 @@ import type { Ipv4RangeExpanderResult } from './ipv4-range-expander.types';
import { calculateCidr } from './ipv4-range-expander.service';
import ResultRow from './result-row.vue';
import { useValidation } from '@/composable/validation';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const rawStartAddress = useStorage('ipv4-range-expander:startAddress', '192.168.1.1');
const rawEndAddress = useStorage('ipv4-range-expander:endAddress', '192.168.6.255');
const rawStartAddress = useQueryParamOrStorage({ name: 'start', storageName: 'ipv4-range-expander:startAddress', defaultValue: '192.168.1.1' });
const rawEndAddress = useQueryParamOrStorage({ name: 'end', storageName: 'ipv4-range-expander:endAddress', defaultValue: '192.168.6.255' });
const result = computed(() => calculateCidr({ startIp: rawStartAddress.value, endIp: rawEndAddress.value }));
@@ -1,17 +1,17 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { Netmask } from 'netmask';
import { useStorage } from '@vueuse/core';
import { ArrowLeft, ArrowRight } from '@vicons/tabler';
import { getIPClass } from './ipv4-subnet-calculator.models';
import { withDefaultOnError } from '@/utils/defaults';
import { isNotThrowing } from '@/utils/boolean';
import SpanCopyable from '@/components/SpanCopyable.vue';
import { getIPNetworkType, getNetworksCount, getSubnets, parseAsCIDR, to6to4Prefix, toARPA, toIPv4MappedAddress, toIPv4MappedAddressDecimal } from '@/utils/ip';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
const ip = useStorage('ipv4-subnet-calculator:ip', '192.168.0.1/24');
const ip = useITStorage('ipv4-subnet-calculator:ip', '192.168.0.1/24');
const getNetworkInfo = (address: string) => new Netmask(parseAsCIDR(address.trim()) || address.trim());
@@ -6,10 +6,11 @@ import { stringifyIp } from 'ip-bigint';
import { convertBase } from '../integer-base-converter/integer-base-converter.model';
import { getIPNetworkType, toARPA, toMicrosoftTranscription } from '@/utils/ip';
import { useValidation } from '@/composable/validation';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
const rawIpAddress = useStorage('ipv6-converter:ip', '2001:db8:0:85a3::ac1f:8001'); // NOSONAR
const rawIpAddress = useITStorage('ipv6-converter:ip', '2001:db8:0:85a3::ac1f:8001'); // NOSONAR
const convertedSections = computed(() => {
try {
@@ -1,15 +1,15 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { useStorage } from '@vueuse/core';
import { Address6 } from 'ip-address';
import { getIPNetworkType, parseAsCIDR } from '@/utils/ip';
import { withDefaultOnError } from '@/utils/defaults';
import SpanCopyable from '@/components/SpanCopyable.vue';
import { isNotThrowing } from '@/utils/boolean';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
const ip = useStorage('ipv6-subnet-calculator:ip', '2001:db8:0:85a3:0:0:ac1f:8001/32'); // NOSONAR
const ip = useITStorage('ipv6-subnet-calculator:ip', '2001:db8:0:85a3:0:0:ac1f:8001/32'); // NOSONAR
const getNetworkInfo = (address: string) => new Address6(parseAsCIDR(address.trim()) || address.trim());
const networkInfo = computed(() => withDefaultOnError(() => getNetworkInfo(ip.value), undefined));
@@ -3,10 +3,11 @@ import { useI18n } from 'vue-i18n';
import { SHA1 } from 'crypto-js';
import InputCopyable from '@/components/InputCopyable.vue';
import { macAddressValidation } from '@/utils/macAddress';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const macAddress = ref('20:37:06:12:34:56');
const macAddress = useQueryParam({ tool: 'ipv6-ula-gen', name: 'mac', defaultValue: '20:37:06:12:34:56' });
const calculatedSections = computed(() => {
const timestamp = new Date().getTime();
const hex40bit = SHA1(timestamp + macAddress.value)
@@ -2,10 +2,11 @@
import { useI18n } from 'vue-i18n';
import ISBN3 from 'isbn3';
import type { CKeyValueListItems } from '@/ui/c-key-value-list/c-key-value-list.types';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const rawIsbn = ref('9782021304534');
const rawIsbn = useQueryParam({ tool: 'isbn-validator', name: 'isbn', defaultValue: '9782021304534' });
const isbnInfos = computed<CKeyValueListItems>(() => {
const isbn = ISBN3.parse(rawIsbn.value);
@@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n';
import type { UseValidationRule } from '@/composable/validation';
import { isNotThrowing } from '@/utils/boolean';
import { withDefaultOnError } from '@/utils/defaults';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -15,7 +16,7 @@ function parseJSON(value: string) {
}
}
const indentSize = useStorage('json-prettify:indent-size', 3);
const indentSize = useQueryParamOrStorage({ name: 'indent', storageName: 'json-prettify:indent-size', defaultValue: 3 });
const transformer = (value: string) => withDefaultOnError(() => JSON.stringify(parseJSON(value), null, indentSize.value), '');
const rules: UseValidationRule<string>[] = [
+3 -2
View File
@@ -5,15 +5,16 @@ import jsonpath from 'jsonpath';
import jq from 'jq-wasm';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
type JQType = 'jq' | 'jsonpath';
const indent = 2;
const jqOrJsonPath = ref('');
const jqOrJsonPath = useQueryParam({ tool: 'jq-tester', name: 'expr', defaultValue: '' });
const json = ref('');
const jqtype = ref<JQType>('jq');
const jqtype = useQueryParam<JQType>({ tool: 'jq-tester', name: 'type', defaultValue: 'jq' });
const jqtypes = [
{ value: 'jq', label: t('tools.jq-tester.texts.label-jq') },
{ value: 'jsonpath', label: t('tools.jq-tester.texts.label-jsonpath') },
+3 -2
View File
@@ -2,10 +2,11 @@
import { useI18n } from 'vue-i18n';
import { addSlashes, removeSlashes } from 'slashes';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const unescapedInput = ref('');
const unescapedInput = useQueryParam({ tool: 'json-escaper', name: 'escape', defaultValue: '' });
const escapedOutput = computed(
() => {
try {
@@ -17,7 +18,7 @@ const escapedOutput = computed(
},
);
const escapedInput = ref('');
const escapedInput = useQueryParam({ tool: 'json-escaper', name: 'unescape', defaultValue: '' });
const unescapedOutput = computed(
() => {
try {
+5 -2
View File
@@ -4,17 +4,20 @@ import JSON5 from 'json5';
import { jsonquery } from '@jsonquerylang/jsonquery';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const indent = 2;
const jsonQuery = ref(`
const jsonQuery = useQueryParam({
tool: 'json-query', name: 'q', defaultValue: `
.friends
| filter(.city == "New York")
| sort(.age)
| pick(.name, .age)
`);
`,
});
const json = ref(`{
"friends": [
{ "name": "Chris", "age": 23, "city": "New York" },
@@ -1,19 +1,19 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import JSON5 from 'json5';
import { useStorage } from '@vueuse/core';
import { formatJson } from './json.models';
import { withDefaultOnError } from '@/utils/defaults';
import { useValidation } from '@/composable/validation';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const inputElement = ref<HTMLElement>();
const rawJson = useStorage('json-prettify:raw-json', '{"hello": "world", "foo": "bar"}');
const sortMethod = useStorage('json-prettify:sort-method', 'key_name');
const indentSize = useStorage('json-prettify:indent-size', 3);
const rawJson = useITStorage('json-prettify:raw-json', '{"hello": "world", "foo": "bar"}');
const sortMethod = useQueryParamOrStorage({ name: 'sort', storageName: 'json-prettify:sort-method', defaultValue: 'key_name' });
const indentSize = useQueryParamOrStorage({ name: 'indent', storageName: 'json-prettify:indent-size', defaultValue: 3 });
const keyName = ref('');
const cleanJson = computed(() => withDefaultOnError(() => formatJson({ rawJson, sortMethod, keyName, indentSize }), ''));
@@ -4,10 +4,11 @@ import JSON5 from 'json5';
import type { UseValidationRule } from '@/composable/validation';
import { isNotThrowing } from '@/utils/boolean';
import { withDefaultOnError } from '@/utils/defaults';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const indentSize = useStorage('json-prettify:indent-size', 3);
const indentSize = useQueryParamOrStorage({ name: 'indent', storageName: 'json-prettify:indent-size', defaultValue: 3 });
const transformer = (value: string) => withDefaultOnError(() => JSON5.stringify(JSON.parse(value), null, indentSize.value), '');
const rules: UseValidationRule<string>[] = [
+1 -1
View File
@@ -17,7 +17,7 @@ const formats = [
{ value: 'clickhouse', label: t('tools.json-to-schema.texts.label-clickhouse-table-schema') },
];
const tableName = ref('TableName');
const tableName = useQueryParamOrStorage({ name: 'table', storageName: 'json-to-schema:tbl', defaultValue: 'TableName' });
const format = useQueryParamOrStorage({ name: 'fmt', storageName: 'json-to-schema:fmt', defaultValue: 'json' });
function convertJsonToSchema(value: string) {
@@ -4,10 +4,11 @@ import JSON5 from 'json5';
import GenerateSchema from 'generate-schema';
import { withDefaultOnError } from '../../utils/defaults';
import type { UseValidationRule } from '@/composable/validation';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const tableName = ref('TableName');
const tableName = useQueryParamOrStorage({ name: 'table', storageName: 'json-to-sqlddl:tbl', defaultValue: 'TableName' });
function convertJsonToDDL(value: string) {
const object = JSON5.parse(value);
@@ -5,6 +5,7 @@ import { flatten } from 'flatten-anything';
import { objectArrayToData } from '@/utils/objectarray.export';
import type { UseValidationRule } from '@/composable/validation';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -17,7 +18,7 @@ const defaultValue = `{
}
}`;
const jsonInput = ref(defaultValue);
const tableName = ref<string>('TableName');
const tableName = useQueryParamOrStorage({ name: 'table', storageName: 'json-to-sql-insert:tbl', defaultValue: 'TableName' });
const sqlOutput = computed(() => {
try {
+6 -6
View File
@@ -3,23 +3,23 @@ import { useI18n } from 'vue-i18n';
import { jsonrepair } from 'jsonrepair';
import {
get,
useStorage,
} from '@vueuse/core';
import { formatJson } from './json.models';
import { withDefaultOnError } from '@/utils/defaults';
import { useValidation } from '@/composable/validation';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
const inputElement = ref<HTMLElement>();
const repairJsonLabel = t('tools.json-viewer.text.repair-json');
const rawJson = useStorage('json-prettify:raw-json', '{"hello": "world", "foo": "bar"}');
const indentSize = useStorage('json-prettify:indent-size', 3);
const sortKeys = useStorage('json-prettify:sort-keys', true);
const unescapeUnicode = useStorage('json-prettify:unescape-unicode', false);
const repairJson = useStorage('json-prettify:repair-json', false);
const rawJson = useITStorage('json-prettify:raw-json', '{"hello": "world", "foo": "bar"}');
const indentSize = useITStorage('json-prettify:indent-size', 3);
const sortKeys = useITStorage('json-prettify:sort-keys', true);
const unescapeUnicode = useITStorage('json-prettify:unescape-unicode', false);
const repairJson = useITStorage('json-prettify:repair-json', false);
const cleanJson = computed(() => withDefaultOnError(() => formatJson({ rawJson, indentSize, sortKeys, unescapeUnicode, repairJson }), ''));
const rawJsonValidation = useValidation({
@@ -8,11 +8,11 @@ import { randIntFromInterval } from '@/utils/random';
const { t } = useI18n();
const paragraphs = useStorage('lorem:paragraphs', 1);
const sentences = useStorage('lorem:sentences', [3, 8]);
const words = useStorage('lorem:words', [8, 15]);
const paragraphs = useQueryParamOrStorage({ name: 'paragraphs', storageName: 'lorem:paragraphs', defaultValue: 1 });
const sentences = useQueryParamOrStorage({ name: 'sentences', storageName: 'lorem:sentences', defaultValue: [3, 8] });
const words = useQueryParamOrStorage({ name: 'words', storageName: 'lorem:words', defaultValue: [8, 15] });
const startWithLoremIpsum = ref(true);
const asHTML = ref(false);
const asHTML = useQueryParamOrStorage({ name: 'html', storageName: 'lorem:html', defaultValue: false });
const language = useQueryParamOrStorage({ defaultValue: 'English', storageName: 'lorem:lang', name: 'lang' });
const supportedLanguages = getSupportedLanguages();
+2 -1
View File
@@ -2,10 +2,11 @@
import { useI18n } from 'vue-i18n';
import Luhn from 'luhn-js';
import type { CKeyValueListItems } from '@/ui/c-key-value-list/c-key-value-list.types';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const rawValue = ref('44540661970241257');
const rawValue = useQueryParam({ tool: 'luhn-validator', name: 'luhn', defaultValue: '44540661970241257' });
const cleanedValue = computed(() => rawValue.value.replace(/[^\d]/g, ''));
const isValid = computed(() => {
try {
@@ -8,10 +8,11 @@ import {
convertMacToEUI64CanonicalIETF, convertMacToLinkLocalIPv6,
convertMacToNumber,
} from './mac-address-converter.service';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const input = ref('AA:BB:CC:DD:EE:FF');
const input = useQueryParam({ tool: 'mac-conv', name: 'addr', defaultValue: 'AA:BB:CC:DD:EE:FF' });
const formats = computed(() => [
{
@@ -5,11 +5,12 @@ import { generateRandomMacAddress } from './mac-adress-generator.models';
import { computedRefreshable } from '@/composable/computedRefreshable';
import { useCopy } from '@/composable/copy';
import { usePartialMacAddressValidation } from '@/utils/macAddress';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const amount = useStorage('mac-address-generator-amount', 1);
const macAddressPrefix = useStorage('mac-address-generator-prefix', '64:16:7F');
const amount = useQueryParamOrStorage({ name: 'amount', storageName: 'mac-address-generator:amount', defaultValue: 1 });
const macAddressPrefix = useQueryParamOrStorage({ name: 'prefix', storageName: 'mac-address-generator:prefix', defaultValue: '64:16:7F' });
const prefixValidation = usePartialMacAddressValidation(macAddressPrefix);
@@ -37,7 +38,7 @@ const separators = [
value: '',
},
];
const separator = useStorage('mac-address-generator-separator', separators[0].value);
const separator = useQueryParamOrStorage({ name: 'sep', storageName: 'mac-address-generator:separator', defaultValue: separators[0].value });
const [macAddresses, refreshMacAddresses] = computedRefreshable(() => {
if (!prefixValidation.isValid) {
@@ -3,12 +3,13 @@ import { useI18n } from 'vue-i18n';
import db from 'oui-data';
import { macAddressValidationRules } from '@/utils/macAddress';
import { useCopy } from '@/composable/copy';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const getVendorValue = (address: string) => address.trim().replace(/[.:-]/g, '').toUpperCase().substring(0, 6);
const macAddress = ref('20:37:06:12:34:56');
const macAddress = useQueryParam({ tool: 'mac-lookup', name: 'addr', defaultValue: '20:37:06:12:34:56' });
const details = computed<string | undefined>(() => (db as Record<string, string>)[getVendorValue(macAddress.value)]);
const { copy } = useCopy({ source: () => details.value ?? '', text: t('tools.mac-address-lookup.texts.text-vendor-info-copied-to-the-clipboard') });
@@ -3,13 +3,14 @@ import { useI18n } from 'vue-i18n';
import _ from 'lodash';
import { type Unit, convertMany } from 'convert';
import allUnits from './allunits.json';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const allUnitsSorted = _.uniq(allUnits).sort();
const inputExpression = ref('');
const outputUnit = ref('');
const inputExpression = useQueryParam({ tool: 'many-units-conv', name: 'expr', defaultValue: '' });
const outputUnit = useQueryParam({ tool: 'many-units-conv', name: 'unit', defaultValue: '' });
const result = computed(() => {
try {
const best = convertMany(inputExpression.value).to('best');
+2 -1
View File
@@ -3,10 +3,11 @@ import { useI18n } from 'vue-i18n';
import { evaluate } from 'mathjs';
import { withDefaultOnError } from '@/utils/defaults';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const expression = ref('');
const expression = useQueryParam({ tool: 'math-eval', name: 'expr', defaultValue: '' });
const result = computed(() => withDefaultOnError(() => evaluate(expression.value) ?? '', ''));
</script>
@@ -2,7 +2,7 @@
import { useI18n } from 'vue-i18n';
import { useScriptTag } from '@vueuse/core';
import { convert_math } from 'mitex-wasm';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -16,7 +16,7 @@ const formats = [
{ value: 'omml', label: t('tools.math-formats-converter.texts.label-ooml') },
];
const source = ref('');
const source = useQueryParam({ tool: 'math-fmts-conv', name: 'input', defaultValue: '' });
const sourceFormat = useQueryParamOrStorage({ name: 'src', storageName: 'math-fmts-conv:src', defaultValue: 'latex' });
const targetFormat = useQueryParamOrStorage({ name: 'target', storageName: 'math-fmts-conv:target', defaultValue: 'mathml' });
const target = computedAsync(async () => {
+3 -2
View File
@@ -3,13 +3,14 @@ import { useI18n } from 'vue-i18n';
import libmime from 'libmime';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { withDefaultOnError } from '@/utils/defaults';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const encodedInput = ref('');
const encodedInput = useQueryParam({ tool: 'mime-conv', name: 'decode', defaultValue: '' });
const decodedOutput = computed(() => withDefaultOnError(() => libmime.decodeWords(encodedInput.value), '# invalid encoded value'));
const rawInput = ref('');
const rawInput = useQueryParam({ tool: 'mime-conv', name: 'encode', defaultValue: '' });
const encodedQOutput = computed(() => withDefaultOnError(() => libmime.encodeWord(rawInput.value, 'Q'), ''));
const encodedBOutput = computed(() => withDefaultOnError(() => libmime.encodeWord(rawInput.value, 'B'), ''));
</script>
@@ -2,13 +2,14 @@
import { useI18n } from 'vue-i18n';
import { decode, encode } from 'morsee';
import { computedCatch } from '@/composable/computed/catchedComputed';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const encodeInput = ref('');
const encodeInput = useQueryParam({ tool: 'morse-conv', name: 'encode', defaultValue: '' });
const encodeOutput = computed(() => encode(encodeInput.value));
const decodeInput = ref('');
const decodeInput = useQueryParam({ tool: 'morse-conv', name: 'decode', defaultValue: '' });
const [decodeOutput, decodeError] = computedCatch(() => decode(decodeInput.value), {
defaultValue: '',
defaultErrorMessage: 'Unable to decode your text',
@@ -6,13 +6,13 @@ import { withDefaultOnError } from '@/utils/defaults';
import { useCopy } from '@/composable/copy';
import { useQueryParam } from '@/composable/queryParams';
const count = useQueryParam({ name: 'count', defaultValue: 1 });
const length = useQueryParam({ name: 'length', defaultValue: 21 });
const withUppercase = useQueryParam({ name: 'uppercase', defaultValue: true });
const withLowercase = useQueryParam({ name: 'lowercase', defaultValue: true });
const withNumbers = useQueryParam({ name: 'numbers', defaultValue: true });
const withSymbols = useQueryParam({ name: 'symbols', defaultValue: true });
const excludeLookalikes = useQueryParam({ name: 'no-lookalikes', defaultValue: false });
const count = useQueryParam({ tool: 'nanoid-gen', name: 'count', defaultValue: 1 });
const length = useQueryParam({ tool: 'nanoid-gen', name: 'length', defaultValue: 21 });
const withUppercase = useQueryParam({ tool: 'nanoid-gen', name: 'uppercase', defaultValue: true });
const withLowercase = useQueryParam({ tool: 'nanoid-gen', name: 'lowercase', defaultValue: true });
const withNumbers = useQueryParam({ tool: 'nanoid-gen', name: 'numbers', defaultValue: true });
const withSymbols = useQueryParam({ tool: 'nanoid-gen', name: 'symbols', defaultValue: true });
const excludeLookalikes = useQueryParam({ tool: 'nanoid-gen', name: 'no-lookalikes', defaultValue: false });
const { t } = useI18n();
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { generateNumeronym } from './numeronym-generator.service';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const word = ref('');
const word = useQueryParam({ tool: 'numeronym-gen', name: 'word', defaultValue: '' });
const numeronym = computed(() => generateNumeronym(word.value));
</script>
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { useStorage } from '@vueuse/core';
import { getOption43Infos } from './option43-generator.service';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -28,8 +28,8 @@ const wifiVendorOptions = [
{ value: 'cambium_01', label: t('tools.option43-generator.texts.label-cambium-cnmaestro') },
];
const dhcpVendor = useStorage('option43-generator:dhcp', 'genuine');
const wifiVendor = useStorage('option43-generator:wifi', 'cisco_01');
const dhcpVendor = useITStorage('option43-generator:dhcp', 'genuine');
const wifiVendor = useITStorage('option43-generator:wifi', 'cisco_01');
const ipAdresses = ref('192.168.0.15'); // NOSONAR
const option43Infos = computed(() => getOption43Infos(ipAdresses.value, wifiVendor.value, dhcpVendor.value));
+10 -9
View File
@@ -3,21 +3,22 @@ import { useI18n } from 'vue-i18n';
import { Base64 } from 'js-base64';
import createQPDFModule from 'qpdf-wasm-esm-embedded';
import { useDownloadFileFromBase64Refs } from '@/composable/downloadBase64';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle');
const file = ref<File | null>(null);
const restrictAccessibility = useStorage('pdf-encrypt:accessibility', false);
const restrictAnnotate = useStorage('pdf-encrypt:annotate', false);
const restrictAssemble = useStorage('pdf-encrypt:assemble', false);
const restrictExtract = useStorage('pdf-encrypt:extract', false);
const restrictForm = useStorage('pdf-encrypt:form', false);
const restrictModifyOther = useStorage('pdf-encrypt:modoth', false);
const clearTextMetadata = useStorage('pdf-encrypt:clearmeta', false);
const restrictModify = useStorage('pdf-encrypt:mod', 'all');
const restrictPrint = useStorage('pdf-encrypt:print', 'full');
const restrictAccessibility = useQueryParamOrStorage({ name: 'a11y', storageName: 'pdf-encrypt:accessibility', defaultValue: false });
const restrictAnnotate = useQueryParamOrStorage({ name: 'annot', storageName: 'pdf-encrypt:annotate', defaultValue: false });
const restrictAssemble = useQueryParamOrStorage({ name: 'assemble', storageName: 'pdf-encrypt:assemble', defaultValue: false });
const restrictExtract = useQueryParamOrStorage({ name: 'extract', storageName: 'pdf-encrypt:extract', defaultValue: false });
const restrictForm = useQueryParamOrStorage({ name: 'form', storageName: 'pdf-encrypt:form', defaultValue: false });
const restrictModifyOther = useQueryParamOrStorage({ name: 'othermodify', storageName: 'pdf-encrypt:modoth', defaultValue: false });
const clearTextMetadata = useQueryParamOrStorage({ name: 'clearmeta', storageName: 'pdf-encrypt:clearmeta', defaultValue: false });
const restrictModify = useQueryParamOrStorage({ name: 'modify', storageName: 'pdf-encrypt:mod', defaultValue: 'all' });
const restrictPrint = useQueryParamOrStorage({ name: 'print', storageName: 'pdf-encrypt:print', defaultValue: 'full' });
const userPassword = ref('');
const ownerPassword = ref('');
+2 -1
View File
@@ -5,6 +5,7 @@ import * as openpgp from 'openpgp';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useValidation } from '@/composable/validation';
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -19,7 +20,7 @@ const username = ref('');
const useremail = ref('');
const password = ref('');
const format = useStorage('pgp-key-pair-generator:format', isWindowSecureContext() ? 'curve25519' : 'p256');
const format = useITStorage('pgp-key-pair-generator:format', isWindowSecureContext() ? 'curve25519' : 'p256');
const formats = isWindowSecureContext()
? [
@@ -10,11 +10,11 @@ import {
import { withDefaultOnError } from '@/utils/defaults';
import { booleanToHumanReadable } from '@/utils/boolean';
import { useValidation } from '@/composable/validation';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const rawPhone = ref('');
const rawPhone = useQueryParam({ tool: 'phone-parser', name: 'phone', defaultValue: '' });
const defaultCountryCode = useQueryParamOrStorage({ name: 'country', storageName: 'phone-parser:country', defaultValue: getDefaultCountryCode() });
const validation = useValidation({
source: rawPhone,
+3 -2
View File
@@ -2,11 +2,12 @@
import { useI18n } from 'vue-i18n';
import ports from 'port-numbers';
import SpanCopyable from '@/components/SpanCopyable.vue';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const port = ref(80);
const protocol = ref('tcp');
const port = useQueryParam({ tool: 'port-numbers', name: 'port', defaultValue: 80 });
const protocol = useQueryParam({ tool: 'port-numbers', name: 'proto', defaultValue: 'tcp' });
const result = computed(() => {
const [type, description] = ports[`${port.value}/${protocol.value}` as (keyof typeof ports)];
return { type: type ?? 'unknown', description: description ?? 'Unknown' };
@@ -2,10 +2,11 @@
import { useI18n } from 'vue-i18n';
import { toASCII, toUnicode } from 'punycode/';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const punycodeInput = ref('');
const punycodeInput = useQueryParam({ tool: 'puny-conv', name: 'punycode', defaultValue: '' });
const intlOutput = computed(
() => {
try {
@@ -17,7 +18,7 @@ const intlOutput = computed(
},
);
const intlInput = ref('');
const intlInput = useQueryParam({ tool: 'puny-conv', name: 'intl', defaultValue: '' });
const punycodeOutput = computed(
() => {
try {
@@ -10,7 +10,7 @@ import type {
import qrcodeConsole from 'qrcode-terminal-nooctal';
import { useQRCodeStyling } from './useQRCode';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -52,7 +52,7 @@ const dotTypes = ['dots',
const cornersDotTypes = ['dot', 'square', 'heart'];
const cornersSquareTypes = ['dot', 'square', 'extra-rounded'];
const text = ref('https://sharevb-it-tools.vercel.app');
const text = useQueryParam({ tool: 'qr-code-gen', name: 'text', defaultValue: 'https://sharevb-it-tools.vercel.app' });
const { qrcode } = useQRCodeStyling({
text,
color: { background, foreground },
@@ -84,7 +84,7 @@ const qrcodeTerminal = computedAsync(() => {
});
});
const filename = ref('qr-code');
const filename = useQueryParam({ tool: 'qr-code-gen', name: 'file', defaultValue: 'qr-code' });
const extension = computed(() => {
// Explicitly access the reactive value
const type = outputType.value;
@@ -2,18 +2,19 @@
import { useI18n } from 'vue-i18n';
import { useContactQRCode } from './useContactQRCode';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const fullName = ref('');
const jobRole = ref('');
const phoneNumber = ref('');
const email = ref('');
const website = ref('');
const address = ref('');
const fullName = useQueryParam({ tool: 'qr-contact-gen', name: 'name', defaultValue: '' });
const jobRole = useQueryParam({ tool: 'qr-contact-gen', name: 'role', defaultValue: '' });
const phoneNumber = useQueryParam({ tool: 'qr-contact-gen', name: 'phone', defaultValue: '' });
const email = useQueryParam({ tool: 'qr-contact-gen', name: 'email', defaultValue: '' });
const website = useQueryParam({ tool: 'qr-contact-gen', name: 'website', defaultValue: '' });
const address = useQueryParam({ tool: 'qr-contact-gen', name: 'addr', defaultValue: '' });
const foreground = ref('#000000ff');
const background = ref('#ffffffff');
const foreground = useQueryParam({ tool: 'qr-contact-gen', name: 'fg', defaultValue: '#000000ff' });
const background = useQueryParam({ tool: 'qr-contact-gen', name: 'bg', defaultValue: '#ffffffff' });
const { qrcode } = useContactQRCode({
fullName,
+6 -6
View File
@@ -8,12 +8,12 @@ import { useQueryParamOrStorage } from '@/composable/queryParams';
const regex = useQueryParamOrStorage({ name: 'regex', storageName: 'regex-tester:regex', defaultValue: '' });
const text = ref('');
const global = ref(true);
const ignoreCase = ref(false);
const multiline = ref(false);
const dotAll = ref(true);
const unicode = ref(true);
const unicodeSets = ref(false);
const global = useQueryParamOrStorage({ storageName: 'regex-tester:g', name: 'global', defaultValue: true });
const ignoreCase = useQueryParamOrStorage({ storageName: 'regex-tester:i', name: 'igncase', defaultValue: false });
const multiline = useQueryParamOrStorage({ storageName: 'regex-tester:m', name: 'multi', defaultValue: false });
const dotAll = useQueryParamOrStorage({ storageName: 'regex-tester:da', name: 'dotall', defaultValue: true });
const unicode = useQueryParamOrStorage({ storageName: 'regex-tester:u', name: 'uni', defaultValue: true });
const unicodeSets = useQueryParamOrStorage({ storageName: 'regex-tester:us', name: 'unisets', defaultValue: false });
const visualizerSVG = ref<ShadowRootExpose>();
const { t } = useI18n();
+2 -1
View File
@@ -2,11 +2,12 @@
import { useI18n } from 'vue-i18n';
import { useThemeVars } from 'naive-ui';
import { rmb } from './rmb-numbers.service';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const themeVars = useThemeVars();
const inputRmb = ref(23);
const inputRmb = useQueryParam({ tool: 'rmb-conv', name: 'amount', defaultValue: 23 });
const outputRmb = computed(() => rmb(inputRmb.value)); ;
</script>
@@ -9,10 +9,11 @@ import {
} from './roman-numeral-converter.service';
import { useCopy } from '@/composable/copy';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const inputNumeral = ref(42);
const inputNumeral = useQueryParam({ tool: 'roman-conver', name: 'dec', defaultValue: 42 });
const outputRoman = computed(() => arabicToRoman(inputNumeral.value));
const { attrs: validationNumeral } = useValidation({
@@ -25,7 +26,7 @@ const { attrs: validationNumeral } = useValidation({
],
});
const inputRoman = ref('XLII');
const inputRoman = useQueryParam({ tool: 'roman-conver', name: 'roman', defaultValue: 'XLII' });
const outputNumeral = computed(() => romanToArabic(inputRoman.value));
const validationRoman = useValidation({
@@ -6,6 +6,7 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { withDefaultOnErrorAsync } from '@/utils/defaults';
import { useValidation } from '@/composable/validation';
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -14,7 +15,7 @@ const comment = ref('');
const password = ref('');
const emptyCerts = { publicKey: '', privateKey: '' };
const format = useStorage('rsa-key-pair-generator:format', 'ssh');
const format = useITStorage('rsa-key-pair-generator:format', 'ssh');
const formatOptions = [
{ value: 'pem', label: t('tools.rsa-key-pair-generator.texts.label-pem') },
{ value: 'pkcs1', label: t('tools.rsa-key-pair-generator.texts.label-pkcs-1') },
@@ -1,9 +1,10 @@
<script setup lang="ts">
import { decodeSafeLinksURL } from './safelink-decoder.service';
import { useQueryParam } from '@/composable/queryParams';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const { t } = useI18n();
const inputSafeLinkUrl = ref('');
const inputSafeLinkUrl = useQueryParam({ tool: 'safelink-decoder', name: 'url', defaultValue: '' });
const outputDecodedUrl = computed(() => {
try {
return decodeSafeLinksURL(inputSafeLinkUrl.value);
@@ -2,6 +2,7 @@
import { useI18n } from 'vue-i18n';
import { type MatcherNames, maskSensitiveData } from './sensitive-data-masker.service';
import { withDefaultOnError } from '@/utils/defaults';
import { useITStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -19,8 +20,8 @@ const defaultValue = `{
token: 'eyJhbGciOiJIUzI1NiJ9.ew0KICAic3ViIjogIjEyMzQ1Njc4OTAiLA0KICAibmFtZSI6ICJBbGV4IEtvemxvdiIsDQogICJpYXQiOiAxNTE2MjM5MDIyDQp9.PNKysYFTCenU5bekHCmwIxCUXoYG41H_xc3uN3ZF_b8',
}`;
const customRegex = useStorage('sensitive-data:regex', '');
const excludedMatchers = useStorage('sensitive-data:exclude', [] as string[]);
const customRegex = useITStorage('sensitive-data:regex', '');
const excludedMatchers = useITStorage('sensitive-data:exclude', [] as string[]);
const allMatchers = [
'uuid', 'creditCard', 'ssn', 'url', 'ipv4', 'email',
'passwordInUri', 'mac', 'ipv6', 'urlWithOrWithoutPrefix',
@@ -2,10 +2,11 @@
import { useI18n } from 'vue-i18n';
import { decodeSharePointsURL } from './sharepoint-decoder.service';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const inputSharePointUrl = ref('');
const inputSharePointUrl = useQueryParam({ tool: 'sharepoint-decoder', name: 'url', defaultValue: '' });
const outputDecodedUrl = computed(() => {
try {
return decodeSharePointsURL(inputSharePointUrl.value);
+2 -2
View File
@@ -36,7 +36,7 @@ const daysHours = useQueryParamOrStorage<{
sun: 24,
},
});
const inputSLA = useQueryParam({ name: 'sla', defaultValue: 99.99 });
const inputSLA = useQueryParam({ tool: 'sla', name: 'sla', defaultValue: 99.99 });
const outputDownTimes = computed(() => {
const weekdaysHours = daysHours.value;
const downtimesSeconds = slaToDowntimes({
@@ -58,7 +58,7 @@ const outputDownTimes = computed(() => {
};
});
const inputDuration = useQueryParam({ name: 'dur', defaultValue: '1s' });
const inputDuration = useQueryParam({ tool: 'sla', name: 'dur', defaultValue: '1s' });
const inputDurationValidation = useValidation({
source: inputDuration,
rules: [
+2 -2
View File
@@ -3,11 +3,11 @@ import { useI18n } from 'vue-i18n';
import slugify from '@sindresorhus/slugify';
import { withDefaultOnError } from '@/utils/defaults';
import { useCopy } from '@/composable/copy';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const input = ref('');
const input = useQueryParam({ tool: 'slugify', name: 'text', defaultValue: '' });
const separator = useQueryParamOrStorage({ name: 'sep', storageName: 'slugify:sep', defaultValue: '-' });
const slug = computed(() => withDefaultOnError(() => slugify(input.value, {
separator: separator.value,
@@ -2,11 +2,12 @@
import { useI18n } from 'vue-i18n';
import { getSmartValue } from './smart-raw-converter.service';
import { useValidation } from '@/composable/validation';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const inputRegex = /^(?:0x(?<hex>[a-f\d]+)|(?<dec>\d+))$/i;
const rawValue = ref('0xFE45E3');
const rawValue = useQueryParam({ tool: 'smart-raw-conv', name: 'raw', defaultValue: '0xFE45E3' });
const rawValueValidation = useValidation({
source: rawValue,
rules: [
@@ -1,11 +1,12 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { extractId, extractMachineId, extractTimestamp } from './snowflake-id-extractor.service';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const inputId = ref('1263785187301658678');
const inputEpoch = ref('');
const inputId = useQueryParam({ tool: 'snowflake-id-ext', name: 'id', defaultValue: '1263785187301658678' });
const inputEpoch = useQueryParam({ tool: 'snowflake-id-ext', name: 'epoch', defaultValue: '' });
const inputProps = {
'labelPosition': 'left',
+2 -2
View File
@@ -2,11 +2,11 @@
import { useI18n } from 'vue-i18n';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { escapeForLanguage, languages } from '@/utils/ascii-lang-utils';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const rawInput = ref('Hello "every"\n A\'');
const rawInput = useQueryParam({ tool: 'string-escaper', name: 'text', defaultValue: 'Hello "every"\n A\'' });
const language = useQueryParamOrStorage({ name: 'lang', storageName: 'string-escaper:l', defaultValue: 'raw' });
const single_linize = useQueryParamOrStorage({ name: 'singleline', storageName: 'string-escaper:sl', defaultValue: false });
const languagesOptions = languages.map(lang => ({ value: lang.id, label: lang.name }));
@@ -2,13 +2,14 @@
import { useI18n } from 'vue-i18n';
import { useObfuscateString } from './string-obfuscator.model';
import { useCopy } from '@/composable/copy';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const str = ref('Lorem ipsum dolor sit amet');
const keepFirst = ref(4);
const keepLast = ref(4);
const keepSpace = ref(true);
const str = useQueryParam({ tool: 'string-obfuscator', name: 'text', defaultValue: 'Lorem ipsum dolor sit amet' });
const keepFirst = useQueryParam({ tool: 'string-obfuscator', name: 'first', defaultValue: 4 });
const keepLast = useQueryParam({ tool: 'string-obfuscator', name: 'last', defaultValue: 4 });
const keepSpace = useQueryParam({ tool: 'string-obfuscator', name: 'space', defaultValue: true });
const obfuscatedString = useObfuscateString(str, { keepFirst, keepLast, keepSpace });
const { copy } = useCopy({ source: obfuscatedString });
@@ -4,16 +4,17 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useCopy } from '@/composable/copy';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
import { textToBase64 } from '@/utils/base64';
import { useQueryParam } from '@/composable/queryParams';
const { t } = useI18n();
const width = ref(600);
const height = ref(350);
const fontSize = ref(26);
const bgColor = ref('#cccccc');
const fgColor = ref('#333333');
const useExactSize = ref(true);
const customText = ref('');
const width = useQueryParam({ tool: 'svg-placeholder-gen', name: 'w', defaultValue: 600 });
const height = useQueryParam({ tool: 'svg-placeholder-gen', name: 'h', defaultValue: 350 });
const fontSize = useQueryParam({ tool: 'svg-placeholder-gen', name: 'fs', defaultValue: 26 });
const bgColor = useQueryParam({ tool: 'svg-placeholder-gen', name: 'bg', defaultValue: '#cccccc' });
const fgColor = useQueryParam({ tool: 'svg-placeholder-gen', name: 'fg', defaultValue: '#333333' });
const useExactSize = useQueryParam({ tool: 'svg-placeholder-gen', name: 'exact', defaultValue: true });
const customText = useQueryParam({ tool: 'svg-placeholder-gen', name: 'text', defaultValue: '' });
const svgString = computed(() => {
const w = width.value;
const h = height.value;
+2 -2
View File
@@ -4,12 +4,12 @@ import { type EncodingBase, convertTextToUtf8Binary, convertUtf8BinaryToText } f
import { withDefaultOnError } from '@/utils/defaults';
import { useCopy } from '@/composable/copy';
import { isNotThrowing } from '@/utils/boolean';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const base = useQueryParamOrStorage({ name: 'base', storageName: 'txt-bin:base', defaultValue: '2' });
const inputText = ref('');
const inputText = useQueryParam({ tool: 'txt-bin', name: 'text', defaultValue: '' });
const binaryFromText = computed(() => convertTextToUtf8Binary(inputText.value, { base: Number(base.value) as EncodingBase }));
const { copy: copyBinary } = useCopy({ source: binaryFromText });
Loaded 100 of 122 files, more files were not shown because too many files have changed in this diff. Show more