Improvements :)
Former-commit-id: c1c1881302a241fdc7140e6aabeb9b49977bd7c6 [formerly 84bb454c2f34baffd9dfa91645b8aff149e52620] [formerly 29e258c7a16db1ca8a3fde7c5e4e3cffc47899a6 [formerly 84ddad027fed623021092d56872ff138bc5ea416]] Former-commit-id: 0018a51df5bc801b783a3ffe17d9f33c504ce094 [formerly 0072c425cd4754e38f30007ab9f5272ea4b40370] Former-commit-id: d298f006e58ef9e4987def4bc354818062b30fcd
This commit is contained in:
@@ -18,17 +18,7 @@
|
||||
<script>
|
||||
import page from '../page'
|
||||
|
||||
// Remove the last directory of an url
|
||||
var removeLastDirectoryPartOf = function (url) {
|
||||
var arr = url.split('/')
|
||||
if (arr.pop() === '') {
|
||||
arr.pop()
|
||||
}
|
||||
return (arr.join('/'))
|
||||
}
|
||||
|
||||
var user = window.info.user
|
||||
var ssl = window.ssl
|
||||
var $ = window.info
|
||||
|
||||
export default {
|
||||
name: 'search',
|
||||
@@ -49,8 +39,8 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
reset: function () {
|
||||
if (user.allowCommands && user.commands.length > 0) {
|
||||
this.box.innerHTML = `Search or use one of your supported commands: ${user.commands.join(', ')}.`
|
||||
if ($.user.allowCommands && $.user.commands.length > 0) {
|
||||
this.box.innerHTML = `Search or use one of your supported commands: ${$.user.commands.join(', ')}.`
|
||||
} else {
|
||||
this.box.innerHTML = 'Type and press enter to search.'
|
||||
}
|
||||
@@ -59,8 +49,8 @@ export default {
|
||||
let value = this.input.value
|
||||
let pieces = value.split(' ')
|
||||
|
||||
for (let i = 0; i < user.commands.length; i++) {
|
||||
if (pieces[0] === user.commands[0]) {
|
||||
for (let i = 0; i < $.user.commands.length; i++) {
|
||||
if (pieces[0] === $.user.commands[0]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -79,7 +69,7 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.supported() || !user.allowCommands) {
|
||||
if (!this.supported() || !$.user.allowCommands) {
|
||||
this.box.innerHTML = 'Press enter to search.'
|
||||
} else {
|
||||
this.box.innerHTML = 'Press enter to execute.'
|
||||
@@ -92,12 +82,12 @@ export default {
|
||||
let url = window.location.host + window.location.pathname
|
||||
|
||||
if (document.getElementById('editor')) {
|
||||
url = removeLastDirectoryPartOf(url)
|
||||
url = page.removeLastDir(url)
|
||||
}
|
||||
|
||||
let protocol = ssl ? 'wss:' : 'ws:'
|
||||
let protocol = $.ssl ? 'wss:' : 'ws:'
|
||||
|
||||
if (this.supported() && user.allowCommands) {
|
||||
if (this.supported() && $.user.allowCommands) {
|
||||
let conn = new window.WebSocket(`${protocol}//${url}?command=true`)
|
||||
|
||||
conn.onopen = () => {
|
||||
|
||||
Reference in New Issue
Block a user