Move to ES6 missing static methods

This commit is contained in:
Juanjo Diaz 2018-01-29 07:28:57 -08:00
parent 78db60c760
commit a607c19f45
2 changed files with 47 additions and 47 deletions

View File

@ -657,44 +657,44 @@ export default class Display {
this.onflush(); this.onflush();
} }
} }
static changeCursor(target, pixels, mask, hotx, hoty, w, h) {
if ((w === 0) || (h === 0)) {
target.style.cursor = 'none';
return;
}
const cur = [];
for (let y = 0; y < h; y++) {
for (let x = 0; x < w; x++) {
let idx = y * Math.ceil(w / 8) + Math.floor(x / 8);
const alpha = (mask[idx] << (x % 8)) & 0x80 ? 255 : 0;
idx = ((w * y) + x) * 4;
cur.push(pixels[idx + 2]); // red
cur.push(pixels[idx + 1]); // green
cur.push(pixels[idx]); // blue
cur.push(alpha); // alpha
}
}
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = w;
canvas.height = h;
let img;
if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) {
img = new ImageData(new Uint8ClampedArray(cur), w, h);
} else {
img = ctx.createImageData(w, h);
img.data.set(new Uint8ClampedArray(cur));
}
ctx.clearRect(0, 0, w, h);
ctx.putImageData(img, 0, 0);
const url = canvas.toDataURL();
target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default';
}
} }
// Class Methods
Display.changeCursor = (target, pixels, mask, hotx, hoty, w, h) => {
if ((w === 0) || (h === 0)) {
target.style.cursor = 'none';
return;
}
const cur = [];
for (let y = 0; y < h; y++) {
for (let x = 0; x < w; x++) {
let idx = y * Math.ceil(w / 8) + Math.floor(x / 8);
const alpha = (mask[idx] << (x % 8)) & 0x80 ? 255 : 0;
idx = ((w * y) + x) * 4;
cur.push(pixels[idx + 2]); // red
cur.push(pixels[idx + 1]); // green
cur.push(pixels[idx]); // blue
cur.push(alpha); // alpha
}
}
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = w;
canvas.height = h;
let img;
if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) {
img = new ImageData(new Uint8ClampedArray(cur), w, h);
} else {
img = ctx.createImageData(w, h);
img.data.set(new Uint8ClampedArray(cur));
}
ctx.clearRect(0, 0, w, h);
ctx.putImageData(img, 0, 0);
const url = canvas.toDataURL();
target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default';
};

View File

@ -1592,6 +1592,14 @@ export default class RFB extends EventTargetMixin {
Log.Info("Sending XVP operation " + op + " (version " + ver + ")"); Log.Info("Sending XVP operation " + op + " (version " + ver + ")");
RFB.messages.xvpOp(this._sock, ver, op); RFB.messages.xvpOp(this._sock, ver, op);
} }
static genDES(password, challenge) {
const passwd = [];
for (let i = 0; i < password.length; i++) {
passwd.push(password.charCodeAt(i));
}
return (new DES(passwd)).encrypt(challenge);
};
} }
// Class Methods // Class Methods
@ -1892,14 +1900,6 @@ RFB.messages = {
} }
}; };
RFB.genDES = (password, challenge) => {
const passwd = [];
for (let i = 0; i < password.length; i++) {
passwd.push(password.charCodeAt(i));
}
return (new DES(passwd)).encrypt(challenge);
};
RFB.encodingHandlers = { RFB.encodingHandlers = {
RAW() { RAW() {
if (this._FBU.lines === 0) { if (this._FBU.lines === 0) {