LT-275: Storing and showing common used labels
This commit is contained in:
1 parent
7d58d84d48
commit
7d4c76ddb0
10 files changed
+114
-14
No files matched your search
@@ -31,3 +31,17 @@ OHIF.string.search = (object, query, property=null, result=[]) => {
|
||||
// Return the found items
|
||||
return result;
|
||||
};
|
||||
|
||||
// Encode any string into a safe format for HTML id attribute
|
||||
OHIF.string.encodeId = string => {
|
||||
// Return an underscore if the given string is empty or if it's not a string
|
||||
if (string === '' || typeof string !== 'string') {
|
||||
return '_';
|
||||
}
|
||||
|
||||
// Create a converter to replace non accepted chars
|
||||
const converter = match => '_' + match[0].charCodeAt(0).toString(16) + '_';
|
||||
|
||||
// Encode the given string and return it
|
||||
return string.replace(/[^a-zA-Z0-9-]/g, converter);
|
||||
};
|
||||
Reference in new issue
Block a user