Browse Source

Fixed a load of Javascript syntax errors found with jshint.

pull/37/head
Simon Eisenmann 11 years ago
parent
commit
6dc0bc3f9b
  1. 8
      static/js/app.js
  2. 7
      static/js/controllers/chatroomcontroller.js
  3. 8
      static/js/controllers/mediastreamcontroller.js
  4. 36
      static/js/directives/audiolevel.js
  5. 4
      static/js/directives/chat.js
  6. 22
      static/js/directives/screenshare.js
  7. 12
      static/js/filters/buddyimagesrc.js
  8. 6
      static/js/filters/displayconference.js
  9. 2
      static/js/filters/displayname.js
  10. 3
      static/js/mediastream/connector.js
  11. 24
      static/js/mediastream/peerscreenshare.js
  12. 4
      static/js/mediastream/tokens.js
  13. 10
      static/js/mediastream/utils.js
  14. 12
      static/js/mediastream/webrtc.js
  15. 2
      static/js/modules/angular-humanize.js
  16. 4
      static/js/services/buddylist.js
  17. 4
      static/js/services/enrichmessage.js
  18. 4
      static/js/services/filetransfer.js
  19. 6
      static/js/services/fileupload.js
  20. 6
      static/js/services/mediastream.js
  21. 5
      static/js/services/randomgen.js
  22. 2
      static/js/services/safedisplayname.js
  23. 12
      static/js/services/toastr.js

8
static/js/app.js

