Commit d109ae1b authored by Maxime Chaillet's avatar Maxime Chaillet

refactor extractFieldsFromCategories and handle the possible cas where...

refactor extractFieldsFromCategories and handle the possible cas where proposal type is a single word.
parent 0881e478
This diff is collapsed.
......@@ -140,25 +140,16 @@ function findRegExpInText(regExp, text) {
function extractFieldsFromCategories(data) {
var catArray = data.categories;
var index;
// extract beamline from data.categories
for (index in catArray) {
if ((findRegExpInText(/id/, catArray[index]) == 0) || (findRegExpInText(/bm/, catArray[index]) == 0)) {
for (index in catArray) {
// extract beamline from data.categories
if ((findRegExpInText(/^id/, catArray[index]) == 0) || (findRegExpInText(/^bm/, catArray[index]) == 0)) {
data.beamline = catArray[index];
}
}
// extract proposal from data.categories
for (index in catArray) {
if (findRegExpInText(/\D+-/, catArray[index]) == 0) {
} else if (findRegExpInText(/^\D+-/, catArray[index]) == 0) {
// extract proposal number from data.categories
data.proposalNumber = catArray[index];
}
}
// extract proposal type from data.categories
for (index in catArray) {
if (findRegExpInText(/\s/, catArray[index]) != -1) {
data.proposalType = catArray[index];
} else {
// catArray[index] is the proposal type. Note that proposal type can be composed of several words separated by spaces or a single word.
data.proposalType = catArray[index];
}
}
}
......
Markdown is supported
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