Centralized + cleaned the testing section in prep for beta.

This commit is contained in:
Joshua A. Horton 2018-03-09 14:00:14 +07:00
parent 918ecda82b
commit 3ae5321f92
24 changed files with 419 additions and 916 deletions

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert unminified KeymanWeb source scripts -->
<script src="../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../intermediate/kmwuitoggle.js"></script>
<script src="../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -58,6 +58,7 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="../commonHeader.js"></script>
<script src="./utilities.js"></script>
<script>
@ -66,7 +67,7 @@
</head>
<!-- Sample page HTML -->
<body onload='loadKeyboards();'>
<body onload='loadKeyboards(1);'>
<h2>KeymanWeb Sample Page - Attachment API Testing</h2>
<p>This page is designed to stress-test the new attachment/enablement API model and its functions.</p>
<p id="modeSelect">You are currently testing under the <em id="mode"> </em> attachment mode. Two other modes are available:

View file

@ -1,226 +1,197 @@
function loadKeyboards()
{
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keyboard to be
// locally sourced.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'en',name:'English'},
filename:'../us-1.0.js'});
// Add more keyboards to the language menu, by keyboard name,
// keyboard name and language code, or just the BCP-47 language code.
kmw.addKeyboards('french','european2@sv','european2@no','@he');
// Add a keyboard by language name. Note that the name must be spelled
// correctly, or the keyboard will not be found. (Using BCP-47 codes is
// usually easier.)
kmw.addKeyboardsForLanguage('Dzongkha');
// Add a fully-specified, locally-sourced, keyboard with custom font
kmw.addKeyboards({id:'lao_2008_basic',name:'Lao Basic',
languages:{
id:'lo',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
},
filename:'../lao_2008_basic.js'
});
// Page-global variable definitions.
{
var inputCounter = 0;
}
// Page-global variable definitions.
{
var inputCounter = 0;
}
function generateDiagnosticDiv(elem) {
var div = document.createElement("div");
div.style.border = "1px solid black";
div.style.borderRadius = "5px";
//div.style.mozBorder
div.style.paddingTop = "5px";
div.style.paddingLeft = "5px";
div.style.paddingRight = "5px";
div.style.paddingBottom = "5px";
div.appendChild(elem);
div.appendChild(document.createElement("p"));
var elemId = elem.id;
// Attachment button
var attachBtn = document.createElement("input");
attachBtn.type = 'button';
attachBtn.id = 'attach_' + elemId;
attachBtn.onclick = function() {
kmw.attachToControl(document.getElementById(elemId));
var attached = kmw.isAttached(elem);
document.getElementById('attachment_' + elemId).textContent = " Currently " + (attached ? "attached." : "detached.");
if(elem.tagName.toLowerCase() != "iframe") {
document.getElementById("independence_" + elemId).textContent = attached ? " Using globally-selected keyboard." : '';
}
};
attachBtn.value = 'Attach';
div.appendChild(attachBtn);
// Detachment button
var detachBtn = document.createElement("input");
detachBtn.type = 'button';
detachBtn.id = 'detach_' + elemId;
detachBtn.onclick = function() {
kmw.detachFromControl(document.getElementById(elemId));
var attached = kmw.isAttached(elem);
document.getElementById('attachment_' + elemId).textContent = " Currently " + (attached ? "attached." : "detached.");
if(!attached) {
document.getElementById('independence_' + elemId).textContent = "";
}
};
detachBtn.value = 'Detach';
div.appendChild(detachBtn);
// We need some extra space to properly detect iframe attachment.
var attachTimer = elem.tagName.toLowerCase() == "iframe" ? 50 : 1;
var attachLabel = document.createElement("a");
attachLabel.id = 'attachment_' + elemId;
window.setTimeout(function() {
attachLabel.textContent = " Currently " + (kmw.isAttached(elem) ? "attached." : "detached.");
}, attachTimer);
div.appendChild(attachLabel);
div.appendChild(document.createElement("p"));
// Enablement button
var enableBtn = document.createElement("input");
enableBtn.type = 'button';
enableBtn.id = 'enable_' + elemId;
enableBtn.onclick = function() {
kmw.enableControl(document.getElementById(elemId));
};
enableBtn.value = 'Enable';
div.appendChild(enableBtn);
// Disablement button
var disableBtn = document.createElement("input");
disableBtn.type = 'button';
disableBtn.id = 'disable_' + elemId;
disableBtn.onclick = function() {
kmw.disableControl(document.getElementById(elemId));
};
disableBtn.value = 'Disable';
div.appendChild(disableBtn);
var enabledLabel = document.createElement("a");
enabledLabel.id = 'enablement_' + elemId;
enabledLabel.textContent = " Currently enabled.";
// We must rely on MutationObservers to stay current about enablement.
var observationTarget = elem;
var observationConfig = {attributes: true, attributeFilter: ['class']};
var enablementObserver = new MutationObserver(function(mutations) {
var isDisabled = mutations[0].target.className.indexOf('kmw-disabled') >= 0;
enabledLabel.textContent = (isDisabled ? " Currently disabled." : " Currently enabled.");
});
enablementObserver.observe(observationTarget, observationConfig);
div.appendChild(enabledLabel);
div.appendChild(document.createElement("p"));
if(elem.tagName.toLowerCase() != "iframe") {
// Set Keyboard button
var setBtn = document.createElement("input");
setBtn.type = 'button';
setBtn.id = 'set_' + elemId;
setBtn.onclick = function() {
kmw.setKeyboardForControl(document.getElementById(elemId), 'dzongkha', 'dzo');
if(kmw.isAttached(elem)) {
kbdLabel.textContent = " Using independently-tracked keyboard.";
}
};
setBtn.value = 'Set to Dzongkha';
div.appendChild(setBtn);
// Clear Keyboard button
var clearBtn = document.createElement("input");
clearBtn.type = 'button';
clearBtn.id = 'clear_' + elemId;
clearBtn.onclick = function() {
kmw.setKeyboardForControl(document.getElementById(elemId), null, null);
if(kmw.isAttached(elem)) {
kbdLabel.textContent = " Using globally-selected keyboard.";
}
};
clearBtn.value = 'Clear Keyboard';
div.appendChild(clearBtn);
var kbdLabel = document.createElement("a");
kbdLabel.id = 'independence_' + elemId;
window.setTimeout(function () {
if(kmw.isAttached(elem)) {
var attached = kmw.isAttached(elem);
kbdLabel.textContent = attached ? " Using globally-selected keyboard." : '';
}
}, 1);
div.appendChild(kbdLabel);
function generateDiagnosticDiv(elem) {
var div = document.createElement("div");
div.style.border = "1px solid black";
div.style.borderRadius = "5px";
//div.style.mozBorder
div.style.paddingTop = "5px";
div.style.paddingLeft = "5px";
div.style.paddingRight = "5px";
div.style.paddingBottom = "5px";
div.appendChild(elem);
div.appendChild(document.createElement("p"));
var elemId = elem.id;
// Attachment button
var attachBtn = document.createElement("input");
attachBtn.type = 'button';
attachBtn.id = 'attach_' + elemId;
attachBtn.onclick = function() {
kmw.attachToControl(document.getElementById(elemId));
var attached = kmw.isAttached(elem);
document.getElementById('attachment_' + elemId).textContent = " Currently " + (attached ? "attached." : "detached.");
if(elem.tagName.toLowerCase() != "iframe") {
document.getElementById("independence_" + elemId).textContent = attached ? " Using globally-selected keyboard." : '';
}
return div;
}
function addInput() {
var masterDiv = document.getElementById('DynamicInputs');
var newInput = document.createElement("input");
var i = inputCounter++;
newInput.id = 'input' + i;
newInput.className = 'test';
newInput.placeholder = "Dynamic area #" + i + "!";
var newDiv = generateDiagnosticDiv(newInput);
masterDiv.appendChild(newDiv);
}
function addText() {
var masterDiv = document.getElementById('DynamicTextareas');
var newTextArea = document.createElement("textarea");
var i = inputCounter++;
newTextArea.id = 'textarea' + i;
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area #" + i + "!";
var newDiv = generateDiagnosticDiv(newTextArea);
masterDiv.appendChild(newDiv);
}
function addIFrame() {
var masterDiv = document.getElementById('DynamicIFrames');
var frame = document.createElement("iframe");
var i = inputCounter++;
frame.height = "100";
frame.src = "iframe.html";
frame.id = 'iframe' + i;
var newDiv = generateDiagnosticDiv(frame);
masterDiv.appendChild(newDiv);
}
function addEditable() {
var masterDiv = document.getElementById('DynamicEditables');
var editable = document.createElement("div");
var i = inputCounter++;
editable.contentEditable = true;
editable.textContent = "Edit me!";
editable.id = 'editable' + i;
editable.style.width="500px";
var newDiv = generateDiagnosticDiv(editable);
masterDiv.appendChild(newDiv);
};
attachBtn.value = 'Attach';
div.appendChild(attachBtn);
// Detachment button
var detachBtn = document.createElement("input");
detachBtn.type = 'button';
detachBtn.id = 'detach_' + elemId;
detachBtn.onclick = function() {
kmw.detachFromControl(document.getElementById(elemId));
var attached = kmw.isAttached(elem);
document.getElementById('attachment_' + elemId).textContent = " Currently " + (attached ? "attached." : "detached.");
if(!attached) {
document.getElementById('independence_' + elemId).textContent = "";
}
};
detachBtn.value = 'Detach';
div.appendChild(detachBtn);
// We need some extra space to properly detect iframe attachment.
var attachTimer = elem.tagName.toLowerCase() == "iframe" ? 50 : 1;
var attachLabel = document.createElement("a");
attachLabel.id = 'attachment_' + elemId;
window.setTimeout(function() {
attachLabel.textContent = " Currently " + (kmw.isAttached(elem) ? "attached." : "detached.");
}, attachTimer);
div.appendChild(attachLabel);
div.appendChild(document.createElement("p"));
// Enablement button
var enableBtn = document.createElement("input");
enableBtn.type = 'button';
enableBtn.id = 'enable_' + elemId;
enableBtn.onclick = function() {
kmw.enableControl(document.getElementById(elemId));
};
enableBtn.value = 'Enable';
div.appendChild(enableBtn);
// Disablement button
var disableBtn = document.createElement("input");
disableBtn.type = 'button';
disableBtn.id = 'disable_' + elemId;
disableBtn.onclick = function() {
kmw.disableControl(document.getElementById(elemId));
};
disableBtn.value = 'Disable';
div.appendChild(disableBtn);
var enabledLabel = document.createElement("a");
enabledLabel.id = 'enablement_' + elemId;
enabledLabel.textContent = " Currently enabled.";
// We must rely on MutationObservers to stay current about enablement.
var observationTarget = elem;
var observationConfig = {attributes: true, attributeFilter: ['class']};
var enablementObserver = new MutationObserver(function(mutations) {
var isDisabled = mutations[0].target.className.indexOf('kmw-disabled') >= 0;
enabledLabel.textContent = (isDisabled ? " Currently disabled." : " Currently enabled.");
});
enablementObserver.observe(observationTarget, observationConfig);
div.appendChild(enabledLabel);
div.appendChild(document.createElement("p"));
if(elem.tagName.toLowerCase() != "iframe") {
// Set Keyboard button
var setBtn = document.createElement("input");
setBtn.type = 'button';
setBtn.id = 'set_' + elemId;
setBtn.onclick = function() {
kmw.setKeyboardForControl(document.getElementById(elemId), 'dzongkha', 'dzo');
if(kmw.isAttached(elem)) {
kbdLabel.textContent = " Using independently-tracked keyboard.";
}
};
setBtn.value = 'Set to Dzongkha';
div.appendChild(setBtn);
// Clear Keyboard button
var clearBtn = document.createElement("input");
clearBtn.type = 'button';
clearBtn.id = 'clear_' + elemId;
clearBtn.onclick = function() {
kmw.setKeyboardForControl(document.getElementById(elemId), null, null);
if(kmw.isAttached(elem)) {
kbdLabel.textContent = " Using globally-selected keyboard.";
}
};
clearBtn.value = 'Clear Keyboard';
div.appendChild(clearBtn);
var kbdLabel = document.createElement("a");
kbdLabel.id = 'independence_' + elemId;
window.setTimeout(function () {
if(kmw.isAttached(elem)) {
var attached = kmw.isAttached(elem);
kbdLabel.textContent = attached ? " Using globally-selected keyboard." : '';
}
}, 1);
div.appendChild(kbdLabel);
}
return div;
}
function addInput() {
var masterDiv = document.getElementById('DynamicInputs');
var newInput = document.createElement("input");
var i = inputCounter++;
newInput.id = 'input' + i;
newInput.className = 'test';
newInput.placeholder = "Dynamic area #" + i + "!";
var newDiv = generateDiagnosticDiv(newInput);
masterDiv.appendChild(newDiv);
}
function addText() {
var masterDiv = document.getElementById('DynamicTextareas');
var newTextArea = document.createElement("textarea");
var i = inputCounter++;
newTextArea.id = 'textarea' + i;
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area #" + i + "!";
var newDiv = generateDiagnosticDiv(newTextArea);
masterDiv.appendChild(newDiv);
}
function addIFrame() {
var masterDiv = document.getElementById('DynamicIFrames');
var frame = document.createElement("iframe");
var i = inputCounter++;
frame.height = "100";
frame.src = "iframe.html";
frame.id = 'iframe' + i;
var newDiv = generateDiagnosticDiv(frame);
masterDiv.appendChild(newDiv);
}
function addEditable() {
var masterDiv = document.getElementById('DynamicEditables');
var editable = document.createElement("div");
var i = inputCounter++;
editable.contentEditable = true;
editable.textContent = "Edit me!";
editable.id = 'editable' + i;
editable.style.width="500px";
var newDiv = generateDiagnosticDiv(editable);
masterDiv.appendChild(newDiv);
}

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -42,12 +42,12 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="./script.js"></script>
<script src="../commonHeader.js"></script>
</head>
<!-- Sample page HTML -->
<body onload='loadKeyboards();'>
<body onload='loadKeyboards(1);'>
<h2>KeymanWeb: Test IFrame connectivity</h2>
<div id='DynamicTextboxes'>

View file

@ -1,80 +0,0 @@
// JavaScript Document samplehdr.js: Keyboard management for KeymanWeb demonstration pages
/*
The keyboard name and/or BCP-47 language code must be specified for each keyboard that is to be available.
If the same keyboard is used for several languages, it must be listed for each
language, but the keyboard itself will only be loaded once.
If two (or more) keyboards are to be available for a given language, both must be listed.
Any number of keyboards may be specified in one or more calls.
Keyboard paths may be absolute (with respect to the server root) or relative to the keyboards option path.
The actual keyboard object will be downloaded asynchronously when first selected for use.
Each argument to addKeyboards() is a string, for example:
european2 loads the current version of the Eurolatin 2 keyboard (for its default language)
european2@fr loads the current version of the Eurolatin 2 keyboard for French
european2@fr@1.2 loads version 1.2 of the Eurolatin 2 keyboard for French
Argument syntax also supports the following extensions:
@fr load the current version of the default keyboard for French
@fr$ load all available keyboards (current version) for French
Each call to addKeyboards() requires a single call to the remote server,
(unless all keyboards listed are local and fully specified) so it is better
to use multiple arguments rather than separate function calls.
Calling addKeyboards() with no arguments returns a list of *all* available keyboards.
The Toolbar (desktop browser) UI is best suited for allowing users to select
the appropriate language and keyboard in this case.
Keyboards may also be specified by language name using addKeyboardsForLanguage()
for example:
keymanweb.addKeyboardsForLanguage('Burmese');
Appending $ to the language name will again cause all available keyboards for that
language to be loaded rather than the default keyboard.
The first call to addKeyboardsForLanguage() makes an additional call to the
keyman API to load the current list of keyboard/language associations.
In this example, the following function loads the indicated keyboards,
and is called when the page loads.
*/
function loadKeyboards()
{
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keyboard to be
// locally sourced.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'en',name:'English'},
filename:'../us-1.0.js'});
// Add more keyboards to the language menu, by keyboard name,
// keyboard name and language code, or just the BCP-47 language code.
kmw.addKeyboards('french','european2@sv','european2@no','@he');
// Add a keyboard by language name. Note that the name must be spelled
// correctly, or the keyboard will not be found. (Using BCP-47 codes is
// usually easier.)
kmw.addKeyboardsForLanguage('Dzongkha');
// Add a fully-specified, locally-sourced, keyboard with custom font
kmw.addKeyboards({id:'lao_2008_basic',name:'Lao Basic',
languages:{
id:'lo',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
},
filename:'../lao_2008_basic.js'
});
// The following two optional calls should be delayed until language menus are fully loaded:
// (a) a specific mapped input element input is focused, to ensure that the OSK appears
// (b) a specific keyboard is loaded, rather than the keyboard last used.
//window.setTimeout(function(){kmw.setActiveElement('ta1',true);},2500);
//window.setTimeout(function(){kmw.setActiveKeyboard('Keyboard_french','fr');},3000);
// Note that locally specified keyboards will be listed before keyboards
// requested from the remote server by user interfaces that do not order
// keyboards alphabetically by language.
}

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -40,15 +40,25 @@
and is called when the page loads.
*/
function loadKeyboards()
function loadKeyboards(nestLevel)
{
var kmw=keyman;
var base_prefix = '../';
var prefix = './'; // The default - when prefix == 0.
if(nestLevel !== undefined && nestLevel > 0) {
prefix = '';
for(var i=0; i < nestLevel; i++) {
prefix = prefix + base_prefix;
}
}
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keyboard to be
// locally sourced.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'en',name:'English'},
filename:'./us-1.0.js'});
filename:(prefix + 'us-1.0.js')});
// Add more keyboards to the language menu, by keyboard name,
// keyboard name and language code, or just the BCP-47 language code.
@ -67,7 +77,7 @@
id:'lo',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
},
filename:'./lao_2008_basic.js'
filename:(prefix + 'lao_2008_basic.js')
});
// The following two optional calls should be delayed until language menus are fully loaded:

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -1,118 +1,7 @@
// JavaScript Document samplehdr.js: Keyboard management for KeymanWeb demonstration pages
function setActiveKeyboard() {
var kmw=window['keyman'] ? keyman : tavultesoft.keymanweb;
/*
The keyboard name and/or BCP-47 code must be specified for each keyboard that is to be available.
If the same keyboard is used for several languages, it must be listed for each
language, but the keyboard itself will only be loaded once.
If two (or more) keyboards are to be available for a given language, both must be listed.
Any number of keyboards may be specified in one or more calls.
Keyboard paths may be absolute (with respect to the server root) or relative to the keyboards option path.
The actual keyboard object will be downloaded asynchronously when first selected for use.
Each argument to addKeyboards() is a string, for example:
european2 loads the current version of the Eurolatin 2 keyboard (for its default language)
european2@fr loads the current version of the Eurolatin 2 keyboard for French
european2@fr@1.2 loads version 1.2 of the Eurolatin 2 keyboard for French
Argument syntax also supports the following extensions:
@fr load the current version of the default keyboard for French
@fr$ load all available keyboards (current version) for French
Each call to addKeyboards() requires a single call to the remote server,
(unless all keyboards listed are local and fully specified) so it is better
to use multiple arguments rather than separate function calls.
Calling addKeyboards() with no arguments returns a list of *all* available keyboards.
The Toolbar (desktop browser) UI is best suited for allowing users to select
the appropriate language and keyboard in this case.
Keyboards may also be specified by language name using addKeyboardsForLanguage()
for example:
keymanweb.addKeyboardsForLanguage('Burmese');
Appending $ to the language name will again cause all available keyboards for that
language to be loaded rather than the default keyboard.
The first call to addKeyboardsForLanguage() makes an additional call to the
keyman API to load the current list of keyboard/language associations.
In this example, the following function loads the indicated keyboards,
and is called when the page loads.
*/
function loadKeyboards()
{
var kmw=window['keyman'] ? keyman : tavultesoft.keymanweb;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keyboard to be
// locally sourced.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'en',name:'English', region:'North America'},
filename:'../us-1.0.js'});
// Add more keyboards to the language menu, by keyboard name,
// keyboard name and language code, or just the BCP-47 language code.
kmw.addKeyboards('french','european2@sv','european2@no','@he');
// Add a keyboard by language name. Note that the name must be spelled
// correctly, or the keyboard will not be found. (Using BCP-47 codes is
// usually easier.)
kmw.addKeyboardsForLanguage('Dzongkha');
// Add a fully-specified, locally-sourced, keyboard with custom font
kmw.addKeyboards({id:'lao_2008_basic',name:'Lao Basic',
languages:{
id:'lo',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
},
filename:'../lao_2008_basic.js'
});
// The following two optional calls should be delayed until language menus are fully loaded:
// (a) a specific mapped input element input is focused, to ensure that the OSK appears
// (b) a specific keyboard is loaded, rather than the keyboard last used.
//window.setTimeout(function(){kmw.setActiveElement('ta1',true);},2500);
//window.setTimeout(function(){kmw.setActiveKeyboard('Keyboard_french','fr');},3000);
// Note that locally specified keyboards will be listed before keyboards
// requested from the remote server by user interfaces that do not order
// keyboards alphabetically by language.
}
// Script to allow a user to add any keyboard to the keyboard menu
function addKeyboard(n)
{
var sKbd, kmw=window['keyman'] ? keyman : tavultesoft.keymanweb;
switch(n)
{
case 1:
sKbd=document.getElementById('kbd_id1').value;
kmw.addKeyboards(sKbd);
break;
case 2:
sKbd=document.getElementById('kbd_id2').value.toLowerCase();
kmw.addKeyboards('@'+sKbd);
break;
case 3:
sKbd=document.getElementById('kbd_id3').value;
kmw.addKeyboardsForLanguage(sKbd);
break;
}
}
// Add keyboard on Enter (as well as pressing button)
function clickOnEnter(e,id)
{
e = e || window.event;
if(e.keyCode == 13) addKeyboard(id);
}
function setActiveKeyboard() {
var kmw=window['keyman'] ? keyman : tavultesoft.keymanweb;
var sKbd = document.getElementById('kbd_id4').value;
var sLng = document.getElementById('lang_id4').value;
var result = kmw.setActiveKeyboard("Keyboard_" + sKbd, sLng);
}
var sKbd = document.getElementById('kbd_id4').value;
var sLng = document.getElementById('lang_id4').value;
var result = kmw.setActiveKeyboard("Keyboard_" + sKbd, sLng);
}

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -43,12 +43,13 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="./header.js"></script>
<script src="../commonHeader.js"></script>
<script src="./header.js"></script>
</head>
<!-- Sample page HTML -->
<body onload='loadKeyboards();'>
<body onload='loadKeyboards(1);'>
<h2>KeymanWeb: Test page for interactions between setActiveKeyboard and the toolbar UI</h2>
<h3>This version is used to test the interactions of <code>SetActiveKeyboard</code> with the Toolbar UI.</h3>
@ -58,7 +59,7 @@
<li>french, fr</li>
<li>european2, no</li>
<li>european2, sv</li>
<li>hebrew, heb</li>
<li>hebrew, he</li>
<li>dzongkha, dzo</li>
<li>lao_2008_basic, lo</li>
</ul>

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -42,12 +42,13 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="./issue-29.js"></script>
<script src="../commonHeader.js"></script>
<script src="issue-29.js"></script>
</head>
<!-- Sample page HTML -->
<body onload='loadKeyboards();'>
<body onload='loadKeyboards(1);'>
<h2>KeymanWeb: Test desktop MutationObserver functionality</h2>
<div id='DynamicTextboxes'>

View file

@ -1,128 +1,45 @@
// JavaScript Document samplehdr.js: Keyboard management for KeymanWeb demonstration pages
{
var inputCounter = 1;
}
/*
The keyboard name and/or BCP-47 code must be specified for each keyboard that is to be available.
If the same keyboard is used for several languages, it must be listed for each
language, but the keyboard itself will only be loaded once.
If two (or more) keyboards are to be available for a given language, both must be listed.
Any number of keyboards may be specified in one or more calls.
Keyboard paths may be absolute (with respect to the server root) or relative to the keyboards option path.
The actual keyboard object will be downloaded asynchronously when first selected for use.
Each argument to addKeyboards() is a string, for example:
european2 loads the current version of the Eurolatin 2 keyboard (for its default language)
european2@fr loads the current version of the Eurolatin 2 keyboard for French
european2@fr@1.2 loads version 1.2 of the Eurolatin 2 keyboard for French
Argument syntax also supports the following extensions:
@fr load the current version of the default keyboard for French
@fr$ load all available keyboards (current version) for French
Each call to addKeyboards() requires a single call to the remote server,
(unless all keyboards listed are local and fully specified) so it is better
to use multiple arguments rather than separate function calls.
Calling addKeyboards() with no arguments returns a list of *all* available keyboards.
The Toolbar (desktop browser) UI is best suited for allowing users to select
the appropriate language and keyboard in this case.
function addInputs() {
var masterDiv = document.getElementById('DynamicTextboxes');
Keyboards may also be specified by language name using addKeyboardsForLanguage()
for example:
keymanweb.addKeyboardsForLanguage('Burmese');
Appending $ to the language name will again cause all available keyboards for that
language to be loaded rather than the default keyboard.
The first call to addKeyboardsForLanguage() makes an additional call to the
keyman API to load the current list of keyboard/language associations.
var newTextArea = document.createElement("textarea");
In this example, the following function loads the indicated keyboards,
and is called when the page loads.
*/
var i = inputCounter++;
function loadKeyboards()
{
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keyboard to be
// locally sourced.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'en',name:'English'},
filename:'../us-1.0.js'});
// Add more keyboards to the language menu, by keyboard name,
// keyboard name and language code, or just the BCP-47 language code.
kmw.addKeyboards('french','european2@sv','european2@no','@he');
// Add a keyboard by language name. Note that the name must be spelled
// correctly, or the keyboard will not be found. (Using BCP-47 codes is
// usually easier.)
kmw.addKeyboardsForLanguage('Dzongkha');
// Add a fully-specified, locally-sourced, keyboard with custom font
kmw.addKeyboards({id:'lao_2008_basic',name:'Lao Basic',
languages:{
id:'lo',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
},
filename:'../lao_2008_basic.js'
});
newTextArea.id = 'ta' + i;
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area!";
// The following two optional calls should be delayed until language menus are fully loaded:
// (a) a specific mapped input element input is focused, to ensure that the OSK appears
// (b) a specific keyboard is loaded, rather than the keyboard last used.
//window.setTimeout(function(){kmw.setActiveElement('ta1',true);},2500);
//window.setTimeout(function(){kmw.setActiveKeyboard('Keyboard_french','fr');},3000);
// Note that locally specified keyboards will be listed before keyboards
// requested from the remote server by user interfaces that do not order
// keyboards alphabetically by language.
}
{
var inputCounter = 1;
}
function addInputs()
{
var masterDiv = document.getElementById('DynamicTextboxes');
var newTextArea = document.createElement("textarea");
var i = inputCounter++;
newTextArea.id = 'ta' + i;
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area!";
var newInput = document.createElement("input");
newInput.id = 'in' + i;
newInput.className = 'test';
newInput.placeholder = "Dynamic area!";
//masterDiv.appendChild(newTextArea);
//masterDiv.appendChild(newInput);
var newDiv = document.createElement("div");
newDiv.appendChild(newTextArea);
newDiv.appendChild(newInput);
masterDiv.appendChild(newDiv);
}
function addIFrame()
{
var masterDiv = document.getElementById('DynamicTextboxes');
var frame = document.createElement("iframe");
frame.height = "100";
frame.src = "issue-29-iframe.html";
frame.onload = function() {console.log('Original onload!');};
//masterDiv.appendChild(frame);
var newDiv = document.createElement("div");
newDiv.appendChild(frame);
masterDiv.appendChild(newDiv);
}
var newInput = document.createElement("input");
newInput.id = 'in' + i;
newInput.className = 'test';
newInput.placeholder = "Dynamic area!";
//masterDiv.appendChild(newTextArea);
//masterDiv.appendChild(newInput);
var newDiv = document.createElement("div");
newDiv.appendChild(newTextArea);
newDiv.appendChild(newInput);
masterDiv.appendChild(newDiv);
}
function addIFrame() {
var masterDiv = document.getElementById('DynamicTextboxes');
var frame = document.createElement("iframe");
frame.height = "100";
frame.src = "issue-29-iframe.html";
frame.onload = function() {console.log('Original onload!');};
//masterDiv.appendChild(frame);
var newDiv = document.createElement("div");
newDiv.appendChild(frame);
masterDiv.appendChild(newDiv);
}

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -1,89 +1,47 @@
// JavaScript Document samplehdr.js: Keyboard management for KeymanWeb demonstration pages
function loadKeyboards()
{
var kmw=keyman;
/*
The keyboard name and/or BCP-47 code must be specified for each keyboard that is to be available.
If the same keyboard is used for several languages, it must be listed for each
language, but the keyboard itself will only be loaded once.
If two (or more) keyboards are to be available for a given language, both must be listed.
Any number of keyboards may be specified in one or more calls.
Keyboard paths may be absolute (with respect to the server root) or relative to the keyboards option path.
The actual keyboard object will be downloaded asynchronously when first selected for use.
Each argument to addKeyboards() is a string, for example:
european2 loads the current version of the Eurolatin 2 keyboard (for its default language)
european2@fr loads the current version of the Eurolatin 2 keyboard for French
european2@fr@1.2 loads version 1.2 of the Eurolatin 2 keyboard for French
Argument syntax also supports the following extensions:
@fr load the current version of the default keyboard for French
@fr$ load all available keyboards (current version) for French
Each call to addKeyboards() requires a single call to the remote server,
(unless all keyboards listed are local and fully specified) so it is better
to use multiple arguments rather than separate function calls.
Calling addKeyboards() with no arguments returns a list of *all* available keyboards.
The Toolbar (desktop browser) UI is best suited for allowing users to select
the appropriate language and keyboard in this case.
// Add a fully-specified, locally-sourced, keyboard.
kmw.addKeyboards({id:'layered_debug_keyboard',name:'Web_Layer_Debugging',
languages:{
id:'dbg',name:'Debug',region:'North America'
},
filename:'./layered_debug_keyboard-1.0.js'
});
}
Keyboards may also be specified by language name using addKeyboardsForLanguage()
for example:
keymanweb.addKeyboardsForLanguage('Burmese');
Appending $ to the language name will again cause all available keyboards for that
language to be loaded rather than the default keyboard.
The first call to addKeyboardsForLanguage() makes an additional call to the
keyman API to load the current list of keyboard/language associations.
In this example, the following function loads the indicated keyboards,
and is called when the page loads.
*/
function loadKeyboards()
{
var kmw=keyman;
// Add a fully-specified, locally-sourced, keyboard.
kmw.addKeyboards({id:'layered_debug_keyboard',name:'Web_Layer_Debugging',
languages:{
id:'dbg',name:'Debug',region:'North America'
},
filename:'./layered_debug_keyboard-1.0.js'
});
}
// Script to allow a user to add any keyboard to the keyboard menu
function addKeyboard(n)
{
var sKbd,kmw=keyman;
switch(n)
{
case 1:
sKbd=document.getElementById('kbd_id1').value;
kmw.addKeyboards(sKbd);
break;
case 2:
sKbd=document.getElementById('kbd_id2').value.toLowerCase();
kmw.addKeyboards('@'+sKbd);
break;
case 3:
sKbd=document.getElementById('kbd_id3').value;
kmw.addKeyboardsForLanguage(sKbd);
break;
}
}
function removeKeyboard(n)
// Script to allow a user to add any keyboard to the keyboard menu
function addKeyboard(n)
{
var sKbd,kmw=keyman;
switch(n)
{
var sKbd=document.getElementById('kbd_id4').value, kmw=keyman;
kmw["removeKeyboards"](sKbd);
}
// Add keyboard on Enter (as well as pressing button)
function clickOnEnter(e,id)
{
e = e || window.event;
if(e.keyCode == 13) addKeyboard(id);
case 1:
sKbd=document.getElementById('kbd_id1').value;
kmw.addKeyboards(sKbd);
break;
case 2:
sKbd=document.getElementById('kbd_id2').value.toLowerCase();
kmw.addKeyboards('@'+sKbd);
break;
case 3:
sKbd=document.getElementById('kbd_id3').value;
kmw.addKeyboardsForLanguage(sKbd);
break;
}
}
function removeKeyboard(n)
{
var sKbd=document.getElementById('kbd_id4').value, kmw=keyman;
kmw["removeKeyboards"](sKbd);
}
// Add keyboard on Enter (as well as pressing button)
function clickOnEnter(e,id)
{
e = e || window.event;
if(e.keyCode == 13) addKeyboard(id);
}

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -43,12 +43,13 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="../commonHeader.js"></script>
<script src="./issue-62.js"></script>
</head>
<!-- Sample page HTML -->
<body onload='loadKeyboards();'>
<body onload='loadKeyboards(1);'>
<h2>KeymanWeb: Light test for touch-based MutationObserver functionality</h2>
<div id='DynamicTextboxes'>

View file

@ -1,98 +1,17 @@
// JavaScript Document samplehdr.js: Keyboard management for KeymanWeb demonstration pages
function addInputs()
{
var masterDiv = document.getElementById('DynamicTextboxes');
/*
The keyboard name and/or BCP-47 code must be specified for each keyboard that is to be available.
If the same keyboard is used for several languages, it must be listed for each
language, but the keyboard itself will only be loaded once.
If two (or more) keyboards are to be available for a given language, both must be listed.
Any number of keyboards may be specified in one or more calls.
Keyboard paths may be absolute (with respect to the server root) or relative to the keyboards option path.
The actual keyboard object will be downloaded asynchronously when first selected for use.
Each argument to addKeyboards() is a string, for example:
european2 loads the current version of the Eurolatin 2 keyboard (for its default language)
european2@fr loads the current version of the Eurolatin 2 keyboard for French
european2@fr@1.2 loads version 1.2 of the Eurolatin 2 keyboard for French
Argument syntax also supports the following extensions:
@fr load the current version of the default keyboard for French
@fr$ load all available keyboards (current version) for French
Each call to addKeyboards() requires a single call to the remote server,
(unless all keyboards listed are local and fully specified) so it is better
to use multiple arguments rather than separate function calls.
Calling addKeyboards() with no arguments returns a list of *all* available keyboards.
The Toolbar (desktop browser) UI is best suited for allowing users to select
the appropriate language and keyboard in this case.
var newTextArea = document.createElement("textarea");
newTextArea.id = 'ta2';
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area!";
Keyboards may also be specified by language name using addKeyboardsForLanguage()
for example:
keymanweb.addKeyboardsForLanguage('Burmese');
Appending $ to the language name will again cause all available keyboards for that
language to be loaded rather than the default keyboard.
The first call to addKeyboardsForLanguage() makes an additional call to the
keyman API to load the current list of keyboard/language associations.
var newInput = document.createElement("input");
newInput.id = 'in2';
newInput.className = 'test';
newInput.placeholder = "Dynamic area!";
In this example, the following function loads the indicated keyboards,
and is called when the page loads.
*/
function loadKeyboards()
{
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keyboard to be
// locally sourced.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'en',name:'English'},
filename:'../us-1.0.js'});
// Add more keyboards to the language menu, by keyboard name,
// keyboard name and language code, or just the BCP-47 language code.
kmw.addKeyboards('french','european2@sv','european2@no','@he');
// Add a keyboard by language name. Note that the name must be spelled
// correctly, or the keyboard will not be found. (Using BCP-47 codes is
// usually easier.)
kmw.addKeyboardsForLanguage('Dzongkha');
// Add a fully-specified, locally-sourced, keyboard with custom font
kmw.addKeyboards({id:'lao_2008_basic',name:'Lao Basic',
languages:{
id:'lo',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
},
filename:'../lao_2008_basic.js'
});
// The following two optional calls should be delayed until language menus are fully loaded:
// (a) a specific mapped input element input is focused, to ensure that the OSK appears
// (b) a specific keyboard is loaded, rather than the keyboard last used.
//window.setTimeout(function(){kmw.setActiveElement('ta1',true);},2500);
//window.setTimeout(function(){kmw.setActiveKeyboard('Keyboard_french','fr');},3000);
// Note that locally specified keyboards will be listed before keyboards
// requested from the remote server by user interfaces that do not order
// keyboards alphabetically by language.
}
function addInputs()
{
var masterDiv = document.getElementById('DynamicTextboxes');
var newTextArea = document.createElement("textarea");
newTextArea.id = 'ta2';
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area!";
var newInput = document.createElement("input");
newInput.id = 'in2';
newInput.className = 'test';
newInput.placeholder = "Dynamic area!";
masterDiv.appendChild(newTextArea);
masterDiv.appendChild(newInput);
}
masterDiv.appendChild(newTextArea);
masterDiv.appendChild(newInput);
}

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -43,12 +43,13 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="../commonHeader.js"></script>
<script src="./issue-63.js"></script>
</head>
<!-- Sample page HTML -->
<body onload='loadKeyboards();'>
<body onload='loadKeyboards(1);'>
<h2>KeymanWeb: Test/stress-test touch-based MutationObserver functionality</h2>
<div id='DynamicTextboxes'>

View file

@ -1,156 +1,70 @@
// JavaScript Document samplehdr.js: Keyboard management for KeymanWeb demonstration pages
{
var inputCounter = 1;
var removalCounter = 1;
var removedElements = [];
}
/*
The keyboard name and/or BCP-47 code must be specified for each keyboard that is to be available.
If the same keyboard is used for several languages, it must be listed for each
language, but the keyboard itself will only be loaded once.
If two (or more) keyboards are to be available for a given language, both must be listed.
Any number of keyboards may be specified in one or more calls.
Keyboard paths may be absolute (with respect to the server root) or relative to the keyboards option path.
The actual keyboard object will be downloaded asynchronously when first selected for use.
Each argument to addKeyboards() is a string, for example:
european2 loads the current version of the Eurolatin 2 keyboard (for its default language)
european2@fr loads the current version of the Eurolatin 2 keyboard for French
european2@fr@1.2 loads version 1.2 of the Eurolatin 2 keyboard for French
Argument syntax also supports the following extensions:
@fr load the current version of the default keyboard for French
@fr$ load all available keyboards (current version) for French
Each call to addKeyboards() requires a single call to the remote server,
(unless all keyboards listed are local and fully specified) so it is better
to use multiple arguments rather than separate function calls.
Calling addKeyboards() with no arguments returns a list of *all* available keyboards.
The Toolbar (desktop browser) UI is best suited for allowing users to select
the appropriate language and keyboard in this case.
function addInputs() {
var masterDiv = document.getElementById('DynamicTextboxes');
Keyboards may also be specified by language name using addKeyboardsForLanguage()
for example:
keymanweb.addKeyboardsForLanguage('Burmese');
Appending $ to the language name will again cause all available keyboards for that
language to be loaded rather than the default keyboard.
The first call to addKeyboardsForLanguage() makes an additional call to the
keyman API to load the current list of keyboard/language associations.
var newTextArea = document.createElement("textarea");
In this example, the following function loads the indicated keyboards,
and is called when the page loads.
*/
var i = inputCounter++;
function loadKeyboards()
{
var kmw=keyman;
// The first keyboard added will be the default keyboard for touch devices.
// For faster loading, it may be best for the default keyboard to be
// locally sourced.
kmw.addKeyboards({id:'us',name:'English',languages:{id:'en',name:'English'},
filename:'../us-1.0.js'});
// Add more keyboards to the language menu, by keyboard name,
// keyboard name and language code, or just the BCP-47 language code.
kmw.addKeyboards('french','european2@sv','european2@no','@he');
// Add a keyboard by language name. Note that the name must be spelled
// correctly, or the keyboard will not be found. (Using BCP-47 codes is
// usually easier.)
kmw.addKeyboardsForLanguage('Dzongkha');
// Add a fully-specified, locally-sourced, keyboard with custom font
kmw.addKeyboards({id:'lao_2008_basic',name:'Lao Basic',
languages:{
id:'lo',name:'Lao',region:'Asia',
font:{family:'LaoWeb',source:['../font/saysettha_web.ttf','../font/saysettha_web.woff','../font/saysettha_web.eot']}
},
filename:'../lao_2008_basic.js'
});
newTextArea.id = 'ta' + i;
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area #" + i + "!";
// The following two optional calls should be delayed until language menus are fully loaded:
// (a) a specific mapped input element input is focused, to ensure that the OSK appears
// (b) a specific keyboard is loaded, rather than the keyboard last used.
//window.setTimeout(function(){kmw.setActiveElement('ta1',true);},2500);
//window.setTimeout(function(){kmw.setActiveKeyboard('Keyboard_french','fr');},3000);
// Note that locally specified keyboards will be listed before keyboards
// requested from the remote server by user interfaces that do not order
// keyboards alphabetically by language.
var newInput = document.createElement("input");
newInput.id = 'in' + i;
newInput.className = 'test';
newInput.placeholder = "Dynamic area #" + i + "!";
//masterDiv.appendChild(newTextArea);
//masterDiv.appendChild(newInput);
var newDiv = document.createElement("div");
newDiv.id = "dynamic_div" + i;
//newDiv.appendChild(newTextArea);
newDiv.appendChild(newInput);
masterDiv.appendChild(newDiv);
}
function removeInputs() {
var parent = document.getElementById('DynamicTextboxes');
var div = document.getElementById("dynamic_div" + removalCounter);
if(div) {
removalCounter++;
parent.removeChild(div);
removedElements.push(div);
}
}
function restoreInputs() {
var masterDiv = document.getElementById('DynamicTextboxes');
removalCounter = 1;
for(var i = 0; i < removedElements.length; i++)
{
var inputCounter = 1;
var removalCounter = 1;
var removedElements = [];
masterDiv.appendChild(removedElements[i]);
}
function addInputs()
{
var masterDiv = document.getElementById('DynamicTextboxes');
var newTextArea = document.createElement("textarea");
var i = inputCounter++;
newTextArea.id = 'ta' + i;
newTextArea.className = 'test';
newTextArea.placeholder = "Dynamic area #" + i + "!";
var newInput = document.createElement("input");
newInput.id = 'in' + i;
newInput.className = 'test';
newInput.placeholder = "Dynamic area #" + i + "!";
//masterDiv.appendChild(newTextArea);
//masterDiv.appendChild(newInput);
var newDiv = document.createElement("div");
newDiv.id = "dynamic_div" + i;
//newDiv.appendChild(newTextArea);
newDiv.appendChild(newInput);
masterDiv.appendChild(newDiv);
}
function removeInputs()
{
var parent = document.getElementById('DynamicTextboxes');
var div = document.getElementById("dynamic_div" + removalCounter);
if(div)
{
removalCounter++;
parent.removeChild(div);
removedElements.push(div);
}
}
function restoreInputs()
{
var masterDiv = document.getElementById('DynamicTextboxes');
removalCounter = 1;
for(var i = 0; i < removedElements.length; i++)
{
masterDiv.appendChild(removedElements[i]);
}
removedElements = [];
}
function addIFrame()
{
var masterDiv = document.getElementById('DynamicTextboxes');
var frame = document.createElement("iframe");
frame.height = "100";
frame.src = "issue-29-iframe.html";
frame.onload = function() {console.log('Original onload!');};
//masterDiv.appendChild(frame);
var newDiv = document.createElement("div");
newDiv.appendChild(frame);
masterDiv.appendChild(newDiv);
}
removedElements = [];
}
function addIFrame() {
var masterDiv = document.getElementById('DynamicTextboxes');
var frame = document.createElement("iframe");
frame.height = "100";
frame.src = "issue-29-iframe.html";
frame.onload = function() {console.log('Original onload!');};
//masterDiv.appendChild(frame);
var newDiv = document.createElement("div");
newDiv.appendChild(frame);
masterDiv.appendChild(newDiv);
}

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../../intermediate/kmwuitoggle.js"></script>
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../intermediate/kmwuitoggle.js"></script>
<script src="../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -43,7 +43,7 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="./samplehdr.js"></script>
<script src="commonHeader.js"></script>
</head>

View file

@ -23,7 +23,7 @@
</style>
<!-- Insert uncompiled KeymanWeb source scripts -->
<script src="../intermediate/keymanweb.js" type="application/javascript"></script>
<script src="../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<!--
For desktop browsers, a script for the user interface must be inserted here.
@ -32,7 +32,7 @@
The toolbar UI is best for any page designed to support keyboards for
a large number of languages.
-->
<script src="../intermediate/kmwuitoggle.js"></script>
<script src="../release/unminified/web/kmwuitoggle.js"></script>
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
@ -43,7 +43,7 @@
</script>
<!-- Add keyboard management script for local selection of keyboards to use -->
<script src="./samplehdr.js"></script>
<script src="commonHeader.js"></script>
</head>