@ -47,7 +47,7 @@ define([ @@ -47,7 +47,7 @@ define([
// angular App is bootstrap to control initialization parameters like translation based on URL parameters.
var urlQuery = (function() {
return (function(a) {
if (a == "") {
if (a === "") {
return {};
}
var b = {};
@ -121,7 +121,7 @@ define([ @@ -121,7 +121,7 @@ define([
_.each(globalContext.Languages, function(l) {
wanted.push(l);
if (l.indexOf("-") != -1) {
wanted.push(l.split("-")[0])
wanted.push(l.split("-")[0]);
}
});
// Loop through browser languages and use first one we got.
@ -151,7 +151,7 @@ define([ @@ -151,7 +151,7 @@ define([
"lang": lang,
"plural_forms" : "nplurals=2; plural=(n != 1);"
}
}
};
}
// Set date language too.
moment.lang([lang, "en"]);
@ -160,7 +160,7 @@ define([ @@ -160,7 +160,7 @@ define([
// Bootstrap AngularJS app.
console.log("Bootstrapping ...");
angular.bootstrap(document, ['app']);
}
};
if (lang !== "en") {
// Load translation file.

7
static/js/controllers/chatroomcontroller.js

@ -312,10 +312,10 @@ define(['underscore', 'moment', 'text!partials/fileinfo.html'], function(_, mome @@ -312,10 +312,10 @@ define(['underscore', 'moment', 'text!partials/fileinfo.html'], function(_, mome
showTitleAndPicture()
}
var message = s.join(" ");
var strMessage = s.join(" ");
if (!is_new_message) {
var element = this.append(message, nodes);
var element = this.append(strMessage, nodes);
if (element) {
return element;
}
@ -336,7 +336,7 @@ define(['underscore', 'moment', 'text!partials/fileinfo.html'], function(_, mome @@ -336,7 +336,7 @@ define(['underscore', 'moment', 'text!partials/fileinfo.html'], function(_, mome
nodes = ts;
}
}
return $scope.display(message, nodes, extra_css, title, picture);
return $scope.display(strMessage, nodes, extra_css, title, picture);
};
@ -381,7 +381,6 @@ define(['underscore', 'moment', 'text!partials/fileinfo.html'], function(_, mome @@ -381,7 +381,6 @@ define(['underscore', 'moment', 'text!partials/fileinfo.html'], function(_, mome
$scope.showtime(new Date());
$scope.display(null, data.Log);
break;
case "Message":
default:
// Definitions.

8
static/js/controllers/mediastreamcontroller.js

@ -484,13 +484,11 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function @@ -484,13 +484,11 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function
switch (msgid) {
case "failed_getusermedia":
message = translation._("Failed to access camera/microphone.");
break
break;
case "failed_peerconnection_setup":
case "failed_peerconnection":
message = translation._("Failed to establish peer connection.")
break
default:
break
break;
}
if (!message) {
message = msgid;
@ -507,7 +505,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function @@ -507,7 +505,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function
var reconnect = function() {
if (connected && autoreconnect) {
if (resurrect == null) {
if (resurrect === null) {
// Storage data at the resurrection shrine.
resurrect = {
status: $scope.getStatus(),

36
static/js/directives/audiolevel.js

@ -65,7 +65,7 @@ define(['jquery', 'underscore', 'rAF'], function($, _) { @@ -65,7 +65,7 @@ define(['jquery', 'underscore', 'rAF'], function($, _) {
this.meter = _.bind(function() {
var talking;
var talking;
if (this.active) {
var level = Math.round(100 * webrtc.usermedia.audioLevel);
if (level < threshhold) {
@ -80,25 +80,25 @@ define(['jquery', 'underscore', 'rAF'], function($, _) { @@ -80,25 +80,25 @@ define(['jquery', 'underscore', 'rAF'], function($, _) {
this.audioActivityMeter = this.audioActivityHistory.reduce(function(a, b) {
return a + b;
}) / this.audioActivityHistory.length;
//console.log("audioActivityMeter", this.audioActivityMeter, $scope.talking);
if (!$scope.talking) {
talking = this.audioActivityMeter > activityThreshold ? true : false;
} else {
talking = this.audioActivityMeter > activityThresholdInactivity ? true : false;
}
} else {
// Clean up.
//console.log("cleaning up");
this.audioActivityHistory = [];
this.audioActivityMeter = 0;
//console.log("audioActivityMeter", this.audioActivityMeter, $scope.talking);
if (!$scope.talking) {
talking = this.audioActivityMeter > activityThreshold ? true : false;
} else {
talking = this.audioActivityMeter > activityThresholdInactivity ? true : false;
}
} else {
// Clean up.
//console.log("cleaning up");
this.audioActivityHistory = [];
this.audioActivityMeter = 0;
talking = false;
}
if (talking !== $scope.talking) {
// Apply to scope.
//console.log("talking changed", talking);
safeApply($scope, function() {
}
if (talking !== $scope.talking) {
// Apply to scope.
//console.log("talking changed", talking);
safeApply($scope, function() {
$scope.talking = talking;
});
});
}
// Check peer changes and update state for peers and keep history.

4
static/js/directives/chat.js

@ -142,8 +142,8 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'], @@ -142,8 +142,8 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
return scope.showRoom(controller.group, stngs, options);
};
scope.showRoom = function(id, settings, options) {
var options = $.extend({}, options);
scope.showRoom = function(id, settings, opts) {
var options = $.extend({}, opts);
var subscope = controller.rooms[id];
var index = controller.visibleRooms.length;
if (!subscope) {

22
static/js/directives/screenshare.js

@ -48,12 +48,14 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials @@ -48,12 +48,14 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials
return;
}
// Control data request.
var msg;
try {
var msg = JSON.parse(data);
msg = JSON.parse(data);
} catch(e) {
// Invalid JSON.
console.warn("Invalid JSON received from screen share channel.", data);
peerscreenshare.close()
peerscreenshare.close();
return;
}
switch (msg.m) {
@ -274,17 +276,17 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials @@ -274,17 +276,17 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials
} else {
BigScreen.toggle(pane.get(0));
}
}
}
};
$scope.$watch("layout.screenshare", function(newval, oldval) {
if (newval && !oldval) {
$scope.doScreenshare();
} else if(!newval && oldval) {
$scope.stopScreenshare();
}
});
$scope.$watch("layout.screenshare", function(newval, oldval) {
if (newval && !oldval) {
$scope.doScreenshare();
} else if(!newval && oldval) {
$scope.stopScreenshare();
}
});
}];

12
static/js/filters/buddyimagesrc.js

@ -24,14 +24,15 @@ define(["underscore"], function(_) { @@ -24,14 +24,15 @@ define(["underscore"], function(_) {
var dataURLToBlob = (function() {
var is_base64 = ";base64,";
return function(dataURL) {
var parts, ct;
if (dataURL.indexOf(is_base64) === -1) {
// No base64.
var parts = dataURL.split(",");
var ct = parts[0].split(":")[1];
parts = dataURL.split(",");
ct = parts[0].split(":")[1];
return new Blob([parts[1]], {type: ct});
}
var parts = dataURL.split(is_base64);
var ct = parts[0].split(":")[1];
parts = dataURL.split(is_base64);
ct = parts[0].split(":")[1];
var data = window.atob(parts[1]);
var length = data.length;
var buffer = new Uint8Array(length);
@ -101,7 +102,8 @@ define(["underscore"], function(_) { @@ -101,7 +102,8 @@ define(["underscore"], function(_) {
}
}
return "";
}
};
}];
});

6
static/js/filters/displayconference.js

@ -27,11 +27,11 @@ define([], function() { @@ -27,11 +27,11 @@ define([], function() {
return "";
}
if (peers.length === 1) {
return " " + translation._("and %s", safeDisplayName(peers[0]))
return " " + translation._("and %s", safeDisplayName(peers[0]));
} else {
return " " + translation._("and %d others", peers.length);
return " " + translation._("and %d others", peers.length);
}
}
};
}];
});

2
static/js/filters/displayname.js

@ -59,7 +59,7 @@ define([], function() { @@ -59,7 +59,7 @@ define([], function() {
}
return someone;
}
}
};
}];
});

3
static/js/mediastream/connector.js

@ -132,8 +132,7 @@ define(['jquery', 'underscore', 'ua-parser'], function($, _, uaparser) { @@ -132,8 +132,7 @@ define(['jquery', 'underscore', 'ua-parser'], function($, _, uaparser) {
}
this.roomid = roomid;
var roomid = this.roomid ? this.roomid : "";
roomid = this.roomid ? this.roomid : "";
if (cb) {
cb();

24
static/js/mediastream/peerscreenshare.js

@ -49,13 +49,13 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens'], f @@ -49,13 +49,13 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens'], f
};
this.sdpConstraints = {
mandatory: {
OfferToReceiveAudio: false,
OfferToReceiveVideo: true
}
OfferToReceiveAudio: false,
OfferToReceiveVideo: true
}
};
// SCTP is supported from Chrome M31.
// No need to pass DTLS constraint as it is on by default in Chrome M31.
// For SCTP, reliable and ordered is true by default.
// No need to pass DTLS constraint as it is on by default in Chrome M31.
// For SCTP, reliable and ordered is true by default.
this.pcConstraints = {};
// Inject token into sessiondescription and ice candidate data.
@ -75,16 +75,16 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens'], f @@ -75,16 +75,16 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens'], f
// support in Chrome 31+. This needs to be enabled in flags:
// chrome://flags/#enable-usermedia-screen-capture
var mandatoryVideoConstraints = $.extend({
chromeMediaSource: 'screen',
maxWidth: screenWidth,
maxHeight: screenHeight
}, options);
chromeMediaSource: 'screen',
maxWidth: screenWidth,
maxHeight: screenHeight
}, options);
var mediaConstraints = {
audio: false,
video: {
mandatory: mandatoryVideoConstraints,
optional: []
}
mandatory: mandatoryVideoConstraints,
optional: []
}
}
console.log("Setting screen sharing media constraints", mandatoryVideoConstraints);
return mediaConstraints;

4
static/js/mediastream/tokens.js

@ -136,7 +136,7 @@ define(['jquery', 'underscore'], function(jquery, _) { @@ -136,7 +136,7 @@ define(['jquery', 'underscore'], function(jquery, _) {
var creator = this.handlers[obj.handlerKey];
if (!creator) {
console.warn("Incoming offer for unknown handler", obj.handlerKey);
return
return;
}
// Create new handler based on type.
handler = creator(webrtc, id, token, from);
@ -163,7 +163,7 @@ define(['jquery', 'underscore'], function(jquery, _) { @@ -163,7 +163,7 @@ define(['jquery', 'underscore'], function(jquery, _) {
break;
case "Candidate":
var candidate = new RTCIceCandidate({sdpMLineIndex: data.sdpMLineIndex, sdpMid: data.sdpMid, candidate: data.candidate});
handler.addIceCandidate(candidate);
handler.addIceCandidate(candidate);
break;
default:
//console.log("Processing token message", type, token);

10
static/js/mediastream/utils.js

@ -44,9 +44,10 @@ define(['jquery', 'underscore'], function($, _) { @@ -44,9 +44,10 @@ define(['jquery', 'underscore'], function($, _) {
var sdpLines = sdp.split('\r\n');
var opusPayload = "";
var fmtpLineIndex = null;
var i;
// Find opus payload.
for (var i = 0; i < sdpLines.length; i++) {
for (i=0; i < sdpLines.length; i++) {
if (sdpLines[i].search('opus/48000') !== -1) {
opusPayload = this.extractSdp(sdpLines[i], /:(\d+) opus\/48000/i);
break;
@ -54,7 +55,7 @@ define(['jquery', 'underscore'], function($, _) { @@ -54,7 +55,7 @@ define(['jquery', 'underscore'], function($, _) {
}
// Find the payload in fmtp line.
for (var i = 0; i < sdpLines.length; i++) {
for (i=0; i < sdpLines.length; i++) {
if (sdpLines[i].search('a=fmtp') !== -1) {
var payload = this.extractSdp(sdpLines[i], /a=fmtp:(\d+)/ );
if (payload === opusPayload) {
@ -83,9 +84,10 @@ define(['jquery', 'underscore'], function($, _) { @@ -83,9 +84,10 @@ define(['jquery', 'underscore'], function($, _) {
var sdpLines = sdp.split('\r\n');
var mLineIndex = null;
var i;
// Search for m line.
for (var i = 0; i < sdpLines.length; i++) {
for (i=0; i < sdpLines.length; i++) {
if (sdpLines[i].search('m=audio') !== -1) {
mLineIndex = i;
break;
@ -96,7 +98,7 @@ define(['jquery', 'underscore'], function($, _) { @@ -96,7 +98,7 @@ define(['jquery', 'underscore'], function($, _) {
}
// If Opus is available, set it as the default in m line.
for (var i = 0; i < sdpLines.length; i++) {
for (i=0; i < sdpLines.length; i++) {
if (sdpLines[i].search('opus/48000') !== -1) {
var opusPayload = this.extractSdp(sdpLines[i], /:(\d+) opus\/48000/i);
if (opusPayload) {

12
static/js/mediastream/webrtc.js

@ -208,6 +208,8 @@ define([ @@ -208,6 +208,8 @@ define([
return;
}
var targetcall;
switch (type) {
case "Offer":
var busy = false;
@ -239,7 +241,7 @@ define([ @@ -239,7 +241,7 @@ define([
}
break;
case "Candidate":
var targetcall = this.findTargetCall(from);
targetcall = this.findTargetCall(from);
if (!targetcall) {
console.warn("Received Candidate for unknown id -> ignore.", from);
return;
@ -249,7 +251,7 @@ define([ @@ -249,7 +251,7 @@ define([
//console.log("Got candidate", data.sdpMid, data.sdpMLineIndex, data.candidate);
break;
case "Answer":
var targetcall = this.findTargetCall(from);
targetcall = this.findTargetCall(from);
if (!targetcall) {
console.warn("Received Answer from unknown id -> ignore", from);
return;
@ -263,7 +265,7 @@ define([ @@ -263,7 +265,7 @@ define([
targetcall.setRemoteDescription(new RTCSessionDescription(data));
break;
case "Bye":
var targetcall = this.findTargetCall(from);
targetcall = this.findTargetCall(from);
if (!targetcall) {
console.warn("Received Bye from unknown id -> ignore.", from);
return;
@ -440,7 +442,7 @@ define([ @@ -440,7 +442,7 @@ define([
case "completed":
case "connected":
// Do nothing here, we wait for dataReady.
break
break;
case "disconnected":
opts.error(currentxfer);
break;
@ -514,7 +516,7 @@ define([ @@ -514,7 +516,7 @@ define([
case "completed":
case "connected":
opts.connected(currentscreenshare);
break
break;
case "disconnected":
opts.error(currentscreenshare);
break;

2
static/js/modules/angular-humanize.js vendored

@ -65,7 +65,7 @@ ngHumanize.filter("humanizeRelativeTime", function() { @@ -65,7 +65,7 @@ ngHumanize.filter("humanizeRelativeTime", function() {
* http://en.wikipedia.org/wiki/Ordinal_number_(linguistics)
*/
ngHumanize.filter("humanizeOrdinal", function() {
return function(input) {
return function(format) {
return humanize.ordinal(format);
}
});

4
static/js/services/buddylist.js

@ -105,7 +105,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -105,7 +105,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
BuddyTree.prototype.clear = function() {
this.tree.clear();
this.data + {};
this.data = {};
};
@ -291,7 +291,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -291,7 +291,7 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
processed++;
refresh = true;
if (processed > 10) {
break
break;
}
}

4
static/js/services/enrichmessage.js

@ -26,9 +26,9 @@ define([], function() { @@ -26,9 +26,9 @@ define([], function() {
var linky = $filter("linky");
var enrichMessage = {
url: function(s) {
var s = linky(s);
s = linky(s);
s = s.replace(/<a/g, '<a rel="external"');
return s
return s;
},
multiline: function(s) {
s = s.replace(/\r\n/g, "<br/>");

4
static/js/services/filetransfer.js

@ -118,7 +118,7 @@ @@ -118,7 +118,7 @@
// SCTP does not work properly in Chrome 31 when used with other Chrome versions.
// Thus we require Chrome 32 for now. Firefox 28 can interop with Chrome 32 data channels - yay.
var supported =
var supported =
($window.webrtcDetectedBrowser === "chrome" && $window.webrtcDetectedVersion >= 32 && !$window.webrtcDetectedAndroid) ||
($window.webrtcDetectedBrowser === "firefox" && $window.webrtcDetectedVersion >= 28 && !$window.webrtcDetectedAndroid);
if (!supported) {
@ -140,7 +140,7 @@ @@ -140,7 +140,7 @@
return filechunk;
default:
console.warn("Unknow data version.");
break
break;
}
},
makeChunk: function(idx, data) {

6
static/js/services/fileupload.js

@ -56,13 +56,15 @@ define(["jquery", "underscore", "webrtc.adapter"], function($, _) { @@ -56,13 +56,15 @@ define(["jquery", "underscore", "webrtc.adapter"], function($, _) {
return;
}
// Control data request.
var msg;
try {
var msg = JSON.parse(data);
msg = JSON.parse(data);
} catch(e) {
// Invalid JSON.
console.warn("Invalid JSON received from file download request.", data);
xfer.cancel()
xfer.cancel();
delete this.connections[xfer.id];
return;
}
this.processRequest(scope, xfer, msg);

6
static/js/services/mediastream.js

@ -180,7 +180,7 @@ define([ @@ -180,7 +180,7 @@ define([
return login;
default:
console.warn("Unknown stored credentials", login.v);
break
break;
}
}
return null;
@ -236,7 +236,7 @@ define([ @@ -236,7 +236,7 @@ define([
if (!ready && room !== defaultRoom && !room) {
// First start.
$location.path("/"+defaultRoom).replace();
return
return;
}
console.info("Selected room is:", [room]);
if (!ready || !cont) {
@ -318,7 +318,7 @@ define([ @@ -318,7 +318,7 @@ define([
}
}).
error(function(data, status) {
if ((status == 403 || status == 413) && data.success == false) {
if ((status == 403 || status == 413) && data.success === false) {
alertify.dialog.error(translation._("Access denied"), translation._("Please provide a valid access code."), function() {
prompt();
});

5
static/js/services/randomgen.js

@ -59,13 +59,14 @@ define(["underscore"], function(_) { @@ -59,13 +59,14 @@ define(["underscore"], function(_) {
} else {
return s;
}
}
};
} else {
return makeRandomId;
}
}()),
binStringToHex: binStringToHex
}
};
return randomGen;
}];

2
static/js/services/safedisplayname.js

@ -23,7 +23,7 @@ define([], function() { @@ -23,7 +23,7 @@ define([], function() {
// safeDisplayName
return ["safeMessage", "$filter", function(safeMessage, $filter) {
var displayName = $filter("displayName");
var displayName = $filter("displayName");
return function() {
var s = displayName.apply(this, arguments);
return safeMessage(s);

12
static/js/services/toastr.js

@ -26,12 +26,12 @@ define(['toastr'], function(toastr) { @@ -26,12 +26,12 @@ define(['toastr'], function(toastr) {
// set default options
toastr.options = {
"debug": false,
"positionClass": "toast-bottom-right",
"onclick": null,
"fadeIn": 500,
"fadeOut": 500,
"timeOut": 0,
"extendedTimeOut": 0
"positionClass": "toast-bottom-right",
"onclick": null,
"fadeIn": 500,
"fadeOut": 500,
"timeOut": 0,
"extendedTimeOut": 0
}
return toastr;

Loading…
Cancel
Save