mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-06 14:07:32 +00:00
fix(web/engine): Fixes variable stores, adds test page
This commit is contained in:
parent
b9932f24e3
commit
3cdffae116
4 changed files with 162 additions and 3 deletions
|
|
@ -936,7 +936,8 @@ namespace com.keyman.text {
|
|||
loadStore(kbdName: string, storeName:string, dfltValue:string): string {
|
||||
let keyman = com.keyman.singleton;
|
||||
this.resetContextCache();
|
||||
var cName='KeymanWeb_'+kbdName+'_Option_'+storeName,cValue=keyman.util.loadCookie(cName);
|
||||
var cName='KeymanWeb_'+kbdName+'_Option_'+storeName;
|
||||
var cValue=keyman.util.loadCookie(cName);
|
||||
if(typeof cValue[storeName] != 'undefined') {
|
||||
return decodeURIComponent(cValue[storeName]);
|
||||
} else {
|
||||
|
|
@ -959,9 +960,14 @@ namespace com.keyman.text {
|
|||
return false;
|
||||
}
|
||||
|
||||
var cName='KeymanWeb_'+kbd.id+'_Option_'+storeName, cValue=encodeURIComponent(optValue);
|
||||
// The cookie entry includes the store name...
|
||||
var cName='KeymanWeb_'+kbd.id+'_Option_'+storeName;
|
||||
var cValue=encodeURIComponent(optValue);
|
||||
|
||||
keyman.util.saveCookie(cName,cValue);
|
||||
// And the lookup under that entry looks for the value under the store name, again.
|
||||
let valueObj = {};
|
||||
valueObj[storeName] = cValue;
|
||||
keyman.util.saveCookie(cName, valueObj);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
<h2><a href="./keyboard-errors/">Tests keyboard error-handling functionality</a></h2>
|
||||
<h2><a href="./attachment-api/?mode=auto">Tests the new Attachment/Enablement API functionality</a><h2>
|
||||
<h2><a href="./chirality/">Chirality testing/bootstrapping</a><h2>
|
||||
<h2><a href="./options-with-save/">Tests option/variable store functionality</a></h2>
|
||||
<h2><a href="./platform/">Platform testing</a></h2>
|
||||
<h2><a href="./prediction-ui/">Prediction UI testing</a></h2>
|
||||
<h2><a href="./toolbar/">Toolbar UI testing</a></h2>
|
||||
|
|
|
|||
88
web/testing/options-with-save/index.html
Normal file
88
web/testing/options-with-save/index.html
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
|
||||
<!-- Set the viewport width to match phone and tablet device widths -->
|
||||
<meta name="viewport" content="width=device-width,user-scalable=no" />
|
||||
|
||||
<!-- Enable IE9 Standards mode -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
|
||||
<title>KeymanWeb Testing Page - Basic Mnemonic Support</title>
|
||||
|
||||
<!-- Your page CSS -->
|
||||
<style type='text/css'>
|
||||
body {font-family: Tahoma,helvetica;}
|
||||
h3 {font-size: 1em;font-weight:normal;color: darkred; margin-bottom: 4px}
|
||||
.test {font-size: 1.5em; width:80%; min-height:30px; border: 1px solid gray;}
|
||||
#KeymanWebControl {width:50%;min-width:600px;}
|
||||
</style>
|
||||
|
||||
<!-- Insert uncompiled KeymanWeb source scripts -->
|
||||
<script src="../../release/unminified/web/keymanweb.js" type="application/javascript"></script>
|
||||
|
||||
<!--
|
||||
For desktop browsers, a script for the user interface must be inserted here.
|
||||
|
||||
Standard UIs are toggle, button, float and toolbar.
|
||||
The toolbar UI is best for any page designed to support keyboards for
|
||||
a large number of languages.
|
||||
-->
|
||||
<script src="../../release/unminified/web/kmwuitoggle.js"></script>
|
||||
|
||||
<!-- Initialization: set paths to keyboards, resources and fonts as required -->
|
||||
<script>
|
||||
var kmw=window.keyman;
|
||||
kmw.init({
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Add keyboard management script for local selection of keyboards to use -->
|
||||
<!--<script src="../commonHeader.js"></script>-->
|
||||
|
||||
<script>
|
||||
kmw.addKeyboards({
|
||||
id:'options_with_save',
|
||||
name:'Options Test',
|
||||
languages: {
|
||||
id:'en',
|
||||
name:'English'
|
||||
},
|
||||
filename:'./options_with_save.js'
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>KeymanWeb: Test basic variable-store functionality</h2>
|
||||
<p><ul>
|
||||
<li><code>a</code>: Outputs "foo." if store is 'true', "no foo." if store is 'false'.</li>
|
||||
<li><code>0</code>: Sets store to 'false'.</li>
|
||||
<li><code>1</code>: Sets store to 'true'.</li>
|
||||
<li><code>2</code>: "Saves" store; value should persist after a page reload.</li>
|
||||
</ul></p>
|
||||
|
||||
<textarea rows='10' cols='80'></textarea>
|
||||
<div id='KeymanWebControl'></div>
|
||||
|
||||
<h3><a href="../">Return to testing home page</a></h3>
|
||||
|
||||
</body>
|
||||
|
||||
<!--
|
||||
*** DEVELOPER NOTE -- FIREFOX CONFIGURATION FOR TESTING ***
|
||||
*
|
||||
* If the URL bar starts with <b>file://</b>, Firefox may not load the font used
|
||||
* to display the special characters used in the On-Screen Keyboard.
|
||||
*
|
||||
* To work around this Firefox bug, navigate to <b>about:config</b>
|
||||
* and set <b>security.fileuri.strict_origin_policy</b> to <b>false</b>
|
||||
* while testing.
|
||||
*
|
||||
* Firefox resolves website-based CSS URI references correctly without needing
|
||||
* any configuration change, so this change should only be made for file-based testing.
|
||||
*
|
||||
***
|
||||
-->
|
||||
</html>
|
||||
64
web/testing/options-with-save/options_with_save.js
Normal file
64
web/testing/options-with-save/options_with_save.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// Original source may be found within the repo at /common/core/desktop/tests/unit/kmx/ as #023.
|
||||
if(typeof keyman === 'undefined') {
|
||||
console.log('Keyboard requires KeymanWeb 10.0 or later');
|
||||
|
||||
if(typeof tavultesoft !== 'undefined')
|
||||
tavultesoft.keymanweb.util.alert("This keyboard requires KeymanWeb 10.0 or later");
|
||||
} else {
|
||||
KeymanWeb.KR(new Keyboard_options_with_save());
|
||||
}
|
||||
|
||||
function Keyboard_options_with_save() {
|
||||
this.KI="Keyboard_options_with_save";
|
||||
this.KN="";
|
||||
this.KMINVER="10.0";
|
||||
this.KV=null;
|
||||
this.KDU=0;
|
||||
this.KH='';
|
||||
this.KM=0;
|
||||
this.KBVER="1.0";
|
||||
this.KMBM=0x0000;
|
||||
this.s4=KeymanWeb.KLOAD(this.KI,"foo","0");
|
||||
this.s8="1";
|
||||
this.s9="0";
|
||||
this.s10="1";
|
||||
this.s11="0";
|
||||
this.KVER="13.0.9999.0";
|
||||
|
||||
this.gs=function(t,e) {
|
||||
return this.g0(t,e);
|
||||
};
|
||||
|
||||
this.g0=function(t,e) {
|
||||
var k=KeymanWeb,r=0,m=0;
|
||||
|
||||
if(k.KKM(e,16384,48)) {
|
||||
if(1){
|
||||
r=m=1;
|
||||
k.KDC(0,t);
|
||||
this.s4=this.s11;
|
||||
}
|
||||
} else if(k.KKM(e,16384,49)) {
|
||||
if(1){
|
||||
r=m=1;
|
||||
k.KDC(0,t);
|
||||
this.s4=this.s10;
|
||||
}
|
||||
} else if(k.KKM(e,16384,50)) {
|
||||
if(1){
|
||||
r=m=1;
|
||||
k.KDC(0,t);
|
||||
k.KSAVE("foo",this.s4);
|
||||
}
|
||||
} else if(k.KKM(e,16384,65)) {
|
||||
if(this.s4===this.s8){
|
||||
r=m=1;
|
||||
k.KDC(0,t);
|
||||
k.KO(-1,t,"foo.");
|
||||
} else if(this.s4===this.s9){
|
||||
r=m=1;k.KDC(0,t);k.KO(-1,t,"no foo.");
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue