mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-55: Automatically fire guacClipboard events from index controller when local clipboard has changed.
This commit is contained in:
@@ -26,6 +26,7 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
||||
// Required services
|
||||
var $document = $injector.get('$document');
|
||||
var $window = $injector.get('$window');
|
||||
var clipboardService = $injector.get('clipboardService');
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
|
||||
/**
|
||||
@@ -124,6 +125,28 @@ angular.module('index').controller('indexController', ['$scope', '$injector',
|
||||
keyboard.reset();
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether the clipboard data has changed, firing a new
|
||||
* "guacClipboard" event if it has.
|
||||
*/
|
||||
var checkClipboard = function checkClipboard() {
|
||||
clipboardService.getLocalClipboard().then(function clipboardRead(data) {
|
||||
$scope.$broadcast('guacClipboard', data);
|
||||
});
|
||||
};
|
||||
|
||||
// Attempt to read the clipboard if it may have changed
|
||||
$window.addEventListener('load', checkClipboard, true);
|
||||
$window.addEventListener('copy', checkClipboard, true);
|
||||
$window.addEventListener('cut', checkClipboard, true);
|
||||
$window.addEventListener('focus', function focusGained(e) {
|
||||
|
||||
// Only recheck clipboard if it's the window itself that gained focus
|
||||
if (e.target === $window)
|
||||
checkClipboard();
|
||||
|
||||
}, true);
|
||||
|
||||
// Display login screen if a whole new set of credentials is needed
|
||||
$scope.$on('guacInvalidCredentials', function loginInvalid(event, parameters, error) {
|
||||
$scope.page.title = 'APP.NAME';
|
||||
|
@@ -23,6 +23,7 @@
|
||||
angular.module('index', [
|
||||
'auth',
|
||||
'client',
|
||||
'clipboard',
|
||||
'home',
|
||||
'login',
|
||||
'manage',
|
||||
|
Reference in New Issue
Block a user