diff --git a/web/source/text/kbdInterface.ts b/web/source/text/kbdInterface.ts index fcea1d26d4..8b018dcb99 100644 --- a/web/source/text/kbdInterface.ts +++ b/web/source/text/kbdInterface.ts @@ -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; } diff --git a/web/testing/index.html b/web/testing/index.html index 001f653ce2..5084af2234 100644 --- a/web/testing/index.html +++ b/web/testing/index.html @@ -25,6 +25,7 @@

Tests keyboard error-handling functionality

Tests the new Attachment/Enablement API functionality

Chirality testing/bootstrapping

+

Tests option/variable store functionality

Platform testing

Prediction UI testing

Toolbar UI testing

diff --git a/web/testing/options-with-save/index.html b/web/testing/options-with-save/index.html new file mode 100644 index 0000000000..05d76af214 --- /dev/null +++ b/web/testing/options-with-save/index.html @@ -0,0 +1,88 @@ + + + + + + + + + + + + KeymanWeb Testing Page - Basic Mnemonic Support + + + + + + + + + + + + + + + + + + + + +

KeymanWeb: Test basic variable-store functionality

+

+ + +
+ +

Return to testing home page

+ + + + + diff --git a/web/testing/options-with-save/options_with_save.js b/web/testing/options-with-save/options_with_save.js new file mode 100644 index 0000000000..6b7a9edcc6 --- /dev/null +++ b/web/testing/options-with-save/options_with_save.js @@ -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; + }; +} \ No newline at end of file