Improvements :)

This commit is contained in:
Henrique Dias
2017-06-28 22:20:28 +01:00
parent 7aa6a549f9
commit 84ddad027f
21 changed files with 467 additions and 445 deletions

View File

@@ -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 = () => {