Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beta.ordbok.uib.no
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Margunn.Rauset
beta.ordbok.uib.no
Commits
245b59b1
Commit
245b59b1
authored
3 years ago
by
Henrik Askjer
Browse files
Options
Downloads
Patches
Plain Diff
Replace blur()
parent
757c0111
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/Autocomplete.vue
+35
-31
35 additions, 31 deletions
src/components/Autocomplete.vue
with
35 additions
and
31 deletions
src/components/Autocomplete.vue
+
35
−
31
View file @
245b59b1
...
...
@@ -50,33 +50,35 @@
return
axios
.
get
(
self
.
endpoint
+
'
suggest?q=
'
+
encodeURIComponent
(
q
))
.
then
(
function
(
response
)
{
let
hits
=
[]
if
(
q
==
self
.
search
)
{
response
.
data
.
forEach
((
item
,
i
)
=>
{
let
match
=
encodeURIComponent
(
item
.
match
)
if
(
self
.
loading
)
{
let
hits
=
[]
if
(
q
==
self
.
search
)
{
response
.
data
.
forEach
((
item
,
i
)
=>
{
let
match
=
encodeURIComponent
(
item
.
match
)
if
(
!
hits
[
0
]
||
hits
[
0
].
word
!=
match
)
{
hits
.
splice
(
0
,
0
,
{
q
:
encodeURIComponent
(
q
),
lang_set
:
new
Set
(),
word
:
match
,
articles
:
[]})
}
hits
[
0
].
lang_set
.
add
(
item
.
dictionary
==
'
bob
'
?
'
bm
'
:
'
nn
'
)
hits
[
0
].
articles
.
push
(
item
)
});
hits
.
forEach
(
function
(
hit
)
{
if
(
hit
.
lang_set
)
{
hit
.
label
=
decodeURIComponent
(
hit
.
word
)
}
});
hits
.
reverse
()
hits
=
hits
.
slice
(
0
,
9
)
}
hits
.
sort
(
(
h1
,
h2
)
=>
{
let
val1
=
h1
.
label
.
length
*
10
+
(
h1
.
label
[
0
].
toLowerCase
()
===
h1
.
label
[
0
]
?
0
:
1
)
let
val2
=
h2
.
label
.
length
*
10
+
(
h2
.
label
[
0
].
toLowerCase
()
===
h2
.
label
[
0
]
?
0
:
1
)
return
val1
-
val2
})
if
(
!
hits
[
0
]
||
hits
[
0
].
word
!=
match
)
{
hits
.
splice
(
0
,
0
,
{
q
:
encodeURIComponent
(
q
),
lang_set
:
new
Set
(),
word
:
match
,
articles
:
[]})
}
hits
[
0
].
lang_set
.
add
(
item
.
dictionary
==
'
bob
'
?
'
bm
'
:
'
nn
'
)
hits
[
0
].
articles
.
push
(
item
)
});
hits
.
forEach
(
function
(
hit
)
{
if
(
hit
.
lang_set
)
{
hit
.
label
=
decodeURIComponent
(
hit
.
word
)
}
});
hits
.
reverse
()
hits
=
hits
.
slice
(
0
,
9
)
}
hits
.
sort
(
(
h1
,
h2
)
=>
{
let
val1
=
h1
.
label
.
length
*
10
+
(
h1
.
label
[
0
].
toLowerCase
()
===
h1
.
label
[
0
]
?
0
:
1
)
let
val2
=
h2
.
label
.
length
*
10
+
(
h2
.
label
[
0
].
toLowerCase
()
===
h2
.
label
[
0
]
?
0
:
1
)
return
val1
-
val2
})
self
.
items
=
hits
self
.
loading
=
false
self
.
items
=
hits
self
.
loading
=
false
}
})
},
100
)
}
...
...
@@ -90,13 +92,15 @@
}
},
select
(
item
)
{
if
(
typeof
item
===
'
string
'
)
{
item
=
{
"
q
"
:
encodeURIComponent
(
item
)}
if
(
item
)
{
if
(
typeof
item
===
'
string
'
)
{
item
=
{
"
q
"
:
encodeURIComponent
(
item
)}
}
this
.
loading
=
false
this
.
$emit
(
'
submit
'
,
item
)
let
self
=
this
setTimeout
(()
=>
self
.
$refs
.
autocomplete
.
$refs
.
input
.
select
(),
1
)
}
this
.
$emit
(
'
submit
'
,
item
)
this
.
$refs
.
autocomplete
.
blur
()
let
self
=
this
setTimeout
(()
=>
self
.
$refs
.
autocomplete
.
$refs
.
input
.
select
(),
1
)
}
},
methods
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment