spiegel-keyman/web/tools/recorder/recorder_KeyboardScripts.js
Marc Durdin 05a4c33200 chore(web): move common/core/web to common/web
Relates to #5816.

Moves folders under common/core/web to common/web:

* input-processor -> common/web/input-processor
* keyboard-processor -> common/web/keyboard-processor
* tools/recorder -> common/web/recorder
* tools/sentry-manager -> common/web/sentry-manager
* utils -> common/web/utils

Updates scripts and configuration to point to new folders.
2022-05-18 06:01:03 +10:00

62 lines
1.9 KiB
JavaScript

function loadKeyboards() {
var commonPrefix = "/resources";
if(location.protocol == "file:") {
// Note: won't actually work, as it'll be blocked by CORS / same-origin policy when
// KeymanWeb tries to load the stub via the file: protocol.
//
// Both Firefox and Chrome don't like that it's not data: or http:/https:
// and will consider the local files to be "remote resource[s]".
commonPrefix = "../../../common/test/resources";
}
var filePrefix = commonPrefix + "/json/keyboards/";
// Existing unit_test stubs at the time of writing:
var preloadFiles = [
filePrefix + "galaxie_hebrew_positional.json",
filePrefix + "khmer_angkor.json",
filePrefix + "lao_2008_basic.json",
filePrefix + "options_with_save.json",
filePrefix + "test_deadkeys.json",
filePrefix + "test_simple_deadkeys.json",
filePrefix + "test_chirality.json"
];
loadExistingStubs(preloadFiles);
}
// Script to allow a user to add any keyboard to the keyboard menu
function addKeyboard(n) {
var sKbd;
switch(n) {
case 1:
sKbd=document.getElementById('kbd_id1').value;
keyman.addKeyboards(sKbd);
break;
case 2:
sKbd=document.getElementById('kbd_id2').value.toLowerCase();
keyman.addKeyboards('@'+sKbd);
break;
case 3:
sKbd=document.getElementById('kbd_id3').value;
keyman.addKeyboardsForLanguage(sKbd);
break;
case 4:
sKbd=document.getElementById('kbd_stub_add').value;
var stub = new KMWRecorder.KeyboardStub(JSON.parse(sKbd));
stub.setBasePath(commonPrefix + "/keyboards", false);
keyman.addKeyboards(stub);
// We actually know the exact details for this one easily, so set it as active!
doKeyboardChange("Keyboard_" + stub.id, stub.getFirstLanguage());
break;
}
}
// Add keyboard on Enter (as well as pressing button)
function clickOnEnter(e,id) {
e = e || window.event;
if(e.keyCode == 13) addKeyboard(id);
}