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
b09cbe3a
Commit
b09cbe3a
authored
4 years ago
by
Sini
Browse files
Options
Download
Email Patches
Plain Diff
ExcelToJson Update
parent
644e98e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/js/search.js
+102
-1
public/js/search.js
with
102 additions
and
1 deletion
+102
-1
public/js/search.js
+
102
-
1
View file @
b09cbe3a
...
@@ -59,6 +59,107 @@ var stuff_paper = []
...
@@ -59,6 +59,107 @@ var stuff_paper = []
// }
// }
// // stuff.forEach(addcontent());
// // stuff.forEach(addcontent());
// });
// });
//
// begining of xlsx to json coversion
//
var
jsonContent
=
[];
/* set up XMLHttpRequest */
var
url
=
"
./content/CitationSheet.xlsx
"
;
var
xmlHttpRequest
=
new
XMLHttpRequest
();
xmlHttpRequest
.
open
(
"
GET
"
,
url
,
true
);
xmlHttpRequest
.
responseType
=
"
arraybuffer
"
;
xmlHttpRequest
.
onload
=
function
(
e
)
{
var
arraybuffer
=
xmlHttpRequest
.
response
;
// convert data to binary string //
var
data
=
new
Uint8Array
(
arraybuffer
);
var
arr
=
new
Array
();
for
(
var
i
=
0
;
i
!=
data
.
length
;
++
i
)
arr
[
i
]
=
String
.
fromCharCode
(
data
[
i
]);
var
bstr
=
arr
.
join
(
""
);
// Call XLSX //
var
workbook
=
XLSX
.
read
(
bstr
,
{
type
:
"
binary
"
});
// DO SOMETHING WITH workbook HERE //
var
first_sheet_name
=
workbook
.
SheetNames
[
0
];
// Get worksheet //
var
worksheet
=
workbook
.
Sheets
[
first_sheet_name
];
var
jsonOutput
=
XLSX
.
utils
.
sheet_to_json
(
worksheet
);
for
(
i
=
0
;
i
<
jsonOutput
.
length
;
i
++
){
var
item
=
{
"
item
"
:
{
"
title
"
:
""
,
"
project
"
:
""
,
"
authors
"
:
[],
"
imageLink
"
:
""
,
"
keywords
"
:
""
,
"
journal
"
:
{
"
name
"
:
"
journal
"
,
"
volume
"
:
""
,
"
year
"
:
""
,
"
pages
"
:
""
},
"
DOI
"
:
""
},
"
links
"
:
{
"
pdf
"
:
""
,
"
url
"
:
""
,
"
demo
"
:
""
}
}
var
authors
=
jsonOutput
[
i
].
Authors
.
replace
(
"
and
"
,
""
).
trim
().
split
(
"
,
"
);
item
[
"
item
"
].
title
=
jsonOutput
[
i
].
Titel
;
item
[
"
item
"
].
project
=
jsonOutput
[
i
].
Project
;
for
(
j
=
0
;
j
<
authors
.
length
;
j
++
){
var
author
=
{
"
firstName
"
:
""
,
"
lastName
"
:
""
}
if
(
authors
[
j
].
trim
().
split
(
"
"
).
length
==
1
){
author
[
"
firstName
"
]
=
authors
[
j
].
trim
().
split
(
"
.
"
)[
0
];
author
[
"
lastName
"
]
=
authors
[
j
].
trim
().
split
(
"
.
"
)[
1
];
item
[
"
item
"
].
authors
.
push
(
author
);
}
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
);
}
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
);
}
}
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
;
}
item
[
"
item
"
].
journal
.
name
=
jsonOutput
[
i
].
Journal
;
item
[
"
item
"
].
journal
.
volume
=
jsonOutput
[
i
].
Volume
;
item
[
"
item
"
].
journal
.
year
=
jsonOutput
[
i
].
Year
;
item
[
"
item
"
].
journal
.
pages
=
jsonOutput
[
i
].
Pages
;
item
[
"
item
"
].
DOI
=
jsonOutput
[
i
].
DOI
;
item
[
"
links
"
].
pdf
=
jsonOutput
[
i
].
URL
;
item
[
"
links
"
].
url
=
jsonOutput
[
i
].
URL
;
item
[
"
links
"
].
demo
=
jsonOutput
[
i
].
URL
;
jsonContent
.
push
(
item
);
}
console
.
log
(
jsonContent
);
}
xmlHttpRequest
.
send
();
//
// ending of xlsx to json coversion
//
$
(
document
).
ready
(
function
(){
$
(
document
).
ready
(
function
(){
$
.
getJSON
(
"
./content/content.json
"
,
function
(
result
){
$
.
getJSON
(
"
./content/content.json
"
,
function
(
result
){
stuff
=
result
;
stuff
=
result
;
...
@@ -177,4 +278,4 @@ input.addEventListener("keyup", function(event) {
...
@@ -177,4 +278,4 @@ input.addEventListener("keyup", function(event) {
document
.
getElementById
(
"
search-button_paper
"
).
click
();
document
.
getElementById
(
"
search-button_paper
"
).
click
();
}
}
});
});
\ No newline at end of file
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