mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-26 22:23:17 -05:00
[web] Allow only numerical values in the integer input field
This commit is contained in:
parent
72454de4ef
commit
a2dd2251c9
@ -13,7 +13,7 @@
|
|||||||
<input
|
<input
|
||||||
ref="setting"
|
ref="setting"
|
||||||
class="column input is-one-fifth"
|
class="column input is-one-fifth"
|
||||||
type="number"
|
inputmode="numeric"
|
||||||
min="0"
|
min="0"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:value="value"
|
:value="value"
|
||||||
@ -84,29 +84,27 @@ export default {
|
|||||||
clear_status() {
|
clear_status() {
|
||||||
this.statusUpdate = ''
|
this.statusUpdate = ''
|
||||||
},
|
},
|
||||||
set_update_timer() {
|
set_update_timer(event) {
|
||||||
|
event.target.value = event.target.value.replace(/[^0-9]/gu, '')
|
||||||
if (this.timerId > 0) {
|
if (this.timerId > 0) {
|
||||||
window.clearTimeout(this.timerId)
|
window.clearTimeout(this.timerId)
|
||||||
this.timerId = -1
|
this.timerId = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
this.statusUpdate = ''
|
this.statusUpdate = ''
|
||||||
const newValue = this.$refs.setting.value
|
this.timerId = window.setTimeout(this.update_setting, this.timerDelay)
|
||||||
if (newValue !== this.value) {
|
|
||||||
this.timerId = window.setTimeout(this.update_setting, this.timerDelay)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
update_setting() {
|
update_setting() {
|
||||||
this.timerId = -1
|
this.timerId = -1
|
||||||
const newValue = this.$refs.setting.value
|
const newValue = parseInt(this.$refs.setting.value, 10)
|
||||||
if (newValue === this.value) {
|
if (isNaN(newValue) || newValue === this.value) {
|
||||||
this.statusUpdate = ''
|
this.statusUpdate = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const option = {
|
const option = {
|
||||||
category: this.category.name,
|
category: this.category.name,
|
||||||
name: this.option_name,
|
name: this.option_name,
|
||||||
value: parseInt(newValue, 10)
|
value: newValue
|
||||||
}
|
}
|
||||||
webapi
|
webapi
|
||||||
.settings_update(this.category.name, option)
|
.settings_update(this.category.name, option)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user