Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
UGL
website
Commits
948821b5
Commit
948821b5
authored
Oct 24, 2023
by
JOE XMG
Browse files
update
parent
69764baf
Pipeline
#8747
passed with stage
in 17 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
public/demos.html
View file @
948821b5
...
...
@@ -423,7 +423,8 @@
<script
src=
"https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js"
></script>
<link
rel=
"stylesheet"
href=
"./css/search.css"
>
<link
rel=
"stylesheet"
href=
"./css/language.css"
>
<script
src=
"js/search.js"
></script>
<!-- <script src="js/search.js"></script> -->
<script
src=
"js/search_demos.js"
></script>
<script
src=
"js/paper_nextpage.js"
></script>
...
...
public/js/search_demos.js
0 → 100644
View file @
948821b5
// search options
// --- needs to be adapted to the form of our content
const
options
=
{
includeScore
:
true
,
// Search in `author` and in `tags` array
keys
:
[
"
item.title
"
,
"
item.keywords
"
,
"
item.author.firstName
"
,
"
item.author.lastName
"
]
}
const
options_paper
=
{
includeScore
:
true
,
// Search in `author` and in `tags` array
keys
:
[
"
item.title
"
,
"
item.keywords
"
,
"
item.authors.lastName
"
,
"
item.authors.firstName
"
]
}
// start search
var
searchanswer
var
searchanswer_paper
function
search
()
{
const
fuse
=
new
Fuse
(
stuff
,
options
);
searchanswer
=
fuse
.
search
(
document
.
getElementById
(
"
search-input
"
).
value
)
var
new_row
=
document
.
getElementById
(
"
row_main
"
)
new_row
.
innerHTML
=
""
;
var
searchLength
=
searchanswer
.
length
;
for
(
var
i
=
0
;
i
<
searchLength
;
i
++
)
{
addcontent
(
searchanswer
[
i
].
item
);
//Do something
}
// alert(searchanswer);
console
.
log
(
searchanswer
);
}
function
search_paper
()
{
const
fuse
=
new
Fuse
(
jsonContent
,
options_paper
);
//stuff_paper
searchanswer_paper
=
fuse
.
search
(
document
.
getElementById
(
"
search-input_paper
"
).
value
)
document
.
getElementById
(
"
nextblock
"
).
style
.
display
=
"
none
"
;
var
new_row
=
document
.
getElementById
(
"
cont_paper
"
)
new_row
.
innerHTML
=
""
;
var
searchLength
=
searchanswer_paper
.
length
;
for
(
var
i
=
0
;
i
<
searchLength
;
i
++
)
{
console
.
log
(
searchanswer_paper
[
i
])
if
(
searchanswer_paper
[
i
].
score
<
0.5
){
addpaper
(
searchanswer_paper
[
i
].
item
);
}
//Do something
}
// alert(searchanswer);
console
.
log
(
searchanswer_paper
);
}
//get json
// --- can be adapted if we load the content from the json
var
stuff
=
[]
var
stuff_paper
=
[]
// $.getJSON("./content/content.json", function(result){
// stuff = result;
// var new_row = document.getElementById("row_main")
// new_row.innerHTML = "";
// var arrayLength = stuff.length;
// for (var i = 0; i < arrayLength; i++) {
// addcontent(stuff[i]);
// //Do something
// }
// // stuff.forEach(addcontent());
// });
function
changeLang
()
{
var
userLang
=
navigator
.
language
||
navigator
.
userLanguage
;
console
.
log
(
"
The language is:
"
+
userLang
);
if
(
userLang
.
includes
(
"
de
"
))
{
console
.
log
(
true
)
var
select1
=
document
.
getElementById
(
'
selectpicker1
'
);
// console.log(select1)
select1
.
value
=
"
2
"
;
select1
.
dispatchEvent
(
new
Event
(
'
change
'
));
}
else
{
var
select1
=
document
.
getElementById
(
'
selectpicker1
'
);
// console.log(select1)
select1
.
value
=
"
1
"
;
select1
.
dispatchEvent
(
new
Event
(
'
change
'
));
}
}
// window.onload = function () {
// var e = document.getElementById("selectpicker1");
// e.value = 2;
// e.dispatchEvent(new Event('change'));
// };
// searchbar and start search
function
searchToggle
(
obj
,
evt
)
{
console
.
log
(
"
arrive
"
)
var
container
=
$
(
obj
).
closest
(
'
.search-wrapper
'
);
if
(
!
container
.
hasClass
(
'
active
'
))
{
container
.
addClass
(
'
active
'
);
evt
.
preventDefault
();
console
.
log
(
"
first
"
)
}
else
if
(
container
.
hasClass
(
'
active
'
)
&&
$
(
obj
).
closest
(
'
.input-holder
'
).
length
==
0
)
{
container
.
removeClass
(
'
active
'
);
// clear input
console
.
log
(
"
second
"
)
var
new_row
=
document
.
getElementById
(
"
row_main
"
)
new_row
.
innerHTML
=
""
;
var
arrayLength
=
stuff
.
length
;
for
(
var
i
=
0
;
i
<
arrayLength
;
i
++
)
{
addcontent
(
stuff
[
i
]);
//Do something
}
container
.
find
(
'
.search-input
'
).
val
(
''
);
}
else
{
console
.
log
(
"
search
"
)
search
();
// addcontent();
}
}
function
searchToggle_paper
(
obj
,
evt
)
{
console
.
log
(
"
arrive
"
)
var
container
=
$
(
obj
).
closest
(
'
.search-wrapper
'
);
if
(
!
container
.
hasClass
(
'
active
'
))
{
container
.
addClass
(
'
active
'
);
evt
.
preventDefault
();
console
.
log
(
"
first
"
)
}
else
if
(
container
.
hasClass
(
'
active
'
)
&&
$
(
obj
).
closest
(
'
.input-holder
'
).
length
==
0
)
{
container
.
removeClass
(
'
active
'
);
// clear input
console
.
log
(
"
second
"
)
var
new_row
=
document
.
getElementById
(
"
cont_paper
"
)
new_row
.
innerHTML
=
""
;
var
arrayLength
=
stuff_paper
.
length
;
for
(
var
i
=
0
;
i
<
arrayLength
;
i
++
)
{
document
.
getElementById
(
"
nextblock
"
).
style
.
display
=
"
block
"
;
if
(
i
<=
max_paper_list
)
{
addpaper
(
stuff_paper
[
i
]);
}
//Do something
}
for
(
var
j
=
0
;
j
<
6
;
j
++
)
{
addpaper
(
jsonContent
[
j
]);
//Do something
}
document
.
getElementById
(
"
nextblock
"
).
style
.
display
=
"
block
"
;
container
.
find
(
'
#search-input_paper
'
).
val
(
''
);
}
else
{
console
.
log
(
"
search
"
)
search_paper
();
// addcontent();
}
}
// search on enter
var
input
=
document
.
getElementById
(
"
search-input
"
);
input
.
addEventListener
(
"
keyup
"
,
function
(
event
)
{
if
(
event
.
keyCode
===
13
)
{
event
.
preventDefault
();
document
.
getElementById
(
"
search-button
"
).
click
();
}
});
var
input2
=
document
.
getElementById
(
"
search-input_paper
"
);
input2
.
addEventListener
(
"
keyup
"
,
function
(
event
)
{
if
(
event
.
keyCode
===
13
)
{
event
.
preventDefault
();
document
.
getElementById
(
"
search-button_paper
"
).
click
();
}
});
$
(
document
).
ready
(
function
()
{
console
.
log
(
"
document ready
"
)
$
.
getJSON
(
"
./content/content.json
"
,
function
(
result
)
{
$
.
getJSON
(
"
https://transfer.hft-stuttgart.de/gitlab/zedflow/fgdi/-/blob/master/public/content/content.json
"
,
function
(
result_zedflow
)
{
console
.
log
(
"
content.json ==> HTML
"
)
// stuff merge result and result_zedflow
stuff
=
result
.
concat
(
result_zedflow
);
var
new_row
=
document
.
getElementById
(
"
row_main
"
)
new_row
.
innerHTML
=
""
;
var
arrayLength
=
stuff
.
length
;
for
(
var
i
=
0
;
i
<
arrayLength
;
i
++
)
{
addcontent
(
stuff
[
i
]);
//Do something
}
$
.
getJSON
(
"
./content/team.json
"
,
function
(
result
){
console
.
log
(
"
team.json ==> HTML
"
)
team
=
result
;
var
new_row
=
document
.
getElementById
(
"
team-section
"
)
new_row
.
innerHTML
=
""
;
var
arrayLength
=
team
.
length
;
for
(
var
i
=
0
;
i
<
arrayLength
;
i
++
)
{
addTeam
(
team
[
i
]);
//Do something
}
});
changeLang
();
});
});
var
currentYear
=
new
Date
().
getFullYear
();
document
.
getElementById
(
'
current-year
'
).
innerHTML
=
currentYear
;
// get the keyword parameter
if
(
urlKeyword
!==
null
)
{
console
.
log
(
`url Keyword:
${
urlKeyword
}
`
)
// insert keyword parameter
$
(
"
#search-input
"
).
val
(
urlKeyword
,
function
(){
console
.
log
(
"
trigger the search
"
)
document
.
getElementById
(
"
search-button
"
).
click
();
});
$
(
"
#search-input_paper
"
).
val
(
urlKeyword
);
// apply keyword parameter
}
// get paper content is commented out for back up
// $.getJSON("./content/paper2.json", function (result) {
// stuff_paper = result;
// var new_row = document.getElementById("cont_paper")
// new_row.innerHTML = "";
// var arrayLength = stuff_paper.length;
// for (var i = 0; i < arrayLength; i++) {
// if (Math.abs(arrayLength - i) <= max_paper_list) {
// console.log("close to " + i)
// addpaper(stuff_paper[i]);
// }
// //Do something
// }
// });
});
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment