change(web): address app/browser linter errors

This commit is contained in:
Joshua Horton 2025-04-29 11:38:08 +07:00
parent 241f9655f2
commit da138b098d
11 changed files with 108 additions and 104 deletions

View file

@ -38,7 +38,7 @@ export class BeepHandler {
}
// All code after this point is DOM-based, triggered by the beep.
var Pelem: HTMLElement = outputTarget.getElement();
let Pelem: HTMLElement = outputTarget.getElement();
if(outputTarget instanceof DesignIFrame) {
Pelem = outputTarget.docRoot; // I1446 - beep sometimes fails to flash when using OSK and rich control
}
@ -51,7 +51,7 @@ export class BeepHandler {
return;
}
for(var Lbo=0; Lbo<this._BeepObjects.length; Lbo++) { // I1446 - beep sometimes fails to return background color to normal
for(let Lbo=0; Lbo<this._BeepObjects.length; Lbo++) { // I1446 - beep sometimes fails to return background color to normal
// I1511 - array prototype extended
if(this._BeepObjects[Lbo].e == Pelem) {
return;
@ -77,7 +77,7 @@ export class BeepHandler {
readonly reset = () => {
this.keyboardInterface.resetContextCache();
var Lbo;
let Lbo;
this._BeepTimeout = 0;
for(Lbo=0;Lbo<this._BeepObjects.length;Lbo++) { // I1511 - array prototype extended
this._BeepObjects[Lbo].reset();

View file

@ -112,7 +112,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
// For design-mode iframes:
// This block: has to do with maintaining focus.
var Lelem=(elem as HTMLIFrameElement).contentWindow.document;
const Lelem=(elem as HTMLIFrameElement).contentWindow.document;
// I2404 - Attach to IFRAMEs child objects, only editable IFRAMEs here
if(device.browser == 'firefox') {
this.domEventTracker.attachDOMEvent(Lelem,'focus', this._ControlFocus);
@ -149,7 +149,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
// For design-mode iframes:
// This block: has to do with maintaining focus.
let Lelem = (elem as HTMLIFrameElement).contentWindow.document;
const Lelem = (elem as HTMLIFrameElement).contentWindow.document;
// Mozilla // I2404 - Attach to IFRAMEs child objects, only editable IFRAMEs here
if(device.browser == 'firefox') {
// Firefox won't handle these events on Lelem.body - only directly on Lelem (the doc) instead.
@ -162,7 +162,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
}
// This block: has to do with maintaining focus (and consequences)
var lastElem = this.mostRecentTarget?.getElement();
const lastElem = this.mostRecentTarget?.getElement();
if(lastElem && lastElem == elem) {
this.forgetActiveTarget(); // should already auto-hide the OSK while at it via event.
}
@ -268,7 +268,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
}
// We condition on 'priorElement' below as a check to allow KMW to set a default active keyboard.
let hadRecentElement = !!previousTarget;
const hadRecentElement = !!previousTarget;
// Must set before _Blur / _Focus to avoid infinite recursion due to complications
// in setActiveKeyboard behavior with managed keyboard settings.
@ -368,7 +368,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
* This is based on the current `.activeTarget` and its related attachment metadata.
*/
protected currentKeyboardSrcTarget(): OutputTarget<any> {
let target = this.currentTarget || this.mostRecentTarget;
const target = this.currentTarget || this.mostRecentTarget;
if(this.isTargetKeyboardIndependent(target)) {
return target;
@ -378,7 +378,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
}
private isTargetKeyboardIndependent(target: OutputTarget<any>): boolean {
let attachmentInfo = target?.getElement()._kmwAttachment;
const attachmentInfo = target?.getElement()._kmwAttachment;
// If null or undefined, we're in 'global' mode.
return !!(attachmentInfo?.keyboard || attachmentInfo?.keyboard === '');
@ -386,7 +386,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
// Note: is part of the keyboard activation process. Not to be called directly by published API.
activateKeyboardForTarget(kbd: {keyboard: Keyboard, metadata: KeyboardStub}, target: OutputTarget<any>) {
let attachment = target?.getElement()._kmwAttachment;
const attachment = target?.getElement()._kmwAttachment;
if(!attachment) {
// if not set with an "independent keyboard", changes the global.
@ -425,7 +425,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
return;
}
let attachment = target.getElement()._kmwAttachment;
const attachment = target.getElement()._kmwAttachment;
// Catches if the target is already in independent-mode, even if it's being cancelled
// during this call.
@ -504,7 +504,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
}
try {
let result = await super.activateKeyboard(keyboardId, languageCode, saveCookie);
const result = await super.activateKeyboard(keyboardId, languageCode, saveCookie);
this.engineConfig.alertHost?.wait(); // clear any pending waits.
@ -568,8 +568,8 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
* whenever a KMW-enabled page element loses control.
*/
_BlurKeyboardSettings(lastElem: HTMLElement, PInternalName?: string, PLgCode?: string) {
var keyboardID = this.activeKeyboard ? this.activeKeyboard.keyboard.id : '';
var langCode = this.activeKeyboard?.metadata.langId;
let keyboardID = this.activeKeyboard ? this.activeKeyboard.keyboard.id : '';
let langCode = this.activeKeyboard?.metadata.langId;
if(PInternalName !== undefined && PLgCode !== undefined) {
keyboardID = PInternalName;
@ -593,7 +593,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
*/
_FocusKeyboardSettings(lastElem: HTMLElement, blockGlobalChange: boolean) {
// Important pre-condition: the newly-focused element must be set as active.
let attachment = lastElem._kmwAttachment;
const attachment = lastElem._kmwAttachment;
const global = this.globalKeyboard;
if(attachment.keyboard != null) {
@ -615,7 +615,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
_CommonFocusHelper(outputTarget: OutputTarget<any>): boolean {
const focusAssistant = this.focusAssistant;
let activeKeyboard = this.activeKeyboard?.keyboard;
const activeKeyboard = this.activeKeyboard?.keyboard;
if(!focusAssistant.restoringFocus) {
outputTarget?.deadkeys().clear();
activeKeyboard?.notify(0, outputTarget, 1); // I2187
@ -684,7 +684,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
}
// Step 1: determine the corresponding OutputTarget instance.
let target = eventOutputTarget(e);
const target = eventOutputTarget(e);
if (target == null) {
return true;
}
@ -715,7 +715,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
*/
this.focusAssistant.restoringFocus = false;
let activeKeyboard = this.activeKeyboard;
const activeKeyboard = this.activeKeyboard;
const maintainingFocus = this.focusAssistant.maintainingFocus;
if(!maintainingFocus && activeKeyboard) {
activeKeyboard.keyboard.notify(0, target, 0); // I2187
@ -738,7 +738,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
doChangeEvent(target: OutputTarget<any>) {
if(target.changed) {
let event = new Event('change', {"bubbles": true, "cancelable": false});
const event = new Event('change', {"bubbles": true, "cancelable": false});
target.getElement().dispatchEvent(event);
}
@ -756,7 +756,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
**/
getSavedKeyboardRaw(): string {
const cookie = new CookieSerializer<KeyboardCookie>('KeymanWeb_Keyboard');
var v = cookie.load(decodeURIComponent);
const v = cookie.load(decodeURIComponent);
if(typeof(v.current) != 'string') {
return null;
@ -776,7 +776,7 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
* @return {string} InternalName:LanguageCode
**/
getSavedKeyboard(): string {
let cookieValue = this.getSavedKeyboardRaw();
const cookieValue = this.getSavedKeyboardRaw();
// Check that the requested keyboard is included in the available keyboard stubs
const stubs = this.keyboardCache.getStubList()
@ -814,13 +814,13 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
const d=kbd;
// Identify the stub with the saved keyboard
let t=d.split(':');
const t=d.split(':');
if(t.length < 2) {
t[1]='';
}
// Find the matching stub; if it doesn't exist, default to the first available stub.
let stub = this.keyboardCache.getStub(t[0], t[1]);
const stub = this.keyboardCache.getStub(t[0], t[1]);
// Sets the default stub (as specified with the `getSavedKeyboard` call) as active.
if(stub) {

View file

@ -8,9 +8,9 @@ import { SourcemappedWorker } from '@keymanapp/lexical-model-layer/web'
* This can only be done during load when the active script will be the
* last script loaded. Otherwise the script must be identified by name.
*/
var scripts = document.getElementsByTagName('script');
var ss = scripts[scripts.length-1].src;
var sPath = ss.substr(0,ss.lastIndexOf('/')+1);
const scripts = document.getElementsByTagName('script');
const ss = scripts[scripts.length-1].src;
const sPath = ss.substr(0,ss.lastIndexOf('/')+1);
// @ts-ignore
window['keyman'] = new KeymanEngine(SourcemappedWorker, sPath);

View file

@ -17,7 +17,7 @@ export default class DefaultBrowserRules extends DefaultRules {
}
isCommand(Lkc: KeyEvent): boolean {
let code = this.codeForEvent(Lkc);
const code = this.codeForEvent(Lkc);
switch(code) {
case Codes.keyCodes['K_TAB']:
@ -33,7 +33,7 @@ export default class DefaultBrowserRules extends DefaultRules {
* applyCommand - used when a RuleBehavior represents a non-text "command" within the Engine.
*/
applyCommand(Lkc: KeyEvent, outputTarget: OutputTarget): void {
let code = this.codeForEvent(Lkc);
const code = this.codeForEvent(Lkc);
const moveToNext = (back: boolean) => {
const contextManager = this.contextManager;

View file

@ -59,10 +59,11 @@ export function preprocessKeyboardEvent(e: KeyboardEvent, keyboardState: Keyboar
}
// Stage 1 - track the true state of the keyboard's modifiers.
var prevModState = keyboardState.modStateFlags, curModState = 0x0000;
var ctrlEvent = false, altEvent = false;
const prevModState = keyboardState.modStateFlags;
let curModState = 0x0000;
let ctrlEvent = false, altEvent = false;
let keyCodes = Codes.keyCodes;
const keyCodes = Codes.keyCodes;
switch(Lcode) {
case keyCodes['K_CTRL']: // The 3 shorter "K_*CTRL" entries exist in some legacy keyboards.
case keyCodes['K_LCTRL']:
@ -129,7 +130,7 @@ export function preprocessKeyboardEvent(e: KeyboardEvent, keyboardState: Keyboar
keyboardState.modStateFlags = curModState;
// For European keyboards, not all browsers properly send both key-up events for the AltGr combo.
let altGrMask = ModifierKeyConstants.RALTFLAG | ModifierKeyConstants.LCTRLFLAG;
const altGrMask = ModifierKeyConstants.RALTFLAG | ModifierKeyConstants.LCTRLFLAG;
if((prevModState & altGrMask) == altGrMask && (curModState & altGrMask) != altGrMask) {
// We just released AltGr - make sure it's all released.
curModState &= ~ altGrMask;
@ -139,7 +140,7 @@ export function preprocessKeyboardEvent(e: KeyboardEvent, keyboardState: Keyboar
curModState &= ~ModifierKeyConstants.LCTRLFLAG;
}
let modifierBitmasks = Codes.modifierBitmasks;
const modifierBitmasks = Codes.modifierBitmasks;
// Stage 4 - map the modifier set to the appropriate keystroke's modifiers.
const activeKeyboard = keyboardState.activeKeyboard;
let Lmodifiers: number;
@ -192,12 +193,12 @@ export function preprocessKeyboardEvent(e: KeyboardEvent, keyboardState: Keyboar
});
// The 0x6F used to be 0x60 - this adjustment now includes the chiral alt and ctrl modifiers in that check.
let LisVirtualKeyCode = (typeof e.charCode != 'undefined' && e.charCode != null && (e.charCode == 0 || (Lmodifiers & 0x6F) != 0));
const LisVirtualKeyCode = (typeof e.charCode != 'undefined' && e.charCode != null && (e.charCode == 0 || (Lmodifiers & 0x6F) != 0));
s.LisVirtualKey = LisVirtualKeyCode || e.type != 'keypress';
s = processForMnemonicsAndLegacy(s, activeKeyboard, keyboardState.baseLayout);
let processedEvent = new KeyEvent(s);
const processedEvent = new KeyEvent(s);
processedEvent.source = e;
return processedEvent;
}
@ -304,17 +305,17 @@ export default class HardwareEventKeyboard extends HardKeyboard {
*/
_KeyUp: (e: KeyboardEvent) => boolean = (e) => {
const target = eventOutputTarget(e);
var Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
const Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
if(Levent == null || target == null) {
return true;
}
var inputEle = target.getElement();
const inputEle = target.getElement();
// Since this part concerns DOM element + browser interaction management, we preprocess it for
// browser form commands before passing control to the Processor module.
if(Levent.Lcode == 13) {
var ignore = false;
let ignore = false;
if(nestedInstanceOf(inputEle, "HTMLTextAreaElement")) {
ignore = true;
}
@ -349,12 +350,12 @@ export default class HardwareEventKeyboard extends HardKeyboard {
this.swallowKeypress = false;
// Get event properties
var Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
const Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
if(Levent == null) {
return true;
}
let resultCapture: { LeventMatched: boolean } = {
const resultCapture: { LeventMatched: boolean } = {
LeventMatched: false
}
@ -385,17 +386,17 @@ export default class HardwareEventKeyboard extends HardKeyboard {
// 1) To detect browser form submissions (handled in kmwdomevents.ts)
// 2) To detect modifier state changes.
private keyUp(e: KeyboardEvent): boolean {
var Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
const Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
if(Levent == null) {
return true;
}
let outputTarget = eventOutputTarget(e);
const outputTarget = eventOutputTarget(e);
return this.processor.doModifierPress(Levent, outputTarget, false);
}
private keyPress(e: KeyboardEvent): boolean {
var Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
const Levent = preprocessKeyboardEvent(e, this.processor, this.hardDevice);
if(Levent == null || Levent.LisVirtualKey) {
return true;
}
@ -417,7 +418,7 @@ export default class HardwareEventKeyboard extends HardKeyboard {
// Only reached if it's a mnemonic keyboard.
let resultCapture: { preventDefaultKeystroke?: boolean } = {};
const resultCapture: { preventDefaultKeystroke?: boolean } = {};
// Should only be run if `preventDefaultKeystroke` is required by the following conditional
// block. If it isn't - that is, swallowKeypress == true, we want to swallow that keypress

View file

@ -29,7 +29,7 @@ export class HotkeyManager {
*/
addHotKey(keyCode: number, shiftState: number, handler: () => void) {
// Test if existing handler for this code and replace it if so
for(var i=0; i<this.hotkeys.length; i++) {
for(let i=0; i<this.hotkeys.length; i++) {
if(this.hotkeys[i].code == keyCode && this.hotkeys[i].shift == shiftState) {
this.hotkeys[i].handler = handler;
return;
@ -48,7 +48,7 @@ export class HotkeyManager {
* Description Remove a hot key handler from array of document-level hotkeys triggered by key up event
*/
removeHotkey(keyCode: number, shiftState: number) {
for(var i=0; i<this.hotkeys.length; i++) {
for(let i=0; i<this.hotkeys.length; i++) {
if(this.hotkeys[i].matches(keyCode, shiftState)) {
this.hotkeys.splice(i,1);
return;
@ -67,18 +67,18 @@ export class HotkeyManager {
e = window.event as KeyboardEvent;
}
var _Lcode = _GetEventKeyCode(e);
const _Lcode = _GetEventKeyCode(e);
if(_Lcode == null) {
return false;
}
// Removed testing of e.shiftKey==null I3363 (Build 301)
var _Lmodifiers =
const _Lmodifiers =
(e.shiftKey ? 0x10 : 0) |
(e.ctrlKey ? 0x20 : 0) |
(e.altKey ? 0x40 : 0);
for(var i=0; i<this.hotkeys.length; i++) {
for(let i=0; i<this.hotkeys.length; i++) {
if(this.hotkeys[i].matches(_Lcode, _Lmodifiers)) {
this.hotkeys[i].handler();
e.returnValue = false;

View file

@ -158,8 +158,8 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
* @returns A Promise that only resolves once the engine is fully initialized.
*/
public async init(options: Required<BrowserInitOptionSpec>) {
let deviceDetector = new DeviceDetector();
let device = deviceDetector.detect();
const deviceDetector = new DeviceDetector();
const device = deviceDetector.detect();
const totalOptions = {...BrowserInitOptionDefaults, ...options};
@ -397,7 +397,7 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
*
*/
private _GetKeyboardDetail = function(Lstub: KeyboardStub, Lkbd: Keyboard) { // I2078 - Full keyboard detail
let Lr = {
const Lr = {
Name: Lstub.KN,
InternalName: Lstub.KI,
LanguageName: Lstub.KL, // I1300 - Add support for language names
@ -433,7 +433,7 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
public isCJK(k0?: KeyboardObject | ReturnType<KeymanEngine['_GetKeyboardDetail']> /* [b/c Toolbar UI]*/) {
let kbd: Keyboard;
if(k0) {
let kbdDetail = k0 as ReturnType<KeymanEngine['_GetKeyboardDetail']>;
const kbdDetail = k0 as ReturnType<KeymanEngine['_GetKeyboardDetail']>;
if(kbdDetail.KeyboardID){
kbd = this.keyboardRequisitioner.cache.getKeyboard(kbdDetail.KeyboardID);
} else {
@ -682,7 +682,7 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
}
PKbd = PKbd || this.core.activeKeyboard;
let Pstub = this.keyboardRequisitioner.cache.getStub(PKbd);
const Pstub = this.keyboardRequisitioner.cache.getStub(PKbd);
// help.keyman.com will set this function in place to specify the desired
// dimensions for the documentation-keyboards, so we'll give it priority. One of those
@ -691,7 +691,7 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
// Note that the main intended use of that function is for embedded KMW on the mobile apps...
// but they never call `BuildVisualKeyboard`, so it's all good.
const getOskHeight = this['getOskHeight'];
let targetHeight = (typeof getOskHeight == 'function' ? getOskHeight() : null) || this.osk.computedHeight || 200;
const targetHeight = (typeof getOskHeight == 'function' ? getOskHeight() : null) || this.osk.computedHeight || 200;
return VisualKeyboard.buildDocumentationKeyboard(
PKbd,

View file

@ -44,9 +44,9 @@ export class LanguageMenu {
}
constructShim(): HTMLDivElement {
let languageMenu = this;
let shim = util._CreateElement('div');
let osk = this.keyman.osk;
const languageMenu = this;
const shim = util._CreateElement('div');
const osk = this.keyman.osk;
shim.id='kmw-language-menu-background';
shim.addEventListener('touchstart', (e) => {
@ -55,8 +55,8 @@ export class LanguageMenu {
// Display build only if touching menu, space *and* one other point on screen (build 369)
if(e.touches.length > 2) {
var sX=e.touches[1].pageX,sY=e.touches[1].pageY;
let spaceBar = osk.vkbd.spaceBar;
const sX=e.touches[1].pageX,sY=e.touches[1].pageY;
const spaceBar = osk.vkbd.spaceBar;
if(sX > spaceBar.offsetLeft && sX < spaceBar.offsetLeft+spaceBar.offsetWidth &&
sY > spaceBar.offsetTop && sY < spaceBar.offsetTop+spaceBar.offsetHeight
) {
@ -73,26 +73,26 @@ export class LanguageMenu {
**/
show() {
const device = this.keyman.config.hostDevice;
let kbdList=this.keyman.keyboardRequisitioner.cache.getStubList();
let nKbds=kbdList.length;
const kbdList=this.keyman.keyboardRequisitioner.cache.getStubList();
const nKbds=kbdList.length;
if(nKbds < 1) {
return;
}
// Create the menu list container element
var menu=this.lgList=util._CreateElement('div');
const menu=this.lgList=util._CreateElement('div');
this.lgList.id='kmw-language-menu';
// Insert a transparent overlay to prevent anything else happening during keyboard selection,
// but allow the menu to be closed if anywhere else on screen is touched
let languageMenu = this;
const languageMenu = this;
document.body.appendChild(this.shim);
// Add two nested DIVs to properly support iOS scrolling with momentum
// c.f. https://github.com/joelambert/ScrollFix/issues/2
var m2=util._CreateElement('div'),s2=m2.style,
const m2=util._CreateElement('div'),s2=m2.style,
m3=util._CreateElement('div');
m2.id='kmw-menu-scroll-container'; m3.id='kmw-menu-scroller';
@ -105,7 +105,8 @@ export class LanguageMenu {
menu.appendChild(m2);
// Add menu index strip
let x,mx=util._CreateElement('div');
let x: HTMLParagraphElement;
const mx=util._CreateElement('div');
mx.id='kmw-menu-index';
for(let i=1; i<=26; i++) {
x=util._CreateElement('p');
@ -154,7 +155,7 @@ export class LanguageMenu {
// Adjust width for pixel scaling on Android tablets
if(device.OS == 'android' && device.formFactor == 'tablet' && 'devicePixelRatio' in window) {
var w=parseInt(util.getStyleValue(menu,'width'),10),
let w=parseInt(util.getStyleValue(menu,'width'),10),
ms=menu.style;
if(!isNaN(w)) {
ms.width=ms.maxWidth=(2*w/window.devicePixelRatio)+'px';
@ -175,17 +176,17 @@ export class LanguageMenu {
this.adjust(0);
// Adjust the index font size and line height
var dy=(<HTMLElement>mx.childNodes[1]).offsetTop-(<HTMLElement>mx.childNodes[0]).offsetTop,
lineHeight=Math.floor(menu.offsetHeight/26.0),
scale=Math.round(100.0*lineHeight/dy)/100.0,
factor=(scale > 0.6 ? 1 : 2);
const dy=(<HTMLElement>mx.childNodes[1]).offsetTop-(<HTMLElement>mx.childNodes[0]).offsetTop;
const lineHeight=Math.floor(menu.offsetHeight/26.0);
let scale=Math.round(100.0*lineHeight/dy)/100.0;
const factor=(scale > 0.6 ? 1 : 2);
if(scale > 1.25) {
scale=1.25;
}
for(let i=0;i<26;i++) {
var qs=(<HTMLElement>mx.childNodes[i]).style;
const qs=(<HTMLElement>mx.childNodes[i]).style;
if(factor == 2 && (i%2) == 1) {
qs.display='none';
} else {
@ -195,7 +196,7 @@ export class LanguageMenu {
}
// Increase width of outer menu DIV by index, else hide index
var menuWidth=m2.offsetWidth;
let menuWidth=m2.offsetWidth;
if(m2.scrollHeight > m2.offsetHeight+3) {
menuWidth = menuWidth+mx.offsetWidth;
} else {
@ -216,15 +217,16 @@ export class LanguageMenu {
* @param {number} nKbds number of displayed keyboards to add to number of languages
**/
adjust(nKbds: number) {
let osk = this.keyman.osk;
let device = this.keyman.config.hostDevice;
const osk = this.keyman.osk;
const device = this.keyman.config.hostDevice;
var menu=this.lgList, m2=<HTMLElement>menu.firstChild, m3=<HTMLElement>m2.firstChild,
barWidth=0,s=menu.style,mx=<HTMLElement>menu.childNodes[1],
maxHeight=window.innerHeight-osk.vkbd.lgKey.offsetHeight-16,
const menu=this.lgList, m2=<HTMLElement>menu.firstChild, m3=<HTMLElement>m2.firstChild;
let barWidth=0;
let maxHeight=window.innerHeight-osk.vkbd.lgKey.offsetHeight-16;
const s=menu.style,mx=<HTMLElement>menu.childNodes[1],
nItems=m3.childNodes.length+nKbds-1, // Number of (visible) keyboard selectors
itemHeight=(<HTMLElement>m3.firstChild.firstChild).offsetHeight,
menuHeight=nItems*itemHeight;
itemHeight=(<HTMLElement>m3.firstChild.firstChild).offsetHeight;
let menuHeight=nItems*itemHeight;
// Correct maxheight for viewport scaling (iPhone/iPod only) and internal position corrections
if(device.OS == 'ios') {
@ -263,17 +265,18 @@ export class LanguageMenu {
e.stopPropagation();
e.preventDefault();
let target = <HTMLElement> e.touches[0].target;
const target = <HTMLElement> e.touches[0].target;
// Will return 'P', not 'p'.
if(target.nodeName != 'P') {
return;
}
var i,t,initial=target.innerHTML.charCodeAt(0),nn=menu.childNodes;
let i: number;
const initial=target.innerHTML.charCodeAt(0), nn=menu.childNodes;
try {
for(i=0; i<nn.length-1; i++) {
t=(<HTMLElement>nn[i].firstChild).innerHTML.toUpperCase().charCodeAt(0);
const t=(<HTMLElement>nn[i].firstChild).innerHTML.toUpperCase().charCodeAt(0);
if(t >= initial) {
break;
}
@ -316,11 +319,11 @@ export class LanguageMenu {
* @return {number} index of currently active language
**/
addLanguages(menu: HTMLDivElement, kbdList: KeyboardStub[]): number {
var nStubs=kbdList.length;
let device = this.keyman.config.hostDevice;
const nStubs=kbdList.length;
const device = this.keyman.config.hostDevice;
// Create and sort a list of languages
let langs: string[] = [];
const langs: string[] = [];
for(let n=0; n<nStubs; n++) {
const lg=kbdList[n]['KL'];
if(langs.indexOf(lg) == -1) {
@ -330,7 +333,7 @@ export class LanguageMenu {
langs.sort();
// Get current scale factor (reciprocal of viewport scale)
var scale=Math.round(100/util.getViewportScale(device.formFactor))/100;
const scale=Math.round(100/util.getViewportScale(device.formFactor))/100;
let activeLanguageIndex=-1;
@ -402,9 +405,9 @@ export class LanguageMenu {
}
// Add a non-selectable bottom bar so to allow scrolling to the last language
var padLast=util._CreateElement('div');
const padLast=util._CreateElement('div');
padLast.id='kmw-menu-footer';
var cancelTouch=function(e: TouchEvent){
const cancelTouch=function(e: TouchEvent){
if(e.cancelable) {
e.preventDefault();
}
@ -498,9 +501,9 @@ export class LanguageMenu {
// Touchmove drags the list and prevents release from selecting the language
const touchMove=function(this: HTMLElement, e: TouchEvent) {
e.stopImmediatePropagation();
var scroller=<HTMLElement>languageMenu.lgList.childNodes[0],
yMax=scroller.scrollHeight-scroller.offsetHeight,
y, dy;
const scroller=<HTMLElement>languageMenu.lgList.childNodes[0];
const yMax=scroller.scrollHeight-scroller.offsetHeight;
let y: number;
// TS does not have a standard definition for TouchEvent.pageY.
//@ts-ignore
@ -513,7 +516,7 @@ export class LanguageMenu {
return false;
}
dy=y-languageMenu.y0;
const dy=y-languageMenu.y0;
// Scroll up (show later listed languages)
if(dy < 0) {
@ -577,7 +580,7 @@ export class LanguageMenu {
* Remove the language menu again
**/
hide() {
let osk = this.keyman.osk;
const osk = this.keyman.osk;
if(this.lgList) {
osk.vkbd.highlightKey(osk.vkbd.lgKey,false);

View file

@ -8,9 +8,9 @@ import { Worker } from '@keymanapp/lexical-model-layer/web'
* This can only be done during load when the active script will be the
* last script loaded. Otherwise the script must be identified by name.
*/
var scripts = document.getElementsByTagName('script');
var ss = scripts[scripts.length-1].src;
var sPath = ss.substr(0,ss.lastIndexOf('/')+1);
const scripts = document.getElementsByTagName('script');
const ss = scripts[scripts.length-1].src;
const sPath = ss.substr(0,ss.lastIndexOf('/')+1);
// @ts-ignore
window['keyman'] = new KeymanEngine(Worker, sPath);

View file

@ -40,7 +40,7 @@ export class RotationProcessor {
}
resolve() {
var osk = this.keyman.osk;
const osk = this.keyman.osk;
// `keyman: KeymanEngine` (modularized app/browser)
this.keyman.touchLanguageMenu?.hide();
@ -81,8 +81,8 @@ export class RotationProcessor {
*/
init() {
// Note: we use wrapper functions instead of `.bind(this)` in this method to facilitate stubbing for our rotation test page.
var os = this.keyman.config.hostDevice.OS;
var util = this.keyman.util;
const os = this.keyman.config.hostDevice.OS;
const util = this.keyman.util;
if(os == 'ios') {
/* iOS is rather inconsistent about these events, with changes to important window state information -
@ -137,7 +137,7 @@ export class RotationProcessor {
}
iOSEventUpdate() {
var newState = new RotationState();
const newState = new RotationState();
if(this.rotState.equals(newState)) {
if(++this.idlePermutationCounter == RotationProcessor.IDLE_PERMUTATION_CAP) {

View file

@ -18,7 +18,7 @@ function buildBaseOskConfiguration(engine: KeymanEngine) {
class PublishedAnchoredOSKView extends AnchoredOSKView {
constructor(engine: KeymanEngine, config?: ViewConfiguration) {
let finalConfig = {
const finalConfig = {
...buildBaseOskConfiguration(engine),
...(config || {})
};
@ -29,7 +29,7 @@ class PublishedAnchoredOSKView extends AnchoredOSKView {
class PublishedFloatingOSKView extends FloatingOSKView {
constructor(engine: KeymanEngine, config?: FloatingOSKViewConfiguration) {
let finalConfig: FloatingOSKViewConfiguration = {
const finalConfig: FloatingOSKViewConfiguration = {
...buildBaseOskConfiguration(engine),
...(config || {})
};
@ -40,7 +40,7 @@ class PublishedFloatingOSKView extends FloatingOSKView {
class PublishedInlineOSKView extends InlinedOSKView {
constructor(engine: KeymanEngine, config?: ViewConfiguration) {
let finalConfig: ViewConfiguration = {
const finalConfig: ViewConfiguration = {
...buildBaseOskConfiguration(engine),
...(config || {})
};