diff options
author | Hubert Chathi <hubert@uhoreg.ca> | 2020-05-19 15:08:27 +0000 |
---|---|---|
committer | Hubert Chathi <hubert@uhoreg.ca> | 2020-05-19 15:08:27 +0000 |
commit | ad173bc798c039bd4e855a25b99f15193bdb04c4 (patch) | |
tree | cb2fb8dff3215ffca77a4a320367ab05fd175a1f | |
parent | 5a9fdd85cb1ad54813df2ecd6eb24ff84e32656a (diff) | |
parent | ddd140b23d4352f7fb5164c42db3ef5e1714fe36 (diff) |
Merge branch 'matthew/js-fixes' into 'master'
Fix JS demos, which had bitrotted
See merge request matrix-org/olm!12
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | javascript/README.md | 3 | ||||
-rw-r--r-- | javascript/demo/group_demo.js | 6 | ||||
-rw-r--r-- | javascript/demo/one_to_one_demo.html | 10 |
4 files changed, 16 insertions, 5 deletions
@@ -33,7 +33,7 @@ JS_ASMJS_TARGET := javascript/olm_legacy.js WASM_TARGET := $(BUILD_DIR)/wasm/libolm.a JS_EXPORTED_FUNCTIONS := javascript/exported_functions.json -JS_EXTRA_EXPORTED_RUNTIME_METHODS := ALLOC_STACK +JS_EXTRA_EXPORTED_RUNTIME_METHODS := [ALLOC_STACK] JS_EXTERNS := javascript/externs.js PUBLIC_HEADERS := include/olm/olm.h include/olm/outbound_group_session.h include/olm/inbound_group_session.h include/olm/pk.h include/olm/sas.h diff --git a/javascript/README.md b/javascript/README.md index d2f1d72..bdf0224 100644 --- a/javascript/README.md +++ b/javascript/README.md @@ -2,7 +2,8 @@ Olm === Note: before using any of the olm functions, you must call `Olm.init()`, and -wait for the promise to resolve. +wait for the promise to resolve, otherwise you will get errors like: +`Uncaught TypeError: Olm.Account is not a constructor` Example: diff --git a/javascript/demo/group_demo.js b/javascript/demo/group_demo.js index 42a3d84..7cd9e3e 100644 --- a/javascript/demo/group_demo.js +++ b/javascript/demo/group_demo.js @@ -489,4 +489,8 @@ function startDemo() { } -document.addEventListener("DOMContentLoaded", startDemo, false); +document.addEventListener("DOMContentLoaded", function() { + Olm.init().then(function() { + startDemo(); + }); +}, false); diff --git a/javascript/demo/one_to_one_demo.html b/javascript/demo/one_to_one_demo.html index fc7e654..a225e4a 100644 --- a/javascript/demo/one_to_one_demo.html +++ b/javascript/demo/one_to_one_demo.html @@ -2,7 +2,13 @@ <head> <script src="../olm.js"></script> <script> -document.addEventListener("DOMContentLoaded", function (event) { +document.addEventListener("DOMContentLoaded", function() { + Olm.init().then(function() { + demo(); + }); +}, false); + +function demo() { function progress(who, message) { var message_element = document.createElement("pre"); var progress = document.getElementById(who + "_progress"); @@ -109,7 +115,7 @@ document.addEventListener("DOMContentLoaded", function (event) { glue_encrypt("bob", "alice", b_session); glue_decrypt("alice", a_session); }); - }, false); +} </script> <body> |