Skip to content

Commit

Permalink
Updated the hard-coded study settings
Browse files Browse the repository at this point in the history
Previously there were hardcoded settings, based on study name, that determined whether metadata was shown for the audio clip, and the study title.
This has been changed to be a little more flexible. It's still hardcoded, but now it will choose the settings based on partial match of the the study name,
meaning that the verification settings can be specified by haveing the word "verification" as part of the study name.
  • Loading branch information
peichins authored and atruskie committed Aug 6, 2020
1 parent 0a2f1e3 commit 4b46442
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/app/citizenScience/listen/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,40 @@ class CitizenScienceListenController {
});
});

$scope.studyTitle = {"bristlebird": "Eastern Bristlebird Search", "koala-verification": "Koala Verification"}[$scope.csProject];

$scope.settings = {
"bristlebird": {
var title_map = {"bristlebird": "Eastern Bristlebird Search", "koala-verification": "Koala Verification"};
if (title_map.hasOwnProperty($scope.csProject)) {
$scope.studyTitle = title_map[$scope.csProject];
} else {
// replace hyphen with space and capitalize words
$scope.studyTitle = $scope.csProject.split("-").map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
}

var study_settings_presets = {
"default": {
showSite: false,
showDateTime: false,
showProgress: false,
},
"koala-verification": {
"verification": {
showSite: true,
showDateTime: true,
showProgress: true
}
}[$scope.csProject];
};

// find the first settings preset that has the key in the study name
// (i.e. use the verification settings if the word 'verification' appears in the study name)
var settings_key;
if (study_settings_presets.hasOwnProperty($scope.csProject)) {
settings_key = $scope.csProject;
} else {
settings_key = Object.keys(study_settings_presets).find(key => {
return $scope.csProject.includes(key);
});
settings_key = settings_key ? settings_key : "default";
}

$scope.settings = study_settings_presets[settings_key];

/**
* When the currentItem changes, change the current audio file / spectrogram to match it
Expand Down

0 comments on commit 4b46442

Please sign in to comment.