Commit c5ae154d authored by Markus Opolka's avatar Markus Opolka
Browse files

Rename some functions and variables

parent 3ba5f7ca
......@@ -85,16 +85,16 @@ export default {
}
},
methods: {
capitalize: function (word) {
capitalize (word) {
// Capitalize first letter of a String
return word.charAt(0).toUpperCase() + word.slice(1)
},
imgfolder: function (img) {
imgfolder (img) {
// Add static image folder to path
// TODO: Do with path?
return '/static/' + img
},
underscore: function (str) {
underscore (str) {
return str.replace('_', ' ')
}
},
......
......@@ -109,18 +109,17 @@ export default {
}
},
methods: {
find: function () {
// Parse input field and call search API
var match = ''
var regex = ''
var params = {
parse () {
let match = ''
let regex = ''
let params = {
element: undefined,
content: undefined,
attribute: undefined,
value: undefined
}
// TODO - Refactor this or put in function
// Parse the input
if (this.search.indexOf('@') > 0) {
regex = new RegExp(this.pattern[0])
match = regex.exec(this.search)
......@@ -134,6 +133,11 @@ export default {
params.element = match[1]
params.content = match[2]
}
return params
},
find () {
// Parse input field and call search API
let params = this.parse()
// Remove undefined values
Object.keys(params).forEach((key) => (params[key] == null) && delete params[key])
......@@ -147,7 +151,7 @@ export default {
// Validate input field
this.search.toLowerCase()
var validator = new RegExp(this.pattern.join('|'))
const validator = new RegExp(this.pattern.join('|'))
if (validator.test(this.search)) {
this.invalid = false
this.find()
......@@ -162,12 +166,12 @@ export default {
},
getValue (obj) {
// Get value of unknown key in object
var key = Object.keys(obj)[0]
let key = Object.keys(obj)[0]
return obj[key].substr(0, this.cutoff)
},
getKey (obj) {
// Get unknown first key from object
var key = Object.keys(obj)[0]
let key = Object.keys(obj)[0]
key = key.replace('teiHeader.xenoData.', '')
key = key.replace(/.[0-9]._text/, '')
return key
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment