Commit d595e656 authored by Joel Martin's avatar Joel Martin

JSLint.

parent 2f6a1c2b
......@@ -41,18 +41,22 @@
*
* ***** END LICENSE BLOCK ***** */
Base64 = {
"use strict";
/*jslint white: false, bitwise: false, plusplus: false */
/*global console */
var Base64 = {
/* Convert data (an array of integers) to a Base64 string. */
toBase64Table : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
base64Pad : '=',
encode: function (data) {
var result = '';
var chrTable = Base64.toBase64Table.split('');
var pad = Base64.base64Pad;
var length = data.length;
var i;
var result = '',
chrTable = Base64.toBase64Table.split(''),
pad = Base64.base64Pad,
length = data.length,
i;
// Convert every three bytes to 4 ascii characters.
for (i = 0; i < (length - 2); i += 3) {
result += chrTable[data[i] >> 2];
......@@ -65,7 +69,7 @@ encode: function (data) {
if (length%3) {
i = length - (length%3);
result += chrTable[data[i] >> 2];
if ((length%3) == 2) {
if ((length%3) === 2) {
result += chrTable[((data[i] & 0x03) << 4) + (data[i+1] >> 4)];
result += chrTable[(data[i+1] & 0x0f) << 2];
result += pad;
......@@ -91,26 +95,26 @@ toBinaryTable : [
],
decode: function (data, offset) {
offset = typeof(offset) != 'undefined' ? offset : 0;
var binTable = Base64.toBinaryTable;
var pad = Base64.base64Pad;
var leftbits = 0; // number of bits decoded, but yet to be appended
var leftdata = 0; // bits decoded, but yet to be appended
offset = typeof(offset) !== 'undefined' ? offset : 0;
var binTable = Base64.toBinaryTable,
pad = Base64.base64Pad,
result, result_length, idx, i, c, padding,
leftbits = 0, // number of bits decoded, but yet to be appended
leftdata = 0, // bits decoded, but yet to be appended
data_length = data.indexOf('=') - offset;
/* Every four characters is 3 resulting numbers */
var data_length = data.indexOf('=') - offset;
if (data_length < 0) data_length = data.length - offset;
if (data_length < 0) { data_length = data.length - offset; }
var result_length = (data_length >> 2) * 3 + Math.floor((data_length%4)/1.5);
var result = new Array(result_length);
/* Every four characters is 3 resulting numbers */
result_length = (data_length >> 2) * 3 + Math.floor((data_length%4)/1.5);
result = new Array(result_length);
// Convert one by one.
var idx = 0;
for (var i = offset; i < data.length; i++) {
var c = binTable[data.charCodeAt(i) & 0x7f];
var padding = (data.charAt(i) == pad);
for (idx = 0, i = offset; i < data.length; i++) {
c = binTable[data.charCodeAt(i) & 0x7f];
padding = (data.charAt(i) === pad);
// Skip illegal characters and whitespace
if (c == -1) {
if (c === -1) {
console.error("Illegal character '" + data.charCodeAt(i) + "'");
continue;
}
......@@ -123,16 +127,18 @@ decode: function (data, offset) {
if (leftbits >= 8) {
leftbits -= 8;
// Append if not padding.
if (!padding)
if (!padding) {
result[idx++] = (leftdata >> leftbits) & 0xff;
}
leftdata &= (1 << leftbits) - 1;
}
}
// If there are any bits left, the base64 string was corrupted
if (leftbits)
if (leftbits) {
throw {name: 'Base64-Error',
message: 'Corrupted base64 string'};
}
return result;
}
......
......@@ -77,7 +77,10 @@
* fine Java utilities: http://www.acme.com/java/
*/
DES = {
"use strict";
/*jslint white: false, bitwise: false, plusplus: false */
var DES = {
// Tables, permutations, S-boxes, etc.
......@@ -107,7 +110,7 @@ DES = {
46, 54, 29, 39, 50, 44,
32, 47, 43, 48, 38, 55,
33, 52, 45, 41, 49, 35,
28, 31, ],
28, 31 ],
SP1 : [ 0x01010400, 0x00000000, 0x00010000,
0x01010404, 0x01010004, 0x00010404, 0x00000004, 0x00010000,
0x00000400, 0x01010400, 0x01010404, 0x00000400, 0x01000404,
......@@ -237,52 +240,57 @@ DES = {
// Turn an 8-byte key into internal keys.
deskey : function(keyBlock, encrypting, KnL) {
var i, j, l, m, n;
var pc1m = new Array(56);
var pcr = new Array(56);
var kn = new Array(32);
var i, j, l, m, n,
pc1m = new Array(56),
pcr = new Array(56),
kn = new Array(32);
for (j = 0; j < 56; ++j) {
l = DES.pc1[j];
m = l & 07;
pc1m[j] = ((keyBlock[l >>> 3] & DES.bytebit[m]) != 0) ? 1: 0;
m = l & 0x7;
pc1m[j] = ((keyBlock[l >>> 3] & DES.bytebit[m]) !== 0) ? 1: 0;
}
for (i = 0; i < 16; ++i) {
if (encrypting)
if (encrypting) {
m = i << 1;
else
} else {
m = (15- i) << 1;
}
n = m + 1;
kn[m] = kn[n] = 0;
for (j = 0; j < 28; ++j) {
l = j + DES.totrot[i];
if (l < 28)
if (l < 28) {
pcr[j] = pc1m[l];
else
} else {
pcr[j] = pc1m[l - 28];
}
}
for (j = 28; j < 56; ++j) {
l = j + DES.totrot[i];
if (l < 56)
if (l < 56) {
pcr[j] = pc1m[l];
else
} else {
pcr[j] = pc1m[l - 28];
}
}
for (j = 0; j < 24; ++j) {
if (pcr[DES.pc2[j]] != 0)
if (pcr[DES.pc2[j]] !== 0) {
kn[m] |= DES.bigbyte[j];
if (pcr[DES.pc2[j + 24]] != 0)
}
if (pcr[DES.pc2[j + 24]] !== 0) {
kn[n] |= DES.bigbyte[j];
}
}
}
DES.cookey(kn, KnL);
},
cookey: function(raw, KnL) {
var raw0, raw1;
var rawi, KnLi;
var i;
var raw0, raw1,
rawi, KnLi,
i;
for (i = 0, rawi = 0, KnLi = 0; i < 16; ++i) {
raw0 = raw[rawi++];
......@@ -320,9 +328,9 @@ DES = {
// The DES function.
des: function(inInts, outInts, keys) {
var fval, work, right, leftt;
var round;
var keysi = 0;
var fval, work, right, leftt,
round,
keysi = 0;
leftt = inInts[0];
right = inInts[1];
......@@ -401,25 +409,26 @@ DES = {
// / Squash bytes down to ints.
squashBytesToInts: function (inBytes, inOff, outInts, outOff, intLen) {
for (var i = 0; i < intLen; ++i)
for (var i = 0; i < intLen; ++i) {
outInts[outOff + i] = ((inBytes[inOff + i * 4] & 0xff) << 24)
| ((inBytes[inOff + i * 4+ 1] & 0xff) << 16)
| ((inBytes[inOff + i * 4+ 2] & 0xff) << 8)
| (inBytes[inOff + i * 4+ 3] & 0xff);
}
},
// / Spread ints into unsigned bytes.
spreadIntsToBytes: function (inInts, inOff, outBytes, outOff, intLen) {
for (var i = 0; i < intLen; ++i) {
var i, j, idx;
for (i = 0; i < intLen; ++i) {
outBytes[outOff + i * 4] = (inInts[inOff + i] >>> 24) % 256;
outBytes[outOff + i * 4+ 1] = (inInts[inOff + i] >>> 16) % 256;
outBytes[outOff + i * 4+ 2] = (inInts[inOff + i] >>> 8) % 256;
outBytes[outOff + i * 4+ 3] = (inInts[inOff + i]) % 256;
}
/* Make unsigned */
var idx;
for (var i = 0; i < intLen; ++i) {
for (var j = 0; j < 4; j++) {
for (i = 0; i < intLen; ++i) {
for (j = 0; j < 4; j++) {
idx = outOff + i * 4 + j;
if (outBytes[idx] < 0) {
outBytes[idx] += 256;
......@@ -428,4 +437,4 @@ DES = {
}
}
}
};
......@@ -112,7 +112,7 @@ var that = {}, // Public API interface
fbu_rt_start : 0,
fbu_rt_total : 0,
fbu_rt_cnt : 0,
fbu_rt_cnt : 0
},
test_mode = false,
......
......@@ -7,7 +7,8 @@
*/
"use strict";
/*global window, VNC_uri_prefix */
/*jslint evil: true */
/*global window, document, VNC_uri_prefix */
// Globals defined here
var VNC_native_ws, WebSocket__swfLocation;
......
/*
* noVNC: HTML5 VNC client
* Copyright (C) 2010 Joel Martin
* Licensed under LGPL-3 (see LICENSE.LGPL-3)
*/
"use strict";
/*jslint browser: true, white: false */
/*global Util, VNC_frame_data, finish */
var rfb, mode, test_state, frame_idx, frame_length,
iteration, iterations, istart_time;
iteration, iterations, istart_time,
// Pre-declarations for jslint
send_array, next_iteration, queue_next_packet, do_packet;
// Override send_array
send_array = function (arr) {
// Stub out send_array
}
function next_iteration () {
var time, iter_time, end_time;
};
next_iteration = function () {
if (iteration === 0) {
frame_length = VNC_frame_data.length;
test_state = 'running';
......@@ -18,7 +29,7 @@ function next_iteration () {
if (test_state !== 'running') { return; }
iteration++;
iteration += 1;
if (iteration > iterations) {
finish();
return;
......@@ -30,10 +41,10 @@ function next_iteration () {
queue_next_packet();
}
};
function queue_next_packet () {
var frame, now, foffset, toffset, delay;
queue_next_packet = function () {
var frame, foffset, toffset, delay;
if (test_state !== 'running') { return; }
frame = VNC_frame_data[frame_idx];
......@@ -66,14 +77,14 @@ function queue_next_packet () {
} else {
setTimeout(do_packet, 1);
}
}
};
function do_packet () {
do_packet = function () {
//Util.Debug("Processing frame: " + frame_idx);
frame = VNC_frame_data[frame_idx];
rfb.recv_message({'data' : frame.slice(frame.indexOf('{', 1)+1)});
var frame = VNC_frame_data[frame_idx];
rfb.recv_message({'data' : frame.slice(frame.indexOf('{', 1) + 1)});
frame_idx += 1;
queue_next_packet();
}
};
<!--
noVNC example: simple example using default controls
-->
<html>
<!--
noVNC example: simple example using default controls
-->
<head>
<title>VNC Client</title>
<link rel="stylesheet" href="include/plain.css">
......
<!--
noVNC Example: Automatically connect on page load.
<html>
<!--
noVNC Example: Automatically connect on page load.
Connect parameters are provided in query string:
Connect parameters are provided in query string:
http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
-->
<html>
-->
<head>
<title>VNC Client</title>
<link rel="stylesheet" href="include/plain.css" title="plain">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment