mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-30 08:25:13 +08:00
update 2026-08-13 04:37:02
This commit is contained in:
1 parent
78221232e9
commit
00ef606a42
1986 files changed
+1523528
-443
No files matched your search
@@ -20,19 +20,31 @@ function is_timehhmm(str) {
|
||||
}
|
||||
|
||||
if (typeof cbi_validators !== 'undefined' && cbi_validators !== null) {
|
||||
cbi_validators['base64'] = function() {
|
||||
return isBase64(this);
|
||||
}
|
||||
cbi_validators['json'] = function() {
|
||||
return is_json(this);
|
||||
}
|
||||
cbi_validators['timehhmm'] = function() {
|
||||
return is_timehhmm(this);
|
||||
}
|
||||
cbi_validators['uuid'] = function() {
|
||||
return isUUID(this);
|
||||
}
|
||||
} else {
|
||||
L.require('validation').then(function(validation) {
|
||||
validation.types['base64'] = function() {
|
||||
return this.assert(isBase64(this.value), _('Must be Base64 text!'));
|
||||
}
|
||||
validation.types['json'] = function() {
|
||||
return this.assert(is_json(this.value), _('Must be JSON text!'));
|
||||
}
|
||||
validation.types['timehhmm'] = function() {
|
||||
return this.assert(is_timehhmm(this.value), _('valid time (hh:mm)'));
|
||||
}
|
||||
validation.types['uuid'] = function() {
|
||||
return this.assert(isUUID(this.value), _('Must be UUID format!'));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -8,6 +8,11 @@ function arraysEqual(a, b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function isBase64(str) {
|
||||
const base64Regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/;
|
||||
return base64Regex.test(str);
|
||||
}
|
||||
|
||||
function decodeIfBase64(str) {
|
||||
try {
|
||||
let s = str.replace(/-/g, '+').replace(/_/g, '/');
|
||||
@@ -24,6 +29,11 @@ function decodeIfBase64(str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
function isUUID(str) {
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
return uuidRegex.test(str);
|
||||
}
|
||||
|
||||
function waitForElement(selector, callback) {
|
||||
const el = document.querySelector(selector);
|
||||
if (el) return callback(el);
|
||||
|
||||
Reference in new issue
Block a user