fix filebrowser/filebrowser#312, use prefix $ for commands (#7)
parent
4c30b2c665
commit
390c53097f
|
@ -125,7 +125,7 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['user', 'show']),
|
...mapState(['user', 'show']),
|
||||||
// Placeholder value.
|
// Placeholder value.
|
||||||
placeholder: function () {
|
placeholder () {
|
||||||
if (this.user.allowCommands && this.user.commands.length > 0) {
|
if (this.user.allowCommands && this.user.commands.length > 0) {
|
||||||
return this.$t('search.searchOrCommand')
|
return this.$t('search.searchOrCommand')
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ export default {
|
||||||
},
|
},
|
||||||
// The text that is shown on the results' box while
|
// The text that is shown on the results' box while
|
||||||
// there is no search result or command output to show.
|
// there is no search result or command output to show.
|
||||||
text: function () {
|
text () {
|
||||||
if (this.ongoing) {
|
if (this.ongoing) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
@ -144,17 +144,27 @@ export default {
|
||||||
return `${this.$t('search.searchOrSupportedCommand')} ${this.user.commands.join(', ')}.`
|
return `${this.$t('search.searchOrSupportedCommand')} ${this.user.commands.join(', ')}.`
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$t('search.type')
|
this.$t('search.typeSearch')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.supported() || !this.user.allowCommands) {
|
if (!(this.value[0] === '$') || !this.user.allowCommands) {
|
||||||
return this.$t('search.pressToSearch')
|
return this.$t('search.pressToSearch')
|
||||||
} else {
|
} else {
|
||||||
|
if (this.command.length === 0) {
|
||||||
|
return this.$t('search.typeCommand')
|
||||||
|
}
|
||||||
|
if (!this.supported()) {
|
||||||
|
return this.$t('search.notSupportedCommand')
|
||||||
|
}
|
||||||
return this.$t('search.pressToExecute')
|
return this.$t('search.pressToExecute')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// The command, without the leading symbol ('$') with or without a following space (' ')
|
||||||
|
command () {
|
||||||
|
return this.value[1] === ' ' ? this.value.slice(2) : this.value.slice(1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted () {
|
||||||
// Gets the result div which will be scrollable.
|
// Gets the result div which will be scrollable.
|
||||||
this.scrollable = document.querySelector('#search #result')
|
this.scrollable = document.querySelector('#search #result')
|
||||||
|
|
||||||
|
@ -181,14 +191,15 @@ export default {
|
||||||
},
|
},
|
||||||
// Checks if the current input is a supported command.
|
// Checks if the current input is a supported command.
|
||||||
supported () {
|
supported () {
|
||||||
let pieces = this.value.split(' ')
|
let cmd = this.command.split(' ')[0]
|
||||||
|
let cl = this.user.commands.length
|
||||||
for (let i = 0; i < this.user.commands.length; i++) {
|
if (cl !== 0) {
|
||||||
if (pieces[0] === this.user.commands[i]) {
|
for (let i = 0; i < cl; i++) {
|
||||||
|
if (cmd.match(this.user.commands[i])) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
// Initializes the search with a default value.
|
// Initializes the search with a default value.
|
||||||
|
@ -227,8 +238,9 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case of being a command.
|
// In case of being a command.
|
||||||
|
if (this.value[0] === '$') {
|
||||||
if (this.supported() && this.user.allowCommands) {
|
if (this.supported() && this.user.allowCommands) {
|
||||||
api.command(path, this.value,
|
api.command(path, this.command,
|
||||||
(event) => {
|
(event) => {
|
||||||
this.commands.push(event.data)
|
this.commands.push(event.data)
|
||||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||||
|
@ -239,7 +251,9 @@ export default {
|
||||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.ongoing = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,13 +175,15 @@ sidebar:
|
||||||
search:
|
search:
|
||||||
images: Images
|
images: Images
|
||||||
music: Music
|
music: Music
|
||||||
|
notSupportedCommand: This is a not supported command.
|
||||||
pdf: PDF
|
pdf: PDF
|
||||||
pressToExecute: Press enter to execute.
|
pressToExecute: Press enter to execute.
|
||||||
pressToSearch: Press enter to search.
|
pressToSearch: Press enter to search.
|
||||||
search: Search...
|
search: Search...
|
||||||
searchOrCommand: Search or execute a command...
|
searchOrCommand: Search or execute a command...
|
||||||
searchOrSupportedCommand: 'Search or use one of your supported commands:'
|
searchOrSupportedCommand: 'Search or prepend ''$'' and use one of your supported commands:'
|
||||||
type: Type and press enter to search.
|
typeCommand: Type and press enter to execute.
|
||||||
|
typeSearch: Type and press enter to search.
|
||||||
types: Types
|
types: Types
|
||||||
video: Video
|
video: Video
|
||||||
writeToSearch: Write here to search
|
writeToSearch: Write here to search
|
||||||
|
|
Loading…
Reference in New Issue