export { guessIFDOKey, getHTMLOfIFDOIcon }
/**
* Try to match the input argument to a set of iFDO keys.
* Check if part of the given argument is contained in a list of known iFDO keys, and return the corresponding iFDO key.
*
* Example:
* Returns 'image-acquisition' for iFDOSimilarKey = 'acquisition' or iFDOSimilarKey = 'iFDO-acquisition'
*
* @param {string} iFDOSimilarKey - Key that is almost similar to iFDO key.
* @returns {string} iFDO key.
*/
function guessIFDOKey(iFDOSimilarKey) {
const iFDOSearchKeyDict = {
'image-acquisition': new RegExp('acquisition', 'i'),
'image-marine-zone': new RegExp('marine(?:[^a-zA-Z\d]{0,1})zone', 'i'),
'image-deployment': new RegExp('deployment', 'i'),
'image-navigation': new RegExp('navigation', 'i'),
'image-illumination': new RegExp('illumination', 'i'),
'image-scale-reference': new RegExp('scale(?:[^a-zA-Z\d]{0,1})reference', 'i'),
'image-quality': new RegExp('quality', 'i'),
'image-pixel-magnitude': new RegExp('pixel(?:[^a-zA-Z\d]{0,1})magnitude', 'i'),
'image-spectral-resolution': new RegExp('spectral(?:[^a-zA-Z\d]{0,1})resolution', 'i'),
'image-capture-mode': new RegExp('capture-mode', 'i'),
'image-license': new RegExp('license', 'i')
}
for (const iFDOSearchKey in iFDOSearchKeyDict) {
if (iFDOSimilarKey.match(iFDOSearchKeyDict[iFDOSearchKey])) {
return iFDOSearchKey
}
}
return null
}
/**
* For an iFDO key, return its HTML element containing the iFDO icon font class name.
* Note: Requires the iFDO-icons stylesheet.
* @param {string} iFDOKey
* @param {string} iFDOValue
* @return {string} HTML element with iFDO icon class.
*/
function getHTMLOfIFDOIcon(iFDOKey, iFDOValue) {
const iconIFDOKey = iFDOKey.replace('image-set-', 'image-');
const iconTitle = `"${iconIFDOKey}: ${iFDOValue}"`;
const iconHTML = `<i class="icon-${iconIFDOKey + '_' + iFDOValue.replace(' ', '-')}" title=${iconTitle}></i>`
return iconHTML
}