mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-04 23:55:52 +00:00
Init
This commit is contained in:
1 parent
ae74db6cf1
commit
0d8e1a2eca
4 files changed
+134
-1
No files matched your search
@@ -2455,4 +2455,16 @@ public class Functions {
|
||||
public static String generateItemId() {
|
||||
return String.valueOf(Math.floor(Math.random() * 3000));
|
||||
}
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static String translateModifierKeysForUsersPlatform(String keyboardShortcut) {
|
||||
StaplerRequest currentRequest = Stapler.getCurrentRequest();
|
||||
currentRequest.getWebApp().getDispatchValidator().allowDispatch(currentRequest, Stapler.getCurrentResponse());
|
||||
String userAgent = currentRequest.getHeader("User-Agent");
|
||||
|
||||
List<String> platformsThatUseCommand = List.of("MAC", "IPHONE", "IPAD");
|
||||
boolean useCmdKey = platformsThatUseCommand.stream().anyMatch(e -> userAgent.toUpperCase().contains(e));
|
||||
|
||||
return keyboardShortcut.replace("CMD", useCmdKey ? "⌘" : "CTRL");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user