2023-09-27 10:37:59 +02:00
|
|
|
// import { ref } from 'vue'
|
2023-10-19 11:50:06 +02:00
|
|
|
import { useUserStore } from '@/stores/user'
|
2023-09-27 10:37:59 +02:00
|
|
|
|
|
|
|
export function useIdGenerator(fieldType, fieldName) {
|
|
|
|
let prefix
|
|
|
|
fieldName = fieldName.toString()
|
|
|
|
|
|
|
|
switch (fieldType) {
|
|
|
|
case 'text':
|
|
|
|
prefix = 'txt'
|
|
|
|
break
|
|
|
|
case 'button':
|
|
|
|
prefix = 'btn'
|
|
|
|
break
|
|
|
|
case 'email':
|
|
|
|
prefix = 'eml'
|
|
|
|
break
|
|
|
|
case 'password':
|
|
|
|
prefix = 'pwd'
|
|
|
|
break
|
|
|
|
case 'radio':
|
|
|
|
prefix = 'rdo'
|
|
|
|
break
|
|
|
|
case 'label':
|
|
|
|
prefix = 'lbl'
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
prefix = 'txt'
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
inputId: prefix + fieldName[0].toUpperCase() + fieldName.toLowerCase().slice(1)
|
|
|
|
}
|
2023-10-19 11:50:06 +02:00
|
|
|
}
|
|
|
|
|
2023-12-05 11:40:39 +01:00
|
|
|
export function useDisplayablePassword(pwd, reveal = false) {
|
2023-10-19 11:50:06 +02:00
|
|
|
const user = useUserStore()
|
|
|
|
|
|
|
|
if (user.preferences.formatPassword && pwd.length > 0) {
|
|
|
|
const x = Math.ceil(user.preferences.formatPasswordBy < 1
|
|
|
|
? pwd.length * user.preferences.formatPasswordBy
|
|
|
|
: user.preferences.formatPasswordBy)
|
|
|
|
|
|
|
|
const chunks = pwd.match(new RegExp(`.{1,${x}}`, 'g'));
|
|
|
|
if (chunks) {
|
|
|
|
pwd = chunks.join(' ')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-05 11:40:39 +01:00
|
|
|
return user.preferences.showOtpAsDot && !reveal ? pwd.replace(/[0-9]/g, '●') : pwd
|
2024-07-30 10:08:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function startsWithUppercase(str) {
|
|
|
|
return str.substr(0, 1).match(/[A-Z\u00C0-\u00DC]/);
|
2023-09-27 10:37:59 +02:00
|
|
|
}
|