Skip to content

Instantly share code, notes, and snippets.

@SamBahrami
Last active May 12, 2020 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamBahrami/c1bfbbd85b5fb87befca553c3d18d7cb to your computer and use it in GitHub Desktop.
Save SamBahrami/c1bfbbd85b5fb87befca553c3d18d7cb to your computer and use it in GitHub Desktop.
var num_obj = 1;
document.querySelector('crowd-form').onsubmit = function(e) {
const keypoints = document.querySelector('crowd-bounding-box').value.boundingBoxes || document.querySelector('crowd-bounding-box')._submittableValue.keypoints;
const labels = keypoints.map(function(p) {
return p.label;
});
if (labels.length != num_obj) {
e.preventDefault();
errorBox.innerHTML = '<crowd-alert type="error" dismissible>You must add exactly one bounding box on an object in the scene. If you have more than one drawn, please delete the additional ones and try to submit again.</crowd-alert>';
errorBox.scrollIntoView();
return;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment