Fix style according to airbnb guidelines (only auto-fixes)
This commit is contained in:
parent
98e1f3cb8b
commit
14e900c4ae
514
.eslintrc
514
.eslintrc
|
|
@ -18,5 +18,519 @@
|
|||
"arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
|
||||
"arrow-spacing": ["error"],
|
||||
"no-confusing-arrow": ["error", { "allowParens": true }],
|
||||
|
||||
// enforce line breaks after opening and before closing array brackets
|
||||
// https://eslint.org/docs/rules/array-bracket-newline
|
||||
// TODO: enable? semver-major
|
||||
"array-bracket-newline": ["off", "consistent"], // object option alternative: { multiline: true, minItems: 3 }
|
||||
|
||||
// enforce line breaks between array elements
|
||||
// https://eslint.org/docs/rules/array-element-newline
|
||||
// TODO: enable? semver-major
|
||||
"array-element-newline": ["off", { multiline: true, minItems: 3 }],
|
||||
|
||||
// enforce spacing inside array brackets
|
||||
"array-bracket-spacing": ["error", "never"],
|
||||
|
||||
// enforce spacing inside single-line blocks
|
||||
// https://eslint.org/docs/rules/block-spacing
|
||||
"block-spacing": ["error", "always"],
|
||||
|
||||
// enforce one true brace style
|
||||
"brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
||||
|
||||
// require camel case names
|
||||
// TODO: semver-major (eslint 5): add ignoreDestructuring: false option
|
||||
// camelcase: ["error", { properties: "never" }],
|
||||
|
||||
// enforce or disallow capitalization of the first letter of a comment
|
||||
// https://eslint.org/docs/rules/capitalized-comments
|
||||
"capitalized-comments": ["off", "never", {
|
||||
line: {
|
||||
ignorePattern: ".*",
|
||||
ignoreInlineComments: true,
|
||||
ignoreConsecutiveComments: true,
|
||||
},
|
||||
block: {
|
||||
ignorePattern: ".*",
|
||||
ignoreInlineComments: true,
|
||||
ignoreConsecutiveComments: true,
|
||||
},
|
||||
}],
|
||||
|
||||
// require trailing commas in multiline object literals
|
||||
// "comma-dangle": ["error", {
|
||||
// arrays: "always-multiline",
|
||||
// objects: "always-multiline",
|
||||
// imports: "always-multiline",
|
||||
// exports: "always-multiline",
|
||||
// functions: "always-multiline",
|
||||
// }],
|
||||
|
||||
// enforce spacing before and after comma
|
||||
"comma-spacing": ["error", { before: false, after: true }],
|
||||
|
||||
// enforce one true comma style
|
||||
"comma-style": ["error", "last", {
|
||||
exceptions: {
|
||||
ArrayExpression: false,
|
||||
ArrayPattern: false,
|
||||
ArrowFunctionExpression: false,
|
||||
CallExpression: false,
|
||||
FunctionDeclaration: false,
|
||||
FunctionExpression: false,
|
||||
ImportDeclaration: false,
|
||||
ObjectExpression: false,
|
||||
ObjectPattern: false,
|
||||
VariableDeclaration: false,
|
||||
NewExpression: false,
|
||||
}
|
||||
}],
|
||||
|
||||
// disallow padding inside computed properties
|
||||
"computed-property-spacing": ["error", "never"],
|
||||
|
||||
// enforces consistent naming when capturing the current execution context
|
||||
"consistent-this": "off",
|
||||
|
||||
// enforce newline at the end of file, with no multiple empty lines
|
||||
"eol-last": ["error", "always"],
|
||||
|
||||
// enforce spacing between functions and their invocations
|
||||
// https://eslint.org/docs/rules/func-call-spacing
|
||||
"func-call-spacing": ["error", "never"],
|
||||
|
||||
// requires function names to match the name of the variable or property to which they are
|
||||
// assigned
|
||||
// https://eslint.org/docs/rules/func-name-matching
|
||||
// TODO: semver-major (eslint 5): add considerPropertyDescriptor: true
|
||||
"func-name-matching": ["off", "always", {
|
||||
includeCommonJSModuleExports: false
|
||||
}],
|
||||
|
||||
// require function expressions to have a name
|
||||
// https://eslint.org/docs/rules/func-names
|
||||
// "func-names": "warn",
|
||||
|
||||
// enforces use of function declarations or expressions
|
||||
// https://eslint.org/docs/rules/func-style
|
||||
// TODO: enable
|
||||
"func-style": ["off", "expression"],
|
||||
|
||||
// enforce consistent line breaks inside function parentheses
|
||||
// https://eslint.org/docs/rules/function-paren-newline
|
||||
"function-paren-newline": ["error", "consistent"],
|
||||
|
||||
// Blacklist certain identifiers to prevent them being used
|
||||
// https://eslint.org/docs/rules/id-blacklist
|
||||
"id-blacklist": "off",
|
||||
|
||||
// this option enforces minimum and maximum identifier lengths
|
||||
// (variable names, property names etc.)
|
||||
"id-length": "off",
|
||||
|
||||
// require identifiers to match the provided regular expression
|
||||
"id-match": "off",
|
||||
|
||||
// Enforce the location of arrow function bodies with implicit returns
|
||||
// https://eslint.org/docs/rules/implicit-arrow-linebreak
|
||||
"implicit-arrow-linebreak": ["error", "beside"],
|
||||
|
||||
// this option sets a specific tab width for your code
|
||||
// https://eslint.org/docs/rules/indent
|
||||
indent: ["error", 2, {
|
||||
SwitchCase: 1,
|
||||
VariableDeclarator: 1,
|
||||
outerIIFEBody: 1,
|
||||
// MemberExpression: null,
|
||||
FunctionDeclaration: {
|
||||
parameters: 1,
|
||||
body: 1
|
||||
},
|
||||
FunctionExpression: {
|
||||
parameters: 1,
|
||||
body: 1
|
||||
},
|
||||
CallExpression: {
|
||||
arguments: 1
|
||||
},
|
||||
ArrayExpression: 1,
|
||||
ObjectExpression: 1,
|
||||
ImportDeclaration: 1,
|
||||
flatTernaryExpressions: false,
|
||||
// list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
|
||||
ignoredNodes: ["JSXElement", "JSXElement > *", "JSXAttribute", "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", "JSXSpreadAttribute", "JSXExpressionContainer", "JSXOpeningElement", "JSXClosingElement", "JSXText", "JSXEmptyExpression", "JSXSpreadChild"],
|
||||
ignoreComments: false
|
||||
}],
|
||||
|
||||
// specify whether double or single quotes should be used in JSX attributes
|
||||
// https://eslint.org/docs/rules/jsx-quotes
|
||||
"jsx-quotes": ["off", "prefer-double"],
|
||||
|
||||
// enforces spacing between keys and values in object literal properties
|
||||
"key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
||||
|
||||
// require a space before & after certain keywords
|
||||
"keyword-spacing": ["error", {
|
||||
before: true,
|
||||
after: true,
|
||||
overrides: {
|
||||
return: { after: true },
|
||||
throw: { after: true },
|
||||
case: { after: true }
|
||||
}
|
||||
}],
|
||||
|
||||
// enforce position of line comments
|
||||
// https://eslint.org/docs/rules/line-comment-position
|
||||
// TODO: enable?
|
||||
"line-comment-position": ["off", {
|
||||
position: "above",
|
||||
ignorePattern: "",
|
||||
applyDefaultPatterns: true,
|
||||
}],
|
||||
|
||||
// disallow mixed "LF" and "CRLF" as linebreaks
|
||||
// https://eslint.org/docs/rules/linebreak-style
|
||||
"linebreak-style": ["error", "unix"],
|
||||
|
||||
// require or disallow an empty line between class members
|
||||
// https://eslint.org/docs/rules/lines-between-class-members
|
||||
"lines-between-class-members": ["error", "always", { exceptAfterSingleLine: false }],
|
||||
|
||||
// enforces empty lines around comments
|
||||
"lines-around-comment": "off",
|
||||
|
||||
// require or disallow newlines around directives
|
||||
// https://eslint.org/docs/rules/lines-around-directive
|
||||
// "lines-around-directive": ["error", {
|
||||
// before: "always",
|
||||
// after: "always",
|
||||
// }],
|
||||
|
||||
// specify the maximum depth that blocks can be nested
|
||||
"max-depth": ["off", 4],
|
||||
|
||||
// specify the maximum length of a line in your program
|
||||
// https://eslint.org/docs/rules/max-len
|
||||
// "max-len": ["error", 100, 2, {
|
||||
// ignoreUrls: true,
|
||||
// ignoreComments: false,
|
||||
// ignoreRegExpLiterals: true,
|
||||
// ignoreStrings: true,
|
||||
// ignoreTemplateLiterals: true,
|
||||
// }],
|
||||
|
||||
// specify the max number of lines in a file
|
||||
// https://eslint.org/docs/rules/max-lines
|
||||
"max-lines": ["off", {
|
||||
max: 300,
|
||||
skipBlankLines: true,
|
||||
skipComments: true
|
||||
}],
|
||||
|
||||
// enforce a maximum function length
|
||||
// https://eslint.org/docs/rules/max-lines-per-function
|
||||
"max-lines-per-function": ["off", {
|
||||
max: 50,
|
||||
skipBlankLines: true,
|
||||
skipComments: true,
|
||||
IIFEs: true,
|
||||
}],
|
||||
|
||||
// specify the maximum depth callbacks can be nested
|
||||
"max-nested-callbacks": "off",
|
||||
|
||||
// limits the number of parameters that can be used in the function declaration.
|
||||
"max-params": ["off", 3],
|
||||
|
||||
// specify the maximum number of statement allowed in a function
|
||||
"max-statements": ["off", 10],
|
||||
|
||||
// restrict the number of statements per line
|
||||
// https://eslint.org/docs/rules/max-statements-per-line
|
||||
"max-statements-per-line": ["off", { max: 1 }],
|
||||
|
||||
// enforce a particular style for multiline comments
|
||||
// https://eslint.org/docs/rules/multiline-comment-style
|
||||
"multiline-comment-style": ["off", "starred-block"],
|
||||
|
||||
// require multiline ternary
|
||||
// https://eslint.org/docs/rules/multiline-ternary
|
||||
// TODO: enable?
|
||||
"multiline-ternary": ["off", "never"],
|
||||
|
||||
// require a capital letter for constructors
|
||||
"new-cap": ["error", {
|
||||
newIsCap: true,
|
||||
newIsCapExceptions: [],
|
||||
capIsNew: false,
|
||||
capIsNewExceptions: ["Immutable.Map", "Immutable.Set", "Immutable.List"],
|
||||
}],
|
||||
|
||||
// disallow the omission of parentheses when invoking a constructor with no arguments
|
||||
// https://eslint.org/docs/rules/new-parens
|
||||
"new-parens": "error",
|
||||
|
||||
// allow/disallow an empty newline after var statement
|
||||
"newline-after-var": "off",
|
||||
|
||||
// https://eslint.org/docs/rules/newline-before-return
|
||||
"newline-before-return": "off",
|
||||
|
||||
// enforces new line after each method call in the chain to make it
|
||||
// more readable and easy to maintain
|
||||
// https://eslint.org/docs/rules/newline-per-chained-call
|
||||
"newline-per-chained-call": ["error", { ignoreChainWithDepth: 4 }],
|
||||
|
||||
// disallow use of the Array constructor
|
||||
"no-array-constructor": "error",
|
||||
|
||||
// disallow use of bitwise operators
|
||||
// https://eslint.org/docs/rules/no-bitwise
|
||||
// "no-bitwise": "error",
|
||||
|
||||
// disallow use of the continue statement
|
||||
// https://eslint.org/docs/rules/no-continue
|
||||
// "no-continue": "error",
|
||||
|
||||
// disallow comments inline after code
|
||||
"no-inline-comments": "off",
|
||||
|
||||
// disallow if as the only statement in an else block
|
||||
// https://eslint.org/docs/rules/no-lonely-if
|
||||
"no-lonely-if": "error",
|
||||
|
||||
// disallow un-paren"d mixes of different operators
|
||||
// https://eslint.org/docs/rules/no-mixed-operators
|
||||
// "no-mixed-operators": ["error", {
|
||||
// // the list of arthmetic groups disallows mixing `%` and `**`
|
||||
// // with other arithmetic operators.
|
||||
// groups: [
|
||||
// ["%", "**"],
|
||||
// ["%", "+"],
|
||||
// ["%", "-"],
|
||||
// ["%", "*"],
|
||||
// ["%", "/"],
|
||||
// ["**", "+"],
|
||||
// ["**", "-"],
|
||||
// ["**", "*"],
|
||||
// ["**", "/"],
|
||||
// ["&", "|", "^", "~", "<<", ">>", ">>>"],
|
||||
// ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
||||
// ["&&", "||"],
|
||||
// ["in", "instanceof"]
|
||||
// ],
|
||||
// allowSamePrecedence: false
|
||||
// }],
|
||||
|
||||
// disallow mixed spaces and tabs for indentation
|
||||
"no-mixed-spaces-and-tabs": "error",
|
||||
|
||||
// disallow use of chained assignment expressions
|
||||
// https://eslint.org/docs/rules/no-multi-assign
|
||||
// "no-multi-assign": ["error"],
|
||||
|
||||
// disallow multiple empty lines and only one newline at the end
|
||||
"no-multiple-empty-lines": ["error", { max: 2, maxEOF: 0 }],
|
||||
|
||||
// disallow negated conditions
|
||||
// https://eslint.org/docs/rules/no-negated-condition
|
||||
"no-negated-condition": "off",
|
||||
|
||||
// disallow nested ternary expressions
|
||||
// "no-nested-ternary": "error",
|
||||
|
||||
// disallow use of the Object constructor
|
||||
"no-new-object": "error",
|
||||
|
||||
// disallow use of unary operators, ++ and --
|
||||
// https://eslint.org/docs/rules/no-plusplus
|
||||
// "no-plusplus": "error",
|
||||
|
||||
// disallow certain syntax forms
|
||||
// https://eslint.org/docs/rules/no-restricted-syntax
|
||||
"no-restricted-syntax": [
|
||||
"error",
|
||||
// {
|
||||
// selector: "ForInStatement",
|
||||
// message: "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.",
|
||||
// },
|
||||
{
|
||||
selector: "ForOfStatement",
|
||||
message: "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.",
|
||||
},
|
||||
{
|
||||
selector: "LabeledStatement",
|
||||
message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
|
||||
},
|
||||
{
|
||||
selector: "WithStatement",
|
||||
message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
|
||||
},
|
||||
],
|
||||
|
||||
// disallow space between function identifier and application
|
||||
"no-spaced-func": "error",
|
||||
|
||||
// disallow tab characters entirely
|
||||
"no-tabs": "error",
|
||||
|
||||
// disallow the use of ternary operators
|
||||
"no-ternary": "off",
|
||||
|
||||
// disallow trailing whitespace at the end of lines
|
||||
"no-trailing-spaces": ["error", {
|
||||
skipBlankLines: false,
|
||||
ignoreComments: false,
|
||||
}],
|
||||
|
||||
// disallow dangling underscores in identifiers
|
||||
// "no-underscore-dangle": ["error", {
|
||||
// allow: [],
|
||||
// allowAfterThis: true,
|
||||
// allowAfterSuper: false,
|
||||
// enforceInMethodNames: false,
|
||||
// }],
|
||||
|
||||
// disallow the use of Boolean literals in conditional expressions
|
||||
// also, prefer `a || b` over `a ? a : b`
|
||||
// https://eslint.org/docs/rules/no-unneeded-ternary
|
||||
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
||||
|
||||
// disallow whitespace before properties
|
||||
// https://eslint.org/docs/rules/no-whitespace-before-property
|
||||
"no-whitespace-before-property": "error",
|
||||
|
||||
// enforce the location of single-line statements
|
||||
// https://eslint.org/docs/rules/nonblock-statement-body-position
|
||||
"nonblock-statement-body-position": ["error", "beside", { overrides: {} }],
|
||||
|
||||
// require padding inside curly braces
|
||||
"object-curly-spacing": ["error", "always"],
|
||||
|
||||
// enforce line breaks between braces
|
||||
// https://eslint.org/docs/rules/object-curly-newline
|
||||
"object-curly-newline": ["error", {
|
||||
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
|
||||
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
|
||||
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
|
||||
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
|
||||
}],
|
||||
|
||||
// enforce "same line" or "multiple line" on object properties.
|
||||
// https://eslint.org/docs/rules/object-property-newline
|
||||
"object-property-newline": ["error", {
|
||||
allowAllPropertiesOnSameLine: true,
|
||||
}],
|
||||
|
||||
// allow just one var statement per function
|
||||
"one-var": ["error", "never"],
|
||||
|
||||
// require a newline around variable declaration
|
||||
// https://eslint.org/docs/rules/one-var-declaration-per-line
|
||||
"one-var-declaration-per-line": ["error", "always"],
|
||||
|
||||
// require assignment operator shorthand where possible or prohibit it entirely
|
||||
// https://eslint.org/docs/rules/operator-assignment
|
||||
"operator-assignment": ["error", "always"],
|
||||
|
||||
// Requires operator at the beginning of the line in multiline statements
|
||||
// https://eslint.org/docs/rules/operator-linebreak
|
||||
"operator-linebreak": ["error", "before", { overrides: { "=": "none" } }],
|
||||
|
||||
// disallow padding within blocks
|
||||
"padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
|
||||
|
||||
// Require or disallow padding lines between statements
|
||||
// https://eslint.org/docs/rules/padding-line-between-statements
|
||||
"padding-line-between-statements": "off",
|
||||
|
||||
// Prefer use of an object spread over Object.assign
|
||||
// https://eslint.org/docs/rules/prefer-object-spread
|
||||
// TODO: semver-major (eslint 5): enable
|
||||
"prefer-object-spread": "off",
|
||||
|
||||
// require quotes around object literal property names
|
||||
// https://eslint.org/docs/rules/quote-props.html
|
||||
"quote-props": ["error", "as-needed", { keywords: false, unnecessary: true, numbers: false }],
|
||||
|
||||
// specify whether double or single quotes should be used
|
||||
quotes: ["error", "single", { avoidEscape: true }],
|
||||
|
||||
// do not require jsdoc
|
||||
// https://eslint.org/docs/rules/require-jsdoc
|
||||
"require-jsdoc": "off",
|
||||
|
||||
// require or disallow use of semicolons instead of ASI
|
||||
semi: ["error", "always"],
|
||||
|
||||
// enforce spacing before and after semicolons
|
||||
"semi-spacing": ["error", { before: false, after: true }],
|
||||
|
||||
// Enforce location of semicolons
|
||||
// https://eslint.org/docs/rules/semi-style
|
||||
"semi-style": ["error", "last"],
|
||||
|
||||
// requires object keys to be sorted
|
||||
"sort-keys": ["off", "asc", { caseSensitive: false, natural: true }],
|
||||
|
||||
// sort variables within the same declaration block
|
||||
"sort-vars": "off",
|
||||
|
||||
// require or disallow space before blocks
|
||||
"space-before-blocks": "error",
|
||||
|
||||
// require or disallow space before function opening parenthesis
|
||||
// https://eslint.org/docs/rules/space-before-function-paren
|
||||
"space-before-function-paren": ["error", {
|
||||
anonymous: "always",
|
||||
named: "never",
|
||||
asyncArrow: "always"
|
||||
}],
|
||||
|
||||
// require or disallow spaces inside parentheses
|
||||
"space-in-parens": ["error", "never"],
|
||||
|
||||
// require spaces around operators
|
||||
"space-infix-ops": "error",
|
||||
|
||||
// Require or disallow spaces before/after unary operators
|
||||
// https://eslint.org/docs/rules/space-unary-ops
|
||||
"space-unary-ops": ["error", {
|
||||
words: true,
|
||||
nonwords: false,
|
||||
overrides: {
|
||||
},
|
||||
}],
|
||||
|
||||
// require or disallow a space immediately following the // or /* in a comment
|
||||
// https://eslint.org/docs/rules/spaced-comment
|
||||
"spaced-comment": ["error", "always", {
|
||||
line: {
|
||||
exceptions: ["-", "+"],
|
||||
markers: ["=", "!"], // space here to support sprockets directives
|
||||
},
|
||||
block: {
|
||||
exceptions: ["-", "+"],
|
||||
markers: ["=", "!"], // space here to support sprockets directives
|
||||
balanced: true,
|
||||
}
|
||||
}],
|
||||
|
||||
// Enforce spacing around colons of switch statements
|
||||
// https://eslint.org/docs/rules/switch-colon-spacing
|
||||
"switch-colon-spacing": ["error", { after: true, before: false }],
|
||||
|
||||
// Require or disallow spacing between template tags and their literals
|
||||
// https://eslint.org/docs/rules/template-tag-spacing
|
||||
"template-tag-spacing": ["error", "never"],
|
||||
|
||||
// require or disallow the Unicode Byte Order Mark
|
||||
// https://eslint.org/docs/rules/unicode-bom
|
||||
"unicode-bom": ["error", "never"],
|
||||
|
||||
// require regex literals to be wrapped in parentheses
|
||||
"wrap-regex": "off"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* eslint-disable prefer-arrow-callback */
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
// Fallback for all uncought errors
|
||||
function handleError(event, err) {
|
||||
|
|
@ -18,19 +18,19 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
let div = document.createElement("div");
|
||||
let div = document.createElement('div');
|
||||
div.classList.add('noVNC_message');
|
||||
div.appendChild(document.createTextNode(event.message));
|
||||
msg.appendChild(div);
|
||||
|
||||
if (event.filename) {
|
||||
div = document.createElement("div");
|
||||
div = document.createElement('div');
|
||||
div.className = 'noVNC_location';
|
||||
let text = event.filename;
|
||||
if (event.lineno !== undefined) {
|
||||
text += ":" + event.lineno;
|
||||
text += ':' + event.lineno;
|
||||
if (event.colno !== undefined) {
|
||||
text += ":" + event.colno;
|
||||
text += ':' + event.colno;
|
||||
}
|
||||
}
|
||||
div.appendChild(document.createTextNode(text));
|
||||
|
|
@ -38,16 +38,16 @@
|
|||
}
|
||||
|
||||
if (err && err.stack) {
|
||||
div = document.createElement("div");
|
||||
div = document.createElement('div');
|
||||
div.className = 'noVNC_stack';
|
||||
div.appendChild(document.createTextNode(err.stack));
|
||||
msg.appendChild(div);
|
||||
}
|
||||
|
||||
document.getElementById('noVNC_fallback_error')
|
||||
.classList.add("noVNC_open");
|
||||
.classList.add('noVNC_open');
|
||||
} catch (exc) {
|
||||
document.write("noVNC encountered an error.");
|
||||
document.write('noVNC encountered an error.');
|
||||
}
|
||||
// Don't return true since this would prevent the error
|
||||
// from being printed to the browser console.
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ export class Localizer {
|
|||
for (let i = 0; i < userLanguages.length; i++) {
|
||||
const userLang = userLanguages[i]
|
||||
.toLowerCase()
|
||||
.replace("_", "-")
|
||||
.split("-");
|
||||
.replace('_', '-')
|
||||
.split('-');
|
||||
|
||||
// Built-in default?
|
||||
if ((userLang[0] === 'en') &&
|
||||
((userLang[1] === undefined) || (userLang[1] === 'us'))) {
|
||||
if ((userLang[0] === 'en')
|
||||
&& ((userLang[1] === undefined) || (userLang[1] === 'us'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -50,13 +50,11 @@ export class Localizer {
|
|||
for (let j = 0; j < supportedLanguages.length; j++) {
|
||||
const supLang = supportedLanguages[j]
|
||||
.toLowerCase()
|
||||
.replace("_", "-")
|
||||
.split("-");
|
||||
.replace('_', '-')
|
||||
.split('-');
|
||||
|
||||
if (userLang[0] !== supLang[0])
|
||||
continue;
|
||||
if (userLang[1] !== supLang[1])
|
||||
continue;
|
||||
if (userLang[0] !== supLang[0]) continue;
|
||||
if (userLang[1] !== supLang[1]) continue;
|
||||
|
||||
this.language = supportedLanguages[j];
|
||||
return;
|
||||
|
|
@ -66,13 +64,11 @@ export class Localizer {
|
|||
for (let j = 0; j < supportedLanguages.length; j++) {
|
||||
const supLang = supportedLanguages[j]
|
||||
.toLowerCase()
|
||||
.replace("_", "-")
|
||||
.split("-");
|
||||
.replace('_', '-')
|
||||
.split('-');
|
||||
|
||||
if (userLang[0] !== supLang[0])
|
||||
continue;
|
||||
if (supLang[1] !== undefined)
|
||||
continue;
|
||||
if (userLang[0] !== supLang[0]) continue;
|
||||
if (supLang[1] !== undefined) continue;
|
||||
|
||||
this.language = supportedLanguages[j];
|
||||
return;
|
||||
|
|
@ -109,44 +105,44 @@ export class Localizer {
|
|||
node.data = str;
|
||||
}
|
||||
|
||||
if (elem.hasAttribute("translate")) {
|
||||
if (isAnyOf(elem.getAttribute("translate"), ["", "yes"])) {
|
||||
if (elem.hasAttribute('translate')) {
|
||||
if (isAnyOf(elem.getAttribute('translate'), ['', 'yes'])) {
|
||||
enabled = true;
|
||||
} else if (isAnyOf(elem.getAttribute("translate"), ["no"])) {
|
||||
} else if (isAnyOf(elem.getAttribute('translate'), ['no'])) {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
if (elem.hasAttribute("abbr") &&
|
||||
elem.tagName === "TH") {
|
||||
translateAttribute(elem, "abbr");
|
||||
if (elem.hasAttribute('abbr')
|
||||
&& elem.tagName === 'TH') {
|
||||
translateAttribute(elem, 'abbr');
|
||||
}
|
||||
if (elem.hasAttribute("alt") &&
|
||||
isAnyOf(elem.tagName, ["AREA", "IMG", "INPUT"])) {
|
||||
translateAttribute(elem, "alt");
|
||||
if (elem.hasAttribute('alt')
|
||||
&& isAnyOf(elem.tagName, ['AREA', 'IMG', 'INPUT'])) {
|
||||
translateAttribute(elem, 'alt');
|
||||
}
|
||||
if (elem.hasAttribute("download") &&
|
||||
isAnyOf(elem.tagName, ["A", "AREA"])) {
|
||||
translateAttribute(elem, "download");
|
||||
if (elem.hasAttribute('download')
|
||||
&& isAnyOf(elem.tagName, ['A', 'AREA'])) {
|
||||
translateAttribute(elem, 'download');
|
||||
}
|
||||
if (elem.hasAttribute("label") &&
|
||||
isAnyOf(elem.tagName, ["MENUITEM", "MENU", "OPTGROUP",
|
||||
"OPTION", "TRACK"])) {
|
||||
translateAttribute(elem, "label");
|
||||
if (elem.hasAttribute('label')
|
||||
&& isAnyOf(elem.tagName, ['MENUITEM', 'MENU', 'OPTGROUP',
|
||||
'OPTION', 'TRACK'])) {
|
||||
translateAttribute(elem, 'label');
|
||||
}
|
||||
// FIXME: Should update "lang"
|
||||
if (elem.hasAttribute("placeholder") &&
|
||||
isAnyOf(elem.tagName, ["INPUT", "TEXTAREA"])) {
|
||||
translateAttribute(elem, "placeholder");
|
||||
if (elem.hasAttribute('placeholder')
|
||||
&& isAnyOf(elem.tagName, ['INPUT', 'TEXTAREA'])) {
|
||||
translateAttribute(elem, 'placeholder');
|
||||
}
|
||||
if (elem.hasAttribute("title")) {
|
||||
translateAttribute(elem, "title");
|
||||
if (elem.hasAttribute('title')) {
|
||||
translateAttribute(elem, 'title');
|
||||
}
|
||||
if (elem.hasAttribute("value") &&
|
||||
elem.tagName === "INPUT" &&
|
||||
isAnyOf(elem.getAttribute("type"), ["reset", "button", "submit"])) {
|
||||
translateAttribute(elem, "value");
|
||||
if (elem.hasAttribute('value')
|
||||
&& elem.tagName === 'INPUT'
|
||||
&& isAnyOf(elem.getAttribute('type'), ['reset', 'button', 'submit'])) {
|
||||
translateAttribute(elem, 'value');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ import { init_logging as main_init_logging } from '../core/util/logging.js';
|
|||
|
||||
// init log level reading the logging HTTP param
|
||||
export function init_logging(level) {
|
||||
"use strict";
|
||||
if (typeof level !== "undefined") {
|
||||
'use strict';
|
||||
|
||||
if (typeof level !== 'undefined') {
|
||||
main_init_logging(level);
|
||||
} else {
|
||||
const param = document.location.href.match(/logging=([A-Za-z0-9._-]*)/);
|
||||
|
|
@ -22,9 +23,12 @@ export function init_logging (level) {
|
|||
|
||||
// Read a query string variable
|
||||
export function getQueryVar(name, defVal) {
|
||||
"use strict";
|
||||
const re = new RegExp('.*[?&]' + name + '=([^&#]*)'),
|
||||
match = document.location.href.match(re);
|
||||
'use strict';
|
||||
|
||||
const re = new RegExp('.*[?&]' + name + '=([^&#]*)');
|
||||
|
||||
|
||||
const match = document.location.href.match(re);
|
||||
if (typeof defVal === 'undefined') { defVal = null; }
|
||||
|
||||
if (match) {
|
||||
|
|
@ -36,9 +40,12 @@ export function getQueryVar (name, defVal) {
|
|||
|
||||
// Read a hash fragment variable
|
||||
export function getHashVar(name, defVal) {
|
||||
"use strict";
|
||||
const re = new RegExp('.*[&#]' + name + '=([^&]*)'),
|
||||
match = document.location.hash.match(re);
|
||||
'use strict';
|
||||
|
||||
const re = new RegExp('.*[&#]' + name + '=([^&]*)');
|
||||
|
||||
|
||||
const match = document.location.hash.match(re);
|
||||
if (typeof defVal === 'undefined') { defVal = null; }
|
||||
|
||||
if (match) {
|
||||
|
|
@ -51,7 +58,8 @@ export function getHashVar (name, defVal) {
|
|||
// Read a variable from the fragment or the query string
|
||||
// Fragment takes precedence
|
||||
export function getConfigVar(name, defVal) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
const val = getHashVar(name);
|
||||
|
||||
if (val === null) {
|
||||
|
|
@ -67,28 +75,31 @@ export function getConfigVar (name, defVal) {
|
|||
|
||||
// No days means only for this browser session
|
||||
export function createCookie(name, value, days) {
|
||||
"use strict";
|
||||
let date, expires;
|
||||
'use strict';
|
||||
|
||||
let date; let
|
||||
expires;
|
||||
if (days) {
|
||||
date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
expires = '; expires=' + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
expires = '';
|
||||
}
|
||||
|
||||
let secure;
|
||||
if (document.location.protocol === "https:") {
|
||||
secure = "; secure";
|
||||
if (document.location.protocol === 'https:') {
|
||||
secure = '; secure';
|
||||
} else {
|
||||
secure = "";
|
||||
secure = '';
|
||||
}
|
||||
document.cookie = name + "=" + value + expires + "; path=/" + secure;
|
||||
document.cookie = name + '=' + value + expires + '; path=/' + secure;
|
||||
}
|
||||
|
||||
export function readCookie(name, defaultValue) {
|
||||
"use strict";
|
||||
const nameEQ = name + "=";
|
||||
'use strict';
|
||||
|
||||
const nameEQ = name + '=';
|
||||
const ca = document.cookie.split(';');
|
||||
|
||||
for (let i = 0; i < ca.length; i += 1) {
|
||||
|
|
@ -105,8 +116,9 @@ export function readCookie (name, defaultValue) {
|
|||
}
|
||||
|
||||
export function eraseCookie(name) {
|
||||
"use strict";
|
||||
createCookie(name, "", -1);
|
||||
'use strict';
|
||||
|
||||
createCookie(name, '', -1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -116,7 +128,8 @@ export function eraseCookie (name) {
|
|||
let settings = {};
|
||||
|
||||
export function initSettings(callback /* , ...callbackArgs */) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
const callbackArgs = Array.prototype.slice.call(arguments, 1);
|
||||
if (window.chrome && window.chrome.storage) {
|
||||
window.chrome.storage.sync.get((cfg) => {
|
||||
|
|
@ -140,7 +153,8 @@ export function setSetting (name, value) {
|
|||
|
||||
// No days means only for this browser session
|
||||
export function writeSetting(name, value) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
if (settings[name] === value) return;
|
||||
settings[name] = value;
|
||||
if (window.chrome && window.chrome.storage) {
|
||||
|
|
@ -151,7 +165,8 @@ export function writeSetting (name, value) {
|
|||
}
|
||||
|
||||
export function readSetting(name, defaultValue) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
let value;
|
||||
if ((name in settings) || (window.chrome && window.chrome.storage)) {
|
||||
value = settings[name];
|
||||
|
|
@ -159,11 +174,11 @@ export function readSetting (name, defaultValue) {
|
|||
value = localStorage.getItem(name);
|
||||
settings[name] = value;
|
||||
}
|
||||
if (typeof value === "undefined") {
|
||||
if (typeof value === 'undefined') {
|
||||
value = null;
|
||||
}
|
||||
|
||||
if (value === null && typeof defaultValue !== "undefined") {
|
||||
if (value === null && typeof defaultValue !== 'undefined') {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +186,8 @@ export function readSetting (name, defaultValue) {
|
|||
}
|
||||
|
||||
export function eraseSetting(name) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
// Deleting here means that next time the setting is read when using local
|
||||
// storage, it will be pulled from local storage again.
|
||||
// If the setting in local storage is changed (e.g. in another tab)
|
||||
|
|
@ -188,12 +204,12 @@ export function eraseSetting (name) {
|
|||
export function injectParamIfMissing(path, param, value) {
|
||||
// force pretend that we're dealing with a relative path
|
||||
// (assume that we wanted an extra if we pass one in)
|
||||
path = "/" + path;
|
||||
path = '/' + path;
|
||||
|
||||
const elem = document.createElement('a');
|
||||
elem.href = path;
|
||||
|
||||
const param_eq = encodeURIComponent(param) + "=";
|
||||
const param_eq = encodeURIComponent(param) + '=';
|
||||
let query;
|
||||
if (elem.search) {
|
||||
query = elem.search.slice(1).split('&');
|
||||
|
|
@ -203,12 +219,12 @@ export function injectParamIfMissing (path, param, value) {
|
|||
|
||||
if (!query.some(v => v.startsWith(param_eq))) {
|
||||
query.push(param_eq + encodeURIComponent(value));
|
||||
elem.search = "?" + query.join("&");
|
||||
elem.search = '?' + query.join('&');
|
||||
}
|
||||
|
||||
// some browsers (e.g. IE11) may occasionally omit the leading slash
|
||||
// in the elem.pathname string. Handle that case gracefully.
|
||||
if (elem.pathname.charAt(0) == "/") {
|
||||
if (elem.pathname.charAt(0) == '/') {
|
||||
return elem.pathname.slice(1) + elem.search + elem.hash;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ export default {
|
|||
base64Pad: '=',
|
||||
|
||||
encode(data) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
let result = '';
|
||||
const length = data.length;
|
||||
const lengthpad = (length % 3);
|
||||
|
|
@ -73,7 +74,7 @@ export default {
|
|||
const padding = (data.charAt(i) === this.base64Pad);
|
||||
// Skip illegal characters and whitespace
|
||||
if (c === -1) {
|
||||
Log.Error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
|
||||
Log.Error('Illegal character code ' + data.charCodeAt(i) + ' at position ' + i);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
31
core/des.js
31
core/des.js
|
|
@ -76,16 +76,24 @@
|
|||
*/
|
||||
|
||||
export default function DES(passwd) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
/* eslint-disable indent, comma-spacing, space-infix-ops */
|
||||
// Tables, permutations, S-boxes, etc.
|
||||
const PC2 = [13,16,10,23, 0, 4, 2,27,14, 5,20, 9,22,18,11, 3,
|
||||
25, 7,15, 6,26,19,12, 1,40,51,30,36,46,54,29,39,
|
||||
50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31 ],
|
||||
totrot = [ 1, 2, 4, 6, 8,10,12,14,15,17,19,21,23,25,27,28],
|
||||
z = 0x0,
|
||||
keys = [];
|
||||
let a,b,c,d,e,f;
|
||||
50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31];
|
||||
const totrot = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
|
||||
|
||||
const z = 0x0;
|
||||
|
||||
const keys = [];
|
||||
let a;
|
||||
let b;
|
||||
let c;
|
||||
let d;
|
||||
let e;
|
||||
let f;
|
||||
|
||||
a=1<<16; b=1<<24; c=a|b; d=1<<2; e=1<<10; f=d|e;
|
||||
const SP1 = [c|e,z|z,a|z,c|f,c|d,a|f,z|d,a|z,z|e,c|e,c|f,z|e,b|f,c|d,b|z,z|d,
|
||||
|
|
@ -128,9 +136,12 @@ export default function DES(passwd) {
|
|||
a|f,a|z,c|e,z|e,z|d,c|d,z|e,a|f,b|e,z|d,b|d,c|z,c|d,b|z,a|z,b|f,
|
||||
z|z,c|f,a|d,b|d,c|z,b|e,b|f,z|z,c|f,a|e,a|e,z|f,z|f,a|d,b|z,c|e];
|
||||
|
||||
/* eslint-enable indent, comma-spacing, space-infix-ops */
|
||||
|
||||
// Set the key.
|
||||
function setKeys(keyBlock) {
|
||||
const pc1m = [], pcr = [], kn = [];
|
||||
const pc1m = []; const pcr = []; const
|
||||
kn = [];
|
||||
|
||||
for (let j = 0, l = 56; j < 56; ++j, l -= 8) {
|
||||
l += l < -5 ? 65 : l < -3 ? 31 : l < -1 ? 63 : l === 27 ? 35 : 0; // PC1
|
||||
|
|
@ -178,7 +189,8 @@ export default function DES(passwd) {
|
|||
// Encrypt 8 bytes of text
|
||||
function enc8(text) {
|
||||
const b = text.slice();
|
||||
let i = 0, l, r, x; // left, right, accumulator
|
||||
let i = 0; let l; let r; let
|
||||
x; // left, right, accumulator
|
||||
|
||||
// Squash 8 bytes to 2 ints
|
||||
l = b[i++] << 24 | b[i++] << 16 | b[i++] << 8 | b[i++];
|
||||
|
|
@ -262,6 +274,5 @@ export default function DES(passwd) {
|
|||
}
|
||||
|
||||
setKeys(passwd); // Setup keys
|
||||
return {'encrypt': encrypt}; // Public interface
|
||||
|
||||
return { encrypt: encrypt }; // Public interface
|
||||
}
|
||||
|
|
|
|||
122
core/display.js
122
core/display.js
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import * as Log from './util/logging.js';
|
||||
import Base64 from "./base64.js";
|
||||
import Base64 from './base64.js';
|
||||
|
||||
let SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
|
||||
try {
|
||||
|
|
@ -30,19 +30,19 @@ export default class Display {
|
|||
this._fb_width = 0;
|
||||
this._fb_height = 0;
|
||||
|
||||
this._prevDrawStyle = "";
|
||||
this._prevDrawStyle = '';
|
||||
this._tile = null;
|
||||
this._tile16x16 = null;
|
||||
this._tile_x = 0;
|
||||
this._tile_y = 0;
|
||||
|
||||
Log.Debug(">> Display.constructor");
|
||||
Log.Debug('>> Display.constructor');
|
||||
|
||||
// The visible canvas
|
||||
this._target = target;
|
||||
|
||||
if (!this._target) {
|
||||
throw new Error("Target must be set");
|
||||
throw new Error('Target must be set');
|
||||
}
|
||||
|
||||
if (typeof this._target === 'string') {
|
||||
|
|
@ -50,33 +50,38 @@ export default class Display {
|
|||
}
|
||||
|
||||
if (!this._target.getContext) {
|
||||
throw new Error("no getContext method");
|
||||
throw new Error('no getContext method');
|
||||
}
|
||||
|
||||
this._targetCtx = this._target.getContext('2d');
|
||||
|
||||
// the visible canvas viewport (i.e. what actually gets seen)
|
||||
this._viewportLoc = { 'x': 0, 'y': 0, 'w': this._target.width, 'h': this._target.height };
|
||||
this._viewportLoc = {
|
||||
x: 0, y: 0, w: this._target.width, h: this._target.height
|
||||
};
|
||||
|
||||
// The hidden canvas, where we do the actual rendering
|
||||
this._backbuffer = document.createElement('canvas');
|
||||
this._drawCtx = this._backbuffer.getContext('2d');
|
||||
|
||||
this._damageBounds = { left:0, top:0,
|
||||
this._damageBounds = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: this._backbuffer.width,
|
||||
bottom: this._backbuffer.height };
|
||||
bottom: this._backbuffer.height
|
||||
};
|
||||
|
||||
Log.Debug("User Agent: " + navigator.userAgent);
|
||||
Log.Debug('User Agent: ' + navigator.userAgent);
|
||||
|
||||
this.clear();
|
||||
|
||||
// Check canvas features
|
||||
if (!('createImageData' in this._drawCtx)) {
|
||||
throw new Error("Canvas does not support createImageData");
|
||||
throw new Error('Canvas does not support createImageData');
|
||||
}
|
||||
|
||||
this._tile16x16 = this._drawCtx.createImageData(16, 16);
|
||||
Log.Debug("<< Display.constructor");
|
||||
Log.Debug('<< Display.constructor');
|
||||
|
||||
// ===== PROPERTIES =====
|
||||
|
||||
|
|
@ -92,11 +97,13 @@ export default class Display {
|
|||
// ===== PROPERTIES =====
|
||||
|
||||
get scale() { return this._scale; }
|
||||
|
||||
set scale(scale) {
|
||||
this._rescale(scale);
|
||||
}
|
||||
|
||||
get clipViewport() { return this._clipViewport; }
|
||||
|
||||
set clipViewport(viewport) {
|
||||
this._clipViewport = viewport;
|
||||
// May need to readjust the viewport dimensions
|
||||
|
|
@ -147,7 +154,7 @@ export default class Display {
|
|||
if (deltaX === 0 && deltaY === 0) {
|
||||
return;
|
||||
}
|
||||
Log.Debug("viewportChange deltaX: " + deltaX + ", deltaY: " + deltaY);
|
||||
Log.Debug('viewportChange deltaX: ' + deltaX + ', deltaY: ' + deltaY);
|
||||
|
||||
vp.x += deltaX;
|
||||
vp.y += deltaY;
|
||||
|
|
@ -158,12 +165,10 @@ export default class Display {
|
|||
}
|
||||
|
||||
viewportChangeSize(width, height) {
|
||||
|
||||
if (!this._clipViewport ||
|
||||
typeof(width) === "undefined" ||
|
||||
typeof(height) === "undefined") {
|
||||
|
||||
Log.Debug("Setting viewport to full display region");
|
||||
if (!this._clipViewport
|
||||
|| typeof (width) === 'undefined'
|
||||
|| typeof (height) === 'undefined') {
|
||||
Log.Debug('Setting viewport to full display region');
|
||||
width = this._fb_width;
|
||||
height = this._fb_height;
|
||||
}
|
||||
|
|
@ -204,14 +209,13 @@ export default class Display {
|
|||
}
|
||||
|
||||
resize(width, height) {
|
||||
this._prevDrawStyle = "";
|
||||
this._prevDrawStyle = '';
|
||||
|
||||
this._fb_width = width;
|
||||
this._fb_height = height;
|
||||
|
||||
const canvas = this._backbuffer;
|
||||
if (canvas.width !== width || canvas.height !== height) {
|
||||
|
||||
// We have to save the canvas data since changing the size will clear it
|
||||
let saveImg = null;
|
||||
if (canvas.width > 0 && canvas.height > 0) {
|
||||
|
|
@ -258,7 +262,7 @@ export default class Display {
|
|||
flip(from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
this._renderQ_push({
|
||||
'type': 'flip'
|
||||
type: 'flip'
|
||||
});
|
||||
} else {
|
||||
let x = this._damageBounds.left;
|
||||
|
|
@ -327,12 +331,12 @@ export default class Display {
|
|||
fillRect(x, y, width, height, color, from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
this._renderQ_push({
|
||||
'type': 'fill',
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'color': color
|
||||
type: 'fill',
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
color: color
|
||||
});
|
||||
} else {
|
||||
this._setFillColor(color);
|
||||
|
|
@ -344,13 +348,13 @@ export default class Display {
|
|||
copyImage(old_x, old_y, new_x, new_y, w, h, from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
this._renderQ_push({
|
||||
'type': 'copy',
|
||||
'old_x': old_x,
|
||||
'old_y': old_y,
|
||||
'x': new_x,
|
||||
'y': new_y,
|
||||
'width': w,
|
||||
'height': h,
|
||||
type: 'copy',
|
||||
old_x: old_x,
|
||||
old_y: old_y,
|
||||
x: new_x,
|
||||
y: new_y,
|
||||
width: w,
|
||||
height: h,
|
||||
});
|
||||
} else {
|
||||
// Due to this bug among others [1] we need to disable the image-smoothing to
|
||||
|
|
@ -374,12 +378,12 @@ export default class Display {
|
|||
|
||||
imageRect(x, y, mime, arr) {
|
||||
const img = new Image();
|
||||
img.src = "data: " + mime + ";base64," + Base64.encode(arr);
|
||||
img.src = 'data: ' + mime + ';base64,' + Base64.encode(arr);
|
||||
this._renderQ_push({
|
||||
'type': 'img',
|
||||
'img': img,
|
||||
'x': x,
|
||||
'y': y
|
||||
type: 'img',
|
||||
img: img,
|
||||
x: x,
|
||||
y: y
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -442,12 +446,12 @@ export default class Display {
|
|||
const new_arr = new Uint8Array(width * height * 4);
|
||||
new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
|
||||
this._renderQ_push({
|
||||
'type': 'blit',
|
||||
'data': new_arr,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
type: 'blit',
|
||||
data: new_arr,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
});
|
||||
} else {
|
||||
this._bgrxImageData(x, y, width, height, arr, offset);
|
||||
|
|
@ -462,12 +466,12 @@ export default class Display {
|
|||
const new_arr = new Uint8Array(width * height * 3);
|
||||
new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
|
||||
this._renderQ_push({
|
||||
'type': 'blitRgb',
|
||||
'data': new_arr,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
type: 'blitRgb',
|
||||
data: new_arr,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
});
|
||||
} else {
|
||||
this._rgbImageData(x, y, width, height, arr, offset);
|
||||
|
|
@ -482,12 +486,12 @@ export default class Display {
|
|||
const new_arr = new Uint8Array(width * height * 4);
|
||||
new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
|
||||
this._renderQ_push({
|
||||
'type': 'blitRgbx',
|
||||
'data': new_arr,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
type: 'blitRgbx',
|
||||
data: new_arr,
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height,
|
||||
});
|
||||
} else {
|
||||
this._rgbxImageData(x, y, width, height, arr, offset);
|
||||
|
|
@ -527,8 +531,8 @@ export default class Display {
|
|||
const width = Math.round(factor * vp.w) + 'px';
|
||||
const height = Math.round(factor * vp.h) + 'px';
|
||||
|
||||
if ((this._target.style.width !== width) ||
|
||||
(this._target.style.height !== height)) {
|
||||
if ((this._target.style.width !== width)
|
||||
|| (this._target.style.height !== height)) {
|
||||
this._target.style.width = width;
|
||||
this._target.style.height = height;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ export const encodings = {
|
|||
|
||||
export function encodingName(num) {
|
||||
switch (num) {
|
||||
case encodings.encodingRaw: return "Raw";
|
||||
case encodings.encodingCopyRect: return "CopyRect";
|
||||
case encodings.encodingRRE: return "RRE";
|
||||
case encodings.encodingHextile: return "Hextile";
|
||||
case encodings.encodingTight: return "Tight";
|
||||
case encodings.encodingTightPNG: return "TightPNG";
|
||||
default: return "[unknown encoding " + num + "]";
|
||||
case encodings.encodingRaw: return 'Raw';
|
||||
case encodings.encodingCopyRect: return 'CopyRect';
|
||||
case encodings.encodingRRE: return 'RRE';
|
||||
case encodings.encodingHextile: return 'Hextile';
|
||||
case encodings.encodingTight: return 'Tight';
|
||||
case encodings.encodingTightPNG: return 'TightPNG';
|
||||
default: return '[unknown encoding ' + num + ']';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { inflateInit, inflate, inflateReset } from "../vendor/pako/lib/zlib/inflate.js";
|
||||
import ZStream from "../vendor/pako/lib/zlib/zstream.js";
|
||||
import { inflateInit, inflate, inflateReset } from '../vendor/pako/lib/zlib/inflate.js';
|
||||
import ZStream from '../vendor/pako/lib/zlib/zstream.js';
|
||||
|
||||
export default class Inflate {
|
||||
constructor() {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
||||
*/
|
||||
|
||||
import KeyTable from "./keysym.js";
|
||||
import KeyTable from './keysym.js';
|
||||
|
||||
/*
|
||||
* Mapping between HTML key values and VNC/X11 keysyms for "special"
|
||||
|
|
@ -15,202 +15,199 @@ import KeyTable from "./keysym.js";
|
|||
|
||||
const DOMKeyTable = {};
|
||||
|
||||
function addStandard(key, standard)
|
||||
{
|
||||
if (standard === undefined) throw "Undefined keysym for key \"" + key + "\"";
|
||||
if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\"";
|
||||
function addStandard(key, standard) {
|
||||
if (standard === undefined) throw 'Undefined keysym for key "' + key + '"';
|
||||
if (key in DOMKeyTable) throw 'Duplicate entry for key "' + key + '"';
|
||||
DOMKeyTable[key] = [standard, standard, standard, standard];
|
||||
}
|
||||
|
||||
function addLeftRight(key, left, right)
|
||||
{
|
||||
if (left === undefined) throw "Undefined keysym for key \"" + key + "\"";
|
||||
if (right === undefined) throw "Undefined keysym for key \"" + key + "\"";
|
||||
if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\"";
|
||||
function addLeftRight(key, left, right) {
|
||||
if (left === undefined) throw 'Undefined keysym for key "' + key + '"';
|
||||
if (right === undefined) throw 'Undefined keysym for key "' + key + '"';
|
||||
if (key in DOMKeyTable) throw 'Duplicate entry for key "' + key + '"';
|
||||
DOMKeyTable[key] = [left, left, right, left];
|
||||
}
|
||||
|
||||
function addNumpad(key, standard, numpad)
|
||||
{
|
||||
if (standard === undefined) throw "Undefined keysym for key \"" + key + "\"";
|
||||
if (numpad === undefined) throw "Undefined keysym for key \"" + key + "\"";
|
||||
if (key in DOMKeyTable) throw "Duplicate entry for key \"" + key + "\"";
|
||||
function addNumpad(key, standard, numpad) {
|
||||
if (standard === undefined) throw 'Undefined keysym for key "' + key + '"';
|
||||
if (numpad === undefined) throw 'Undefined keysym for key "' + key + '"';
|
||||
if (key in DOMKeyTable) throw 'Duplicate entry for key "' + key + '"';
|
||||
DOMKeyTable[key] = [standard, standard, standard, numpad];
|
||||
}
|
||||
|
||||
// 2.2. Modifier Keys
|
||||
|
||||
addLeftRight("Alt", KeyTable.XK_Alt_L, KeyTable.XK_Alt_R);
|
||||
addStandard("AltGraph", KeyTable.XK_ISO_Level3_Shift);
|
||||
addStandard("CapsLock", KeyTable.XK_Caps_Lock);
|
||||
addLeftRight("Control", KeyTable.XK_Control_L, KeyTable.XK_Control_R);
|
||||
addLeftRight('Alt', KeyTable.XK_Alt_L, KeyTable.XK_Alt_R);
|
||||
addStandard('AltGraph', KeyTable.XK_ISO_Level3_Shift);
|
||||
addStandard('CapsLock', KeyTable.XK_Caps_Lock);
|
||||
addLeftRight('Control', KeyTable.XK_Control_L, KeyTable.XK_Control_R);
|
||||
// - Fn
|
||||
// - FnLock
|
||||
addLeftRight("Hyper", KeyTable.XK_Super_L, KeyTable.XK_Super_R);
|
||||
addLeftRight("Meta", KeyTable.XK_Super_L, KeyTable.XK_Super_R);
|
||||
addStandard("NumLock", KeyTable.XK_Num_Lock);
|
||||
addStandard("ScrollLock", KeyTable.XK_Scroll_Lock);
|
||||
addLeftRight("Shift", KeyTable.XK_Shift_L, KeyTable.XK_Shift_R);
|
||||
addLeftRight("Super", KeyTable.XK_Super_L, KeyTable.XK_Super_R);
|
||||
addLeftRight('Hyper', KeyTable.XK_Super_L, KeyTable.XK_Super_R);
|
||||
addLeftRight('Meta', KeyTable.XK_Super_L, KeyTable.XK_Super_R);
|
||||
addStandard('NumLock', KeyTable.XK_Num_Lock);
|
||||
addStandard('ScrollLock', KeyTable.XK_Scroll_Lock);
|
||||
addLeftRight('Shift', KeyTable.XK_Shift_L, KeyTable.XK_Shift_R);
|
||||
addLeftRight('Super', KeyTable.XK_Super_L, KeyTable.XK_Super_R);
|
||||
// - Symbol
|
||||
// - SymbolLock
|
||||
|
||||
// 2.3. Whitespace Keys
|
||||
|
||||
addNumpad("Enter", KeyTable.XK_Return, KeyTable.XK_KP_Enter);
|
||||
addStandard("Tab", KeyTable.XK_Tab);
|
||||
addNumpad(" ", KeyTable.XK_space, KeyTable.XK_KP_Space);
|
||||
addNumpad('Enter', KeyTable.XK_Return, KeyTable.XK_KP_Enter);
|
||||
addStandard('Tab', KeyTable.XK_Tab);
|
||||
addNumpad(' ', KeyTable.XK_space, KeyTable.XK_KP_Space);
|
||||
|
||||
// 2.4. Navigation Keys
|
||||
|
||||
addNumpad("ArrowDown", KeyTable.XK_Down, KeyTable.XK_KP_Down);
|
||||
addNumpad("ArrowUp", KeyTable.XK_Up, KeyTable.XK_KP_Up);
|
||||
addNumpad("ArrowLeft", KeyTable.XK_Left, KeyTable.XK_KP_Left);
|
||||
addNumpad("ArrowRight", KeyTable.XK_Right, KeyTable.XK_KP_Right);
|
||||
addNumpad("End", KeyTable.XK_End, KeyTable.XK_KP_End);
|
||||
addNumpad("Home", KeyTable.XK_Home, KeyTable.XK_KP_Home);
|
||||
addNumpad("PageDown", KeyTable.XK_Next, KeyTable.XK_KP_Next);
|
||||
addNumpad("PageUp", KeyTable.XK_Prior, KeyTable.XK_KP_Prior);
|
||||
addNumpad('ArrowDown', KeyTable.XK_Down, KeyTable.XK_KP_Down);
|
||||
addNumpad('ArrowUp', KeyTable.XK_Up, KeyTable.XK_KP_Up);
|
||||
addNumpad('ArrowLeft', KeyTable.XK_Left, KeyTable.XK_KP_Left);
|
||||
addNumpad('ArrowRight', KeyTable.XK_Right, KeyTable.XK_KP_Right);
|
||||
addNumpad('End', KeyTable.XK_End, KeyTable.XK_KP_End);
|
||||
addNumpad('Home', KeyTable.XK_Home, KeyTable.XK_KP_Home);
|
||||
addNumpad('PageDown', KeyTable.XK_Next, KeyTable.XK_KP_Next);
|
||||
addNumpad('PageUp', KeyTable.XK_Prior, KeyTable.XK_KP_Prior);
|
||||
|
||||
// 2.5. Editing Keys
|
||||
|
||||
addStandard("Backspace", KeyTable.XK_BackSpace);
|
||||
addNumpad("Clear", KeyTable.XK_Clear, KeyTable.XK_KP_Begin);
|
||||
addStandard("Copy", KeyTable.XF86XK_Copy);
|
||||
addStandard('Backspace', KeyTable.XK_BackSpace);
|
||||
addNumpad('Clear', KeyTable.XK_Clear, KeyTable.XK_KP_Begin);
|
||||
addStandard('Copy', KeyTable.XF86XK_Copy);
|
||||
// - CrSel
|
||||
addStandard("Cut", KeyTable.XF86XK_Cut);
|
||||
addNumpad("Delete", KeyTable.XK_Delete, KeyTable.XK_KP_Delete);
|
||||
addStandard('Cut', KeyTable.XF86XK_Cut);
|
||||
addNumpad('Delete', KeyTable.XK_Delete, KeyTable.XK_KP_Delete);
|
||||
// - EraseEof
|
||||
// - ExSel
|
||||
addNumpad("Insert", KeyTable.XK_Insert, KeyTable.XK_KP_Insert);
|
||||
addStandard("Paste", KeyTable.XF86XK_Paste);
|
||||
addStandard("Redo", KeyTable.XK_Redo);
|
||||
addStandard("Undo", KeyTable.XK_Undo);
|
||||
addNumpad('Insert', KeyTable.XK_Insert, KeyTable.XK_KP_Insert);
|
||||
addStandard('Paste', KeyTable.XF86XK_Paste);
|
||||
addStandard('Redo', KeyTable.XK_Redo);
|
||||
addStandard('Undo', KeyTable.XK_Undo);
|
||||
|
||||
// 2.6. UI Keys
|
||||
|
||||
// - Accept
|
||||
// - Again (could just be XK_Redo)
|
||||
// - Attn
|
||||
addStandard("Cancel", KeyTable.XK_Cancel);
|
||||
addStandard("ContextMenu", KeyTable.XK_Menu);
|
||||
addStandard("Escape", KeyTable.XK_Escape);
|
||||
addStandard("Execute", KeyTable.XK_Execute);
|
||||
addStandard("Find", KeyTable.XK_Find);
|
||||
addStandard("Help", KeyTable.XK_Help);
|
||||
addStandard("Pause", KeyTable.XK_Pause);
|
||||
addStandard('Cancel', KeyTable.XK_Cancel);
|
||||
addStandard('ContextMenu', KeyTable.XK_Menu);
|
||||
addStandard('Escape', KeyTable.XK_Escape);
|
||||
addStandard('Execute', KeyTable.XK_Execute);
|
||||
addStandard('Find', KeyTable.XK_Find);
|
||||
addStandard('Help', KeyTable.XK_Help);
|
||||
addStandard('Pause', KeyTable.XK_Pause);
|
||||
// - Play
|
||||
// - Props
|
||||
addStandard("Select", KeyTable.XK_Select);
|
||||
addStandard("ZoomIn", KeyTable.XF86XK_ZoomIn);
|
||||
addStandard("ZoomOut", KeyTable.XF86XK_ZoomOut);
|
||||
addStandard('Select', KeyTable.XK_Select);
|
||||
addStandard('ZoomIn', KeyTable.XF86XK_ZoomIn);
|
||||
addStandard('ZoomOut', KeyTable.XF86XK_ZoomOut);
|
||||
|
||||
// 2.7. Device Keys
|
||||
|
||||
addStandard("BrightnessDown", KeyTable.XF86XK_MonBrightnessDown);
|
||||
addStandard("BrightnessUp", KeyTable.XF86XK_MonBrightnessUp);
|
||||
addStandard("Eject", KeyTable.XF86XK_Eject);
|
||||
addStandard("LogOff", KeyTable.XF86XK_LogOff);
|
||||
addStandard("Power", KeyTable.XF86XK_PowerOff);
|
||||
addStandard("PowerOff", KeyTable.XF86XK_PowerDown);
|
||||
addStandard("PrintScreen", KeyTable.XK_Print);
|
||||
addStandard("Hibernate", KeyTable.XF86XK_Hibernate);
|
||||
addStandard("Standby", KeyTable.XF86XK_Standby);
|
||||
addStandard("WakeUp", KeyTable.XF86XK_WakeUp);
|
||||
addStandard('BrightnessDown', KeyTable.XF86XK_MonBrightnessDown);
|
||||
addStandard('BrightnessUp', KeyTable.XF86XK_MonBrightnessUp);
|
||||
addStandard('Eject', KeyTable.XF86XK_Eject);
|
||||
addStandard('LogOff', KeyTable.XF86XK_LogOff);
|
||||
addStandard('Power', KeyTable.XF86XK_PowerOff);
|
||||
addStandard('PowerOff', KeyTable.XF86XK_PowerDown);
|
||||
addStandard('PrintScreen', KeyTable.XK_Print);
|
||||
addStandard('Hibernate', KeyTable.XF86XK_Hibernate);
|
||||
addStandard('Standby', KeyTable.XF86XK_Standby);
|
||||
addStandard('WakeUp', KeyTable.XF86XK_WakeUp);
|
||||
|
||||
// 2.8. IME and Composition Keys
|
||||
|
||||
addStandard("AllCandidates", KeyTable.XK_MultipleCandidate);
|
||||
addStandard("Alphanumeric", KeyTable.XK_Eisu_Shift); // could also be _Eisu_Toggle
|
||||
addStandard("CodeInput", KeyTable.XK_Codeinput);
|
||||
addStandard("Compose", KeyTable.XK_Multi_key);
|
||||
addStandard("Convert", KeyTable.XK_Henkan);
|
||||
addStandard('AllCandidates', KeyTable.XK_MultipleCandidate);
|
||||
addStandard('Alphanumeric', KeyTable.XK_Eisu_Shift); // could also be _Eisu_Toggle
|
||||
addStandard('CodeInput', KeyTable.XK_Codeinput);
|
||||
addStandard('Compose', KeyTable.XK_Multi_key);
|
||||
addStandard('Convert', KeyTable.XK_Henkan);
|
||||
// - Dead
|
||||
// - FinalMode
|
||||
addStandard("GroupFirst", KeyTable.XK_ISO_First_Group);
|
||||
addStandard("GroupLast", KeyTable.XK_ISO_Last_Group);
|
||||
addStandard("GroupNext", KeyTable.XK_ISO_Next_Group);
|
||||
addStandard("GroupPrevious", KeyTable.XK_ISO_Prev_Group);
|
||||
addStandard('GroupFirst', KeyTable.XK_ISO_First_Group);
|
||||
addStandard('GroupLast', KeyTable.XK_ISO_Last_Group);
|
||||
addStandard('GroupNext', KeyTable.XK_ISO_Next_Group);
|
||||
addStandard('GroupPrevious', KeyTable.XK_ISO_Prev_Group);
|
||||
// - ModeChange (XK_Mode_switch is often used for AltGr)
|
||||
// - NextCandidate
|
||||
addStandard("NonConvert", KeyTable.XK_Muhenkan);
|
||||
addStandard("PreviousCandidate", KeyTable.XK_PreviousCandidate);
|
||||
addStandard('NonConvert', KeyTable.XK_Muhenkan);
|
||||
addStandard('PreviousCandidate', KeyTable.XK_PreviousCandidate);
|
||||
// - Process
|
||||
addStandard("SingleCandidate", KeyTable.XK_SingleCandidate);
|
||||
addStandard("HangulMode", KeyTable.XK_Hangul);
|
||||
addStandard("HanjaMode", KeyTable.XK_Hangul_Hanja);
|
||||
addStandard("JunjuaMode", KeyTable.XK_Hangul_Jeonja);
|
||||
addStandard("Eisu", KeyTable.XK_Eisu_toggle);
|
||||
addStandard("Hankaku", KeyTable.XK_Hankaku);
|
||||
addStandard("Hiragana", KeyTable.XK_Hiragana);
|
||||
addStandard("HiraganaKatakana", KeyTable.XK_Hiragana_Katakana);
|
||||
addStandard("KanaMode", KeyTable.XK_Kana_Shift); // could also be _Kana_Lock
|
||||
addStandard("KanjiMode", KeyTable.XK_Kanji);
|
||||
addStandard("Katakana", KeyTable.XK_Katakana);
|
||||
addStandard("Romaji", KeyTable.XK_Romaji);
|
||||
addStandard("Zenkaku", KeyTable.XK_Zenkaku);
|
||||
addStandard("ZenkakuHanaku", KeyTable.XK_Zenkaku_Hankaku);
|
||||
addStandard('SingleCandidate', KeyTable.XK_SingleCandidate);
|
||||
addStandard('HangulMode', KeyTable.XK_Hangul);
|
||||
addStandard('HanjaMode', KeyTable.XK_Hangul_Hanja);
|
||||
addStandard('JunjuaMode', KeyTable.XK_Hangul_Jeonja);
|
||||
addStandard('Eisu', KeyTable.XK_Eisu_toggle);
|
||||
addStandard('Hankaku', KeyTable.XK_Hankaku);
|
||||
addStandard('Hiragana', KeyTable.XK_Hiragana);
|
||||
addStandard('HiraganaKatakana', KeyTable.XK_Hiragana_Katakana);
|
||||
addStandard('KanaMode', KeyTable.XK_Kana_Shift); // could also be _Kana_Lock
|
||||
addStandard('KanjiMode', KeyTable.XK_Kanji);
|
||||
addStandard('Katakana', KeyTable.XK_Katakana);
|
||||
addStandard('Romaji', KeyTable.XK_Romaji);
|
||||
addStandard('Zenkaku', KeyTable.XK_Zenkaku);
|
||||
addStandard('ZenkakuHanaku', KeyTable.XK_Zenkaku_Hankaku);
|
||||
|
||||
// 2.9. General-Purpose Function Keys
|
||||
|
||||
addStandard("F1", KeyTable.XK_F1);
|
||||
addStandard("F2", KeyTable.XK_F2);
|
||||
addStandard("F3", KeyTable.XK_F3);
|
||||
addStandard("F4", KeyTable.XK_F4);
|
||||
addStandard("F5", KeyTable.XK_F5);
|
||||
addStandard("F6", KeyTable.XK_F6);
|
||||
addStandard("F7", KeyTable.XK_F7);
|
||||
addStandard("F8", KeyTable.XK_F8);
|
||||
addStandard("F9", KeyTable.XK_F9);
|
||||
addStandard("F10", KeyTable.XK_F10);
|
||||
addStandard("F11", KeyTable.XK_F11);
|
||||
addStandard("F12", KeyTable.XK_F12);
|
||||
addStandard("F13", KeyTable.XK_F13);
|
||||
addStandard("F14", KeyTable.XK_F14);
|
||||
addStandard("F15", KeyTable.XK_F15);
|
||||
addStandard("F16", KeyTable.XK_F16);
|
||||
addStandard("F17", KeyTable.XK_F17);
|
||||
addStandard("F18", KeyTable.XK_F18);
|
||||
addStandard("F19", KeyTable.XK_F19);
|
||||
addStandard("F20", KeyTable.XK_F20);
|
||||
addStandard("F21", KeyTable.XK_F21);
|
||||
addStandard("F22", KeyTable.XK_F22);
|
||||
addStandard("F23", KeyTable.XK_F23);
|
||||
addStandard("F24", KeyTable.XK_F24);
|
||||
addStandard("F25", KeyTable.XK_F25);
|
||||
addStandard("F26", KeyTable.XK_F26);
|
||||
addStandard("F27", KeyTable.XK_F27);
|
||||
addStandard("F28", KeyTable.XK_F28);
|
||||
addStandard("F29", KeyTable.XK_F29);
|
||||
addStandard("F30", KeyTable.XK_F30);
|
||||
addStandard("F31", KeyTable.XK_F31);
|
||||
addStandard("F32", KeyTable.XK_F32);
|
||||
addStandard("F33", KeyTable.XK_F33);
|
||||
addStandard("F34", KeyTable.XK_F34);
|
||||
addStandard("F35", KeyTable.XK_F35);
|
||||
addStandard('F1', KeyTable.XK_F1);
|
||||
addStandard('F2', KeyTable.XK_F2);
|
||||
addStandard('F3', KeyTable.XK_F3);
|
||||
addStandard('F4', KeyTable.XK_F4);
|
||||
addStandard('F5', KeyTable.XK_F5);
|
||||
addStandard('F6', KeyTable.XK_F6);
|
||||
addStandard('F7', KeyTable.XK_F7);
|
||||
addStandard('F8', KeyTable.XK_F8);
|
||||
addStandard('F9', KeyTable.XK_F9);
|
||||
addStandard('F10', KeyTable.XK_F10);
|
||||
addStandard('F11', KeyTable.XK_F11);
|
||||
addStandard('F12', KeyTable.XK_F12);
|
||||
addStandard('F13', KeyTable.XK_F13);
|
||||
addStandard('F14', KeyTable.XK_F14);
|
||||
addStandard('F15', KeyTable.XK_F15);
|
||||
addStandard('F16', KeyTable.XK_F16);
|
||||
addStandard('F17', KeyTable.XK_F17);
|
||||
addStandard('F18', KeyTable.XK_F18);
|
||||
addStandard('F19', KeyTable.XK_F19);
|
||||
addStandard('F20', KeyTable.XK_F20);
|
||||
addStandard('F21', KeyTable.XK_F21);
|
||||
addStandard('F22', KeyTable.XK_F22);
|
||||
addStandard('F23', KeyTable.XK_F23);
|
||||
addStandard('F24', KeyTable.XK_F24);
|
||||
addStandard('F25', KeyTable.XK_F25);
|
||||
addStandard('F26', KeyTable.XK_F26);
|
||||
addStandard('F27', KeyTable.XK_F27);
|
||||
addStandard('F28', KeyTable.XK_F28);
|
||||
addStandard('F29', KeyTable.XK_F29);
|
||||
addStandard('F30', KeyTable.XK_F30);
|
||||
addStandard('F31', KeyTable.XK_F31);
|
||||
addStandard('F32', KeyTable.XK_F32);
|
||||
addStandard('F33', KeyTable.XK_F33);
|
||||
addStandard('F34', KeyTable.XK_F34);
|
||||
addStandard('F35', KeyTable.XK_F35);
|
||||
// - Soft1...
|
||||
|
||||
// 2.10. Multimedia Keys
|
||||
|
||||
// - ChannelDown
|
||||
// - ChannelUp
|
||||
addStandard("Close", KeyTable.XF86XK_Close);
|
||||
addStandard("MailForward", KeyTable.XF86XK_MailForward);
|
||||
addStandard("MailReply", KeyTable.XF86XK_Reply);
|
||||
addStandard("MainSend", KeyTable.XF86XK_Send);
|
||||
addStandard("MediaFastForward", KeyTable.XF86XK_AudioForward);
|
||||
addStandard("MediaPause", KeyTable.XF86XK_AudioPause);
|
||||
addStandard("MediaPlay", KeyTable.XF86XK_AudioPlay);
|
||||
addStandard("MediaRecord", KeyTable.XF86XK_AudioRecord);
|
||||
addStandard("MediaRewind", KeyTable.XF86XK_AudioRewind);
|
||||
addStandard("MediaStop", KeyTable.XF86XK_AudioStop);
|
||||
addStandard("MediaTrackNext", KeyTable.XF86XK_AudioNext);
|
||||
addStandard("MediaTrackPrevious", KeyTable.XF86XK_AudioPrev);
|
||||
addStandard("New", KeyTable.XF86XK_New);
|
||||
addStandard("Open", KeyTable.XF86XK_Open);
|
||||
addStandard("Print", KeyTable.XK_Print);
|
||||
addStandard("Save", KeyTable.XF86XK_Save);
|
||||
addStandard("SpellCheck", KeyTable.XF86XK_Spell);
|
||||
addStandard('Close', KeyTable.XF86XK_Close);
|
||||
addStandard('MailForward', KeyTable.XF86XK_MailForward);
|
||||
addStandard('MailReply', KeyTable.XF86XK_Reply);
|
||||
addStandard('MainSend', KeyTable.XF86XK_Send);
|
||||
addStandard('MediaFastForward', KeyTable.XF86XK_AudioForward);
|
||||
addStandard('MediaPause', KeyTable.XF86XK_AudioPause);
|
||||
addStandard('MediaPlay', KeyTable.XF86XK_AudioPlay);
|
||||
addStandard('MediaRecord', KeyTable.XF86XK_AudioRecord);
|
||||
addStandard('MediaRewind', KeyTable.XF86XK_AudioRewind);
|
||||
addStandard('MediaStop', KeyTable.XF86XK_AudioStop);
|
||||
addStandard('MediaTrackNext', KeyTable.XF86XK_AudioNext);
|
||||
addStandard('MediaTrackPrevious', KeyTable.XF86XK_AudioPrev);
|
||||
addStandard('New', KeyTable.XF86XK_New);
|
||||
addStandard('Open', KeyTable.XF86XK_Open);
|
||||
addStandard('Print', KeyTable.XK_Print);
|
||||
addStandard('Save', KeyTable.XF86XK_Save);
|
||||
addStandard('SpellCheck', KeyTable.XF86XK_Spell);
|
||||
|
||||
// 2.11. Multimedia Numpad Keys
|
||||
|
||||
|
|
@ -231,13 +228,13 @@ addStandard("SpellCheck", KeyTable.XF86XK_Spell);
|
|||
// - AudioSurroundModeNext
|
||||
// - AudioTrebleDown
|
||||
// - AudioTrebleUp
|
||||
addStandard("AudioVolumeDown", KeyTable.XF86XK_AudioLowerVolume);
|
||||
addStandard("AudioVolumeUp", KeyTable.XF86XK_AudioRaiseVolume);
|
||||
addStandard("AudioVolumeMute", KeyTable.XF86XK_AudioMute);
|
||||
addStandard('AudioVolumeDown', KeyTable.XF86XK_AudioLowerVolume);
|
||||
addStandard('AudioVolumeUp', KeyTable.XF86XK_AudioRaiseVolume);
|
||||
addStandard('AudioVolumeMute', KeyTable.XF86XK_AudioMute);
|
||||
// - MicrophoneToggle
|
||||
// - MicrophoneVolumeDown
|
||||
// - MicrophoneVolumeUp
|
||||
addStandard("MicrophoneVolumeMute", KeyTable.XF86XK_AudioMicMute);
|
||||
addStandard('MicrophoneVolumeMute', KeyTable.XF86XK_AudioMicMute);
|
||||
|
||||
// 2.13. Speech Keys
|
||||
|
||||
|
|
@ -246,28 +243,28 @@ addStandard("MicrophoneVolumeMute", KeyTable.XF86XK_AudioMicMute);
|
|||
|
||||
// 2.14. Application Keys
|
||||
|
||||
addStandard("LaunchCalculator", KeyTable.XF86XK_Calculator);
|
||||
addStandard("LaunchCalendar", KeyTable.XF86XK_Calendar);
|
||||
addStandard("LaunchMail", KeyTable.XF86XK_Mail);
|
||||
addStandard("LaunchMediaPlayer", KeyTable.XF86XK_AudioMedia);
|
||||
addStandard("LaunchMusicPlayer", KeyTable.XF86XK_Music);
|
||||
addStandard("LaunchMyComputer", KeyTable.XF86XK_MyComputer);
|
||||
addStandard("LaunchPhone", KeyTable.XF86XK_Phone);
|
||||
addStandard("LaunchScreenSaver", KeyTable.XF86XK_ScreenSaver);
|
||||
addStandard("LaunchSpreadsheet", KeyTable.XF86XK_Excel);
|
||||
addStandard("LaunchWebBrowser", KeyTable.XF86XK_WWW);
|
||||
addStandard("LaunchWebCam", KeyTable.XF86XK_WebCam);
|
||||
addStandard("LaunchWordProcessor", KeyTable.XF86XK_Word);
|
||||
addStandard('LaunchCalculator', KeyTable.XF86XK_Calculator);
|
||||
addStandard('LaunchCalendar', KeyTable.XF86XK_Calendar);
|
||||
addStandard('LaunchMail', KeyTable.XF86XK_Mail);
|
||||
addStandard('LaunchMediaPlayer', KeyTable.XF86XK_AudioMedia);
|
||||
addStandard('LaunchMusicPlayer', KeyTable.XF86XK_Music);
|
||||
addStandard('LaunchMyComputer', KeyTable.XF86XK_MyComputer);
|
||||
addStandard('LaunchPhone', KeyTable.XF86XK_Phone);
|
||||
addStandard('LaunchScreenSaver', KeyTable.XF86XK_ScreenSaver);
|
||||
addStandard('LaunchSpreadsheet', KeyTable.XF86XK_Excel);
|
||||
addStandard('LaunchWebBrowser', KeyTable.XF86XK_WWW);
|
||||
addStandard('LaunchWebCam', KeyTable.XF86XK_WebCam);
|
||||
addStandard('LaunchWordProcessor', KeyTable.XF86XK_Word);
|
||||
|
||||
// 2.15. Browser Keys
|
||||
|
||||
addStandard("BrowserBack", KeyTable.XF86XK_Back);
|
||||
addStandard("BrowserFavorites", KeyTable.XF86XK_Favorites);
|
||||
addStandard("BrowserForward", KeyTable.XF86XK_Forward);
|
||||
addStandard("BrowserHome", KeyTable.XF86XK_HomePage);
|
||||
addStandard("BrowserRefresh", KeyTable.XF86XK_Refresh);
|
||||
addStandard("BrowserSearch", KeyTable.XF86XK_Search);
|
||||
addStandard("BrowserStop", KeyTable.XF86XK_Stop);
|
||||
addStandard('BrowserBack', KeyTable.XF86XK_Back);
|
||||
addStandard('BrowserFavorites', KeyTable.XF86XK_Favorites);
|
||||
addStandard('BrowserForward', KeyTable.XF86XK_Forward);
|
||||
addStandard('BrowserHome', KeyTable.XF86XK_HomePage);
|
||||
addStandard('BrowserRefresh', KeyTable.XF86XK_Refresh);
|
||||
addStandard('BrowserSearch', KeyTable.XF86XK_Search);
|
||||
addStandard('BrowserStop', KeyTable.XF86XK_Stop);
|
||||
|
||||
// 2.16. Mobile Phone Keys
|
||||
|
||||
|
|
@ -280,31 +277,31 @@ addStandard("BrowserStop", KeyTable.XF86XK_Stop);
|
|||
// 2.18. Media Controller Keys
|
||||
|
||||
// - A whole bunch...
|
||||
addStandard("Dimmer", KeyTable.XF86XK_BrightnessAdjust);
|
||||
addStandard("MediaAudioTrack", KeyTable.XF86XK_AudioCycleTrack);
|
||||
addStandard("RandomToggle", KeyTable.XF86XK_AudioRandomPlay);
|
||||
addStandard("SplitScreenToggle", KeyTable.XF86XK_SplitScreen);
|
||||
addStandard("Subtitle", KeyTable.XF86XK_Subtitle);
|
||||
addStandard("VideoModeNext", KeyTable.XF86XK_Next_VMode);
|
||||
addStandard('Dimmer', KeyTable.XF86XK_BrightnessAdjust);
|
||||
addStandard('MediaAudioTrack', KeyTable.XF86XK_AudioCycleTrack);
|
||||
addStandard('RandomToggle', KeyTable.XF86XK_AudioRandomPlay);
|
||||
addStandard('SplitScreenToggle', KeyTable.XF86XK_SplitScreen);
|
||||
addStandard('Subtitle', KeyTable.XF86XK_Subtitle);
|
||||
addStandard('VideoModeNext', KeyTable.XF86XK_Next_VMode);
|
||||
|
||||
// Extra: Numpad
|
||||
|
||||
addNumpad("=", KeyTable.XK_equal, KeyTable.XK_KP_Equal);
|
||||
addNumpad("+", KeyTable.XK_plus, KeyTable.XK_KP_Add);
|
||||
addNumpad("-", KeyTable.XK_minus, KeyTable.XK_KP_Subtract);
|
||||
addNumpad("*", KeyTable.XK_asterisk, KeyTable.XK_KP_Multiply);
|
||||
addNumpad("/", KeyTable.XK_slash, KeyTable.XK_KP_Divide);
|
||||
addNumpad(".", KeyTable.XK_period, KeyTable.XK_KP_Decimal);
|
||||
addNumpad(",", KeyTable.XK_comma, KeyTable.XK_KP_Separator);
|
||||
addNumpad("0", KeyTable.XK_0, KeyTable.XK_KP_0);
|
||||
addNumpad("1", KeyTable.XK_1, KeyTable.XK_KP_1);
|
||||
addNumpad("2", KeyTable.XK_2, KeyTable.XK_KP_2);
|
||||
addNumpad("3", KeyTable.XK_3, KeyTable.XK_KP_3);
|
||||
addNumpad("4", KeyTable.XK_4, KeyTable.XK_KP_4);
|
||||
addNumpad("5", KeyTable.XK_5, KeyTable.XK_KP_5);
|
||||
addNumpad("6", KeyTable.XK_6, KeyTable.XK_KP_6);
|
||||
addNumpad("7", KeyTable.XK_7, KeyTable.XK_KP_7);
|
||||
addNumpad("8", KeyTable.XK_8, KeyTable.XK_KP_8);
|
||||
addNumpad("9", KeyTable.XK_9, KeyTable.XK_KP_9);
|
||||
addNumpad('=', KeyTable.XK_equal, KeyTable.XK_KP_Equal);
|
||||
addNumpad('+', KeyTable.XK_plus, KeyTable.XK_KP_Add);
|
||||
addNumpad('-', KeyTable.XK_minus, KeyTable.XK_KP_Subtract);
|
||||
addNumpad('*', KeyTable.XK_asterisk, KeyTable.XK_KP_Multiply);
|
||||
addNumpad('/', KeyTable.XK_slash, KeyTable.XK_KP_Divide);
|
||||
addNumpad('.', KeyTable.XK_period, KeyTable.XK_KP_Decimal);
|
||||
addNumpad(',', KeyTable.XK_comma, KeyTable.XK_KP_Separator);
|
||||
addNumpad('0', KeyTable.XK_0, KeyTable.XK_KP_0);
|
||||
addNumpad('1', KeyTable.XK_1, KeyTable.XK_KP_1);
|
||||
addNumpad('2', KeyTable.XK_2, KeyTable.XK_KP_2);
|
||||
addNumpad('3', KeyTable.XK_3, KeyTable.XK_KP_3);
|
||||
addNumpad('4', KeyTable.XK_4, KeyTable.XK_KP_4);
|
||||
addNumpad('5', KeyTable.XK_5, KeyTable.XK_KP_5);
|
||||
addNumpad('6', KeyTable.XK_6, KeyTable.XK_KP_6);
|
||||
addNumpad('7', KeyTable.XK_7, KeyTable.XK_KP_7);
|
||||
addNumpad('8', KeyTable.XK_8, KeyTable.XK_KP_8);
|
||||
addNumpad('9', KeyTable.XK_9, KeyTable.XK_KP_9);
|
||||
|
||||
export default DOMKeyTable;
|
||||
|
|
|
|||
|
|
@ -18,110 +18,110 @@ export default {
|
|||
|
||||
// 3.1.1.1. Writing System Keys
|
||||
|
||||
'Backspace': 'Backspace',
|
||||
Backspace: 'Backspace',
|
||||
|
||||
// 3.1.1.2. Functional Keys
|
||||
|
||||
'AltLeft': 'Alt',
|
||||
'AltRight': 'Alt', // This could also be 'AltGraph'
|
||||
'CapsLock': 'CapsLock',
|
||||
'ContextMenu': 'ContextMenu',
|
||||
'ControlLeft': 'Control',
|
||||
'ControlRight': 'Control',
|
||||
'Enter': 'Enter',
|
||||
'MetaLeft': 'Meta',
|
||||
'MetaRight': 'Meta',
|
||||
'ShiftLeft': 'Shift',
|
||||
'ShiftRight': 'Shift',
|
||||
'Tab': 'Tab',
|
||||
AltLeft: 'Alt',
|
||||
AltRight: 'Alt', // This could also be 'AltGraph'
|
||||
CapsLock: 'CapsLock',
|
||||
ContextMenu: 'ContextMenu',
|
||||
ControlLeft: 'Control',
|
||||
ControlRight: 'Control',
|
||||
Enter: 'Enter',
|
||||
MetaLeft: 'Meta',
|
||||
MetaRight: 'Meta',
|
||||
ShiftLeft: 'Shift',
|
||||
ShiftRight: 'Shift',
|
||||
Tab: 'Tab',
|
||||
// FIXME: Japanese/Korean keys
|
||||
|
||||
// 3.1.2. Control Pad Section
|
||||
|
||||
'Delete': 'Delete',
|
||||
'End': 'End',
|
||||
'Help': 'Help',
|
||||
'Home': 'Home',
|
||||
'Insert': 'Insert',
|
||||
'PageDown': 'PageDown',
|
||||
'PageUp': 'PageUp',
|
||||
Delete: 'Delete',
|
||||
End: 'End',
|
||||
Help: 'Help',
|
||||
Home: 'Home',
|
||||
Insert: 'Insert',
|
||||
PageDown: 'PageDown',
|
||||
PageUp: 'PageUp',
|
||||
|
||||
// 3.1.3. Arrow Pad Section
|
||||
|
||||
'ArrowDown': 'ArrowDown',
|
||||
'ArrowLeft': 'ArrowLeft',
|
||||
'ArrowRight': 'ArrowRight',
|
||||
'ArrowUp': 'ArrowUp',
|
||||
ArrowDown: 'ArrowDown',
|
||||
ArrowLeft: 'ArrowLeft',
|
||||
ArrowRight: 'ArrowRight',
|
||||
ArrowUp: 'ArrowUp',
|
||||
|
||||
// 3.1.4. Numpad Section
|
||||
|
||||
'NumLock': 'NumLock',
|
||||
'NumpadBackspace': 'Backspace',
|
||||
'NumpadClear': 'Clear',
|
||||
NumLock: 'NumLock',
|
||||
NumpadBackspace: 'Backspace',
|
||||
NumpadClear: 'Clear',
|
||||
|
||||
// 3.1.5. Function Section
|
||||
|
||||
'Escape': 'Escape',
|
||||
'F1': 'F1',
|
||||
'F2': 'F2',
|
||||
'F3': 'F3',
|
||||
'F4': 'F4',
|
||||
'F5': 'F5',
|
||||
'F6': 'F6',
|
||||
'F7': 'F7',
|
||||
'F8': 'F8',
|
||||
'F9': 'F9',
|
||||
'F10': 'F10',
|
||||
'F11': 'F11',
|
||||
'F12': 'F12',
|
||||
'F13': 'F13',
|
||||
'F14': 'F14',
|
||||
'F15': 'F15',
|
||||
'F16': 'F16',
|
||||
'F17': 'F17',
|
||||
'F18': 'F18',
|
||||
'F19': 'F19',
|
||||
'F20': 'F20',
|
||||
'F21': 'F21',
|
||||
'F22': 'F22',
|
||||
'F23': 'F23',
|
||||
'F24': 'F24',
|
||||
'F25': 'F25',
|
||||
'F26': 'F26',
|
||||
'F27': 'F27',
|
||||
'F28': 'F28',
|
||||
'F29': 'F29',
|
||||
'F30': 'F30',
|
||||
'F31': 'F31',
|
||||
'F32': 'F32',
|
||||
'F33': 'F33',
|
||||
'F34': 'F34',
|
||||
'F35': 'F35',
|
||||
'PrintScreen': 'PrintScreen',
|
||||
'ScrollLock': 'ScrollLock',
|
||||
'Pause': 'Pause',
|
||||
Escape: 'Escape',
|
||||
F1: 'F1',
|
||||
F2: 'F2',
|
||||
F3: 'F3',
|
||||
F4: 'F4',
|
||||
F5: 'F5',
|
||||
F6: 'F6',
|
||||
F7: 'F7',
|
||||
F8: 'F8',
|
||||
F9: 'F9',
|
||||
F10: 'F10',
|
||||
F11: 'F11',
|
||||
F12: 'F12',
|
||||
F13: 'F13',
|
||||
F14: 'F14',
|
||||
F15: 'F15',
|
||||
F16: 'F16',
|
||||
F17: 'F17',
|
||||
F18: 'F18',
|
||||
F19: 'F19',
|
||||
F20: 'F20',
|
||||
F21: 'F21',
|
||||
F22: 'F22',
|
||||
F23: 'F23',
|
||||
F24: 'F24',
|
||||
F25: 'F25',
|
||||
F26: 'F26',
|
||||
F27: 'F27',
|
||||
F28: 'F28',
|
||||
F29: 'F29',
|
||||
F30: 'F30',
|
||||
F31: 'F31',
|
||||
F32: 'F32',
|
||||
F33: 'F33',
|
||||
F34: 'F34',
|
||||
F35: 'F35',
|
||||
PrintScreen: 'PrintScreen',
|
||||
ScrollLock: 'ScrollLock',
|
||||
Pause: 'Pause',
|
||||
|
||||
// 3.1.6. Media Keys
|
||||
|
||||
'BrowserBack': 'BrowserBack',
|
||||
'BrowserFavorites': 'BrowserFavorites',
|
||||
'BrowserForward': 'BrowserForward',
|
||||
'BrowserHome': 'BrowserHome',
|
||||
'BrowserRefresh': 'BrowserRefresh',
|
||||
'BrowserSearch': 'BrowserSearch',
|
||||
'BrowserStop': 'BrowserStop',
|
||||
'Eject': 'Eject',
|
||||
'LaunchApp1': 'LaunchMyComputer',
|
||||
'LaunchApp2': 'LaunchCalendar',
|
||||
'LaunchMail': 'LaunchMail',
|
||||
'MediaPlayPause': 'MediaPlay',
|
||||
'MediaStop': 'MediaStop',
|
||||
'MediaTrackNext': 'MediaTrackNext',
|
||||
'MediaTrackPrevious': 'MediaTrackPrevious',
|
||||
'Power': 'Power',
|
||||
'Sleep': 'Sleep',
|
||||
'AudioVolumeDown': 'AudioVolumeDown',
|
||||
'AudioVolumeMute': 'AudioVolumeMute',
|
||||
'AudioVolumeUp': 'AudioVolumeUp',
|
||||
'WakeUp': 'WakeUp',
|
||||
BrowserBack: 'BrowserBack',
|
||||
BrowserFavorites: 'BrowserFavorites',
|
||||
BrowserForward: 'BrowserForward',
|
||||
BrowserHome: 'BrowserHome',
|
||||
BrowserRefresh: 'BrowserRefresh',
|
||||
BrowserSearch: 'BrowserSearch',
|
||||
BrowserStop: 'BrowserStop',
|
||||
Eject: 'Eject',
|
||||
LaunchApp1: 'LaunchMyComputer',
|
||||
LaunchApp2: 'LaunchCalendar',
|
||||
LaunchMail: 'LaunchMail',
|
||||
MediaPlayPause: 'MediaPlay',
|
||||
MediaStop: 'MediaStop',
|
||||
MediaTrackNext: 'MediaTrackNext',
|
||||
MediaTrackPrevious: 'MediaTrackPrevious',
|
||||
Power: 'Power',
|
||||
Sleep: 'Sleep',
|
||||
AudioVolumeDown: 'AudioVolumeDown',
|
||||
AudioVolumeMute: 'AudioVolumeMute',
|
||||
AudioVolumeUp: 'AudioVolumeUp',
|
||||
WakeUp: 'WakeUp',
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
import * as Log from '../util/logging.js';
|
||||
import { stopEvent } from '../util/events.js';
|
||||
import * as KeyboardUtil from "./util.js";
|
||||
import KeyTable from "./keysym.js";
|
||||
import * as browser from "../util/browser.js";
|
||||
import * as KeyboardUtil from './util.js';
|
||||
import KeyTable from './keysym.js';
|
||||
import * as browser from '../util/browser.js';
|
||||
|
||||
//
|
||||
// Keyboard event handler
|
||||
|
|
@ -26,11 +26,11 @@ export default class Keyboard {
|
|||
|
||||
// keep these here so we can refer to them later
|
||||
this._eventHandlers = {
|
||||
'keyup': this._handleKeyUp.bind(this),
|
||||
'keydown': this._handleKeyDown.bind(this),
|
||||
'keypress': this._handleKeyPress.bind(this),
|
||||
'blur': this._allKeysUp.bind(this),
|
||||
'checkalt': this._checkAlt.bind(this),
|
||||
keyup: this._handleKeyUp.bind(this),
|
||||
keydown: this._handleKeyDown.bind(this),
|
||||
keypress: this._handleKeyPress.bind(this),
|
||||
blur: this._allKeysUp.bind(this),
|
||||
checkalt: this._checkAlt.bind(this),
|
||||
};
|
||||
|
||||
// ===== EVENT HANDLERS =====
|
||||
|
|
@ -51,8 +51,8 @@ export default class Keyboard {
|
|||
delete this._keyDownList[code];
|
||||
}
|
||||
|
||||
Log.Debug("onkeyevent " + (down ? "down" : "up") +
|
||||
", keysym: " + keysym, ", code: " + code);
|
||||
Log.Debug('onkeyevent ' + (down ? 'down' : 'up')
|
||||
+ ', keysym: ' + keysym, ', code: ' + code);
|
||||
this.onkeyevent(keysym, code, down);
|
||||
}
|
||||
|
||||
|
|
@ -102,8 +102,8 @@ export default class Keyboard {
|
|||
this._altGrArmed = false;
|
||||
clearTimeout(this._altGrTimeout);
|
||||
|
||||
if ((code === "AltRight") &&
|
||||
((e.timeStamp - this._altGrCtrlTime) < 50)) {
|
||||
if ((code === 'AltRight')
|
||||
&& ((e.timeStamp - this._altGrCtrlTime) < 50)) {
|
||||
// FIXME: We fail to detect this if either Ctrl key is
|
||||
// first manually pressed as Windows then no
|
||||
// longer sends the fake Ctrl down event. It
|
||||
|
|
@ -113,7 +113,7 @@ export default class Keyboard {
|
|||
// key to "AltGraph".
|
||||
keysym = KeyTable.XK_ISO_Level3_Shift;
|
||||
} else {
|
||||
this._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
||||
this._sendKeyEvent(KeyTable.XK_Control_L, 'ControlLeft', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -189,8 +189,8 @@ export default class Keyboard {
|
|||
stopEvent(e);
|
||||
|
||||
// Possible start of AltGr sequence? (see above)
|
||||
if ((code === "ControlLeft") && browser.isWindows() &&
|
||||
!("ControlLeft" in this._keyDownList)) {
|
||||
if ((code === 'ControlLeft') && browser.isWindows()
|
||||
&& !('ControlLeft' in this._keyDownList)) {
|
||||
this._altGrArmed = true;
|
||||
this._altGrTimeout = setTimeout(this._handleAltGrTimeout.bind(this), 100);
|
||||
this._altGrCtrlTime = e.timeStamp;
|
||||
|
|
@ -249,10 +249,8 @@ export default class Keyboard {
|
|||
// Character (A-Z)
|
||||
let char = String.fromCharCode(e.keyCode);
|
||||
// A feeble attempt at the correct case
|
||||
if (e.shiftKey)
|
||||
char = char.toUpperCase();
|
||||
else
|
||||
char = char.toLowerCase();
|
||||
if (e.shiftKey) char = char.toUpperCase();
|
||||
else char = char.toLowerCase();
|
||||
keysym = char.charCodeAt();
|
||||
} else {
|
||||
// Unknown, give up
|
||||
|
|
@ -272,7 +270,7 @@ export default class Keyboard {
|
|||
if (this._altGrArmed) {
|
||||
this._altGrArmed = false;
|
||||
clearTimeout(this._altGrTimeout);
|
||||
this._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
||||
this._sendKeyEvent(KeyTable.XK_Control_L, 'ControlLeft', true);
|
||||
}
|
||||
|
||||
// See comment in _handleKeyDown()
|
||||
|
|
@ -288,15 +286,15 @@ export default class Keyboard {
|
|||
_handleAltGrTimeout() {
|
||||
this._altGrArmed = false;
|
||||
clearTimeout(this._altGrTimeout);
|
||||
this._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
||||
this._sendKeyEvent(KeyTable.XK_Control_L, 'ControlLeft', true);
|
||||
}
|
||||
|
||||
_allKeysUp() {
|
||||
Log.Debug(">> Keyboard.allKeysUp");
|
||||
Log.Debug('>> Keyboard.allKeysUp');
|
||||
for (let code in this._keyDownList) {
|
||||
this._sendKeyEvent(this._keyDownList[code], code, false);
|
||||
}
|
||||
Log.Debug("<< Keyboard.allKeysUp");
|
||||
Log.Debug('<< Keyboard.allKeysUp');
|
||||
}
|
||||
|
||||
// Firefox Alt workaround, see below
|
||||
|
|
@ -313,8 +311,10 @@ export default class Keyboard {
|
|||
}
|
||||
|
||||
const event = new KeyboardEvent('keyup',
|
||||
{ key: downList[code],
|
||||
code: code });
|
||||
{
|
||||
key: downList[code],
|
||||
code: code
|
||||
});
|
||||
target.dispatchEvent(event);
|
||||
});
|
||||
}
|
||||
|
|
@ -338,10 +338,11 @@ export default class Keyboard {
|
|||
const handler = this._eventHandlers.checkalt;
|
||||
['mousedown', 'mouseup', 'mousemove', 'wheel',
|
||||
'touchstart', 'touchend', 'touchmove',
|
||||
'keydown', 'keyup'].forEach(type =>
|
||||
document.addEventListener(type, handler,
|
||||
{ capture: true,
|
||||
passive: true }));
|
||||
'keydown', 'keyup'].forEach(type => document.addEventListener(type, handler,
|
||||
{
|
||||
capture: true,
|
||||
passive: true
|
||||
}));
|
||||
}
|
||||
|
||||
// Log.Debug("<< Keyboard.grab");
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ export default class Mouse {
|
|||
this._accumulatedWheelDeltaY = 0;
|
||||
|
||||
this._eventHandlers = {
|
||||
'mousedown': this._handleMouseDown.bind(this),
|
||||
'mouseup': this._handleMouseUp.bind(this),
|
||||
'mousemove': this._handleMouseMove.bind(this),
|
||||
'mousewheel': this._handleMouseWheel.bind(this),
|
||||
'mousedisable': this._handleMouseDisable.bind(this)
|
||||
mousedown: this._handleMouseDown.bind(this),
|
||||
mouseup: this._handleMouseUp.bind(this),
|
||||
mousemove: this._handleMouseMove.bind(this),
|
||||
mousewheel: this._handleMouseWheel.bind(this),
|
||||
mousedisable: this._handleMouseDisable.bind(this)
|
||||
};
|
||||
|
||||
// ===== PROPERTIES =====
|
||||
|
|
@ -90,13 +90,13 @@ export default class Mouse {
|
|||
bmask = 1 << e.button;
|
||||
} else {
|
||||
/* IE including 9 */
|
||||
bmask = (e.button & 0x1) + // Left
|
||||
(e.button & 0x2) * 2 + // Right
|
||||
(e.button & 0x4) / 2; // Middle
|
||||
bmask = (e.button & 0x1) // Left
|
||||
+ (e.button & 0x2) * 2 // Right
|
||||
+ (e.button & 0x4) / 2; // Middle
|
||||
}
|
||||
|
||||
Log.Debug("onmousebutton " + (down ? "down" : "up") +
|
||||
", x: " + pos.x + ", y: " + pos.y + ", bmask: " + bmask);
|
||||
Log.Debug('onmousebutton ' + (down ? 'down' : 'up')
|
||||
+ ', x: ' + pos.x + ', y: ' + pos.y + ', bmask: ' + bmask);
|
||||
this.onmousebutton(pos.x, pos.y, down, bmask);
|
||||
|
||||
stopEvent(e);
|
||||
|
|
@ -104,7 +104,7 @@ export default class Mouse {
|
|||
|
||||
_handleMouseDown(e) {
|
||||
// Touch events have implicit capture
|
||||
if (e.type === "mousedown") {
|
||||
if (e.type === 'mousedown') {
|
||||
setCapture(this._target);
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +119,6 @@ export default class Mouse {
|
|||
// protocol can't handle a wheel event with specific distance or speed.
|
||||
// Therefor, if we get a lot of small mouse wheel events we combine them.
|
||||
_generateWheelStepX() {
|
||||
|
||||
if (this._accumulatedWheelDeltaX < 0) {
|
||||
this.onmousebutton(this._pos.x, this._pos.y, 1, 1 << 5);
|
||||
this.onmousebutton(this._pos.x, this._pos.y, 0, 1 << 5);
|
||||
|
|
@ -132,7 +131,6 @@ export default class Mouse {
|
|||
}
|
||||
|
||||
_generateWheelStepY() {
|
||||
|
||||
if (this._accumulatedWheelDeltaY < 0) {
|
||||
this.onmousebutton(this._pos.x, this._pos.y, 1, 1 << 3);
|
||||
this.onmousebutton(this._pos.x, this._pos.y, 0, 1 << 3);
|
||||
|
|
@ -179,15 +177,13 @@ export default class Mouse {
|
|||
if (Math.abs(this._accumulatedWheelDeltaX) > WHEEL_STEP) {
|
||||
this._generateWheelStepX();
|
||||
} else {
|
||||
this._wheelStepXTimer =
|
||||
window.setTimeout(this._generateWheelStepX.bind(this),
|
||||
this._wheelStepXTimer = window.setTimeout(this._generateWheelStepX.bind(this),
|
||||
WHEEL_STEP_TIMEOUT);
|
||||
}
|
||||
if (Math.abs(this._accumulatedWheelDeltaY) > WHEEL_STEP) {
|
||||
this._generateWheelStepY();
|
||||
} else {
|
||||
this._wheelStepYTimer =
|
||||
window.setTimeout(this._generateWheelStepY.bind(this),
|
||||
this._wheelStepYTimer = window.setTimeout(this._generateWheelStepY.bind(this),
|
||||
WHEEL_STEP_TIMEOUT);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import keysyms from "./keysymdef.js";
|
||||
import vkeys from "./vkeys.js";
|
||||
import fixedkeys from "./fixedkeys.js";
|
||||
import DOMKeyTable from "./domkeytable.js";
|
||||
import * as browser from "../util/browser.js";
|
||||
import keysyms from './keysymdef.js';
|
||||
import vkeys from './vkeys.js';
|
||||
import fixedkeys from './fixedkeys.js';
|
||||
import DOMKeyTable from './domkeytable.js';
|
||||
import * as browser from '../util/browser.js';
|
||||
|
||||
// Get 'KeyboardEvent.code', handling legacy browsers
|
||||
export function getKeycode(evt) {
|
||||
|
|
|
|||
|
|
@ -5,167 +5,167 @@
|
|||
* keymap-gen --lang=js code-map keymaps.csv html atset1
|
||||
*/
|
||||
export default {
|
||||
"Again": 0xe005, /* html:Again (Again) -> linux:129 (KEY_AGAIN) -> atset1:57349 */
|
||||
"AltLeft": 0x38, /* html:AltLeft (AltLeft) -> linux:56 (KEY_LEFTALT) -> atset1:56 */
|
||||
"AltRight": 0xe038, /* html:AltRight (AltRight) -> linux:100 (KEY_RIGHTALT) -> atset1:57400 */
|
||||
"ArrowDown": 0xe050, /* html:ArrowDown (ArrowDown) -> linux:108 (KEY_DOWN) -> atset1:57424 */
|
||||
"ArrowLeft": 0xe04b, /* html:ArrowLeft (ArrowLeft) -> linux:105 (KEY_LEFT) -> atset1:57419 */
|
||||
"ArrowRight": 0xe04d, /* html:ArrowRight (ArrowRight) -> linux:106 (KEY_RIGHT) -> atset1:57421 */
|
||||
"ArrowUp": 0xe048, /* html:ArrowUp (ArrowUp) -> linux:103 (KEY_UP) -> atset1:57416 */
|
||||
"AudioVolumeDown": 0xe02e, /* html:AudioVolumeDown (AudioVolumeDown) -> linux:114 (KEY_VOLUMEDOWN) -> atset1:57390 */
|
||||
"AudioVolumeMute": 0xe020, /* html:AudioVolumeMute (AudioVolumeMute) -> linux:113 (KEY_MUTE) -> atset1:57376 */
|
||||
"AudioVolumeUp": 0xe030, /* html:AudioVolumeUp (AudioVolumeUp) -> linux:115 (KEY_VOLUMEUP) -> atset1:57392 */
|
||||
"Backquote": 0x29, /* html:Backquote (Backquote) -> linux:41 (KEY_GRAVE) -> atset1:41 */
|
||||
"Backslash": 0x2b, /* html:Backslash (Backslash) -> linux:43 (KEY_BACKSLASH) -> atset1:43 */
|
||||
"Backspace": 0xe, /* html:Backspace (Backspace) -> linux:14 (KEY_BACKSPACE) -> atset1:14 */
|
||||
"BracketLeft": 0x1a, /* html:BracketLeft (BracketLeft) -> linux:26 (KEY_LEFTBRACE) -> atset1:26 */
|
||||
"BracketRight": 0x1b, /* html:BracketRight (BracketRight) -> linux:27 (KEY_RIGHTBRACE) -> atset1:27 */
|
||||
"BrowserBack": 0xe06a, /* html:BrowserBack (BrowserBack) -> linux:158 (KEY_BACK) -> atset1:57450 */
|
||||
"BrowserFavorites": 0xe066, /* html:BrowserFavorites (BrowserFavorites) -> linux:156 (KEY_BOOKMARKS) -> atset1:57446 */
|
||||
"BrowserForward": 0xe069, /* html:BrowserForward (BrowserForward) -> linux:159 (KEY_FORWARD) -> atset1:57449 */
|
||||
"BrowserHome": 0xe032, /* html:BrowserHome (BrowserHome) -> linux:172 (KEY_HOMEPAGE) -> atset1:57394 */
|
||||
"BrowserRefresh": 0xe067, /* html:BrowserRefresh (BrowserRefresh) -> linux:173 (KEY_REFRESH) -> atset1:57447 */
|
||||
"BrowserSearch": 0xe065, /* html:BrowserSearch (BrowserSearch) -> linux:217 (KEY_SEARCH) -> atset1:57445 */
|
||||
"BrowserStop": 0xe068, /* html:BrowserStop (BrowserStop) -> linux:128 (KEY_STOP) -> atset1:57448 */
|
||||
"CapsLock": 0x3a, /* html:CapsLock (CapsLock) -> linux:58 (KEY_CAPSLOCK) -> atset1:58 */
|
||||
"Comma": 0x33, /* html:Comma (Comma) -> linux:51 (KEY_COMMA) -> atset1:51 */
|
||||
"ContextMenu": 0xe05d, /* html:ContextMenu (ContextMenu) -> linux:127 (KEY_COMPOSE) -> atset1:57437 */
|
||||
"ControlLeft": 0x1d, /* html:ControlLeft (ControlLeft) -> linux:29 (KEY_LEFTCTRL) -> atset1:29 */
|
||||
"ControlRight": 0xe01d, /* html:ControlRight (ControlRight) -> linux:97 (KEY_RIGHTCTRL) -> atset1:57373 */
|
||||
"Convert": 0x79, /* html:Convert (Convert) -> linux:92 (KEY_HENKAN) -> atset1:121 */
|
||||
"Copy": 0xe078, /* html:Copy (Copy) -> linux:133 (KEY_COPY) -> atset1:57464 */
|
||||
"Cut": 0xe03c, /* html:Cut (Cut) -> linux:137 (KEY_CUT) -> atset1:57404 */
|
||||
"Delete": 0xe053, /* html:Delete (Delete) -> linux:111 (KEY_DELETE) -> atset1:57427 */
|
||||
"Digit0": 0xb, /* html:Digit0 (Digit0) -> linux:11 (KEY_0) -> atset1:11 */
|
||||
"Digit1": 0x2, /* html:Digit1 (Digit1) -> linux:2 (KEY_1) -> atset1:2 */
|
||||
"Digit2": 0x3, /* html:Digit2 (Digit2) -> linux:3 (KEY_2) -> atset1:3 */
|
||||
"Digit3": 0x4, /* html:Digit3 (Digit3) -> linux:4 (KEY_3) -> atset1:4 */
|
||||
"Digit4": 0x5, /* html:Digit4 (Digit4) -> linux:5 (KEY_4) -> atset1:5 */
|
||||
"Digit5": 0x6, /* html:Digit5 (Digit5) -> linux:6 (KEY_5) -> atset1:6 */
|
||||
"Digit6": 0x7, /* html:Digit6 (Digit6) -> linux:7 (KEY_6) -> atset1:7 */
|
||||
"Digit7": 0x8, /* html:Digit7 (Digit7) -> linux:8 (KEY_7) -> atset1:8 */
|
||||
"Digit8": 0x9, /* html:Digit8 (Digit8) -> linux:9 (KEY_8) -> atset1:9 */
|
||||
"Digit9": 0xa, /* html:Digit9 (Digit9) -> linux:10 (KEY_9) -> atset1:10 */
|
||||
"Eject": 0xe07d, /* html:Eject (Eject) -> linux:162 (KEY_EJECTCLOSECD) -> atset1:57469 */
|
||||
"End": 0xe04f, /* html:End (End) -> linux:107 (KEY_END) -> atset1:57423 */
|
||||
"Enter": 0x1c, /* html:Enter (Enter) -> linux:28 (KEY_ENTER) -> atset1:28 */
|
||||
"Equal": 0xd, /* html:Equal (Equal) -> linux:13 (KEY_EQUAL) -> atset1:13 */
|
||||
"Escape": 0x1, /* html:Escape (Escape) -> linux:1 (KEY_ESC) -> atset1:1 */
|
||||
"F1": 0x3b, /* html:F1 (F1) -> linux:59 (KEY_F1) -> atset1:59 */
|
||||
"F10": 0x44, /* html:F10 (F10) -> linux:68 (KEY_F10) -> atset1:68 */
|
||||
"F11": 0x57, /* html:F11 (F11) -> linux:87 (KEY_F11) -> atset1:87 */
|
||||
"F12": 0x58, /* html:F12 (F12) -> linux:88 (KEY_F12) -> atset1:88 */
|
||||
"F13": 0x5d, /* html:F13 (F13) -> linux:183 (KEY_F13) -> atset1:93 */
|
||||
"F14": 0x5e, /* html:F14 (F14) -> linux:184 (KEY_F14) -> atset1:94 */
|
||||
"F15": 0x5f, /* html:F15 (F15) -> linux:185 (KEY_F15) -> atset1:95 */
|
||||
"F16": 0x55, /* html:F16 (F16) -> linux:186 (KEY_F16) -> atset1:85 */
|
||||
"F17": 0xe003, /* html:F17 (F17) -> linux:187 (KEY_F17) -> atset1:57347 */
|
||||
"F18": 0xe077, /* html:F18 (F18) -> linux:188 (KEY_F18) -> atset1:57463 */
|
||||
"F19": 0xe004, /* html:F19 (F19) -> linux:189 (KEY_F19) -> atset1:57348 */
|
||||
"F2": 0x3c, /* html:F2 (F2) -> linux:60 (KEY_F2) -> atset1:60 */
|
||||
"F20": 0x5a, /* html:F20 (F20) -> linux:190 (KEY_F20) -> atset1:90 */
|
||||
"F21": 0x74, /* html:F21 (F21) -> linux:191 (KEY_F21) -> atset1:116 */
|
||||
"F22": 0xe079, /* html:F22 (F22) -> linux:192 (KEY_F22) -> atset1:57465 */
|
||||
"F23": 0x6d, /* html:F23 (F23) -> linux:193 (KEY_F23) -> atset1:109 */
|
||||
"F24": 0x6f, /* html:F24 (F24) -> linux:194 (KEY_F24) -> atset1:111 */
|
||||
"F3": 0x3d, /* html:F3 (F3) -> linux:61 (KEY_F3) -> atset1:61 */
|
||||
"F4": 0x3e, /* html:F4 (F4) -> linux:62 (KEY_F4) -> atset1:62 */
|
||||
"F5": 0x3f, /* html:F5 (F5) -> linux:63 (KEY_F5) -> atset1:63 */
|
||||
"F6": 0x40, /* html:F6 (F6) -> linux:64 (KEY_F6) -> atset1:64 */
|
||||
"F7": 0x41, /* html:F7 (F7) -> linux:65 (KEY_F7) -> atset1:65 */
|
||||
"F8": 0x42, /* html:F8 (F8) -> linux:66 (KEY_F8) -> atset1:66 */
|
||||
"F9": 0x43, /* html:F9 (F9) -> linux:67 (KEY_F9) -> atset1:67 */
|
||||
"Find": 0xe041, /* html:Find (Find) -> linux:136 (KEY_FIND) -> atset1:57409 */
|
||||
"Help": 0xe075, /* html:Help (Help) -> linux:138 (KEY_HELP) -> atset1:57461 */
|
||||
"Hiragana": 0x77, /* html:Hiragana (Lang4) -> linux:91 (KEY_HIRAGANA) -> atset1:119 */
|
||||
"Home": 0xe047, /* html:Home (Home) -> linux:102 (KEY_HOME) -> atset1:57415 */
|
||||
"Insert": 0xe052, /* html:Insert (Insert) -> linux:110 (KEY_INSERT) -> atset1:57426 */
|
||||
"IntlBackslash": 0x56, /* html:IntlBackslash (IntlBackslash) -> linux:86 (KEY_102ND) -> atset1:86 */
|
||||
"IntlRo": 0x73, /* html:IntlRo (IntlRo) -> linux:89 (KEY_RO) -> atset1:115 */
|
||||
"IntlYen": 0x7d, /* html:IntlYen (IntlYen) -> linux:124 (KEY_YEN) -> atset1:125 */
|
||||
"KanaMode": 0x70, /* html:KanaMode (KanaMode) -> linux:93 (KEY_KATAKANAHIRAGANA) -> atset1:112 */
|
||||
"Katakana": 0x78, /* html:Katakana (Lang3) -> linux:90 (KEY_KATAKANA) -> atset1:120 */
|
||||
"KeyA": 0x1e, /* html:KeyA (KeyA) -> linux:30 (KEY_A) -> atset1:30 */
|
||||
"KeyB": 0x30, /* html:KeyB (KeyB) -> linux:48 (KEY_B) -> atset1:48 */
|
||||
"KeyC": 0x2e, /* html:KeyC (KeyC) -> linux:46 (KEY_C) -> atset1:46 */
|
||||
"KeyD": 0x20, /* html:KeyD (KeyD) -> linux:32 (KEY_D) -> atset1:32 */
|
||||
"KeyE": 0x12, /* html:KeyE (KeyE) -> linux:18 (KEY_E) -> atset1:18 */
|
||||
"KeyF": 0x21, /* html:KeyF (KeyF) -> linux:33 (KEY_F) -> atset1:33 */
|
||||
"KeyG": 0x22, /* html:KeyG (KeyG) -> linux:34 (KEY_G) -> atset1:34 */
|
||||
"KeyH": 0x23, /* html:KeyH (KeyH) -> linux:35 (KEY_H) -> atset1:35 */
|
||||
"KeyI": 0x17, /* html:KeyI (KeyI) -> linux:23 (KEY_I) -> atset1:23 */
|
||||
"KeyJ": 0x24, /* html:KeyJ (KeyJ) -> linux:36 (KEY_J) -> atset1:36 */
|
||||
"KeyK": 0x25, /* html:KeyK (KeyK) -> linux:37 (KEY_K) -> atset1:37 */
|
||||
"KeyL": 0x26, /* html:KeyL (KeyL) -> linux:38 (KEY_L) -> atset1:38 */
|
||||
"KeyM": 0x32, /* html:KeyM (KeyM) -> linux:50 (KEY_M) -> atset1:50 */
|
||||
"KeyN": 0x31, /* html:KeyN (KeyN) -> linux:49 (KEY_N) -> atset1:49 */
|
||||
"KeyO": 0x18, /* html:KeyO (KeyO) -> linux:24 (KEY_O) -> atset1:24 */
|
||||
"KeyP": 0x19, /* html:KeyP (KeyP) -> linux:25 (KEY_P) -> atset1:25 */
|
||||
"KeyQ": 0x10, /* html:KeyQ (KeyQ) -> linux:16 (KEY_Q) -> atset1:16 */
|
||||
"KeyR": 0x13, /* html:KeyR (KeyR) -> linux:19 (KEY_R) -> atset1:19 */
|
||||
"KeyS": 0x1f, /* html:KeyS (KeyS) -> linux:31 (KEY_S) -> atset1:31 */
|
||||
"KeyT": 0x14, /* html:KeyT (KeyT) -> linux:20 (KEY_T) -> atset1:20 */
|
||||
"KeyU": 0x16, /* html:KeyU (KeyU) -> linux:22 (KEY_U) -> atset1:22 */
|
||||
"KeyV": 0x2f, /* html:KeyV (KeyV) -> linux:47 (KEY_V) -> atset1:47 */
|
||||
"KeyW": 0x11, /* html:KeyW (KeyW) -> linux:17 (KEY_W) -> atset1:17 */
|
||||
"KeyX": 0x2d, /* html:KeyX (KeyX) -> linux:45 (KEY_X) -> atset1:45 */
|
||||
"KeyY": 0x15, /* html:KeyY (KeyY) -> linux:21 (KEY_Y) -> atset1:21 */
|
||||
"KeyZ": 0x2c, /* html:KeyZ (KeyZ) -> linux:44 (KEY_Z) -> atset1:44 */
|
||||
"Lang3": 0x78, /* html:Lang3 (Lang3) -> linux:90 (KEY_KATAKANA) -> atset1:120 */
|
||||
"Lang4": 0x77, /* html:Lang4 (Lang4) -> linux:91 (KEY_HIRAGANA) -> atset1:119 */
|
||||
"Lang5": 0x76, /* html:Lang5 (Lang5) -> linux:85 (KEY_ZENKAKUHANKAKU) -> atset1:118 */
|
||||
"LaunchApp1": 0xe06b, /* html:LaunchApp1 (LaunchApp1) -> linux:157 (KEY_COMPUTER) -> atset1:57451 */
|
||||
"LaunchApp2": 0xe021, /* html:LaunchApp2 (LaunchApp2) -> linux:140 (KEY_CALC) -> atset1:57377 */
|
||||
"LaunchMail": 0xe06c, /* html:LaunchMail (LaunchMail) -> linux:155 (KEY_MAIL) -> atset1:57452 */
|
||||
"MediaPlayPause": 0xe022, /* html:MediaPlayPause (MediaPlayPause) -> linux:164 (KEY_PLAYPAUSE) -> atset1:57378 */
|
||||
"MediaSelect": 0xe06d, /* html:MediaSelect (MediaSelect) -> linux:226 (KEY_MEDIA) -> atset1:57453 */
|
||||
"MediaStop": 0xe024, /* html:MediaStop (MediaStop) -> linux:166 (KEY_STOPCD) -> atset1:57380 */
|
||||
"MediaTrackNext": 0xe019, /* html:MediaTrackNext (MediaTrackNext) -> linux:163 (KEY_NEXTSONG) -> atset1:57369 */
|
||||
"MediaTrackPrevious": 0xe010, /* html:MediaTrackPrevious (MediaTrackPrevious) -> linux:165 (KEY_PREVIOUSSONG) -> atset1:57360 */
|
||||
"MetaLeft": 0xe05b, /* html:MetaLeft (MetaLeft) -> linux:125 (KEY_LEFTMETA) -> atset1:57435 */
|
||||
"MetaRight": 0xe05c, /* html:MetaRight (MetaRight) -> linux:126 (KEY_RIGHTMETA) -> atset1:57436 */
|
||||
"Minus": 0xc, /* html:Minus (Minus) -> linux:12 (KEY_MINUS) -> atset1:12 */
|
||||
"NonConvert": 0x7b, /* html:NonConvert (NonConvert) -> linux:94 (KEY_MUHENKAN) -> atset1:123 */
|
||||
"NumLock": 0x45, /* html:NumLock (NumLock) -> linux:69 (KEY_NUMLOCK) -> atset1:69 */
|
||||
"Numpad0": 0x52, /* html:Numpad0 (Numpad0) -> linux:82 (KEY_KP0) -> atset1:82 */
|
||||
"Numpad1": 0x4f, /* html:Numpad1 (Numpad1) -> linux:79 (KEY_KP1) -> atset1:79 */
|
||||
"Numpad2": 0x50, /* html:Numpad2 (Numpad2) -> linux:80 (KEY_KP2) -> atset1:80 */
|
||||
"Numpad3": 0x51, /* html:Numpad3 (Numpad3) -> linux:81 (KEY_KP3) -> atset1:81 */
|
||||
"Numpad4": 0x4b, /* html:Numpad4 (Numpad4) -> linux:75 (KEY_KP4) -> atset1:75 */
|
||||
"Numpad5": 0x4c, /* html:Numpad5 (Numpad5) -> linux:76 (KEY_KP5) -> atset1:76 */
|
||||
"Numpad6": 0x4d, /* html:Numpad6 (Numpad6) -> linux:77 (KEY_KP6) -> atset1:77 */
|
||||
"Numpad7": 0x47, /* html:Numpad7 (Numpad7) -> linux:71 (KEY_KP7) -> atset1:71 */
|
||||
"Numpad8": 0x48, /* html:Numpad8 (Numpad8) -> linux:72 (KEY_KP8) -> atset1:72 */
|
||||
"Numpad9": 0x49, /* html:Numpad9 (Numpad9) -> linux:73 (KEY_KP9) -> atset1:73 */
|
||||
"NumpadAdd": 0x4e, /* html:NumpadAdd (NumpadAdd) -> linux:78 (KEY_KPPLUS) -> atset1:78 */
|
||||
"NumpadComma": 0x7e, /* html:NumpadComma (NumpadComma) -> linux:121 (KEY_KPCOMMA) -> atset1:126 */
|
||||
"NumpadDecimal": 0x53, /* html:NumpadDecimal (NumpadDecimal) -> linux:83 (KEY_KPDOT) -> atset1:83 */
|
||||
"NumpadDivide": 0xe035, /* html:NumpadDivide (NumpadDivide) -> linux:98 (KEY_KPSLASH) -> atset1:57397 */
|
||||
"NumpadEnter": 0xe01c, /* html:NumpadEnter (NumpadEnter) -> linux:96 (KEY_KPENTER) -> atset1:57372 */
|
||||
"NumpadEqual": 0x59, /* html:NumpadEqual (NumpadEqual) -> linux:117 (KEY_KPEQUAL) -> atset1:89 */
|
||||
"NumpadMultiply": 0x37, /* html:NumpadMultiply (NumpadMultiply) -> linux:55 (KEY_KPASTERISK) -> atset1:55 */
|
||||
"NumpadParenLeft": 0xe076, /* html:NumpadParenLeft (NumpadParenLeft) -> linux:179 (KEY_KPLEFTPAREN) -> atset1:57462 */
|
||||
"NumpadParenRight": 0xe07b, /* html:NumpadParenRight (NumpadParenRight) -> linux:180 (KEY_KPRIGHTPAREN) -> atset1:57467 */
|
||||
"NumpadSubtract": 0x4a, /* html:NumpadSubtract (NumpadSubtract) -> linux:74 (KEY_KPMINUS) -> atset1:74 */
|
||||
"Open": 0x64, /* html:Open (Open) -> linux:134 (KEY_OPEN) -> atset1:100 */
|
||||
"PageDown": 0xe051, /* html:PageDown (PageDown) -> linux:109 (KEY_PAGEDOWN) -> atset1:57425 */
|
||||
"PageUp": 0xe049, /* html:PageUp (PageUp) -> linux:104 (KEY_PAGEUP) -> atset1:57417 */
|
||||
"Paste": 0x65, /* html:Paste (Paste) -> linux:135 (KEY_PASTE) -> atset1:101 */
|
||||
"Pause": 0xe046, /* html:Pause (Pause) -> linux:119 (KEY_PAUSE) -> atset1:57414 */
|
||||
"Period": 0x34, /* html:Period (Period) -> linux:52 (KEY_DOT) -> atset1:52 */
|
||||
"Power": 0xe05e, /* html:Power (Power) -> linux:116 (KEY_POWER) -> atset1:57438 */
|
||||
"PrintScreen": 0x54, /* html:PrintScreen (PrintScreen) -> linux:99 (KEY_SYSRQ) -> atset1:84 */
|
||||
"Props": 0xe006, /* html:Props (Props) -> linux:130 (KEY_PROPS) -> atset1:57350 */
|
||||
"Quote": 0x28, /* html:Quote (Quote) -> linux:40 (KEY_APOSTROPHE) -> atset1:40 */
|
||||
"ScrollLock": 0x46, /* html:ScrollLock (ScrollLock) -> linux:70 (KEY_SCROLLLOCK) -> atset1:70 */
|
||||
"Semicolon": 0x27, /* html:Semicolon (Semicolon) -> linux:39 (KEY_SEMICOLON) -> atset1:39 */
|
||||
"ShiftLeft": 0x2a, /* html:ShiftLeft (ShiftLeft) -> linux:42 (KEY_LEFTSHIFT) -> atset1:42 */
|
||||
"ShiftRight": 0x36, /* html:ShiftRight (ShiftRight) -> linux:54 (KEY_RIGHTSHIFT) -> atset1:54 */
|
||||
"Slash": 0x35, /* html:Slash (Slash) -> linux:53 (KEY_SLASH) -> atset1:53 */
|
||||
"Sleep": 0xe05f, /* html:Sleep (Sleep) -> linux:142 (KEY_SLEEP) -> atset1:57439 */
|
||||
"Space": 0x39, /* html:Space (Space) -> linux:57 (KEY_SPACE) -> atset1:57 */
|
||||
"Suspend": 0xe025, /* html:Suspend (Suspend) -> linux:205 (KEY_SUSPEND) -> atset1:57381 */
|
||||
"Tab": 0xf, /* html:Tab (Tab) -> linux:15 (KEY_TAB) -> atset1:15 */
|
||||
"Undo": 0xe007, /* html:Undo (Undo) -> linux:131 (KEY_UNDO) -> atset1:57351 */
|
||||
"WakeUp": 0xe063, /* html:WakeUp (WakeUp) -> linux:143 (KEY_WAKEUP) -> atset1:57443 */
|
||||
Again: 0xe005, /* html:Again (Again) -> linux:129 (KEY_AGAIN) -> atset1:57349 */
|
||||
AltLeft: 0x38, /* html:AltLeft (AltLeft) -> linux:56 (KEY_LEFTALT) -> atset1:56 */
|
||||
AltRight: 0xe038, /* html:AltRight (AltRight) -> linux:100 (KEY_RIGHTALT) -> atset1:57400 */
|
||||
ArrowDown: 0xe050, /* html:ArrowDown (ArrowDown) -> linux:108 (KEY_DOWN) -> atset1:57424 */
|
||||
ArrowLeft: 0xe04b, /* html:ArrowLeft (ArrowLeft) -> linux:105 (KEY_LEFT) -> atset1:57419 */
|
||||
ArrowRight: 0xe04d, /* html:ArrowRight (ArrowRight) -> linux:106 (KEY_RIGHT) -> atset1:57421 */
|
||||
ArrowUp: 0xe048, /* html:ArrowUp (ArrowUp) -> linux:103 (KEY_UP) -> atset1:57416 */
|
||||
AudioVolumeDown: 0xe02e, /* html:AudioVolumeDown (AudioVolumeDown) -> linux:114 (KEY_VOLUMEDOWN) -> atset1:57390 */
|
||||
AudioVolumeMute: 0xe020, /* html:AudioVolumeMute (AudioVolumeMute) -> linux:113 (KEY_MUTE) -> atset1:57376 */
|
||||
AudioVolumeUp: 0xe030, /* html:AudioVolumeUp (AudioVolumeUp) -> linux:115 (KEY_VOLUMEUP) -> atset1:57392 */
|
||||
Backquote: 0x29, /* html:Backquote (Backquote) -> linux:41 (KEY_GRAVE) -> atset1:41 */
|
||||
Backslash: 0x2b, /* html:Backslash (Backslash) -> linux:43 (KEY_BACKSLASH) -> atset1:43 */
|
||||
Backspace: 0xe, /* html:Backspace (Backspace) -> linux:14 (KEY_BACKSPACE) -> atset1:14 */
|
||||
BracketLeft: 0x1a, /* html:BracketLeft (BracketLeft) -> linux:26 (KEY_LEFTBRACE) -> atset1:26 */
|
||||
BracketRight: 0x1b, /* html:BracketRight (BracketRight) -> linux:27 (KEY_RIGHTBRACE) -> atset1:27 */
|
||||
BrowserBack: 0xe06a, /* html:BrowserBack (BrowserBack) -> linux:158 (KEY_BACK) -> atset1:57450 */
|
||||
BrowserFavorites: 0xe066, /* html:BrowserFavorites (BrowserFavorites) -> linux:156 (KEY_BOOKMARKS) -> atset1:57446 */
|
||||
BrowserForward: 0xe069, /* html:BrowserForward (BrowserForward) -> linux:159 (KEY_FORWARD) -> atset1:57449 */
|
||||
BrowserHome: 0xe032, /* html:BrowserHome (BrowserHome) -> linux:172 (KEY_HOMEPAGE) -> atset1:57394 */
|
||||
BrowserRefresh: 0xe067, /* html:BrowserRefresh (BrowserRefresh) -> linux:173 (KEY_REFRESH) -> atset1:57447 */
|
||||
BrowserSearch: 0xe065, /* html:BrowserSearch (BrowserSearch) -> linux:217 (KEY_SEARCH) -> atset1:57445 */
|
||||
BrowserStop: 0xe068, /* html:BrowserStop (BrowserStop) -> linux:128 (KEY_STOP) -> atset1:57448 */
|
||||
CapsLock: 0x3a, /* html:CapsLock (CapsLock) -> linux:58 (KEY_CAPSLOCK) -> atset1:58 */
|
||||
Comma: 0x33, /* html:Comma (Comma) -> linux:51 (KEY_COMMA) -> atset1:51 */
|
||||
ContextMenu: 0xe05d, /* html:ContextMenu (ContextMenu) -> linux:127 (KEY_COMPOSE) -> atset1:57437 */
|
||||
ControlLeft: 0x1d, /* html:ControlLeft (ControlLeft) -> linux:29 (KEY_LEFTCTRL) -> atset1:29 */
|
||||
ControlRight: 0xe01d, /* html:ControlRight (ControlRight) -> linux:97 (KEY_RIGHTCTRL) -> atset1:57373 */
|
||||
Convert: 0x79, /* html:Convert (Convert) -> linux:92 (KEY_HENKAN) -> atset1:121 */
|
||||
Copy: 0xe078, /* html:Copy (Copy) -> linux:133 (KEY_COPY) -> atset1:57464 */
|
||||
Cut: 0xe03c, /* html:Cut (Cut) -> linux:137 (KEY_CUT) -> atset1:57404 */
|
||||
Delete: 0xe053, /* html:Delete (Delete) -> linux:111 (KEY_DELETE) -> atset1:57427 */
|
||||
Digit0: 0xb, /* html:Digit0 (Digit0) -> linux:11 (KEY_0) -> atset1:11 */
|
||||
Digit1: 0x2, /* html:Digit1 (Digit1) -> linux:2 (KEY_1) -> atset1:2 */
|
||||
Digit2: 0x3, /* html:Digit2 (Digit2) -> linux:3 (KEY_2) -> atset1:3 */
|
||||
Digit3: 0x4, /* html:Digit3 (Digit3) -> linux:4 (KEY_3) -> atset1:4 */
|
||||
Digit4: 0x5, /* html:Digit4 (Digit4) -> linux:5 (KEY_4) -> atset1:5 */
|
||||
Digit5: 0x6, /* html:Digit5 (Digit5) -> linux:6 (KEY_5) -> atset1:6 */
|
||||
Digit6: 0x7, /* html:Digit6 (Digit6) -> linux:7 (KEY_6) -> atset1:7 */
|
||||
Digit7: 0x8, /* html:Digit7 (Digit7) -> linux:8 (KEY_7) -> atset1:8 */
|
||||
Digit8: 0x9, /* html:Digit8 (Digit8) -> linux:9 (KEY_8) -> atset1:9 */
|
||||
Digit9: 0xa, /* html:Digit9 (Digit9) -> linux:10 (KEY_9) -> atset1:10 */
|
||||
Eject: 0xe07d, /* html:Eject (Eject) -> linux:162 (KEY_EJECTCLOSECD) -> atset1:57469 */
|
||||
End: 0xe04f, /* html:End (End) -> linux:107 (KEY_END) -> atset1:57423 */
|
||||
Enter: 0x1c, /* html:Enter (Enter) -> linux:28 (KEY_ENTER) -> atset1:28 */
|
||||
Equal: 0xd, /* html:Equal (Equal) -> linux:13 (KEY_EQUAL) -> atset1:13 */
|
||||
Escape: 0x1, /* html:Escape (Escape) -> linux:1 (KEY_ESC) -> atset1:1 */
|
||||
F1: 0x3b, /* html:F1 (F1) -> linux:59 (KEY_F1) -> atset1:59 */
|
||||
F10: 0x44, /* html:F10 (F10) -> linux:68 (KEY_F10) -> atset1:68 */
|
||||
F11: 0x57, /* html:F11 (F11) -> linux:87 (KEY_F11) -> atset1:87 */
|
||||
F12: 0x58, /* html:F12 (F12) -> linux:88 (KEY_F12) -> atset1:88 */
|
||||
F13: 0x5d, /* html:F13 (F13) -> linux:183 (KEY_F13) -> atset1:93 */
|
||||
F14: 0x5e, /* html:F14 (F14) -> linux:184 (KEY_F14) -> atset1:94 */
|
||||
F15: 0x5f, /* html:F15 (F15) -> linux:185 (KEY_F15) -> atset1:95 */
|
||||
F16: 0x55, /* html:F16 (F16) -> linux:186 (KEY_F16) -> atset1:85 */
|
||||
F17: 0xe003, /* html:F17 (F17) -> linux:187 (KEY_F17) -> atset1:57347 */
|
||||
F18: 0xe077, /* html:F18 (F18) -> linux:188 (KEY_F18) -> atset1:57463 */
|
||||
F19: 0xe004, /* html:F19 (F19) -> linux:189 (KEY_F19) -> atset1:57348 */
|
||||
F2: 0x3c, /* html:F2 (F2) -> linux:60 (KEY_F2) -> atset1:60 */
|
||||
F20: 0x5a, /* html:F20 (F20) -> linux:190 (KEY_F20) -> atset1:90 */
|
||||
F21: 0x74, /* html:F21 (F21) -> linux:191 (KEY_F21) -> atset1:116 */
|
||||
F22: 0xe079, /* html:F22 (F22) -> linux:192 (KEY_F22) -> atset1:57465 */
|
||||
F23: 0x6d, /* html:F23 (F23) -> linux:193 (KEY_F23) -> atset1:109 */
|
||||
F24: 0x6f, /* html:F24 (F24) -> linux:194 (KEY_F24) -> atset1:111 */
|
||||
F3: 0x3d, /* html:F3 (F3) -> linux:61 (KEY_F3) -> atset1:61 */
|
||||
F4: 0x3e, /* html:F4 (F4) -> linux:62 (KEY_F4) -> atset1:62 */
|
||||
F5: 0x3f, /* html:F5 (F5) -> linux:63 (KEY_F5) -> atset1:63 */
|
||||
F6: 0x40, /* html:F6 (F6) -> linux:64 (KEY_F6) -> atset1:64 */
|
||||
F7: 0x41, /* html:F7 (F7) -> linux:65 (KEY_F7) -> atset1:65 */
|
||||
F8: 0x42, /* html:F8 (F8) -> linux:66 (KEY_F8) -> atset1:66 */
|
||||
F9: 0x43, /* html:F9 (F9) -> linux:67 (KEY_F9) -> atset1:67 */
|
||||
Find: 0xe041, /* html:Find (Find) -> linux:136 (KEY_FIND) -> atset1:57409 */
|
||||
Help: 0xe075, /* html:Help (Help) -> linux:138 (KEY_HELP) -> atset1:57461 */
|
||||
Hiragana: 0x77, /* html:Hiragana (Lang4) -> linux:91 (KEY_HIRAGANA) -> atset1:119 */
|
||||
Home: 0xe047, /* html:Home (Home) -> linux:102 (KEY_HOME) -> atset1:57415 */
|
||||
Insert: 0xe052, /* html:Insert (Insert) -> linux:110 (KEY_INSERT) -> atset1:57426 */
|
||||
IntlBackslash: 0x56, /* html:IntlBackslash (IntlBackslash) -> linux:86 (KEY_102ND) -> atset1:86 */
|
||||
IntlRo: 0x73, /* html:IntlRo (IntlRo) -> linux:89 (KEY_RO) -> atset1:115 */
|
||||
IntlYen: 0x7d, /* html:IntlYen (IntlYen) -> linux:124 (KEY_YEN) -> atset1:125 */
|
||||
KanaMode: 0x70, /* html:KanaMode (KanaMode) -> linux:93 (KEY_KATAKANAHIRAGANA) -> atset1:112 */
|
||||
Katakana: 0x78, /* html:Katakana (Lang3) -> linux:90 (KEY_KATAKANA) -> atset1:120 */
|
||||
KeyA: 0x1e, /* html:KeyA (KeyA) -> linux:30 (KEY_A) -> atset1:30 */
|
||||
KeyB: 0x30, /* html:KeyB (KeyB) -> linux:48 (KEY_B) -> atset1:48 */
|
||||
KeyC: 0x2e, /* html:KeyC (KeyC) -> linux:46 (KEY_C) -> atset1:46 */
|
||||
KeyD: 0x20, /* html:KeyD (KeyD) -> linux:32 (KEY_D) -> atset1:32 */
|
||||
KeyE: 0x12, /* html:KeyE (KeyE) -> linux:18 (KEY_E) -> atset1:18 */
|
||||
KeyF: 0x21, /* html:KeyF (KeyF) -> linux:33 (KEY_F) -> atset1:33 */
|
||||
KeyG: 0x22, /* html:KeyG (KeyG) -> linux:34 (KEY_G) -> atset1:34 */
|
||||
KeyH: 0x23, /* html:KeyH (KeyH) -> linux:35 (KEY_H) -> atset1:35 */
|
||||
KeyI: 0x17, /* html:KeyI (KeyI) -> linux:23 (KEY_I) -> atset1:23 */
|
||||
KeyJ: 0x24, /* html:KeyJ (KeyJ) -> linux:36 (KEY_J) -> atset1:36 */
|
||||
KeyK: 0x25, /* html:KeyK (KeyK) -> linux:37 (KEY_K) -> atset1:37 */
|
||||
KeyL: 0x26, /* html:KeyL (KeyL) -> linux:38 (KEY_L) -> atset1:38 */
|
||||
KeyM: 0x32, /* html:KeyM (KeyM) -> linux:50 (KEY_M) -> atset1:50 */
|
||||
KeyN: 0x31, /* html:KeyN (KeyN) -> linux:49 (KEY_N) -> atset1:49 */
|
||||
KeyO: 0x18, /* html:KeyO (KeyO) -> linux:24 (KEY_O) -> atset1:24 */
|
||||
KeyP: 0x19, /* html:KeyP (KeyP) -> linux:25 (KEY_P) -> atset1:25 */
|
||||
KeyQ: 0x10, /* html:KeyQ (KeyQ) -> linux:16 (KEY_Q) -> atset1:16 */
|
||||
KeyR: 0x13, /* html:KeyR (KeyR) -> linux:19 (KEY_R) -> atset1:19 */
|
||||
KeyS: 0x1f, /* html:KeyS (KeyS) -> linux:31 (KEY_S) -> atset1:31 */
|
||||
KeyT: 0x14, /* html:KeyT (KeyT) -> linux:20 (KEY_T) -> atset1:20 */
|
||||
KeyU: 0x16, /* html:KeyU (KeyU) -> linux:22 (KEY_U) -> atset1:22 */
|
||||
KeyV: 0x2f, /* html:KeyV (KeyV) -> linux:47 (KEY_V) -> atset1:47 */
|
||||
KeyW: 0x11, /* html:KeyW (KeyW) -> linux:17 (KEY_W) -> atset1:17 */
|
||||
KeyX: 0x2d, /* html:KeyX (KeyX) -> linux:45 (KEY_X) -> atset1:45 */
|
||||
KeyY: 0x15, /* html:KeyY (KeyY) -> linux:21 (KEY_Y) -> atset1:21 */
|
||||
KeyZ: 0x2c, /* html:KeyZ (KeyZ) -> linux:44 (KEY_Z) -> atset1:44 */
|
||||
Lang3: 0x78, /* html:Lang3 (Lang3) -> linux:90 (KEY_KATAKANA) -> atset1:120 */
|
||||
Lang4: 0x77, /* html:Lang4 (Lang4) -> linux:91 (KEY_HIRAGANA) -> atset1:119 */
|
||||
Lang5: 0x76, /* html:Lang5 (Lang5) -> linux:85 (KEY_ZENKAKUHANKAKU) -> atset1:118 */
|
||||
LaunchApp1: 0xe06b, /* html:LaunchApp1 (LaunchApp1) -> linux:157 (KEY_COMPUTER) -> atset1:57451 */
|
||||
LaunchApp2: 0xe021, /* html:LaunchApp2 (LaunchApp2) -> linux:140 (KEY_CALC) -> atset1:57377 */
|
||||
LaunchMail: 0xe06c, /* html:LaunchMail (LaunchMail) -> linux:155 (KEY_MAIL) -> atset1:57452 */
|
||||
MediaPlayPause: 0xe022, /* html:MediaPlayPause (MediaPlayPause) -> linux:164 (KEY_PLAYPAUSE) -> atset1:57378 */
|
||||
MediaSelect: 0xe06d, /* html:MediaSelect (MediaSelect) -> linux:226 (KEY_MEDIA) -> atset1:57453 */
|
||||
MediaStop: 0xe024, /* html:MediaStop (MediaStop) -> linux:166 (KEY_STOPCD) -> atset1:57380 */
|
||||
MediaTrackNext: 0xe019, /* html:MediaTrackNext (MediaTrackNext) -> linux:163 (KEY_NEXTSONG) -> atset1:57369 */
|
||||
MediaTrackPrevious: 0xe010, /* html:MediaTrackPrevious (MediaTrackPrevious) -> linux:165 (KEY_PREVIOUSSONG) -> atset1:57360 */
|
||||
MetaLeft: 0xe05b, /* html:MetaLeft (MetaLeft) -> linux:125 (KEY_LEFTMETA) -> atset1:57435 */
|
||||
MetaRight: 0xe05c, /* html:MetaRight (MetaRight) -> linux:126 (KEY_RIGHTMETA) -> atset1:57436 */
|
||||
Minus: 0xc, /* html:Minus (Minus) -> linux:12 (KEY_MINUS) -> atset1:12 */
|
||||
NonConvert: 0x7b, /* html:NonConvert (NonConvert) -> linux:94 (KEY_MUHENKAN) -> atset1:123 */
|
||||
NumLock: 0x45, /* html:NumLock (NumLock) -> linux:69 (KEY_NUMLOCK) -> atset1:69 */
|
||||
Numpad0: 0x52, /* html:Numpad0 (Numpad0) -> linux:82 (KEY_KP0) -> atset1:82 */
|
||||
Numpad1: 0x4f, /* html:Numpad1 (Numpad1) -> linux:79 (KEY_KP1) -> atset1:79 */
|
||||
Numpad2: 0x50, /* html:Numpad2 (Numpad2) -> linux:80 (KEY_KP2) -> atset1:80 */
|
||||
Numpad3: 0x51, /* html:Numpad3 (Numpad3) -> linux:81 (KEY_KP3) -> atset1:81 */
|
||||
Numpad4: 0x4b, /* html:Numpad4 (Numpad4) -> linux:75 (KEY_KP4) -> atset1:75 */
|
||||
Numpad5: 0x4c, /* html:Numpad5 (Numpad5) -> linux:76 (KEY_KP5) -> atset1:76 */
|
||||
Numpad6: 0x4d, /* html:Numpad6 (Numpad6) -> linux:77 (KEY_KP6) -> atset1:77 */
|
||||
Numpad7: 0x47, /* html:Numpad7 (Numpad7) -> linux:71 (KEY_KP7) -> atset1:71 */
|
||||
Numpad8: 0x48, /* html:Numpad8 (Numpad8) -> linux:72 (KEY_KP8) -> atset1:72 */
|
||||
Numpad9: 0x49, /* html:Numpad9 (Numpad9) -> linux:73 (KEY_KP9) -> atset1:73 */
|
||||
NumpadAdd: 0x4e, /* html:NumpadAdd (NumpadAdd) -> linux:78 (KEY_KPPLUS) -> atset1:78 */
|
||||
NumpadComma: 0x7e, /* html:NumpadComma (NumpadComma) -> linux:121 (KEY_KPCOMMA) -> atset1:126 */
|
||||
NumpadDecimal: 0x53, /* html:NumpadDecimal (NumpadDecimal) -> linux:83 (KEY_KPDOT) -> atset1:83 */
|
||||
NumpadDivide: 0xe035, /* html:NumpadDivide (NumpadDivide) -> linux:98 (KEY_KPSLASH) -> atset1:57397 */
|
||||
NumpadEnter: 0xe01c, /* html:NumpadEnter (NumpadEnter) -> linux:96 (KEY_KPENTER) -> atset1:57372 */
|
||||
NumpadEqual: 0x59, /* html:NumpadEqual (NumpadEqual) -> linux:117 (KEY_KPEQUAL) -> atset1:89 */
|
||||
NumpadMultiply: 0x37, /* html:NumpadMultiply (NumpadMultiply) -> linux:55 (KEY_KPASTERISK) -> atset1:55 */
|
||||
NumpadParenLeft: 0xe076, /* html:NumpadParenLeft (NumpadParenLeft) -> linux:179 (KEY_KPLEFTPAREN) -> atset1:57462 */
|
||||
NumpadParenRight: 0xe07b, /* html:NumpadParenRight (NumpadParenRight) -> linux:180 (KEY_KPRIGHTPAREN) -> atset1:57467 */
|
||||
NumpadSubtract: 0x4a, /* html:NumpadSubtract (NumpadSubtract) -> linux:74 (KEY_KPMINUS) -> atset1:74 */
|
||||
Open: 0x64, /* html:Open (Open) -> linux:134 (KEY_OPEN) -> atset1:100 */
|
||||
PageDown: 0xe051, /* html:PageDown (PageDown) -> linux:109 (KEY_PAGEDOWN) -> atset1:57425 */
|
||||
PageUp: 0xe049, /* html:PageUp (PageUp) -> linux:104 (KEY_PAGEUP) -> atset1:57417 */
|
||||
Paste: 0x65, /* html:Paste (Paste) -> linux:135 (KEY_PASTE) -> atset1:101 */
|
||||
Pause: 0xe046, /* html:Pause (Pause) -> linux:119 (KEY_PAUSE) -> atset1:57414 */
|
||||
Period: 0x34, /* html:Period (Period) -> linux:52 (KEY_DOT) -> atset1:52 */
|
||||
Power: 0xe05e, /* html:Power (Power) -> linux:116 (KEY_POWER) -> atset1:57438 */
|
||||
PrintScreen: 0x54, /* html:PrintScreen (PrintScreen) -> linux:99 (KEY_SYSRQ) -> atset1:84 */
|
||||
Props: 0xe006, /* html:Props (Props) -> linux:130 (KEY_PROPS) -> atset1:57350 */
|
||||
Quote: 0x28, /* html:Quote (Quote) -> linux:40 (KEY_APOSTROPHE) -> atset1:40 */
|
||||
ScrollLock: 0x46, /* html:ScrollLock (ScrollLock) -> linux:70 (KEY_SCROLLLOCK) -> atset1:70 */
|
||||
Semicolon: 0x27, /* html:Semicolon (Semicolon) -> linux:39 (KEY_SEMICOLON) -> atset1:39 */
|
||||
ShiftLeft: 0x2a, /* html:ShiftLeft (ShiftLeft) -> linux:42 (KEY_LEFTSHIFT) -> atset1:42 */
|
||||
ShiftRight: 0x36, /* html:ShiftRight (ShiftRight) -> linux:54 (KEY_RIGHTSHIFT) -> atset1:54 */
|
||||
Slash: 0x35, /* html:Slash (Slash) -> linux:53 (KEY_SLASH) -> atset1:53 */
|
||||
Sleep: 0xe05f, /* html:Sleep (Sleep) -> linux:142 (KEY_SLEEP) -> atset1:57439 */
|
||||
Space: 0x39, /* html:Space (Space) -> linux:57 (KEY_SPACE) -> atset1:57 */
|
||||
Suspend: 0xe025, /* html:Suspend (Suspend) -> linux:205 (KEY_SUSPEND) -> atset1:57381 */
|
||||
Tab: 0xf, /* html:Tab (Tab) -> linux:15 (KEY_TAB) -> atset1:15 */
|
||||
Undo: 0xe007, /* html:Undo (Undo) -> linux:131 (KEY_UNDO) -> atset1:57351 */
|
||||
WakeUp: 0xe063, /* html:WakeUp (WakeUp) -> linux:143 (KEY_WAKEUP) -> atset1:57443 */
|
||||
};
|
||||
|
|
|
|||
615
core/rfb.js
615
core/rfb.js
File diff suppressed because it is too large
Load Diff
|
|
@ -9,12 +9,12 @@
|
|||
import * as Log from './logging.js';
|
||||
|
||||
// Touch detection
|
||||
export let isTouchDevice = ('ontouchstart' in document.documentElement) ||
|
||||
export let isTouchDevice = ('ontouchstart' in document.documentElement)
|
||||
// requried for Chrome debugger
|
||||
(document.ontouchstart !== undefined) ||
|
||||
|| (document.ontouchstart !== undefined)
|
||||
// required for MS Surface
|
||||
(navigator.maxTouchPoints > 0) ||
|
||||
(navigator.msMaxTouchPoints > 0);
|
||||
|| (navigator.maxTouchPoints > 0)
|
||||
|| (navigator.msMaxTouchPoints > 0);
|
||||
window.addEventListener('touchstart', function onFirstTouch() {
|
||||
isTouchDevice = true;
|
||||
window.removeEventListener('touchstart', onFirstTouch, false);
|
||||
|
|
@ -29,14 +29,14 @@ export function supportsCursorURIs () {
|
|||
target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
|
||||
|
||||
if (target.style.cursor) {
|
||||
Log.Info("Data URI scheme cursor supported");
|
||||
Log.Info('Data URI scheme cursor supported');
|
||||
_cursor_uris_supported = true;
|
||||
} else {
|
||||
Log.Warn("Data URI scheme cursor not supported");
|
||||
Log.Warn('Data URI scheme cursor not supported');
|
||||
_cursor_uris_supported = false;
|
||||
}
|
||||
} catch (exc) {
|
||||
Log.Error("Data URI scheme cursor test exception: " + exc);
|
||||
Log.Error('Data URI scheme cursor test exception: ' + exc);
|
||||
_cursor_uris_supported = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -65,9 +65,8 @@ export function isWindows() {
|
|||
}
|
||||
|
||||
export function isIOS() {
|
||||
return navigator &&
|
||||
(!!(/ipad/i).exec(navigator.platform) ||
|
||||
!!(/iphone/i).exec(navigator.platform) ||
|
||||
!!(/ipod/i).exec(navigator.platform));
|
||||
return navigator
|
||||
&& (!!(/ipad/i).exec(navigator.platform)
|
||||
|| !!(/iphone/i).exec(navigator.platform)
|
||||
|| !!(/ipod/i).exec(navigator.platform));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ export default class Cursor {
|
|||
this._hotSpot = { x: 0, y: 0 };
|
||||
|
||||
this._eventHandlers = {
|
||||
'mouseover': this._handleMouseOver.bind(this),
|
||||
'mouseleave': this._handleMouseLeave.bind(this),
|
||||
'mousemove': this._handleMouseMove.bind(this),
|
||||
'mouseup': this._handleMouseUp.bind(this),
|
||||
'touchstart': this._handleTouchStart.bind(this),
|
||||
'touchmove': this._handleTouchMove.bind(this),
|
||||
'touchend': this._handleTouchEnd.bind(this),
|
||||
mouseover: this._handleMouseOver.bind(this),
|
||||
mouseleave: this._handleMouseLeave.bind(this),
|
||||
mousemove: this._handleMouseMove.bind(this),
|
||||
mouseup: this._handleMouseUp.bind(this),
|
||||
touchstart: this._handleTouchStart.bind(this),
|
||||
touchmove: this._handleTouchMove.bind(this),
|
||||
touchend: this._handleTouchEnd.bind(this),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ export default class Cursor {
|
|||
return;
|
||||
}
|
||||
|
||||
let cur = []
|
||||
let 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);
|
||||
|
|
@ -187,13 +187,11 @@ export default class Cursor {
|
|||
}
|
||||
|
||||
_showCursor() {
|
||||
if (this._canvas.style.visibility === 'hidden')
|
||||
this._canvas.style.visibility = '';
|
||||
if (this._canvas.style.visibility === 'hidden') this._canvas.style.visibility = '';
|
||||
}
|
||||
|
||||
_hideCursor() {
|
||||
if (this._canvas.style.visibility !== 'hidden')
|
||||
this._canvas.style.visibility = 'hidden';
|
||||
if (this._canvas.style.visibility !== 'hidden') this._canvas.style.visibility = 'hidden';
|
||||
}
|
||||
|
||||
// Should we currently display the cursor?
|
||||
|
|
@ -201,28 +199,23 @@ export default class Cursor {
|
|||
// different cursor set)
|
||||
_shouldShowCursor(target) {
|
||||
// Easy case
|
||||
if (target === this._target)
|
||||
return true;
|
||||
if (target === this._target) return true;
|
||||
// Other part of the DOM?
|
||||
if (!this._target.contains(target))
|
||||
return false;
|
||||
if (!this._target.contains(target)) return false;
|
||||
// Has the child its own cursor?
|
||||
// FIXME: How can we tell that a sub element has an
|
||||
// explicit "cursor: none;"?
|
||||
if (window.getComputedStyle(target).cursor !== 'none')
|
||||
return false;
|
||||
if (window.getComputedStyle(target).cursor !== 'none') return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
_updateVisibility(target) {
|
||||
if (this._shouldShowCursor(target))
|
||||
this._showCursor();
|
||||
else
|
||||
this._hideCursor();
|
||||
if (this._shouldShowCursor(target)) this._showCursor();
|
||||
else this._hideCursor();
|
||||
}
|
||||
|
||||
_updatePosition() {
|
||||
this._canvas.style.left = this._position.x + "px";
|
||||
this._canvas.style.top = this._position.y + "px";
|
||||
this._canvas.style.left = this._position.x + 'px';
|
||||
this._canvas.style.top = this._position.y + 'px';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ function _captureProxy(e) {
|
|||
}
|
||||
|
||||
// Implicitly release the capture on button release
|
||||
if (e.type === "mouseup") {
|
||||
if (e.type === 'mouseup') {
|
||||
releaseCapture();
|
||||
}
|
||||
}
|
||||
|
||||
// Follow cursor style of target element
|
||||
function _captureElemChanged() {
|
||||
const captureElem = document.getElementById("noVNC_mouse_capture_elem");
|
||||
const captureElem = document.getElementById('noVNC_mouse_capture_elem');
|
||||
captureElem.style.cursor = window.getComputedStyle(_captureElem).cursor;
|
||||
}
|
||||
|
||||
|
|
@ -59,29 +59,27 @@ let _captureIndex = 0;
|
|||
|
||||
export function setCapture(elem) {
|
||||
if (elem.setCapture) {
|
||||
|
||||
elem.setCapture();
|
||||
|
||||
// IE releases capture on 'click' events which might not trigger
|
||||
elem.addEventListener('mouseup', releaseCapture);
|
||||
|
||||
} else {
|
||||
// Release any existing capture in case this method is
|
||||
// called multiple times without coordination
|
||||
releaseCapture();
|
||||
|
||||
let captureElem = document.getElementById("noVNC_mouse_capture_elem");
|
||||
let captureElem = document.getElementById('noVNC_mouse_capture_elem');
|
||||
|
||||
if (captureElem === null) {
|
||||
captureElem = document.createElement("div");
|
||||
captureElem.id = "noVNC_mouse_capture_elem";
|
||||
captureElem.style.position = "fixed";
|
||||
captureElem.style.top = "0px";
|
||||
captureElem.style.left = "0px";
|
||||
captureElem.style.width = "100%";
|
||||
captureElem.style.height = "100%";
|
||||
captureElem = document.createElement('div');
|
||||
captureElem.id = 'noVNC_mouse_capture_elem';
|
||||
captureElem.style.position = 'fixed';
|
||||
captureElem.style.top = '0px';
|
||||
captureElem.style.left = '0px';
|
||||
captureElem.style.width = '100%';
|
||||
captureElem.style.height = '100%';
|
||||
captureElem.style.zIndex = 10000;
|
||||
captureElem.style.display = "none";
|
||||
captureElem.style.display = 'none';
|
||||
document.body.appendChild(captureElem);
|
||||
|
||||
// This is to make sure callers don't get confused by having
|
||||
|
|
@ -99,7 +97,7 @@ export function setCapture (elem) {
|
|||
_captureObserver.observe(elem, { attributes: true });
|
||||
_captureElemChanged();
|
||||
|
||||
captureElem.style.display = "";
|
||||
captureElem.style.display = '';
|
||||
|
||||
// We listen to events on window in order to keep tracking if it
|
||||
// happens to leave the viewport
|
||||
|
|
@ -110,9 +108,7 @@ export function setCapture (elem) {
|
|||
|
||||
export function releaseCapture() {
|
||||
if (document.releaseCapture) {
|
||||
|
||||
document.releaseCapture();
|
||||
|
||||
} else {
|
||||
if (!_captureElem) {
|
||||
return;
|
||||
|
|
@ -130,8 +126,8 @@ export function releaseCapture () {
|
|||
|
||||
_captureObserver.disconnect();
|
||||
|
||||
const captureElem = document.getElementById("noVNC_mouse_capture_elem");
|
||||
captureElem.style.display = "none";
|
||||
const captureElem = document.getElementById('noVNC_mouse_capture_elem');
|
||||
captureElem.style.display = 'none';
|
||||
|
||||
window.removeEventListener('mousemove', _captureProxy);
|
||||
window.removeEventListener('mouseup', _captureProxy);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export function init_logging (level) {
|
|||
|
||||
Debug = Info = Warn = Error = () => {};
|
||||
|
||||
if (typeof window.console !== "undefined") {
|
||||
if (typeof window.console !== 'undefined') {
|
||||
/* eslint-disable no-console, no-fallthrough */
|
||||
switch (level) {
|
||||
case 'debug':
|
||||
|
|
@ -50,7 +50,9 @@ export function get_logging () {
|
|||
return _log_level;
|
||||
}
|
||||
|
||||
export { Debug, Info, Warn, Error };
|
||||
export {
|
||||
Debug, Info, Warn, Error
|
||||
};
|
||||
|
||||
// Initialize logging level
|
||||
init_logging();
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@
|
|||
/* Object.assign() (taken from MDN) */
|
||||
if (typeof Object.assign != 'function') {
|
||||
// Must be writable: true, enumerable: false, configurable: true
|
||||
Object.defineProperty(Object, "assign", {
|
||||
Object.defineProperty(Object, 'assign', {
|
||||
value: function assign(target, varArgs) { // .length of function is 2
|
||||
'use strict';
|
||||
|
||||
if (target == null) { // TypeError if undefined or null
|
||||
throw new TypeError('Cannot convert undefined or null to object');
|
||||
}
|
||||
|
|
@ -48,7 +49,7 @@ if (typeof Object.assign != 'function') {
|
|||
|
||||
CustomEvent.prototype = window.Event.prototype;
|
||||
|
||||
if (typeof window.CustomEvent !== "function") {
|
||||
if (typeof window.CustomEvent !== 'function') {
|
||||
window.CustomEvent = CustomEvent;
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -84,20 +84,20 @@ export default class Websock {
|
|||
|
||||
// TODO(directxman12): test performance with these vs a DataView
|
||||
rQshift16() {
|
||||
return (this._rQ[this._rQi++] << 8) +
|
||||
this._rQ[this._rQi++];
|
||||
return (this._rQ[this._rQi++] << 8)
|
||||
+ this._rQ[this._rQi++];
|
||||
}
|
||||
|
||||
rQshift32() {
|
||||
return (this._rQ[this._rQi++] << 24) +
|
||||
(this._rQ[this._rQi++] << 16) +
|
||||
(this._rQ[this._rQi++] << 8) +
|
||||
this._rQ[this._rQi++];
|
||||
return (this._rQ[this._rQi++] << 24)
|
||||
+ (this._rQ[this._rQi++] << 16)
|
||||
+ (this._rQ[this._rQi++] << 8)
|
||||
+ this._rQ[this._rQi++];
|
||||
}
|
||||
|
||||
rQshiftStr(len) {
|
||||
if (typeof (len) === 'undefined') { len = this.rQlen(); }
|
||||
let str = "";
|
||||
let str = '';
|
||||
// Handle large arrays in steps to avoid long strings on the stack
|
||||
for (let i = 0; i < len; i += 4096) {
|
||||
let part = this.rQshiftBytes(Math.min(4096, len - i));
|
||||
|
|
@ -139,7 +139,7 @@ export default class Websock {
|
|||
if (rQlen < num) {
|
||||
if (goback) {
|
||||
if (this._rQi < goback) {
|
||||
throw new Error("rQwait cannot backup " + goback + " bytes");
|
||||
throw new Error('rQwait cannot backup ' + goback + ' bytes');
|
||||
}
|
||||
this._rQi -= goback;
|
||||
}
|
||||
|
|
@ -197,29 +197,29 @@ export default class Websock {
|
|||
this._websocket.onopen = () => {
|
||||
Log.Debug('>> WebSock.onopen');
|
||||
if (this._websocket.protocol) {
|
||||
Log.Info("Server choose sub-protocol: " + this._websocket.protocol);
|
||||
Log.Info('Server choose sub-protocol: ' + this._websocket.protocol);
|
||||
}
|
||||
|
||||
this._eventHandlers.open();
|
||||
Log.Debug("<< WebSock.onopen");
|
||||
Log.Debug('<< WebSock.onopen');
|
||||
};
|
||||
this._websocket.onclose = (e) => {
|
||||
Log.Debug(">> WebSock.onclose");
|
||||
Log.Debug('>> WebSock.onclose');
|
||||
this._eventHandlers.close(e);
|
||||
Log.Debug("<< WebSock.onclose");
|
||||
Log.Debug('<< WebSock.onclose');
|
||||
};
|
||||
this._websocket.onerror = (e) => {
|
||||
Log.Debug(">> WebSock.onerror: " + e);
|
||||
Log.Debug('>> WebSock.onerror: ' + e);
|
||||
this._eventHandlers.error(e);
|
||||
Log.Debug("<< WebSock.onerror: " + e);
|
||||
Log.Debug('<< WebSock.onerror: ' + e);
|
||||
};
|
||||
}
|
||||
|
||||
close() {
|
||||
if (this._websocket) {
|
||||
if ((this._websocket.readyState === WebSocket.OPEN) ||
|
||||
(this._websocket.readyState === WebSocket.CONNECTING)) {
|
||||
Log.Info("Closing WebSocket connection");
|
||||
if ((this._websocket.readyState === WebSocket.OPEN)
|
||||
|| (this._websocket.readyState === WebSocket.CONNECTING)) {
|
||||
Log.Info('Closing WebSocket connection');
|
||||
this._websocket.close();
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ export default class Websock {
|
|||
if (this._rQbufferSize > MAX_RQ_GROW_SIZE) {
|
||||
this._rQbufferSize = MAX_RQ_GROW_SIZE;
|
||||
if (this._rQbufferSize - this._rQlen - this._rQi < min_fit) {
|
||||
throw new Error("Receive Queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
|
||||
throw new Error('Receive Queue buffer exceeded ' + MAX_RQ_GROW_SIZE + ' bytes, and the new message could not fit');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,13 +259,11 @@ export default class Websock {
|
|||
this._rQmax = this._rQbufferSize / 8;
|
||||
this._rQ = new Uint8Array(this._rQbufferSize);
|
||||
this._rQ.set(new Uint8Array(old_rQbuffer, this._rQi));
|
||||
} else {
|
||||
if (ENABLE_COPYWITHIN) {
|
||||
} else if (ENABLE_COPYWITHIN) {
|
||||
this._rQ.copyWithin(0, this._rQi);
|
||||
} else {
|
||||
this._rQ.set(new Uint8Array(this._rQ.buffer, this._rQi));
|
||||
}
|
||||
}
|
||||
|
||||
this._rQlen = this._rQlen - this._rQi;
|
||||
this._rQi = 0;
|
||||
|
|
@ -293,7 +291,7 @@ export default class Websock {
|
|||
this._expand_compact_rQ();
|
||||
}
|
||||
} else {
|
||||
Log.Debug("Ignoring empty message");
|
||||
Log.Debug('Ignoring empty message');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"rules": {
|
||||
"no-console": 0
|
||||
}
|
||||
}
|
||||
14
po/po2js
14
po/po2js
|
|
@ -19,25 +19,25 @@
|
|||
|
||||
const getopt = require('node-getopt');
|
||||
const fs = require('fs');
|
||||
const po2json = require("po2json");
|
||||
const po2json = require('po2json');
|
||||
|
||||
const opt = getopt.create([
|
||||
['h', 'help', 'display this help'],
|
||||
]).bindHelp().parseSystem();
|
||||
|
||||
if (opt.argv.length != 2) {
|
||||
console.error("Incorrect number of arguments given");
|
||||
console.error('Incorrect number of arguments given');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const data = po2json.parseFileSync(opt.argv[0]);
|
||||
|
||||
const bodyPart = Object.keys(data).filter((msgid) => msgid !== "").map((msgid) => {
|
||||
if (msgid === "") return;
|
||||
const bodyPart = Object.keys(data).filter(msgid => msgid !== '').map((msgid) => {
|
||||
if (msgid === '') return;
|
||||
const msgstr = data[msgid][1];
|
||||
return " " + JSON.stringify(msgid) + ": " + JSON.stringify(msgstr);
|
||||
}).join(",\n");
|
||||
return ' ' + JSON.stringify(msgid) + ': ' + JSON.stringify(msgstr);
|
||||
}).join(',\n');
|
||||
|
||||
const output = "{\n" + bodyPart + "\n}";
|
||||
const output = '{\n' + bodyPart + '\n}';
|
||||
|
||||
fs.writeFileSync(opt.argv[1], output);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ chai.use(function (_chai, utils) {
|
|||
// NB(directxman12): PhantomJS 1.x doesn't implement Uint8ClampedArray, so work around that
|
||||
const data = new Uint8Array(data_cl);
|
||||
const len = data_cl.length;
|
||||
new chai.Assertion(len).to.be.equal(target_data.length, "unexpected display size");
|
||||
new chai.Assertion(len).to.be.equal(target_data.length, 'unexpected display size');
|
||||
let same = true;
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (data[i] != target_data[i]) {
|
||||
|
|
@ -21,11 +21,11 @@ chai.use(function (_chai, utils) {
|
|||
}
|
||||
if (!same) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("expected data: %o, actual data: %o", target_data, data);
|
||||
console.log('expected data: %o, actual data: %o', target_data, data);
|
||||
}
|
||||
this.assert(same,
|
||||
"expected #{this} to have displayed the image #{exp}, but instead it displayed #{act}",
|
||||
"expected #{this} not to have displayed the image #{act}",
|
||||
'expected #{this} to have displayed the image #{exp}, but instead it displayed #{act}',
|
||||
'expected #{this} not to have displayed the image #{act}',
|
||||
target_data,
|
||||
data);
|
||||
});
|
||||
|
|
@ -33,8 +33,12 @@ chai.use(function (_chai, utils) {
|
|||
_chai.Assertion.addMethod('sent', function (target_data) {
|
||||
const obj = this._obj;
|
||||
obj.inspect = () => {
|
||||
const res = { _websocket: obj._websocket, rQi: obj._rQi, _rQ: new Uint8Array(obj._rQ.buffer, 0, obj._rQlen),
|
||||
_sQ: new Uint8Array(obj._sQ.buffer, 0, obj._sQlen) };
|
||||
const res = {
|
||||
_websocket: obj._websocket,
|
||||
rQi: obj._rQi,
|
||||
_rQ: new Uint8Array(obj._rQ.buffer, 0, obj._rQlen),
|
||||
_sQ: new Uint8Array(obj._sQ.buffer, 0, obj._sQlen)
|
||||
};
|
||||
res.prototype = obj;
|
||||
return res;
|
||||
};
|
||||
|
|
@ -52,11 +56,11 @@ chai.use(function (_chai, utils) {
|
|||
}
|
||||
if (!same) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("expected data: %o, actual data: %o", target_data, data);
|
||||
console.log('expected data: %o, actual data: %o', target_data, data);
|
||||
}
|
||||
this.assert(same,
|
||||
"expected #{this} to have sent the data #{exp}, but it actually sent #{act}",
|
||||
"expected #{this} not to have sent the data #{act}",
|
||||
'expected #{this} to have sent the data #{exp}, but it actually sent #{act}',
|
||||
'expected #{this} not to have sent the data #{act}',
|
||||
Array.prototype.slice.call(target_data),
|
||||
Array.prototype.slice.call(data));
|
||||
});
|
||||
|
|
@ -81,8 +85,8 @@ chai.use(function (_chai, utils) {
|
|||
}
|
||||
|
||||
this.assert(same,
|
||||
"expected #{this} to have elements deeply equal to #{exp}",
|
||||
"expected #{this} not to have elements deeply equal to #{exp}",
|
||||
'expected #{this} to have elements deeply equal to #{exp}',
|
||||
'expected #{this} not to have elements deeply equal to #{exp}',
|
||||
Array.prototype.slice.call(target));
|
||||
} else {
|
||||
for (let i = 0; i < obj.length; i++) {
|
||||
|
|
@ -93,8 +97,8 @@ chai.use(function (_chai, utils) {
|
|||
}
|
||||
|
||||
this.assert(same,
|
||||
"expected #{this} to have elements equal to #{exp}",
|
||||
"expected #{this} not to have elements equal to #{exp}",
|
||||
'expected #{this} to have elements equal to #{exp}',
|
||||
'expected #{this} not to have elements equal to #{exp}',
|
||||
Array.prototype.slice.call(target));
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ function make_event(name, props) {
|
|||
export default class FakeWebSocket {
|
||||
constructor(uri, protocols) {
|
||||
this.url = uri;
|
||||
this.binaryType = "arraybuffer";
|
||||
this.extensions = "";
|
||||
this.binaryType = 'arraybuffer';
|
||||
this.extensions = '';
|
||||
|
||||
if (!protocols || typeof protocols === 'string') {
|
||||
this.protocol = protocols;
|
||||
|
|
@ -35,7 +35,7 @@ export default class FakeWebSocket {
|
|||
close(code, reason) {
|
||||
this.readyState = FakeWebSocket.CLOSED;
|
||||
if (this.onclose) {
|
||||
this.onclose(make_event("close", { 'code': code, 'reason': reason, 'wasClean': true }));
|
||||
this.onclose(make_event('close', { code: code, reason: reason, wasClean: true }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ export default class FakeWebSocket {
|
|||
}
|
||||
|
||||
_receive_data(data) {
|
||||
this.onmessage(make_event("message", { 'data': data }));
|
||||
this.onmessage(make_event('message', { data: data }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ let encoding = null;
|
|||
|
||||
function message(str) {
|
||||
const cell = document.getElementById('messages');
|
||||
cell.textContent += str + "\n";
|
||||
cell.textContent += str + '\n';
|
||||
cell.scrollTop = cell.scrollHeight;
|
||||
}
|
||||
|
||||
|
|
@ -16,17 +16,17 @@ function loadFile() {
|
|||
const fname = WebUtil.getQueryVar('data', null);
|
||||
|
||||
if (!fname) {
|
||||
return Promise.reject("Must specify data=FOO in query string.");
|
||||
return Promise.reject('Must specify data=FOO in query string.');
|
||||
}
|
||||
|
||||
message("Loading " + fname);
|
||||
message('Loading ' + fname);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const script = document.createElement("script");
|
||||
const script = document.createElement('script');
|
||||
script.onload = resolve;
|
||||
script.onerror = reject;
|
||||
document.body.appendChild(script);
|
||||
script.src = "../recordings/" + fname;
|
||||
script.src = '../recordings/' + fname;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ function enableUI() {
|
|||
document.getElementById('mode1').checked = true;
|
||||
}
|
||||
|
||||
message("VNC_frame_data.length: " + VNC_frame_data.length);
|
||||
message('VNC_frame_data.length: ' + VNC_frame_data.length);
|
||||
|
||||
const startButton = document.getElementById('startButton');
|
||||
startButton.disabled = false;
|
||||
|
|
@ -49,8 +49,7 @@ function enableUI() {
|
|||
|
||||
frames = VNC_frame_data;
|
||||
// Only present in older recordings
|
||||
if (window.VNC_frame_encoding)
|
||||
encoding = VNC_frame_encoding;
|
||||
if (window.VNC_frame_encoding) encoding = VNC_frame_encoding;
|
||||
}
|
||||
|
||||
class IterationPlayer {
|
||||
|
|
@ -131,7 +130,7 @@ class IterationPlayer {
|
|||
}
|
||||
|
||||
function start() {
|
||||
document.getElementById('startButton').value = "Running";
|
||||
document.getElementById('startButton').value = 'Running';
|
||||
document.getElementById('startButton').disabled = true;
|
||||
|
||||
const iterations = document.getElementById('iterations').value;
|
||||
|
|
@ -160,9 +159,9 @@ function start() {
|
|||
message(`${evt.iterations} iterations took ${evt.duration}ms (average ${iterTime}ms / iteration)`);
|
||||
|
||||
document.getElementById('startButton').disabled = false;
|
||||
document.getElementById('startButton').value = "Start";
|
||||
document.getElementById('startButton').value = 'Start';
|
||||
};
|
||||
player.start(mode);
|
||||
}
|
||||
|
||||
loadFile().then(enableUI).catch(e => message("Error loading recording: " + e));
|
||||
loadFile().then(enableUI).catch(e => message('Error loading recording: ' + e));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ if (window.setImmediate === undefined) {
|
|||
window.setImmediate = (func) => {
|
||||
const index = _immediateIdCounter++;
|
||||
_immediateFuncs[index] = func;
|
||||
window.postMessage("noVNC immediate trigger:" + index, "*");
|
||||
window.postMessage('noVNC immediate trigger:' + index, '*');
|
||||
return index;
|
||||
};
|
||||
|
||||
|
|
@ -24,13 +24,13 @@ if (window.setImmediate === undefined) {
|
|||
_immediateFuncs[id];
|
||||
};
|
||||
|
||||
window.addEventListener("message", (event) => {
|
||||
if ((typeof event.data !== "string") ||
|
||||
(event.data.indexOf("noVNC immediate trigger:") !== 0)) {
|
||||
window.addEventListener('message', (event) => {
|
||||
if ((typeof event.data !== 'string')
|
||||
|| (event.data.indexOf('noVNC immediate trigger:') !== 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = event.data.slice("noVNC immediate trigger:".length);
|
||||
const index = event.data.slice('noVNC immediate trigger:'.length);
|
||||
|
||||
const callback = _immediateFuncs[index];
|
||||
if (callback === undefined) {
|
||||
|
|
@ -77,7 +77,7 @@ export default class RecordingPlayer {
|
|||
// initialize a new RFB
|
||||
this._rfb = new RFB(document.getElementById('VNC_screen'), 'wss://test');
|
||||
this._rfb.viewOnly = true;
|
||||
this._rfb.addEventListener("disconnect",
|
||||
this._rfb.addEventListener('disconnect',
|
||||
this._handleDisconnect.bind(this));
|
||||
this._enablePlaybackMode();
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ export default class RecordingPlayer {
|
|||
let frame = this._frames[this._frame_index];
|
||||
|
||||
// skip send frames
|
||||
while (this._frame_index < this._frame_length && frame.charAt(0) === "}") {
|
||||
while (this._frame_index < this._frame_length && frame.charAt(0) === '}') {
|
||||
this._frame_index++;
|
||||
frame = this._frames[this._frame_index];
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ export default class RecordingPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
this._rfb._sock._recv_message({'data': u8});
|
||||
this._rfb._sock._recv_message({ data: u8 });
|
||||
this._frame_index++;
|
||||
|
||||
this._queueNextPacket();
|
||||
|
|
@ -181,7 +181,7 @@ export default class RecordingPlayer {
|
|||
this._rfb._display.flush();
|
||||
} else {
|
||||
this._running = false;
|
||||
this._rfb._sock._eventHandlers.close({code: 1000, reason: ""});
|
||||
this._rfb._sock._eventHandlers.close({ code: 1000, reason: '' });
|
||||
delete this._rfb;
|
||||
this.onfinish((new Date()).getTime() - this._start_time);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ const expect = chai.expect;
|
|||
import Base64 from '../core/base64.js';
|
||||
|
||||
describe('Base64 Tools', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
const BIN_ARR = new Array(256);
|
||||
for (let i = 0; i < 256; i++) {
|
||||
BIN_ARR[i] = i;
|
||||
}
|
||||
|
||||
const B64_STR = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==";
|
||||
const B64_STR = 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==';
|
||||
|
||||
|
||||
describe('encode', function () {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe('Display/Canvas Helper', function () {
|
|||
function make_image_png(input_data) {
|
||||
const canvas = make_image_canvas(input_data);
|
||||
const url = canvas.toDataURL();
|
||||
const data = url.split(",")[1];
|
||||
const data = url.split(',')[1];
|
||||
return Base64.decode(data);
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +251,6 @@ describe('Display/Canvas Helper', function () {
|
|||
expect(display.absY(18)).to.equal(6);
|
||||
expect(canvas.clientWidth).to.equal(12); // 16 * (4 / 3)
|
||||
expect(canvas.clientHeight).to.equal(9);
|
||||
|
||||
});
|
||||
|
||||
it('should not change the bitmap size of the canvas', function () {
|
||||
|
|
@ -262,7 +261,6 @@ describe('Display/Canvas Helper', function () {
|
|||
});
|
||||
|
||||
describe('drawing', function () {
|
||||
|
||||
// TODO(directxman12): improve the tests for each of the drawing functions to cover more than just the
|
||||
// basic cases
|
||||
let display;
|
||||
|
|
@ -282,7 +280,9 @@ describe('Display/Canvas Helper', function () {
|
|||
});
|
||||
|
||||
it('should draw the logo on #clear with a logo set', function (done) {
|
||||
display._logo = { width: 4, height: 4, type: "image/png", data: make_image_png(checked_data) };
|
||||
display._logo = {
|
||||
width: 4, height: 4, type: 'image/png', data: make_image_png(checked_data)
|
||||
};
|
||||
display.clear();
|
||||
display.onflush = () => {
|
||||
expect(display).to.have.displayed(checked_data);
|
||||
|
|
@ -323,7 +323,7 @@ describe('Display/Canvas Helper', function () {
|
|||
});
|
||||
|
||||
it('should support drawing images via #imageRect', function (done) {
|
||||
display.imageRect(0, 0, "image/png", make_image_png(checked_data));
|
||||
display.imageRect(0, 0, 'image/png', make_image_png(checked_data));
|
||||
display.flip();
|
||||
display.onflush = () => {
|
||||
expect(display).to.have.displayed(checked_data);
|
||||
|
|
@ -424,9 +424,13 @@ describe('Display/Canvas Helper', function () {
|
|||
});
|
||||
|
||||
it('should wait until an image is loaded to attempt to draw it and the rest of the queue', function () {
|
||||
const img = { complete: false, addEventListener: sinon.spy() }
|
||||
display._renderQ = [{ type: 'img', x: 3, y: 4, img: img },
|
||||
{ type: 'fill', x: 1, y: 2, width: 3, height: 4, color: 5 }];
|
||||
const img = { complete: false, addEventListener: sinon.spy() };
|
||||
display._renderQ = [{
|
||||
type: 'img', x: 3, y: 4, img: img
|
||||
},
|
||||
{
|
||||
type: 'fill', x: 1, y: 2, width: 3, height: 4, color: 5
|
||||
}];
|
||||
display.drawImage = sinon.spy();
|
||||
display.fillRect = sinon.spy();
|
||||
|
||||
|
|
@ -452,35 +456,45 @@ describe('Display/Canvas Helper', function () {
|
|||
|
||||
it('should draw a blit image on type "blit"', function () {
|
||||
display.blitImage = sinon.spy();
|
||||
display._renderQ_push({ type: 'blit', x: 3, y: 4, width: 5, height: 6, data: [7, 8, 9] });
|
||||
display._renderQ_push({
|
||||
type: 'blit', x: 3, y: 4, width: 5, height: 6, data: [7, 8, 9]
|
||||
});
|
||||
expect(display.blitImage).to.have.been.calledOnce;
|
||||
expect(display.blitImage).to.have.been.calledWith(3, 4, 5, 6, [7, 8, 9], 0);
|
||||
});
|
||||
|
||||
it('should draw a blit RGB image on type "blitRgb"', function () {
|
||||
display.blitRgbImage = sinon.spy();
|
||||
display._renderQ_push({ type: 'blitRgb', x: 3, y: 4, width: 5, height: 6, data: [7, 8, 9] });
|
||||
display._renderQ_push({
|
||||
type: 'blitRgb', x: 3, y: 4, width: 5, height: 6, data: [7, 8, 9]
|
||||
});
|
||||
expect(display.blitRgbImage).to.have.been.calledOnce;
|
||||
expect(display.blitRgbImage).to.have.been.calledWith(3, 4, 5, 6, [7, 8, 9], 0);
|
||||
});
|
||||
|
||||
it('should copy a region on type "copy"', function () {
|
||||
display.copyImage = sinon.spy();
|
||||
display._renderQ_push({ type: 'copy', x: 3, y: 4, width: 5, height: 6, old_x: 7, old_y: 8 });
|
||||
display._renderQ_push({
|
||||
type: 'copy', x: 3, y: 4, width: 5, height: 6, old_x: 7, old_y: 8
|
||||
});
|
||||
expect(display.copyImage).to.have.been.calledOnce;
|
||||
expect(display.copyImage).to.have.been.calledWith(7, 8, 3, 4, 5, 6);
|
||||
});
|
||||
|
||||
it('should fill a rect with a given color on type "fill"', function () {
|
||||
display.fillRect = sinon.spy();
|
||||
display._renderQ_push({ type: 'fill', x: 3, y: 4, width: 5, height: 6, color: [7, 8, 9]});
|
||||
display._renderQ_push({
|
||||
type: 'fill', x: 3, y: 4, width: 5, height: 6, color: [7, 8, 9]
|
||||
});
|
||||
expect(display.fillRect).to.have.been.calledOnce;
|
||||
expect(display.fillRect).to.have.been.calledWith(3, 4, 5, 6, [7, 8, 9]);
|
||||
});
|
||||
|
||||
it('should draw an image from an image object on type "img" (if complete)', function () {
|
||||
display.drawImage = sinon.spy();
|
||||
display._renderQ_push({ type: 'img', x: 3, y: 4, img: { complete: true } });
|
||||
display._renderQ_push({
|
||||
type: 'img', x: 3, y: 4, img: { complete: true }
|
||||
});
|
||||
expect(display.drawImage).to.have.been.calledOnce;
|
||||
expect(display.drawImage).to.have.been.calledWith({ complete: true }, 3, 4);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
const expect = chai.expect;
|
||||
const expect = chai.expect;
|
||||
|
||||
import keysyms from '../core/input/keysymdef.js';
|
||||
import * as KeyboardUtil from "../core/input/util.js";
|
||||
import * as KeyboardUtil from '../core/input/util.js';
|
||||
import * as browser from '../core/util/browser.js';
|
||||
|
||||
describe('Helpers', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
describe('keysyms.lookup', function () {
|
||||
it('should map ASCII characters to keysyms', function () {
|
||||
|
|
@ -69,24 +69,24 @@ describe('Helpers', function() {
|
|||
// window.navigator is a protected read-only property in many
|
||||
// environments, so we need to redefine it whilst running these
|
||||
// tests.
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, 'navigator');
|
||||
if (origNavigator === undefined) {
|
||||
// Object.getOwnPropertyDescriptor() doesn't work
|
||||
// properly in any version of IE
|
||||
this.skip();
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "navigator", {value: {}});
|
||||
Object.defineProperty(window, 'navigator', { value: {} });
|
||||
if (window.navigator.platform !== undefined) {
|
||||
// Object.defineProperty() doesn't work properly in old
|
||||
// versions of Chrome
|
||||
this.skip();
|
||||
}
|
||||
|
||||
window.navigator.platform = "Mac x86_64";
|
||||
window.navigator.platform = 'Mac x86_64';
|
||||
});
|
||||
afterEach(function () {
|
||||
Object.defineProperty(window, "navigator", origNavigator);
|
||||
Object.defineProperty(window, 'navigator', origNavigator);
|
||||
});
|
||||
|
||||
it('should respect ContextMenu on modern browser', function () {
|
||||
|
|
@ -101,7 +101,9 @@ describe('Helpers', function() {
|
|||
describe('getKey', function () {
|
||||
it('should prefer key', function () {
|
||||
if (browser.isIE() || browser.isEdge()) this.skip();
|
||||
expect(KeyboardUtil.getKey({key: 'a', charCode: 'Š'.charCodeAt(), keyCode: 0x42, which: 0x43})).to.be.equal('a');
|
||||
expect(KeyboardUtil.getKey({
|
||||
key: 'a', charCode: 'Š'.charCodeAt(), keyCode: 0x42, which: 0x43
|
||||
})).to.be.equal('a');
|
||||
});
|
||||
it('should map legacy values', function () {
|
||||
expect(KeyboardUtil.getKey({ key: 'Spacebar' })).to.be.equal(' ');
|
||||
|
|
@ -132,14 +134,14 @@ describe('Helpers', function() {
|
|||
// window.navigator is a protected read-only property in many
|
||||
// environments, so we need to redefine it whilst running these
|
||||
// tests.
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, 'navigator');
|
||||
if (origNavigator === undefined) {
|
||||
// Object.getOwnPropertyDescriptor() doesn't work
|
||||
// properly in any version of IE
|
||||
this.skip();
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "navigator", {value: {}});
|
||||
Object.defineProperty(window, 'navigator', { value: {} });
|
||||
if (window.navigator.platform !== undefined) {
|
||||
// Object.defineProperty() doesn't work properly in old
|
||||
// versions of Chrome
|
||||
|
|
@ -147,23 +149,23 @@ describe('Helpers', function() {
|
|||
}
|
||||
});
|
||||
afterEach(function () {
|
||||
Object.defineProperty(window, "navigator", origNavigator);
|
||||
Object.defineProperty(window, 'navigator', origNavigator);
|
||||
});
|
||||
|
||||
it('should ignore printable character key on IE', function () {
|
||||
window.navigator.userAgent = "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko";
|
||||
window.navigator.userAgent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
|
||||
expect(KeyboardUtil.getKey({ key: 'a' })).to.be.equal('Unidentified');
|
||||
});
|
||||
it('should ignore printable character key on Edge', function () {
|
||||
window.navigator.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393";
|
||||
window.navigator.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393';
|
||||
expect(KeyboardUtil.getKey({ key: 'a' })).to.be.equal('Unidentified');
|
||||
});
|
||||
it('should allow non-printable character key on IE', function () {
|
||||
window.navigator.userAgent = "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko";
|
||||
window.navigator.userAgent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
|
||||
expect(KeyboardUtil.getKey({ key: 'Shift' })).to.be.equal('Shift');
|
||||
});
|
||||
it('should allow non-printable character key on Edge', function () {
|
||||
window.navigator.userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393";
|
||||
window.navigator.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393';
|
||||
expect(KeyboardUtil.getKey({ key: 'Shift' })).to.be.equal('Shift');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import Keyboard from '../core/input/keyboard.js';
|
|||
import * as browser from '../core/util/browser.js';
|
||||
|
||||
describe('Key Event Handling', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
// The real KeyboardEvent constructor might not work everywhere we
|
||||
// want to run these tests
|
||||
|
|
@ -184,24 +184,24 @@ describe('Key Event Handling', function() {
|
|||
// window.navigator is a protected read-only property in many
|
||||
// environments, so we need to redefine it whilst running these
|
||||
// tests.
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, 'navigator');
|
||||
if (origNavigator === undefined) {
|
||||
// Object.getOwnPropertyDescriptor() doesn't work
|
||||
// properly in any version of IE
|
||||
this.skip();
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "navigator", {value: {}});
|
||||
Object.defineProperty(window, 'navigator', { value: {} });
|
||||
if (window.navigator.platform !== undefined) {
|
||||
// Object.defineProperty() doesn't work properly in old
|
||||
// versions of Chrome
|
||||
this.skip();
|
||||
}
|
||||
|
||||
window.navigator.platform = "iPhone 9.0";
|
||||
window.navigator.platform = 'iPhone 9.0';
|
||||
});
|
||||
afterEach(function () {
|
||||
Object.defineProperty(window, "navigator", origNavigator);
|
||||
Object.defineProperty(window, 'navigator', origNavigator);
|
||||
});
|
||||
|
||||
it('should fake keyup events on iOS', function (done) {
|
||||
|
|
@ -305,24 +305,24 @@ describe('Key Event Handling', function() {
|
|||
// window.navigator is a protected read-only property in many
|
||||
// environments, so we need to redefine it whilst running these
|
||||
// tests.
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, 'navigator');
|
||||
if (origNavigator === undefined) {
|
||||
// Object.getOwnPropertyDescriptor() doesn't work
|
||||
// properly in any version of IE
|
||||
this.skip();
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "navigator", {value: {}});
|
||||
Object.defineProperty(window, 'navigator', { value: {} });
|
||||
if (window.navigator.platform !== undefined) {
|
||||
// Object.defineProperty() doesn't work properly in old
|
||||
// versions of Chrome
|
||||
this.skip();
|
||||
}
|
||||
|
||||
window.navigator.platform = "Mac x86_64";
|
||||
window.navigator.platform = 'Mac x86_64';
|
||||
});
|
||||
afterEach(function () {
|
||||
Object.defineProperty(window, "navigator", origNavigator);
|
||||
Object.defineProperty(window, 'navigator', origNavigator);
|
||||
});
|
||||
|
||||
it('should change Alt to AltGraph', function () {
|
||||
|
|
@ -370,26 +370,26 @@ describe('Key Event Handling', function() {
|
|||
// window.navigator is a protected read-only property in many
|
||||
// environments, so we need to redefine it whilst running these
|
||||
// tests.
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, 'navigator');
|
||||
if (origNavigator === undefined) {
|
||||
// Object.getOwnPropertyDescriptor() doesn't work
|
||||
// properly in any version of IE
|
||||
this.skip();
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "navigator", {value: {}});
|
||||
Object.defineProperty(window, 'navigator', { value: {} });
|
||||
if (window.navigator.platform !== undefined) {
|
||||
// Object.defineProperty() doesn't work properly in old
|
||||
// versions of Chrome
|
||||
this.skip();
|
||||
}
|
||||
|
||||
window.navigator.platform = "Windows x86_64";
|
||||
window.navigator.platform = 'Windows x86_64';
|
||||
|
||||
this.clock = sinon.useFakeTimers();
|
||||
});
|
||||
afterEach(function () {
|
||||
Object.defineProperty(window, "navigator", origNavigator);
|
||||
Object.defineProperty(window, 'navigator', origNavigator);
|
||||
this.clock.restore();
|
||||
});
|
||||
|
||||
|
|
@ -406,8 +406,8 @@ describe('Key Event Handling', function() {
|
|||
kbd._handleKeyDown(keyevent('keydown', { code: 'ControlLeft', key: 'Control', location: 1 }));
|
||||
kbd._handleKeyDown(keyevent('keydown', { code: 'ControlLeft', key: 'Control', location: 1 }));
|
||||
expect(kbd.onkeyevent).to.have.been.calledTwice;
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, "ControlLeft", true);
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffe3, "ControlLeft", true);
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, 'ControlLeft', true);
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffe3, 'ControlLeft', true);
|
||||
});
|
||||
|
||||
it('should not supress ControlRight', function () {
|
||||
|
|
@ -415,7 +415,7 @@ describe('Key Event Handling', function() {
|
|||
kbd.onkeyevent = sinon.spy();
|
||||
kbd._handleKeyDown(keyevent('keydown', { code: 'ControlRight', key: 'Control', location: 2 }));
|
||||
expect(kbd.onkeyevent).to.have.been.calledOnce;
|
||||
expect(kbd.onkeyevent).to.have.been.calledWith(0xffe4, "ControlRight", true);
|
||||
expect(kbd.onkeyevent).to.have.been.calledWith(0xffe4, 'ControlRight', true);
|
||||
});
|
||||
|
||||
it('should release ControlLeft after 100 ms', function () {
|
||||
|
|
@ -425,7 +425,7 @@ describe('Key Event Handling', function() {
|
|||
expect(kbd.onkeyevent).to.not.have.been.called;
|
||||
this.clock.tick(100);
|
||||
expect(kbd.onkeyevent).to.have.been.calledOnce;
|
||||
expect(kbd.onkeyevent).to.have.been.calledWith(0xffe3, "ControlLeft", true);
|
||||
expect(kbd.onkeyevent).to.have.been.calledWith(0xffe3, 'ControlLeft', true);
|
||||
});
|
||||
|
||||
it('should release ControlLeft on other key press', function () {
|
||||
|
|
@ -435,8 +435,8 @@ describe('Key Event Handling', function() {
|
|||
expect(kbd.onkeyevent).to.not.have.been.called;
|
||||
kbd._handleKeyDown(keyevent('keydown', { code: 'KeyA', key: 'a' }));
|
||||
expect(kbd.onkeyevent).to.have.been.calledTwice;
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, "ControlLeft", true);
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0x61, "KeyA", true);
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, 'ControlLeft', true);
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0x61, 'KeyA', true);
|
||||
|
||||
// Check that the timer is properly dead
|
||||
kbd.onkeyevent.reset();
|
||||
|
|
@ -450,11 +450,11 @@ describe('Key Event Handling', function() {
|
|||
kbd._handleKeyDown(keyevent('keydown', { code: 'KeyA', key: 'a' }));
|
||||
kbd._handleKeyDown(keyevent('keydown', { code: 'ControlLeft', key: 'Control', location: 1 }));
|
||||
expect(kbd.onkeyevent).to.have.been.calledOnce;
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0x61, "KeyA", true);
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0x61, 'KeyA', true);
|
||||
kbd._handleKeyUp(keyevent('keyup', { code: 'KeyA', key: 'a' }));
|
||||
expect(kbd.onkeyevent).to.have.been.calledThrice;
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffe3, "ControlLeft", true);
|
||||
expect(kbd.onkeyevent.thirdCall).to.have.been.calledWith(0x61, "KeyA", false);
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffe3, 'ControlLeft', true);
|
||||
expect(kbd.onkeyevent.thirdCall).to.have.been.calledWith(0x61, 'KeyA', false);
|
||||
|
||||
// Check that the timer is properly dead
|
||||
kbd.onkeyevent.reset();
|
||||
|
|
@ -465,9 +465,13 @@ describe('Key Event Handling', function() {
|
|||
it('should generate AltGraph for quick Ctrl+Alt sequence', function () {
|
||||
const kbd = new Keyboard(document);
|
||||
kbd.onkeyevent = sinon.spy();
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'ControlLeft', key: 'Control', location: 1, timeStamp: Date.now()}));
|
||||
kbd._handleKeyDown(keyevent('keydown', {
|
||||
code: 'ControlLeft', key: 'Control', location: 1, timeStamp: Date.now()
|
||||
}));
|
||||
this.clock.tick(20);
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'AltRight', key: 'Alt', location: 2, timeStamp: Date.now()}));
|
||||
kbd._handleKeyDown(keyevent('keydown', {
|
||||
code: 'AltRight', key: 'Alt', location: 2, timeStamp: Date.now()
|
||||
}));
|
||||
expect(kbd.onkeyevent).to.have.been.calledOnce;
|
||||
expect(kbd.onkeyevent).to.have.been.calledWith(0xfe03, 'AltRight', true);
|
||||
|
||||
|
|
@ -480,12 +484,16 @@ describe('Key Event Handling', function() {
|
|||
it('should generate Ctrl, Alt for slow Ctrl+Alt sequence', function () {
|
||||
const kbd = new Keyboard(document);
|
||||
kbd.onkeyevent = sinon.spy();
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'ControlLeft', key: 'Control', location: 1, timeStamp: Date.now()}));
|
||||
kbd._handleKeyDown(keyevent('keydown', {
|
||||
code: 'ControlLeft', key: 'Control', location: 1, timeStamp: Date.now()
|
||||
}));
|
||||
this.clock.tick(60);
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'AltRight', key: 'Alt', location: 2, timeStamp: Date.now()}));
|
||||
kbd._handleKeyDown(keyevent('keydown', {
|
||||
code: 'AltRight', key: 'Alt', location: 2, timeStamp: Date.now()
|
||||
}));
|
||||
expect(kbd.onkeyevent).to.have.been.calledTwice;
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, "ControlLeft", true);
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffea, "AltRight", true);
|
||||
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, 'ControlLeft', true);
|
||||
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffea, 'AltRight', true);
|
||||
|
||||
// Check that the timer is properly dead
|
||||
kbd.onkeyevent.reset();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ const expect = chai.expect;
|
|||
import { l10n } from '../app/localization.js';
|
||||
|
||||
describe('Localization', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
describe('language selection', function () {
|
||||
let origNavigator;
|
||||
|
|
@ -10,14 +10,14 @@ describe('Localization', function() {
|
|||
// window.navigator is a protected read-only property in many
|
||||
// environments, so we need to redefine it whilst running these
|
||||
// tests.
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
|
||||
origNavigator = Object.getOwnPropertyDescriptor(window, 'navigator');
|
||||
if (origNavigator === undefined) {
|
||||
// Object.getOwnPropertyDescriptor() doesn't work
|
||||
// properly in any version of IE
|
||||
this.skip();
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "navigator", {value: {}});
|
||||
Object.defineProperty(window, 'navigator', { value: {} });
|
||||
if (window.navigator.languages !== undefined) {
|
||||
// Object.defineProperty() doesn't work properly in old
|
||||
// versions of Chrome
|
||||
|
|
@ -27,45 +27,45 @@ describe('Localization', function() {
|
|||
window.navigator.languages = [];
|
||||
});
|
||||
afterEach(function () {
|
||||
Object.defineProperty(window, "navigator", origNavigator);
|
||||
Object.defineProperty(window, 'navigator', origNavigator);
|
||||
});
|
||||
|
||||
it('should use English by default', function () {
|
||||
expect(l10n.language).to.equal('en');
|
||||
});
|
||||
it('should use English if no user language matches', function () {
|
||||
window.navigator.languages = ["nl", "de"];
|
||||
l10n.setup(["es", "fr"]);
|
||||
window.navigator.languages = ['nl', 'de'];
|
||||
l10n.setup(['es', 'fr']);
|
||||
expect(l10n.language).to.equal('en');
|
||||
});
|
||||
it('should use the most preferred user language', function () {
|
||||
window.navigator.languages = ["nl", "de", "fr"];
|
||||
l10n.setup(["es", "fr", "de"]);
|
||||
window.navigator.languages = ['nl', 'de', 'fr'];
|
||||
l10n.setup(['es', 'fr', 'de']);
|
||||
expect(l10n.language).to.equal('de');
|
||||
});
|
||||
it('should prefer sub-languages languages', function () {
|
||||
window.navigator.languages = ["pt-BR"];
|
||||
l10n.setup(["pt", "pt-BR"]);
|
||||
window.navigator.languages = ['pt-BR'];
|
||||
l10n.setup(['pt', 'pt-BR']);
|
||||
expect(l10n.language).to.equal('pt-BR');
|
||||
});
|
||||
it('should fall back to language "parents"', function () {
|
||||
window.navigator.languages = ["pt-BR"];
|
||||
l10n.setup(["fr", "pt", "de"]);
|
||||
window.navigator.languages = ['pt-BR'];
|
||||
l10n.setup(['fr', 'pt', 'de']);
|
||||
expect(l10n.language).to.equal('pt');
|
||||
});
|
||||
it('should not use specific language when user asks for a generic language', function () {
|
||||
window.navigator.languages = ["pt", "de"];
|
||||
l10n.setup(["fr", "pt-BR", "de"]);
|
||||
window.navigator.languages = ['pt', 'de'];
|
||||
l10n.setup(['fr', 'pt-BR', 'de']);
|
||||
expect(l10n.language).to.equal('de');
|
||||
});
|
||||
it('should handle underscore as a separator', function () {
|
||||
window.navigator.languages = ["pt-BR"];
|
||||
l10n.setup(["pt_BR"]);
|
||||
window.navigator.languages = ['pt-BR'];
|
||||
l10n.setup(['pt_BR']);
|
||||
expect(l10n.language).to.equal('pt_BR');
|
||||
});
|
||||
it('should handle difference in case', function () {
|
||||
window.navigator.languages = ["pt-br"];
|
||||
l10n.setup(["pt-BR"]);
|
||||
window.navigator.languages = ['pt-br'];
|
||||
l10n.setup(['pt-BR']);
|
||||
expect(l10n.language).to.equal('pt-BR');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,14 +6,17 @@ import Mouse from '../core/input/mouse.js';
|
|||
import * as eventUtils from '../core/util/events.js';
|
||||
|
||||
describe('Mouse Event Handling', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
sinon.stub(eventUtils, 'setCapture');
|
||||
// This function is only used on target (the canvas)
|
||||
// and for these tests we can assume that the canvas is 100x100
|
||||
// located at coordinates 10x10
|
||||
sinon.stub(Element.prototype, 'getBoundingClientRect').returns(
|
||||
{left: 10, right: 110, top: 10, bottom: 110, width: 100, height: 100});
|
||||
{
|
||||
left: 10, right: 110, top: 10, bottom: 110, width: 100, height: 100
|
||||
}
|
||||
);
|
||||
const target = document.createElement('canvas');
|
||||
|
||||
// The real constructors might not work everywhere we
|
||||
|
|
@ -77,13 +80,15 @@ describe('Mouse Event Handling', function() {
|
|||
}
|
||||
};
|
||||
mouse._handleMouseWheel(mouseevent('mousewheel',
|
||||
{ deltaX: 50, deltaY: 0,
|
||||
deltaMode: 0}));
|
||||
{
|
||||
deltaX: 50,
|
||||
deltaY: 0,
|
||||
deltaMode: 0
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Double-click for Touch', function () {
|
||||
|
||||
beforeEach(function () { this.clock = sinon.useFakeTimers(); });
|
||||
afterEach(function () { this.clock.restore(); });
|
||||
|
||||
|
|
@ -106,16 +111,20 @@ describe('Mouse Event Handling', function() {
|
|||
// touch events are sent in an array of events
|
||||
// with one item for each touch point
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }]}));
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }] }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(touchevent(
|
||||
'touchend', { touches: [{ clientX: 79, clientY: 45 }]}));
|
||||
'touchend', { touches: [{ clientX: 79, clientY: 45 }] }
|
||||
));
|
||||
this.clock.tick(200);
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 67, clientY: 35 }]}));
|
||||
'touchstart', { touches: [{ clientX: 67, clientY: 35 }] }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(touchevent(
|
||||
'touchend', { touches: [{ clientX: 66, clientY: 36 }]}));
|
||||
'touchend', { touches: [{ clientX: 66, clientY: 36 }] }
|
||||
));
|
||||
});
|
||||
|
||||
it('should not modify 2nd tap pos if far apart', function (done) {
|
||||
|
|
@ -135,16 +144,20 @@ describe('Mouse Event Handling', function() {
|
|||
}
|
||||
};
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }]}));
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }] }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(touchevent(
|
||||
'touchend', { touches: [{ clientX: 79, clientY: 45 }]}));
|
||||
'touchend', { touches: [{ clientX: 79, clientY: 45 }] }
|
||||
));
|
||||
this.clock.tick(200);
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 57, clientY: 35 }]}));
|
||||
'touchstart', { touches: [{ clientX: 57, clientY: 35 }] }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(touchevent(
|
||||
'touchend', { touches: [{ clientX: 56, clientY: 36 }]}));
|
||||
'touchend', { touches: [{ clientX: 56, clientY: 36 }] }
|
||||
));
|
||||
});
|
||||
|
||||
it('should not modify 2nd tap pos if not soon enough', function (done) {
|
||||
|
|
@ -164,16 +177,20 @@ describe('Mouse Event Handling', function() {
|
|||
}
|
||||
};
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }]}));
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }] }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(touchevent(
|
||||
'touchend', { touches: [{ clientX: 79, clientY: 45 }]}));
|
||||
'touchend', { touches: [{ clientX: 79, clientY: 45 }] }
|
||||
));
|
||||
this.clock.tick(500);
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 67, clientY: 35 }]}));
|
||||
'touchstart', { touches: [{ clientX: 67, clientY: 35 }] }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(touchevent(
|
||||
'touchend', { touches: [{ clientX: 66, clientY: 36 }]}));
|
||||
'touchend', { touches: [{ clientX: 66, clientY: 36 }] }
|
||||
));
|
||||
});
|
||||
|
||||
it('should not modify 2nd tap pos if not touch', function (done) {
|
||||
|
|
@ -193,22 +210,24 @@ describe('Mouse Event Handling', function() {
|
|||
}
|
||||
};
|
||||
mouse._handleMouseDown(mouseevent(
|
||||
'mousedown', { button: '0x01', clientX: 78, clientY: 46 }));
|
||||
'mousedown', { button: '0x01', clientX: 78, clientY: 46 }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(mouseevent(
|
||||
'mouseup', { button: '0x01', clientX: 79, clientY: 45 }));
|
||||
'mouseup', { button: '0x01', clientX: 79, clientY: 45 }
|
||||
));
|
||||
this.clock.tick(200);
|
||||
mouse._handleMouseDown(mouseevent(
|
||||
'mousedown', { button: '0x01', clientX: 67, clientY: 35 }));
|
||||
'mousedown', { button: '0x01', clientX: 67, clientY: 35 }
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseUp(mouseevent(
|
||||
'mouseup', { button: '0x01', clientX: 66, clientY: 36 }));
|
||||
'mouseup', { button: '0x01', clientX: 66, clientY: 36 }
|
||||
));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Accumulate mouse wheel events with small delta', function () {
|
||||
|
||||
beforeEach(function () { this.clock = sinon.useFakeTimers(); });
|
||||
afterEach(function () { this.clock.restore(); });
|
||||
|
||||
|
|
@ -217,27 +236,51 @@ describe('Mouse Event Handling', function() {
|
|||
mouse.onmousebutton = sinon.spy();
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 4, deltaY: 0, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 4,
|
||||
deltaY: 0,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 4, deltaY: 0, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 4,
|
||||
deltaY: 0,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
|
||||
// threshold is 10
|
||||
expect(mouse._accumulatedWheelDeltaX).to.be.equal(8);
|
||||
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 4, deltaY: 0, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 4,
|
||||
deltaY: 0,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
|
||||
expect(mouse.onmousebutton).to.have.callCount(2); // mouse down and up
|
||||
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 4, deltaY: 9, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 4,
|
||||
deltaY: 9,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
|
||||
expect(mouse._accumulatedWheelDeltaX).to.be.equal(4);
|
||||
expect(mouse._accumulatedWheelDeltaY).to.be.equal(9);
|
||||
|
|
@ -250,16 +293,34 @@ describe('Mouse Event Handling', function() {
|
|||
mouse.onmousebutton = sinon.spy();
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 11, deltaY: 0, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 11,
|
||||
deltaY: 0,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 0, deltaY: 70, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 0,
|
||||
deltaY: 70,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
this.clock.tick(10);
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 400, deltaY: 400, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 400,
|
||||
deltaY: 400,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
|
||||
expect(mouse.onmousebutton).to.have.callCount(8); // mouse down and up
|
||||
});
|
||||
|
|
@ -269,8 +330,14 @@ describe('Mouse Event Handling', function() {
|
|||
mouse.onmousebutton = sinon.spy();
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 1, deltaY: 0, deltaMode: 0 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 1,
|
||||
deltaY: 0,
|
||||
deltaMode: 0
|
||||
}
|
||||
));
|
||||
this.clock.tick(51); // timeout on 50 ms
|
||||
|
||||
expect(mouse.onmousebutton).to.have.callCount(2); // mouse down and up
|
||||
|
|
@ -281,17 +348,28 @@ describe('Mouse Event Handling', function() {
|
|||
mouse.onmousebutton = sinon.spy();
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 0, deltaY: 2, deltaMode: 1 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 0,
|
||||
deltaY: 2,
|
||||
deltaMode: 1
|
||||
}
|
||||
));
|
||||
|
||||
this.clock.tick(10);
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
deltaX: 1, deltaY: 0, deltaMode: 2 }));
|
||||
'mousewheel', {
|
||||
clientX: 18,
|
||||
clientY: 40,
|
||||
deltaX: 1,
|
||||
deltaY: 0,
|
||||
deltaMode: 2
|
||||
}
|
||||
));
|
||||
|
||||
expect(mouse.onmousebutton).to.have.callCount(4); // mouse down and up
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ import sinon from '../vendor/sinon.js';
|
|||
|
||||
/* UIEvent constructor polyfill for IE */
|
||||
(() => {
|
||||
if (typeof window.UIEvent === "function") return;
|
||||
if (typeof window.UIEvent === 'function') return;
|
||||
|
||||
function UIEvent(event, params) {
|
||||
params = params || { bubbles: false, cancelable: false, view: window, detail: undefined };
|
||||
params = params || {
|
||||
bubbles: false, cancelable: false, view: window, detail: undefined
|
||||
};
|
||||
const evt = document.createEvent('UIEvent');
|
||||
evt.initUIEvent(event, params.bubbles, params.cancelable, params.view, params.detail);
|
||||
return evt;
|
||||
|
|
@ -24,18 +26,21 @@ import sinon from '../vendor/sinon.js';
|
|||
})();
|
||||
|
||||
function push8(arr, num) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
arr.push(num & 0xFF);
|
||||
}
|
||||
|
||||
function push16(arr, num) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
arr.push((num >> 8) & 0xFF,
|
||||
num & 0xFF);
|
||||
}
|
||||
|
||||
function push32(arr, num) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
arr.push((num >> 24) & 0xFF,
|
||||
(num >> 16) & 0xFF,
|
||||
(num >> 8) & 0xFF,
|
||||
|
|
@ -65,7 +70,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
this._sQ = _sQ;
|
||||
this._rQ = rQ;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
|
@ -80,8 +84,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
beforeEach(function () {
|
||||
// Create a container element for all RFB objects to attach to
|
||||
container = document.createElement('div');
|
||||
container.style.width = "100%";
|
||||
container.style.height = "100%";
|
||||
container.style.width = '100%';
|
||||
container.style.height = '100%';
|
||||
document.body.appendChild(container);
|
||||
|
||||
// And track all created RFB objects
|
||||
|
|
@ -106,7 +110,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
clock.tick();
|
||||
rfb._sock._websocket._open();
|
||||
rfb._rfb_connection_state = 'connected';
|
||||
sinon.spy(rfb, "_disconnect");
|
||||
sinon.spy(rfb, '_disconnect');
|
||||
rfbs.push(rfb);
|
||||
return rfb;
|
||||
}
|
||||
|
|
@ -208,7 +212,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should not send the keys if we are not in a normal state', function () {
|
||||
sinon.spy(client._sock, 'flush');
|
||||
client._rfb_connection_state = "connecting";
|
||||
client._rfb_connection_state = 'connecting';
|
||||
client.sendCtrlAltDel();
|
||||
expect(client._sock.flush).to.not.have.been.called;
|
||||
});
|
||||
|
|
@ -239,7 +243,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should not send the key if we are not in a normal state', function () {
|
||||
sinon.spy(client._sock, 'flush');
|
||||
client._rfb_connection_state = "connecting";
|
||||
client._rfb_connection_state = 'connecting';
|
||||
client.sendKey(123, 'Key123');
|
||||
expect(client._sock.flush).to.not.have.been.called;
|
||||
});
|
||||
|
|
@ -286,8 +290,12 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
describe('#clipboardPasteFrom', function () {
|
||||
it('should send the given text in a paste event', function () {
|
||||
const expected = {_sQ: new Uint8Array(11), _sQlen: 0,
|
||||
_sQbufferSize: 11, flush: () => {}};
|
||||
const expected = {
|
||||
_sQ: new Uint8Array(11),
|
||||
_sQlen: 0,
|
||||
_sQbufferSize: 11,
|
||||
flush: () => {}
|
||||
};
|
||||
RFB.messages.clientCutText(expected, 'abc');
|
||||
client.clipboardPasteFrom('abc');
|
||||
expect(client._sock).to.have.sent(expected._sQ);
|
||||
|
|
@ -295,7 +303,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should flush multiple times for large clipboards', function () {
|
||||
sinon.spy(client._sock, 'flush');
|
||||
let long_text = "";
|
||||
let long_text = '';
|
||||
for (let i = 0; i < client._sock._sQbufferSize + 100; i++) {
|
||||
long_text += 'a';
|
||||
}
|
||||
|
|
@ -305,13 +313,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should not send the text if we are not in a normal state', function () {
|
||||
sinon.spy(client._sock, 'flush');
|
||||
client._rfb_connection_state = "connecting";
|
||||
client._rfb_connection_state = 'connecting';
|
||||
client.clipboardPasteFrom('abc');
|
||||
expect(client._sock.flush).to.not.have.been.called;
|
||||
});
|
||||
});
|
||||
|
||||
describe("XVP operations", function () {
|
||||
describe('XVP operations', function () {
|
||||
beforeEach(function () {
|
||||
client._rfb_xvp_ver = 1;
|
||||
});
|
||||
|
|
@ -349,7 +357,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should update display clip state when changing the property', function () {
|
||||
const spy = sinon.spy(client._display, "clipViewport", ["set"]);
|
||||
const spy = sinon.spy(client._display, 'clipViewport', ['set']);
|
||||
|
||||
client.clipViewport = false;
|
||||
expect(spy.set).to.have.been.calledOnce;
|
||||
|
|
@ -362,7 +370,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should update the viewport when the container size changes', function () {
|
||||
sinon.spy(client._display, "viewportChangeSize");
|
||||
sinon.spy(client._display, 'viewportChangeSize');
|
||||
|
||||
container.style.width = '40px';
|
||||
container.style.height = '50px';
|
||||
|
|
@ -382,7 +390,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00];
|
||||
|
||||
sinon.spy(client._display, "viewportChangeSize");
|
||||
sinon.spy(client._display, 'viewportChangeSize');
|
||||
|
||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
||||
|
||||
|
|
@ -394,7 +402,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should not update the viewport if not clipping', function () {
|
||||
client.clipViewport = false;
|
||||
sinon.spy(client._display, "viewportChangeSize");
|
||||
sinon.spy(client._display, 'viewportChangeSize');
|
||||
|
||||
container.style.width = '40px';
|
||||
container.style.height = '50px';
|
||||
|
|
@ -407,7 +415,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should not update the viewport if scaling', function () {
|
||||
client.scaleViewport = true;
|
||||
sinon.spy(client._display, "viewportChangeSize");
|
||||
sinon.spy(client._display, 'viewportChangeSize');
|
||||
|
||||
container.style.width = '40px';
|
||||
container.style.height = '50px';
|
||||
|
|
@ -421,7 +429,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
describe('Dragging', function () {
|
||||
beforeEach(function () {
|
||||
client.dragViewport = true;
|
||||
sinon.spy(RFB.messages, "pointerEvent");
|
||||
sinon.spy(RFB.messages, 'pointerEvent');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
|
@ -455,7 +463,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should be initiate viewport dragging on sufficient movement', function () {
|
||||
sinon.spy(client._display, "viewportChangePos");
|
||||
sinon.spy(client._display, 'viewportChangePos');
|
||||
|
||||
// Too small movement
|
||||
|
||||
|
|
@ -503,7 +511,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
// Another movement now should not move the viewport
|
||||
|
||||
sinon.spy(client._display, "viewportChangePos");
|
||||
sinon.spy(client._display, 'viewportChangePos');
|
||||
|
||||
client._handleMouseMove(43, 59);
|
||||
|
||||
|
|
@ -522,8 +530,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should update display scale factor when changing the property', function () {
|
||||
const spy = sinon.spy(client._display, "scale", ["set"]);
|
||||
sinon.spy(client._display, "autoscale");
|
||||
const spy = sinon.spy(client._display, 'scale', ['set']);
|
||||
sinon.spy(client._display, 'autoscale');
|
||||
|
||||
client.scaleViewport = false;
|
||||
expect(spy.set).to.have.been.calledOnce;
|
||||
|
|
@ -538,7 +546,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
it('should update the clipping setting when changing the property', function () {
|
||||
client.clipViewport = true;
|
||||
|
||||
const spy = sinon.spy(client._display, "clipViewport", ["set"]);
|
||||
const spy = sinon.spy(client._display, 'clipViewport', ['set']);
|
||||
|
||||
client.scaleViewport = false;
|
||||
expect(spy.set).to.have.been.calledOnce;
|
||||
|
|
@ -552,7 +560,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should update the scaling when the container size changes', function () {
|
||||
sinon.spy(client._display, "autoscale");
|
||||
sinon.spy(client._display, 'autoscale');
|
||||
|
||||
container.style.width = '40px';
|
||||
container.style.height = '50px';
|
||||
|
|
@ -572,7 +580,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00];
|
||||
|
||||
sinon.spy(client._display, "autoscale");
|
||||
sinon.spy(client._display, 'autoscale');
|
||||
|
||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
||||
|
||||
|
|
@ -583,7 +591,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
it('should not update the display scale factor if not scaling', function () {
|
||||
client.scaleViewport = false;
|
||||
|
||||
sinon.spy(client._display, "autoscale");
|
||||
sinon.spy(client._display, 'autoscale');
|
||||
|
||||
container.style.width = '40px';
|
||||
container.style.height = '50px';
|
||||
|
|
@ -603,7 +611,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
client.resizeSession = true;
|
||||
container.style.width = '70px';
|
||||
container.style.height = '80px';
|
||||
sinon.spy(RFB.messages, "setDesktopSize");
|
||||
sinon.spy(RFB.messages, 'setDesktopSize');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
|
@ -759,7 +767,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should ignore state changes to the same state', function () {
|
||||
const connectSpy = sinon.spy();
|
||||
client.addEventListener("connect", connectSpy);
|
||||
client.addEventListener('connect', connectSpy);
|
||||
|
||||
expect(client._rfb_connection_state).to.equal('connected');
|
||||
client._updateConnectionState('connected');
|
||||
|
|
@ -768,7 +776,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
client.disconnect();
|
||||
|
||||
const disconnectSpy = sinon.spy();
|
||||
client.addEventListener("disconnect", disconnectSpy);
|
||||
client.addEventListener('disconnect', disconnectSpy);
|
||||
|
||||
expect(client._rfb_connection_state).to.equal('disconnected');
|
||||
client._updateConnectionState('disconnected');
|
||||
|
|
@ -777,7 +785,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should ignore illegal state changes', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("disconnect", spy);
|
||||
client.addEventListener('disconnect', spy);
|
||||
client._updateConnectionState('disconnected');
|
||||
expect(client._rfb_connection_state).to.not.equal('disconnected');
|
||||
expect(spy).to.not.have.been.called;
|
||||
|
|
@ -814,13 +822,12 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
it('should result in disconnect event with clean set to false', function () {
|
||||
client._rfb_connection_state = 'connected';
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("disconnect", spy);
|
||||
client.addEventListener('disconnect', spy);
|
||||
client._fail();
|
||||
this.clock.tick(2000);
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0][0].detail.clean).to.be.false;
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -843,7 +850,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should result in a connect event if state becomes connected', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("connect", spy);
|
||||
client.addEventListener('connect', spy);
|
||||
client._rfb_connection_state = 'connecting';
|
||||
client._updateConnectionState('connected');
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
|
|
@ -851,7 +858,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should not result in a connect event if the state is not "connected"', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("connect", spy);
|
||||
client.addEventListener('connect', spy);
|
||||
client._sock._websocket.open = () => {}; // explicitly don't call onopen
|
||||
client._updateConnectionState('connecting');
|
||||
expect(spy).to.not.have.been.called;
|
||||
|
|
@ -870,8 +877,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
client._updateConnectionState('disconnecting');
|
||||
this.clock.tick(3 * 1000);
|
||||
expect(client._updateConnectionState).to.have.been.calledTwice;
|
||||
expect(client._rfb_disconnect_reason).to.not.equal("");
|
||||
expect(client._rfb_connection_state).to.equal("disconnected");
|
||||
expect(client._rfb_disconnect_reason).to.not.equal('');
|
||||
expect(client._rfb_connection_state).to.equal('disconnected');
|
||||
});
|
||||
|
||||
it('should not fail if Websock.onclose gets called within the disconnection timeout', function () {
|
||||
|
|
@ -890,7 +897,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should not result in a disconnect event', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("disconnect", spy);
|
||||
client.addEventListener('disconnect', spy);
|
||||
client._sock._websocket.close = () => {}; // explicitly don't call onclose
|
||||
client._updateConnectionState('disconnecting');
|
||||
expect(spy).to.not.have.been.called;
|
||||
|
|
@ -905,7 +912,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should result in a disconnect event if state becomes "disconnected"', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("disconnect", spy);
|
||||
client.addEventListener('disconnect', spy);
|
||||
client._rfb_connection_state = 'disconnecting';
|
||||
client._updateConnectionState('disconnected');
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
|
|
@ -914,9 +921,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should result in a disconnect event without msg when no reason given', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("disconnect", spy);
|
||||
client.addEventListener('disconnect', spy);
|
||||
client._rfb_connection_state = 'disconnecting';
|
||||
client._rfb_disconnect_reason = "";
|
||||
client._rfb_disconnect_reason = '';
|
||||
client._updateConnectionState('disconnected');
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0].length).to.equal(1);
|
||||
|
|
@ -984,7 +991,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail on an invalid version', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
send_ver('002.000', client);
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
});
|
||||
|
|
@ -1009,7 +1016,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
describe('Repeater', function () {
|
||||
beforeEach(function () {
|
||||
client = make_rfb('wss://host:8675', { repeaterID: "12345" });
|
||||
client = make_rfb('wss://host:8675', { repeaterID: '12345' });
|
||||
client._rfb_connection_state = 'connecting';
|
||||
});
|
||||
|
||||
|
|
@ -1038,8 +1045,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
it('should simply receive the auth scheme when for versions < 3.7', function () {
|
||||
client._rfb_version = 3.6;
|
||||
const auth_scheme_raw = [1, 2, 3, 4];
|
||||
const auth_scheme = (auth_scheme_raw[0] << 24) + (auth_scheme_raw[1] << 16) +
|
||||
(auth_scheme_raw[2] << 8) + auth_scheme_raw[3];
|
||||
const auth_scheme = (auth_scheme_raw[0] << 24) + (auth_scheme_raw[1] << 16)
|
||||
+ (auth_scheme_raw[2] << 8) + auth_scheme_raw[3];
|
||||
client._sock._websocket._receive_data(auth_scheme_raw);
|
||||
expect(client._rfb_auth_scheme).to.equal(auth_scheme);
|
||||
});
|
||||
|
|
@ -1061,7 +1068,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail if there are no supported schemes for versions >= 3.7', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
client._rfb_version = 3.7;
|
||||
const auth_schemes = [1, 32];
|
||||
client._sock._websocket._receive_data(auth_schemes);
|
||||
|
|
@ -1076,7 +1083,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
expect(client._fail).to.have.been.calledWith(
|
||||
'Security negotiation failed on no security types (reason: whoops)');
|
||||
'Security negotiation failed on no security types (reason: whoops)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should transition to the Authentication state and continue on successful negotiation', function () {
|
||||
|
|
@ -1100,7 +1108,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should fail on auth scheme 0 (pre 3.7) with the given message', function () {
|
||||
client._rfb_version = 3.6;
|
||||
const err_msg = "Whoopsies";
|
||||
const err_msg = 'Whoopsies';
|
||||
const data = [0, 0, 0, 0];
|
||||
const err_len = err_msg.length;
|
||||
push32(data, err_len);
|
||||
|
|
@ -1111,7 +1119,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
sinon.spy(client, '_fail');
|
||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
||||
expect(client._fail).to.have.been.calledWith(
|
||||
'Security negotiation failed on authentication scheme (reason: Whoopsies)');
|
||||
'Security negotiation failed on authentication scheme (reason: Whoopsies)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should transition straight to SecurityResult on "no auth" (1) for versions >= 3.8', function () {
|
||||
|
|
@ -1127,7 +1136,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail on an unknown auth scheme', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
client._rfb_version = 3.8;
|
||||
send_security(57, client);
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
|
|
@ -1141,7 +1150,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should fire the credentialsrequired event if missing a password', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("credentialsrequired", spy);
|
||||
client.addEventListener('credentialsrequired', spy);
|
||||
send_security(2, client);
|
||||
|
||||
const challenge = [];
|
||||
|
|
@ -1150,7 +1159,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
expect(client._rfb_credentials).to.be.empty;
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0][0].detail.types).to.have.members(["password"]);
|
||||
expect(spy.args[0][0].detail.types).to.have.members(['password']);
|
||||
});
|
||||
|
||||
it('should encrypt the password with DES and then send it back', function () {
|
||||
|
|
@ -1185,9 +1194,11 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fall through to standard VNC authentication upon completion', function () {
|
||||
client._rfb_credentials = { username: 'user',
|
||||
client._rfb_credentials = {
|
||||
username: 'user',
|
||||
target: 'target',
|
||||
password: 'password' };
|
||||
password: 'password'
|
||||
};
|
||||
client._negotiate_std_vnc_auth = sinon.spy();
|
||||
send_security(22, client);
|
||||
expect(client._negotiate_std_vnc_auth).to.have.been.calledOnce;
|
||||
|
|
@ -1195,30 +1206,34 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should fire the credentialsrequired event if all credentials are missing', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("credentialsrequired", spy);
|
||||
client.addEventListener('credentialsrequired', spy);
|
||||
client._rfb_credentials = {};
|
||||
send_security(22, client);
|
||||
|
||||
expect(client._rfb_credentials).to.be.empty;
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0][0].detail.types).to.have.members(["username", "password", "target"]);
|
||||
expect(spy.args[0][0].detail.types).to.have.members(['username', 'password', 'target']);
|
||||
});
|
||||
|
||||
it('should fire the credentialsrequired event if some credentials are missing', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("credentialsrequired", spy);
|
||||
client._rfb_credentials = { username: 'user',
|
||||
target: 'target' };
|
||||
client.addEventListener('credentialsrequired', spy);
|
||||
client._rfb_credentials = {
|
||||
username: 'user',
|
||||
target: 'target'
|
||||
};
|
||||
send_security(22, client);
|
||||
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0][0].detail.types).to.have.members(["username", "password", "target"]);
|
||||
expect(spy.args[0][0].detail.types).to.have.members(['username', 'password', 'target']);
|
||||
});
|
||||
|
||||
it('should send user and target separately', function () {
|
||||
client._rfb_credentials = { username: 'user',
|
||||
client._rfb_credentials = {
|
||||
username: 'user',
|
||||
target: 'target',
|
||||
password: 'password' };
|
||||
password: 'password'
|
||||
};
|
||||
client._negotiate_std_vnc_auth = sinon.spy();
|
||||
|
||||
send_security(22, client);
|
||||
|
|
@ -1261,7 +1276,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail if no supported tunnels are listed', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
send_num_str_pairs([[123, 'OTHR', 'SOMETHNG']], client);
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
});
|
||||
|
|
@ -1310,7 +1325,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail if there are no supported auth types', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
client._rfb_tightvnc = true;
|
||||
send_num_str_pairs([[23, 'stdv', 'badval__']], client);
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
|
|
@ -1334,7 +1349,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
const failure_data = [0, 0, 0, 1, 0, 0, 0, 6, 119, 104, 111, 111, 112, 115];
|
||||
client._sock._websocket._receive_data(new Uint8Array(failure_data));
|
||||
expect(client._fail).to.have.been.calledWith(
|
||||
'Security negotiation failed on security result (reason: whoops)');
|
||||
'Security negotiation failed on security result (reason: whoops)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should fail on an error code of 1 with a standard message for version < 3.8', function () {
|
||||
|
|
@ -1342,12 +1358,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
client._rfb_version = 3.7;
|
||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 1]));
|
||||
expect(client._fail).to.have.been.calledWith(
|
||||
'Security handshake failed');
|
||||
'Security handshake failed'
|
||||
);
|
||||
});
|
||||
|
||||
it('should result in securityfailure event when receiving a non zero status', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("securityfailure", spy);
|
||||
client.addEventListener('securityfailure', spy);
|
||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 2]));
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
expect(spy.args[0][0].detail.status).to.equal(2);
|
||||
|
|
@ -1356,7 +1373,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
it('should include reason when provided in securityfailure event', function () {
|
||||
client._rfb_version = 3.8;
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("securityfailure", spy);
|
||||
client.addEventListener('securityfailure', spy);
|
||||
const failure_data = [0, 0, 0, 1, 0, 0, 0, 12, 115, 117, 99, 104,
|
||||
32, 102, 97, 105, 108, 117, 114, 101];
|
||||
client._sock._websocket._receive_data(new Uint8Array(failure_data));
|
||||
|
|
@ -1367,7 +1384,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
it('should not include reason when length is zero in securityfailure event', function () {
|
||||
client._rfb_version = 3.9;
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("securityfailure", spy);
|
||||
client.addEventListener('securityfailure', spy);
|
||||
const failure_data = [0, 0, 0, 1, 0, 0, 0, 0];
|
||||
client._sock._websocket._receive_data(new Uint8Array(failure_data));
|
||||
expect(spy.args[0][0].detail.status).to.equal(1);
|
||||
|
|
@ -1377,7 +1394,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
it('should not include reason in securityfailure event for version < 3.8', function () {
|
||||
client._rfb_version = 3.6;
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("securityfailure", spy);
|
||||
client.addEventListener('securityfailure', spy);
|
||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 2]));
|
||||
expect(spy.args[0][0].detail.status).to.equal(2);
|
||||
expect('reason' in spy.args[0][0].detail).to.be.false;
|
||||
|
|
@ -1416,9 +1433,21 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
function send_server_init(opts, client) {
|
||||
const full_opts = { width: 10, height: 12, bpp: 24, depth: 24, big_endian: 0,
|
||||
true_color: 1, red_max: 255, green_max: 255, blue_max: 255,
|
||||
red_shift: 16, green_shift: 8, blue_shift: 0, name: 'a name' };
|
||||
const full_opts = {
|
||||
width: 10,
|
||||
height: 12,
|
||||
bpp: 24,
|
||||
depth: 24,
|
||||
big_endian: 0,
|
||||
true_color: 1,
|
||||
red_max: 255,
|
||||
green_max: 255,
|
||||
blue_max: 255,
|
||||
red_shift: 16,
|
||||
green_shift: 8,
|
||||
blue_shift: 0,
|
||||
name: 'a name'
|
||||
};
|
||||
for (let opt in opts) {
|
||||
full_opts[opt] = opts[opt];
|
||||
}
|
||||
|
|
@ -1464,7 +1493,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should set the framebuffer name and call the callback', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("desktopname", spy);
|
||||
client.addEventListener('desktopname', spy);
|
||||
send_server_init({ name: 'some name' }, client);
|
||||
|
||||
expect(client._fb_name).to.equal('some name');
|
||||
|
|
@ -1509,9 +1538,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
describe('Initial Update Request', function () {
|
||||
beforeEach(function () {
|
||||
sinon.spy(RFB.messages, "pixelFormat");
|
||||
sinon.spy(RFB.messages, "clientEncodings");
|
||||
sinon.spy(RFB.messages, "fbUpdateRequest");
|
||||
sinon.spy(RFB.messages, 'pixelFormat');
|
||||
sinon.spy(RFB.messages, 'clientEncodings');
|
||||
sinon.spy(RFB.messages, 'fbUpdateRequest');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
|
@ -1535,7 +1564,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should reply with restricted settings for Intel AMT servers', function () {
|
||||
send_server_init({ width: 27, height: 32, name: "Intel(r) AMT KVM"}, client);
|
||||
send_server_init({ width: 27, height: 32, name: 'Intel(r) AMT KVM' }, client);
|
||||
|
||||
expect(RFB.messages.pixelFormat).to.have.been.calledOnce;
|
||||
expect(RFB.messages.pixelFormat).to.have.been.calledWith(client._sock, 8, true);
|
||||
|
|
@ -1651,8 +1680,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail on an unsupported encoding', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
const rect_info = { x: 8, y: 11, width: 27, height: 32, encoding: 234 };
|
||||
sinon.spy(client, '_fail');
|
||||
const rect_info = {
|
||||
x: 8, y: 11, width: 27, height: 32, encoding: 234
|
||||
};
|
||||
send_fbu_msg([rect_info], [[]], client);
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
});
|
||||
|
|
@ -1664,8 +1695,12 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
client._display.resize(4, 4);
|
||||
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||
|
||||
const info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
|
||||
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
|
||||
const info = [{
|
||||
x: 0, y: 2, width: 2, height: 2, encoding: 0x01
|
||||
},
|
||||
{
|
||||
x: 2, y: 2, width: 2, height: 2, encoding: 0x01
|
||||
}];
|
||||
// data says [{ old_x: 2, old_y: 0 }, { old_x: 0, old_y: 0 }]
|
||||
const rects = [[0, 2, 0, 0], [0, 0, 0, 0]];
|
||||
send_fbu_msg([info[0]], [rects[0]], client, 2);
|
||||
|
|
@ -1683,10 +1718,18 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should handle the RAW encoding', function () {
|
||||
const info = [{ x: 0, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||
{ x: 2, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||
{ x: 0, y: 2, width: 4, height: 1, encoding: 0x00 },
|
||||
{ x: 0, y: 3, width: 4, height: 1, encoding: 0x00 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 2, height: 2, encoding: 0x00
|
||||
},
|
||||
{
|
||||
x: 2, y: 0, width: 2, height: 2, encoding: 0x00
|
||||
},
|
||||
{
|
||||
x: 0, y: 2, width: 4, height: 1, encoding: 0x00
|
||||
},
|
||||
{
|
||||
x: 0, y: 3, width: 4, height: 1, encoding: 0x00
|
||||
}];
|
||||
// data is in bgrx
|
||||
const rects = [
|
||||
[0x00, 0x00, 0xff, 0, 0x00, 0xff, 0x00, 0, 0x00, 0xff, 0x00, 0, 0x00, 0x00, 0xff, 0],
|
||||
|
|
@ -1698,10 +1741,18 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should handle the RAW encoding in low colour mode', function () {
|
||||
const info = [{ x: 0, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||
{ x: 2, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||
{ x: 0, y: 2, width: 4, height: 1, encoding: 0x00 },
|
||||
{ x: 0, y: 3, width: 4, height: 1, encoding: 0x00 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 2, height: 2, encoding: 0x00
|
||||
},
|
||||
{
|
||||
x: 2, y: 0, width: 2, height: 2, encoding: 0x00
|
||||
},
|
||||
{
|
||||
x: 0, y: 2, width: 4, height: 1, encoding: 0x00
|
||||
},
|
||||
{
|
||||
x: 0, y: 3, width: 4, height: 1, encoding: 0x00
|
||||
}];
|
||||
const rects = [
|
||||
[0x03, 0x03, 0x03, 0x03],
|
||||
[0x0c, 0x0c, 0x0c, 0x0c],
|
||||
|
|
@ -1716,8 +1767,12 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
// seed some initial data to copy
|
||||
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||
|
||||
const info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
|
||||
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
|
||||
const info = [{
|
||||
x: 0, y: 2, width: 2, height: 2, encoding: 0x01
|
||||
},
|
||||
{
|
||||
x: 2, y: 2, width: 2, height: 2, encoding: 0x01
|
||||
}];
|
||||
// data says [{ old_x: 0, old_y: 0 }, { old_x: 0, old_y: 0 }]
|
||||
const rects = [[0, 2, 0, 0], [0, 0, 0, 0]];
|
||||
send_fbu_msg(info, rects, client);
|
||||
|
|
@ -1728,7 +1783,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
// TODO(directxman12): test rre_chunk_sz (related to above about subrects)?
|
||||
|
||||
it('should handle the RRE encoding', function () {
|
||||
const info = [{ x: 0, y: 0, width: 4, height: 4, encoding: 0x02 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 4, height: 4, encoding: 0x02
|
||||
}];
|
||||
const rect = [];
|
||||
push32(rect, 2); // 2 subrects
|
||||
push32(rect, 0xff00ff); // becomes 00ff00ff --> #00FF00 bg color
|
||||
|
|
@ -1755,7 +1812,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
describe('the HEXTILE encoding handler', function () {
|
||||
it('should handle a tile with fg, bg specified, normal subrects', function () {
|
||||
const info = [{ x: 0, y: 0, width: 4, height: 4, encoding: 0x05 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 4, height: 4, encoding: 0x05
|
||||
}];
|
||||
const rect = [];
|
||||
rect.push(0x02 | 0x04 | 0x08); // bg spec, fg spec, anysubrects
|
||||
push32(rect, 0xff00ff); // becomes 00ff00ff --> #00FF00 bg color
|
||||
|
|
@ -1773,7 +1832,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should handle a raw tile', function () {
|
||||
const info = [{ x: 0, y: 0, width: 4, height: 4, encoding: 0x05 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 4, height: 4, encoding: 0x05
|
||||
}];
|
||||
const rect = [];
|
||||
rect.push(0x01); // raw
|
||||
for (let i = 0; i < target_data.length; i += 4) {
|
||||
|
|
@ -1787,7 +1848,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should handle a tile with only bg specified (solid bg)', function () {
|
||||
const info = [{ x: 0, y: 0, width: 4, height: 4, encoding: 0x05 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 4, height: 4, encoding: 0x05
|
||||
}];
|
||||
const rect = [];
|
||||
rect.push(0x02);
|
||||
push32(rect, 0xff00ff); // becomes 00ff00ff --> #00FF00 bg color
|
||||
|
|
@ -1803,7 +1866,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
client._fb_width = 8;
|
||||
client._display.resize(8, 4);
|
||||
|
||||
const info = [{ x: 0, y: 0, width: 32, height: 4, encoding: 0x05 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 32, height: 4, encoding: 0x05
|
||||
}];
|
||||
|
||||
const rect = [];
|
||||
|
||||
|
|
@ -1823,7 +1888,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should handle a tile with bg and coloured subrects', function () {
|
||||
const info = [{ x: 0, y: 0, width: 4, height: 4, encoding: 0x05 }];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 4, height: 4, encoding: 0x05
|
||||
}];
|
||||
const rect = [];
|
||||
rect.push(0x02 | 0x08 | 0x10); // bg spec, anysubrects, colouredsubrects
|
||||
push32(rect, 0xff00ff); // becomes 00ff00ff --> #00FF00 bg color
|
||||
|
|
@ -1849,7 +1916,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
client._fb_height = 17;
|
||||
client._display.resize(4, 17);
|
||||
|
||||
const info = [{ x: 0, y: 0, width: 4, height: 17, encoding: 0x05}];
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 4, height: 17, encoding: 0x05
|
||||
}];
|
||||
const rect = [];
|
||||
rect.push(0x02 | 0x04 | 0x08); // bg spec, fg spec, anysubrects
|
||||
push32(rect, 0xff00ff); // becomes 00ff00ff --> #00FF00 bg color
|
||||
|
|
@ -1877,8 +1946,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail on an invalid subencoding', function () {
|
||||
sinon.spy(client,"_fail");
|
||||
const info = [{ x: 0, y: 0, width: 4, height: 4, encoding: 0x05 }];
|
||||
sinon.spy(client, '_fail');
|
||||
const info = [{
|
||||
x: 0, y: 0, width: 4, height: 4, encoding: 0x05
|
||||
}];
|
||||
const rects = [[45]]; // an invalid subencoding
|
||||
send_fbu_msg(info, rects, client);
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
|
|
@ -1895,7 +1966,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should handle the DesktopSize pseduo-encoding', function () {
|
||||
sinon.spy(client._display, 'resize');
|
||||
send_fbu_msg([{ x: 0, y: 0, width: 20, height: 50, encoding: -223 }], [[]], client);
|
||||
send_fbu_msg([{
|
||||
x: 0, y: 0, width: 20, height: 50, encoding: -223
|
||||
}], [[]], client);
|
||||
|
||||
expect(client._fb_width).to.equal(20);
|
||||
expect(client._fb_height).to.equal(50);
|
||||
|
|
@ -1933,8 +2006,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
const reason_for_change = 1; // requested by this client
|
||||
const status_code = 0; // No error
|
||||
|
||||
send_fbu_msg([{ x: reason_for_change, y: status_code,
|
||||
width: 20, height: 50, encoding: -308 }],
|
||||
send_fbu_msg([{
|
||||
x: reason_for_change,
|
||||
y: status_code,
|
||||
width: 20,
|
||||
height: 50,
|
||||
encoding: -308
|
||||
}],
|
||||
make_screen_data(1), client);
|
||||
|
||||
expect(client._fb_width).to.equal(20);
|
||||
|
|
@ -1948,8 +2026,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
const reason_for_change = 2; // requested by another client
|
||||
const status_code = 0; // No error
|
||||
|
||||
send_fbu_msg([{ x: reason_for_change, y: status_code,
|
||||
width: 20, height: 50, encoding: -308 }],
|
||||
send_fbu_msg([{
|
||||
x: reason_for_change,
|
||||
y: status_code,
|
||||
width: 20,
|
||||
height: 50,
|
||||
encoding: -308
|
||||
}],
|
||||
make_screen_data(1), client);
|
||||
|
||||
expect(client._fb_width).to.equal(20);
|
||||
|
|
@ -1963,8 +2046,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
const reason_for_change = 2; // requested by another client
|
||||
const status_code = 0; // No error
|
||||
|
||||
send_fbu_msg([{ x: reason_for_change, y: status_code,
|
||||
width: 60, height: 50, encoding: -308 }],
|
||||
send_fbu_msg([{
|
||||
x: reason_for_change,
|
||||
y: status_code,
|
||||
width: 60,
|
||||
height: 50,
|
||||
encoding: -308
|
||||
}],
|
||||
make_screen_data(3), client);
|
||||
|
||||
expect(client._fb_width).to.equal(60);
|
||||
|
|
@ -1978,8 +2066,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
const reason_for_change = 1; // requested by this client
|
||||
const status_code = 1; // Resize is administratively prohibited
|
||||
|
||||
send_fbu_msg([{ x: reason_for_change, y: status_code,
|
||||
width: 20, height: 50, encoding: -308 }],
|
||||
send_fbu_msg([{
|
||||
x: reason_for_change,
|
||||
y: status_code,
|
||||
width: 20,
|
||||
height: 50,
|
||||
encoding: -308
|
||||
}],
|
||||
make_screen_data(1), client);
|
||||
|
||||
expect(client._fb_width).to.equal(4);
|
||||
|
|
@ -1994,7 +2087,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should handle the last_rect pseudo-encoding', function () {
|
||||
send_fbu_msg([{ x: 0, y: 0, width: 0, height: 0, encoding: -224}], [[]], client, 100);
|
||||
send_fbu_msg([{
|
||||
x: 0, y: 0, width: 0, height: 0, encoding: -224
|
||||
}], [[]], client, 100);
|
||||
expect(client._FBU.rects).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
|
@ -2003,7 +2098,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
describe('XVP Message Handling', function () {
|
||||
it('should set the XVP version and fire the callback with the version on XVP_INIT', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("capabilities", spy);
|
||||
client.addEventListener('capabilities', spy);
|
||||
client._sock._websocket._receive_data(new Uint8Array([250, 0, 10, 1]));
|
||||
expect(client._rfb_xvp_ver).to.equal(10);
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
|
|
@ -2012,7 +2107,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail on unknown XVP message types', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
client._sock._websocket._receive_data(new Uint8Array([250, 0, 10, 237]));
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
});
|
||||
|
|
@ -2024,7 +2119,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
push32(data, expected_str.length);
|
||||
for (let i = 0; i < expected_str.length; i++) { data.push(expected_str.charCodeAt(i)); }
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("clipboard", spy);
|
||||
client.addEventListener('clipboard', spy);
|
||||
|
||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
|
|
@ -2033,7 +2128,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should fire the bell callback on Bell', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("bell", spy);
|
||||
client.addEventListener('bell', spy);
|
||||
client._sock._websocket._receive_data(new Uint8Array([2]));
|
||||
expect(spy).to.have.been.calledOnce;
|
||||
});
|
||||
|
|
@ -2042,7 +2137,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
const expected_msg = { _sQ: new Uint8Array(16), _sQlen: 0, flush: () => {} };
|
||||
const incoming_msg = { _sQ: new Uint8Array(16), _sQlen: 0, flush: () => {} };
|
||||
|
||||
const payload = "foo\x00ab9";
|
||||
const payload = 'foo\x00ab9';
|
||||
|
||||
// ClientFence and ServerFence are identical in structure
|
||||
RFB.messages.clientFence(expected_msg, (1 << 0) | (1 << 1), payload);
|
||||
|
|
@ -2101,7 +2196,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail on an unknown message type', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
client._sock._websocket._receive_data(new Uint8Array([87]));
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
});
|
||||
|
|
@ -2207,7 +2302,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
|
||||
it('should process all normal messages directly', function () {
|
||||
const spy = sinon.spy();
|
||||
client.addEventListener("bell", spy);
|
||||
client.addEventListener('bell', spy);
|
||||
client._sock._websocket._receive_data(new Uint8Array([0x02, 0x02]));
|
||||
expect(spy).to.have.been.calledTwice;
|
||||
});
|
||||
|
|
@ -2221,7 +2316,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail if we are not currently ready to connect and we get an "open" event', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
client._rfb_connection_state = 'connected';
|
||||
client._sock._websocket._open();
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
|
|
@ -2239,7 +2334,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
|||
});
|
||||
|
||||
it('should fail if we get a close event while connecting', function () {
|
||||
sinon.spy(client, "_fail");
|
||||
sinon.spy(client, '_fail');
|
||||
client._rfb_connection_state = 'connecting';
|
||||
client._sock._websocket.close();
|
||||
expect(client._fail).to.have.been.calledOnce;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import * as Log from '../core/util/logging.js';
|
|||
import sinon from '../vendor/sinon.js';
|
||||
|
||||
describe('Utils', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
describe('logging functions', function () {
|
||||
beforeEach(function () {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import FakeWebSocket from './fake.websocket.js';
|
|||
import sinon from '../vendor/sinon.js';
|
||||
|
||||
describe('Websock', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
describe('Queue methods', function () {
|
||||
let sock;
|
||||
|
|
@ -26,7 +26,7 @@ describe('Websock', function() {
|
|||
expect(sock.rQlen()).to.equal(RQ_TEMPLATE.length);
|
||||
});
|
||||
|
||||
it("should return the proper length if we read some from the receive queue", function () {
|
||||
it('should return the proper length if we read some from the receive queue', function () {
|
||||
sock.set_rQi(1);
|
||||
|
||||
expect(sock.rQlen()).to.equal(RQ_TEMPLATE.length - 1);
|
||||
|
|
@ -63,10 +63,10 @@ describe('Websock', function() {
|
|||
describe('rQshift32', function () {
|
||||
it('should pop four bytes from the receive queue and return a single number', function () {
|
||||
const bef_len = sock.rQlen();
|
||||
const expected = (RQ_TEMPLATE[0] << 24) +
|
||||
(RQ_TEMPLATE[1] << 16) +
|
||||
(RQ_TEMPLATE[2] << 8) +
|
||||
RQ_TEMPLATE[3];
|
||||
const expected = (RQ_TEMPLATE[0] << 24)
|
||||
+ (RQ_TEMPLATE[1] << 16)
|
||||
+ (RQ_TEMPLATE[2] << 8)
|
||||
+ RQ_TEMPLATE[3];
|
||||
expect(sock.rQshift32()).to.equal(expected);
|
||||
expect(sock.rQlen()).to.equal(bef_len - 4);
|
||||
});
|
||||
|
|
@ -90,7 +90,7 @@ describe('Websock', function() {
|
|||
it('should be able to handle very large strings', function () {
|
||||
const BIG_LEN = 500000;
|
||||
const RQ_BIG = new Uint8Array(BIG_LEN);
|
||||
let expected = "";
|
||||
let expected = '';
|
||||
let letterCode = 'a'.charCodeAt(0);
|
||||
for (let i = 0; i < BIG_LEN; i++) {
|
||||
RQ_BIG[i] = letterCode;
|
||||
|
|
@ -197,7 +197,7 @@ describe('Websock', function() {
|
|||
|
||||
it('should actually send on the websocket', function () {
|
||||
sock._websocket.bufferedAmount = 8;
|
||||
sock._websocket.readyState = WebSocket.OPEN
|
||||
sock._websocket.readyState = WebSocket.OPEN;
|
||||
sock._sQ = new Uint8Array([1, 2, 3]);
|
||||
sock._sQlen = 3;
|
||||
const encoded = sock._encode_message();
|
||||
|
|
@ -240,7 +240,7 @@ describe('Websock', function() {
|
|||
});
|
||||
|
||||
it('should call send after converting the string to an array', function () {
|
||||
sock.send_string("\x01\x02\x03");
|
||||
sock.send_string('\x01\x02\x03');
|
||||
expect(sock.send).to.have.been.calledWith([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,10 +7,9 @@ import * as WebUtil from '../app/webutil.js';
|
|||
import sinon from '../vendor/sinon.js';
|
||||
|
||||
describe('WebUtil', function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
describe('settings', function () {
|
||||
|
||||
describe('localStorage', function () {
|
||||
let chrome = window.chrome;
|
||||
before(function () {
|
||||
|
|
@ -23,14 +22,14 @@ describe('WebUtil', function() {
|
|||
|
||||
let origLocalStorage;
|
||||
beforeEach(function () {
|
||||
origLocalStorage = Object.getOwnPropertyDescriptor(window, "localStorage");
|
||||
origLocalStorage = Object.getOwnPropertyDescriptor(window, 'localStorage');
|
||||
if (origLocalStorage === undefined) {
|
||||
// Object.getOwnPropertyDescriptor() doesn't work
|
||||
// properly in any version of IE
|
||||
this.skip();
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "localStorage", {value: {}});
|
||||
Object.defineProperty(window, 'localStorage', { value: {} });
|
||||
if (window.localStorage.setItem !== undefined) {
|
||||
// Object.defineProperty() doesn't work properly in old
|
||||
// versions of Chrome
|
||||
|
|
@ -44,7 +43,7 @@ describe('WebUtil', function() {
|
|||
WebUtil.initSettings();
|
||||
});
|
||||
afterEach(function () {
|
||||
Object.defineProperty(window, "localStorage", origLocalStorage);
|
||||
Object.defineProperty(window, 'localStorage', origLocalStorage);
|
||||
});
|
||||
|
||||
describe('writeSetting', function () {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
|
|
@ -15,12 +15,12 @@ let filename;
|
|||
|
||||
for (let i = 2; i < process.argv.length; ++i) {
|
||||
switch (process.argv[i]) {
|
||||
case "--help":
|
||||
case "-h":
|
||||
case '--help':
|
||||
case '-h':
|
||||
show_help = true;
|
||||
break;
|
||||
case "--file":
|
||||
case "-f":
|
||||
case '--file':
|
||||
case '-f':
|
||||
default:
|
||||
filename = process.argv[i];
|
||||
}
|
||||
|
|
@ -28,14 +28,14 @@ for (let i = 2; i < process.argv.length; ++i) {
|
|||
|
||||
if (!filename) {
|
||||
show_help = true;
|
||||
console.log("Error: No filename specified\n");
|
||||
console.log('Error: No filename specified\n');
|
||||
}
|
||||
|
||||
if (show_help) {
|
||||
console.log("Parses a *nix keysymdef.h to generate Unicode code point mappings");
|
||||
console.log("Usage: node parse.js [options] filename:");
|
||||
console.log(" -h [ --help ] Produce this help message");
|
||||
console.log(" filename The keysymdef.h file to parse");
|
||||
console.log('Parses a *nix keysymdef.h to generate Unicode code point mappings');
|
||||
console.log('Usage: node parse.js [options] filename:');
|
||||
console.log(' -h [ --help ] Produce this help message');
|
||||
console.log(' filename The keysymdef.h file to parse');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -66,24 +66,23 @@ for (let i = 0; i < arr.length; ++i) {
|
|||
}
|
||||
}
|
||||
|
||||
let out =
|
||||
"/*\n" +
|
||||
" * Mapping from Unicode codepoints to X11/RFB keysyms\n" +
|
||||
" *\n" +
|
||||
" * This file was automatically generated from keysymdef.h\n" +
|
||||
" * DO NOT EDIT!\n" +
|
||||
" */\n" +
|
||||
"\n" +
|
||||
"/* Functions at the bottom */\n" +
|
||||
"\n" +
|
||||
"const codepoints = {\n";
|
||||
let out = '/*\n'
|
||||
+ ' * Mapping from Unicode codepoints to X11/RFB keysyms\n'
|
||||
+ ' *\n'
|
||||
+ ' * This file was automatically generated from keysymdef.h\n'
|
||||
+ ' * DO NOT EDIT!\n'
|
||||
+ ' */\n'
|
||||
+ '\n'
|
||||
+ '/* Functions at the bottom */\n'
|
||||
+ '\n'
|
||||
+ 'const codepoints = {\n';
|
||||
|
||||
function toHex(num) {
|
||||
let s = num.toString(16);
|
||||
if (s.length < 4) {
|
||||
s = ("0000" + s).slice(-4);
|
||||
s = ('0000' + s).slice(-4);
|
||||
}
|
||||
return "0x" + s;
|
||||
return '0x' + s;
|
||||
}
|
||||
|
||||
for (let codepoint in codepoints) {
|
||||
|
|
@ -99,30 +98,30 @@ for (let codepoint in codepoints) {
|
|||
continue;
|
||||
}
|
||||
|
||||
out += " " + toHex(codepoint) + ": " +
|
||||
toHex(codepoints[codepoint].keysym) +
|
||||
", // XK_" + codepoints[codepoint].name + "\n";
|
||||
out += ' ' + toHex(codepoint) + ': '
|
||||
+ toHex(codepoints[codepoint].keysym)
|
||||
+ ', // XK_' + codepoints[codepoint].name + '\n';
|
||||
}
|
||||
|
||||
out +=
|
||||
"};\n" +
|
||||
"\n" +
|
||||
"export default {\n" +
|
||||
" lookup(u) {\n" +
|
||||
" // Latin-1 is one-to-one mapping\n" +
|
||||
" if ((u >= 0x20) && (u <= 0xff)) {\n" +
|
||||
" return u;\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" // Lookup table (fairly random)\n" +
|
||||
" const keysym = codepoints[u];\n" +
|
||||
" if (keysym !== undefined) {\n" +
|
||||
" return keysym;\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" // General mapping as final fallback\n" +
|
||||
" return 0x01000000 | u;\n" +
|
||||
" },\n" +
|
||||
"};";
|
||||
out
|
||||
+= '};\n'
|
||||
+ '\n'
|
||||
+ 'export default {\n'
|
||||
+ ' lookup(u) {\n'
|
||||
+ ' // Latin-1 is one-to-one mapping\n'
|
||||
+ ' if ((u >= 0x20) && (u <= 0xff)) {\n'
|
||||
+ ' return u;\n'
|
||||
+ ' }\n'
|
||||
+ '\n'
|
||||
+ ' // Lookup table (fairly random)\n'
|
||||
+ ' const keysym = codepoints[u];\n'
|
||||
+ ' if (keysym !== undefined) {\n'
|
||||
+ ' return keysym;\n'
|
||||
+ ' }\n'
|
||||
+ '\n'
|
||||
+ ' // General mapping as final fallback\n'
|
||||
+ ' return 0x01000000 | u;\n'
|
||||
+ ' },\n'
|
||||
+ '};';
|
||||
|
||||
console.log(out);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function promisify(original) {
|
|||
resolve(value);
|
||||
}));
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const readFile = promisify(fs.readFile);
|
||||
|
|
@ -140,7 +140,7 @@ function transform_html (legacy_scripts, only_legacy) {
|
|||
|
||||
function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
|
||||
if (!import_format) {
|
||||
throw new Error("you must specify an import format to generate compiled noVNC libraries");
|
||||
throw new Error('you must specify an import format to generate compiled noVNC libraries');
|
||||
} else if (!SUPPORTED_FORMATS.has(import_format)) {
|
||||
throw new Error(`unsupported output format "${import_format}" for import/export -- only ${Array.from(SUPPORTED_FORMATS)} are supported`);
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
|
|||
.then(() => {
|
||||
console.log(`Writing ${out_path}`);
|
||||
return copy(filename, out_path);
|
||||
})
|
||||
});
|
||||
})
|
||||
.then(() => ensureDir(path.dirname(legacy_path)))
|
||||
.then(() => {
|
||||
|
|
@ -214,9 +214,11 @@ function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
|
|||
// Adjust for the fact that we move the core files relative
|
||||
// to the vendor directory
|
||||
if (vendor_rewrite) {
|
||||
opts.plugins.push(["import-redirect",
|
||||
{"root": legacy_path_base,
|
||||
"redirect": { "vendor/(.+)": "./vendor/$1"}}]);
|
||||
opts.plugins.push(['import-redirect',
|
||||
{
|
||||
root: legacy_path_base,
|
||||
redirect: { 'vendor/(.+)': './vendor/$1' }
|
||||
}]);
|
||||
}
|
||||
|
||||
return babelTransformFile(filename, opts)
|
||||
|
|
@ -279,14 +281,13 @@ function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
|
|||
})
|
||||
.then(() => {
|
||||
if (!helper.removeModules) return;
|
||||
console.log(`Cleaning up temporary files...`);
|
||||
console.log('Cleaning up temporary files...');
|
||||
return Promise.all(outFiles.map((filepath) => {
|
||||
unlink(filepath)
|
||||
.then(() => {
|
||||
// Try to clean up any empty directories if this
|
||||
// was the last file in there
|
||||
const rmdir_r = dir =>
|
||||
rmdir(dir)
|
||||
const rmdir_r = dir => rmdir(dir)
|
||||
.then(() => rmdir_r(path.dirname(dir)))
|
||||
.catch(() => {
|
||||
// Assume the error was ENOTEMPTY and ignore it
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ function promisify(original) {
|
|||
resolve(value);
|
||||
}));
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const writeFile = promisify(fs.writeFile);
|
||||
|
||||
module.exports = {
|
||||
'amd': {
|
||||
amd: {
|
||||
appWriter: (base_out_path, script_base_path, out_path) => {
|
||||
// setup for requirejs
|
||||
const ui_path = path.relative(base_out_path,
|
||||
|
|
@ -27,16 +27,16 @@ module.exports = {
|
|||
.then(() => {
|
||||
console.log(`Please place RequireJS in ${path.join(script_base_path, 'require.js')}`);
|
||||
const require_path = path.relative(base_out_path,
|
||||
path.join(script_base_path, 'require.js'))
|
||||
path.join(script_base_path, 'require.js'));
|
||||
return [require_path];
|
||||
});
|
||||
},
|
||||
noCopyOverride: () => {},
|
||||
},
|
||||
'commonjs': {
|
||||
commonjs: {
|
||||
optionsOverride: (opts) => {
|
||||
// CommonJS supports properly shifting the default export to work as normal
|
||||
opts.plugins.unshift("add-module-exports");
|
||||
opts.plugins.unshift('add-module-exports');
|
||||
},
|
||||
appWriter: (base_out_path, script_base_path, out_path) => {
|
||||
const browserify = require('browserify');
|
||||
|
|
@ -48,7 +48,7 @@ module.exports = {
|
|||
noCopyOverride: () => {},
|
||||
removeModules: true,
|
||||
},
|
||||
'systemjs': {
|
||||
systemjs: {
|
||||
appWriter: (base_out_path, script_base_path, out_path) => {
|
||||
const ui_path = path.relative(base_out_path,
|
||||
path.join(script_base_path, 'app', 'ui.js'));
|
||||
|
|
@ -57,9 +57,9 @@ module.exports = {
|
|||
console.log(`Please place SystemJS in ${path.join(script_base_path, 'system-production.js')}`);
|
||||
// FIXME: Should probably be in the legacy directory
|
||||
const promise_path = path.relative(base_out_path,
|
||||
path.join(base_out_path, 'vendor', 'promise.js'))
|
||||
path.join(base_out_path, 'vendor', 'promise.js'));
|
||||
const systemjs_path = path.relative(base_out_path,
|
||||
path.join(script_base_path, 'system-production.js'))
|
||||
path.join(script_base_path, 'system-production.js'));
|
||||
return [promise_path, systemjs_path];
|
||||
});
|
||||
},
|
||||
|
|
@ -67,10 +67,10 @@ module.exports = {
|
|||
no_copy_files.delete(path.join(paths.vendor, 'promise.js'));
|
||||
},
|
||||
},
|
||||
'umd': {
|
||||
umd: {
|
||||
optionsOverride: (opts) => {
|
||||
// umd supports properly shifting the default export to work as normal
|
||||
opts.plugins.unshift("add-module-exports");
|
||||
opts.plugins.unshift('add-module-exports');
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue