mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add text validate for dark schedule
This commit is contained in:
parent
f096943dbd
commit
ec2aa12100
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -22,7 +22,7 @@
|
||||
const $ = unsafeWindow.$ || self$;
|
||||
const settings = {
|
||||
darkScheduleStart: "18:00",
|
||||
darkScheduleEnd: "06:00",
|
||||
darkScheduleEnd: "6:00",
|
||||
darkSchedule: false,
|
||||
blurSettingsPanel: false,
|
||||
blurVideoControl: false,
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
const $ = unsafeWindow.$ || self$;
|
||||
const settings = {
|
||||
darkScheduleStart: "18:00",
|
||||
darkScheduleEnd: "06:00",
|
||||
darkScheduleEnd: "6:00",
|
||||
darkSchedule: false,
|
||||
blurSettingsPanel: false,
|
||||
blurVideoControl: false,
|
||||
|
||||
2
min/gui-settings.min.js
vendored
2
min/gui-settings.min.js
vendored
File diff suppressed because one or more lines are too long
@ -26,7 +26,7 @@
|
||||
ok: "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"
|
||||
};
|
||||
const textValidate = {
|
||||
"customStyleColor": text =>
|
||||
customStyleColor: text =>
|
||||
{
|
||||
const match = text.match(/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/);
|
||||
if (match)
|
||||
@ -45,7 +45,7 @@
|
||||
return settings.customStyleColor;
|
||||
}
|
||||
},
|
||||
"blurBackgroundOpacity": text =>
|
||||
blurBackgroundOpacity: text =>
|
||||
{
|
||||
const match = text.match(/^([-\+]?\d+)(\.\d+)?$/);
|
||||
if (match)
|
||||
@ -59,6 +59,42 @@
|
||||
return settings.blurBackgroundOpacity;
|
||||
}
|
||||
};
|
||||
function darkScheduleValidate(text, defaultValue)
|
||||
{
|
||||
const match = text.match(/^([\d]{1,2}):([\d]{1,2})$/);
|
||||
if (match && match.length >= 3)
|
||||
{
|
||||
const time = { hour: match[1], minute: match[2] };
|
||||
(function ()
|
||||
{
|
||||
while (this.minute < 0)
|
||||
{
|
||||
this.minute += 60;
|
||||
this.hour -= 1;
|
||||
}
|
||||
while (this.minute >= 60)
|
||||
{
|
||||
this.minute -= 60;
|
||||
this.hour += 1;
|
||||
}
|
||||
while (this.hour < 0)
|
||||
{
|
||||
this.hour += 24;
|
||||
}
|
||||
while (this.hour >= 24)
|
||||
{
|
||||
this.hour -= 24;
|
||||
}
|
||||
}).call(time);
|
||||
return `${time.hour}:${time.minute}`;
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
textValidate.darkScheduleStart = text => darkScheduleValidate(text, settings.darkScheduleStart);
|
||||
textValidate.darkScheduleEnd = text => darkScheduleValidate(text, settings.darkScheduleEnd);
|
||||
|
||||
function settingsChange(key, _, newValue)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user