Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cortex/webgl/resources/css/mriview.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,16 @@ a:visited { color:white; }
position:absolute;
z-index:8;
top: 50%;
left: 0%;
transform: translate(0%, -50%);
left: 50%;
transform: translate(-50%, -50%);
padding:15px;
margin:20px;
border-radius:10px;
background:rgba(255,255,255,.2);
max-width:400px;
display:none;
font-size:12pt;
font-family:Helvetica, Arial, sans-serif;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For design consistency across the application, please use Helvetica Neue, sans-serif to match the font family defined for the body element on line 3.

    font-family:Helvetica Neue, sans-serif;

color:white;
transition:all .3s;
transition-timing-function:ease;
Expand Down
6 changes: 3 additions & 3 deletions cortex/webgl/resources/js/mriview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1242,16 +1242,16 @@ var mriview = (function(module) {
new_html += '<tr><td style="text-align: center;">'
if ('modKeys' in list[i][name]){
let modKeys = list[i][name]['modKeys'];
modKeys = modKeys.map((modKey) => modKey.substring(0, modKey.length - 3));
modKeys = modKeys.map((modKey) => modKey.charAt(0).toUpperCase() + modKey.substring(1, modKey.length - 3));
modKeys = modKeys.join(' + ');
Comment on lines 1244 to 1246
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using string manipulation (substring and charAt) to format modifier keys is fragile and hard to maintain. If a modifier key name does not end with 'Key' or is formatted differently, this logic will break. Using a mapping object is much cleaner, safer, and more robust.

Suggested change
let modKeys = list[i][name]['modKeys'];
modKeys = modKeys.map((modKey) => modKey.substring(0, modKey.length - 3));
modKeys = modKeys.map((modKey) => modKey.charAt(0).toUpperCase() + modKey.substring(1, modKey.length - 3));
modKeys = modKeys.join(' + ');
let modKeys = list[i][name]['modKeys'];
const modMap = { shiftKey: 'Shift', ctrlKey: 'Ctrl', altKey: 'Alt', metaKey: 'Meta' };
modKeys = modKeys.map((modKey) => modMap[modKey] || modKey);
modKeys = modKeys.join(' + ');

new_html += modKeys + ' + ';
}
new_html += list[i][name]['key'].toUpperCase() + '</td><td>' + diplay_name + '</td></tr>'
new_html += list[i][name]['key'] + '</td><td>' + diplay_name + '</td></tr>'
}
if ('wheel' in list[i][name]){
new_html += '<tr><td style="text-align: center;">'
var modKeys = list[i][name]['modKeys']
modKeys = modKeys.map((modKey) => modKey.substring(0, modKey.length - 3))
modKeys = modKeys.map((modKey) => modKey.charAt(0).toUpperCase() + modKey.substring(1, modKey.length - 3))
modKeys = modKeys.join(' + ')
new_html += modKeys + ' + wheel </td><td>' + diplay_name + '</td></tr>'
Comment on lines 1253 to 1256
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If modKeys is undefined (e.g., if a wheel action does not require modifier keys), calling .map on it will throw a TypeError. We should guard against this by defaulting to an empty array, and also use a mapping object for cleaner and safer translation.

                            var modKeys = list[i][name]['modKeys'] || [];
                            const modMap = { shiftKey: 'Shift', ctrlKey: 'Ctrl', altKey: 'Alt', metaKey: 'Meta' };
                            modKeys = modKeys.map((modKey) => modMap[modKey] || modKey);
                            var modStr = modKeys.join(' + ');
                            new_html += (modStr ? modStr + ' + ' : '') + 'wheel  </td><td>' + diplay_name + '</td></tr>'

}
Expand Down