Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
UGL
website
Commits
cb3b2f78
Commit
cb3b2f78
authored
4 years ago
by
Sini
Browse files
Options
Download
Email Patches
Plain Diff
ExcelSheetToJsonWithBibtexAsAttributeOfTheJsonFile
parent
c7ec381d
master
revert-205bb8ef
rosanny-202111
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/js/citationSheetParse.js
+44
-6
public/js/citationSheetParse.js
with
44 additions
and
6 deletions
+44
-6
public/js/citationSheetParse.js
+
44
-
6
View file @
cb3b2f78
...
...
@@ -3,6 +3,9 @@
//
var
jsonContent
=
[];
var
bibAuthors
=
""
;
var
bit1stAuthorLN
=
""
;
/* set up XMLHttpRequest */
var
url
=
"
./content/CitationSheet.xlsx
"
;
...
...
@@ -31,6 +34,8 @@ xmlHttpRequest.onload = function (e) {
var
jsonOutput
=
XLSX
.
utils
.
sheet_to_json
(
worksheet
);
for
(
i
=
0
;
i
<
jsonOutput
.
length
;
i
++
)
{
var
authors
=
jsonOutput
[
i
].
Authors
.
replace
(
"
and
"
,
""
).
trim
().
split
(
"
,
"
);
var
bibAuthors
;
var
item
=
{
"
item
"
:
{
"
title
"
:
""
,
...
...
@@ -50,12 +55,13 @@ xmlHttpRequest.onload = function (e) {
"
pdf
"
:
""
,
"
url
"
:
""
,
"
demo
"
:
""
}
},
"
bibtex
"
:
""
}
var
authors
=
jsonOutput
[
i
].
Authors
.
replace
(
"
and
"
,
""
).
trim
().
split
(
"
,
"
);
item
[
"
item
"
].
title
=
jsonOutput
[
i
].
Titel
;
item
[
"
item
"
].
project
=
jsonOutput
[
i
].
Project
;
bibAuthors
=
""
;
bit1stAuthorLN
=
""
;
for
(
j
=
0
;
j
<
authors
.
length
;
j
++
)
{
var
author
=
{
"
firstName
"
:
""
,
...
...
@@ -65,23 +71,38 @@ xmlHttpRequest.onload = function (e) {
author
[
"
firstName
"
]
=
authors
[
j
].
trim
().
split
(
"
.
"
)[
0
];
author
[
"
lastName
"
]
=
authors
[
j
].
trim
().
split
(
"
.
"
)[
1
];
item
[
"
item
"
].
authors
.
push
(
author
);
bibAuthors
+=
authors
[
j
].
trim
().
split
(
"
.
"
)[
1
]
+
"
,
"
+
authors
[
j
].
trim
().
split
(
"
.
"
)[
0
]
+
"
and
"
;
}
else
if
(
authors
[
j
].
trim
().
split
(
"
"
).
length
==
2
)
{
author
[
"
firstName
"
]
=
authors
[
j
].
trim
().
split
(
"
"
)[
0
];
author
[
"
lastName
"
]
=
authors
[
j
].
trim
().
split
(
"
"
)[
1
];
item
[
"
item
"
].
authors
.
push
(
author
);
bibAuthors
+=
authors
[
j
].
trim
().
split
(
"
"
)[
1
]
+
"
,
"
+
authors
[
j
].
trim
().
split
(
"
"
)[
0
]
+
"
and
"
;
}
else
if
(
authors
[
j
].
trim
().
split
(
"
"
).
length
==
3
)
{
author
[
"
firstName
"
]
=
authors
[
j
].
trim
().
split
(
"
"
)[
0
];
author
[
"
lastName
"
]
=
authors
[
j
].
trim
().
split
(
"
"
)[
2
];
item
[
"
item
"
].
authors
.
push
(
author
);
bibAuthors
+=
authors
[
j
].
trim
().
split
(
"
"
)[
2
]
+
"
,
"
+
authors
[
j
].
trim
().
split
(
"
"
)[
0
]
+
"
and
"
;
}
}
item
[
"
item
"
].
imageLink
=
jsonOutput
[
i
][
"
Path to demo image
"
]
if
(
jsonOutput
[
i
].
Keywords
!=
undefined
)
{
item
[
"
item
"
].
keywords
=
jsonOutput
[
i
].
Keywords
.
split
(
"
,
"
);
}
else
{
item
[
"
item
"
].
keywords
=
jsonOutput
[
i
].
Keywords
;
}
if
(
authors
[
0
].
split
(
"
"
).
length
==
3
){
bit1stAuthorLN
=
authors
[
0
].
split
(
"
"
)[
2
];
}
else
if
(
authors
[
0
].
split
(
"
"
).
length
==
2
){
bit1stAuthorLN
=
authors
[
0
].
split
(
"
"
)[
1
];
}
else
if
(
authors
[
0
].
split
(
"
"
).
length
==
1
){
bit1stAuthorLN
=
authors
[
0
].
split
(
"
"
)[
0
];
}
item
[
"
item
"
].
title
=
jsonOutput
[
i
].
Titel
;
item
[
"
item
"
].
project
=
jsonOutput
[
i
].
Project
;
item
[
"
item
"
].
imageLink
=
jsonOutput
[
i
][
"
Path to demo image
"
]
item
[
"
item
"
].
journal
.
name
=
jsonOutput
[
i
].
Journal
;
item
[
"
item
"
].
journal
.
volume
=
jsonOutput
[
i
].
Volume
;
item
[
"
item
"
].
journal
.
year
=
jsonOutput
[
i
].
Year
;
...
...
@@ -91,14 +112,31 @@ xmlHttpRequest.onload = function (e) {
item
[
"
links
"
].
url
=
jsonOutput
[
i
].
URL
;
item
[
"
links
"
].
demo
=
jsonOutput
[
i
].
URL
;
//// BibTex /////////////////////
item
[
"
bibtex
"
]
=
"
@article{
"
+
bit1stAuthorLN
+
jsonOutput
[
i
].
Year
+
"
,
"
+
"
title={
"
+
jsonOutput
[
i
].
Titel
+
"
},author={
"
+
bibAuthors
.
trim
().
substring
(
0
,
bibAuthors
.
trim
().
lastIndexOf
(
"
"
))
+
"
},journal={
"
+
jsonOutput
[
i
].
Journal
+
"
},volume={
"
+
jsonOutput
[
i
].
Volume
+
// "},number={"+ number
"
},pages={
"
+
jsonOutput
[
i
].
Pages
+
"
},year={
"
+
jsonOutput
[
i
].
Year
+
"
},DOI ={
"
+
jsonOutput
[
i
].
DOI
+
"
},url ={
"
+
jsonOutput
[
i
].
URL
+
"
}}
"
jsonContent
.
push
(
item
);
}
//
console.log(jsonContent);
console
.
log
(
jsonContent
);
}
xmlHttpRequest
.
send
();
// str = str.substring(0, lastIndex);
//
// ending of xlsx to json coversion
//
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets