Merge pull request #168 from glyptodon/js-warnings

GUAC-1170: Fix basic JavaScript warnings.
This commit is contained in:
James Muehlner
2015-04-27 19:21:04 -07:00
5 changed files with 89 additions and 49 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 Glyptodon LLC
* Copyright (C) 2015 Glyptodon LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -70,7 +70,12 @@ Guacamole.AudioChannel = function() {
};
// Define context if available
if (window.webkitAudioContext) {
if (window.AudioContext) {
Guacamole.AudioChannel.context = new AudioContext();
}
// Fallback to Webkit-specific AudioContext implementation
else if (window.webkitAudioContext) {
Guacamole.AudioChannel.context = new webkitAudioContext();
}

View File

@@ -954,6 +954,34 @@ Guacamole.Keyboard = function(element) {
}
/**
* Returns the keyboard location of the key associated with the given
* keyboard event. The location differentiates key events which otherwise
* have the same keycode, such as left shift vs. right shift.
*
* @param {KeyboardEvent} e
* A JavaScript keyboard event, as received through the DOM via a
* "keydown", "keyup", or "keypress" handler.
*
* @returns {Number}
* The location of the key event on the keyboard, as defined at:
* http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent
*/
var getEventLocation = function getEventLocation(e) {
// Use standard location, if possible
if ('location' in e)
return e.location;
// Failing that, attempt to use deprecated keyLocation
if ('keyLocation' in e)
return e.keyLocation;
// If no location is available, assume left side
return 0;
};
// When key pressed
element.addEventListener("keydown", function(e) {
@@ -973,7 +1001,7 @@ Guacamole.Keyboard = function(element) {
return;
// Log event
var keydownEvent = new KeydownEvent(keyCode, e.keyIdentifier, e.key, e.location || e.keyLocation);
var keydownEvent = new KeydownEvent(keyCode, e.keyIdentifier, e.key, getEventLocation(e));
eventLog.push(keydownEvent);
// Interpret as many events as possible, prevent default if indicated
@@ -1021,7 +1049,7 @@ Guacamole.Keyboard = function(element) {
update_modifier_state(e);
// Log event, call for interpretation
var keyupEvent = new KeyupEvent(keyCode, e.keyIdentifier, e.key, e.location || e.keyLocation);
var keyupEvent = new KeyupEvent(keyCode, e.keyIdentifier, e.key, getEventLocation(e));
eventLog.push(keyupEvent);
interpret_events();

View File

@@ -83,7 +83,7 @@ angular.module('element').directive('guacResize', ['$document', function guacRes
// Call resize callback, if defined
if (guacResize) {
$scope.$apply(function elementSizeChanged() {
$scope.$evalAsync(function elementSizeChanged() {
guacResize(element.offsetWidth, element.offsetHeight);
});
}

View File

@@ -1,5 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>_</title>
</head>
<!--
Copyright (C) 2014 Glyptodon LLC
Copyright (C) 2015 Glyptodon LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +25,5 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html><body></body></html>
<body></body>
</html>

View File

@@ -1,5 +1,18 @@
<!DOCTYPE html>
<html ng-app="index" ng-controller="indexController">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi"/>
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link rel="icon" type="image/png" href="images/guacamole-logo-64.png"/>
<link rel="icon" type="image/png" sizes="144x144" href="images/guacamole-logo-144.png"/>
<link rel="apple-touch-icon" type="image/png" href="images/guacamole-logo-144.png"/>
<link rel="stylesheet" type="text/css" href="guacamole.min.css">
<title ng-bind="page.title | translate"></title>
</head>
<!--
Copyright 2014 Glyptodon LLC.
Copyright 2015 Glyptodon LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,19 +32,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!DOCTYPE html>
<html ng-app="index" ng-controller="indexController">
<head>
<link rel="icon" type="image/png" href="images/guacamole-logo-64.png"/>
<link rel="icon" type="image/png" sizes="144x144" href="images/guacamole-logo-144.png"/>
<link rel="apple-touch-icon" type="image/png" href="images/guacamole-logo-144.png"/>
<title ng-bind="page.title | translate"></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi"/>
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link rel="stylesheet" type="text/css" href="guacamole.min.css">
</head>
<body ng-class="page.bodyClassName">
<!-- Content for logged-in users -->