[rs-commit] r17 - in /rst-interop/trunk/src/site: resources/crypto.signText/signtext-form.js xhtml5/crypto.signText/index.xhtml5
rs-commit at redwax.eu
rs-commit at redwax.eu
Sun Sep 19 14:39:37 CEST 2021
Author: minfrin at redwax.eu
Date: Sun Sep 19 14:39:36 2021
New Revision: 17
Log:
Add option for detection.
Modified:
rst-interop/trunk/src/site/resources/crypto.signText/signtext-form.js
rst-interop/trunk/src/site/xhtml5/crypto.signText/index.xhtml5
Modified: rst-interop/trunk/src/site/resources/crypto.signText/signtext-form.js
==============================================================================
--- rst-interop/trunk/src/site/resources/crypto.signText/signtext-form.js (original)
+++ rst-interop/trunk/src/site/resources/crypto.signText/signtext-form.js Sun Sep 19 14:39:36 2021
@@ -4,6 +4,15 @@
function signRequest(form) {
if (crypto.signText) {
crypto.signText(form['tobesigned'].value).then(response => { form['signed'].value = response });
+ }
+ else {
+ alert('An implementation of crypto.signText() is not installed in this browser.');
+ }
+}
+
+function detectRequest(form) {
+ if (crypto.signText) {
+ crypto.signText().then(response => { form['detected'].value = response });
}
else {
alert('An implementation of crypto.signText() is not installed in this browser.');
Modified: rst-interop/trunk/src/site/xhtml5/crypto.signText/index.xhtml5
==============================================================================
--- rst-interop/trunk/src/site/xhtml5/crypto.signText/index.xhtml5 (original)
+++ rst-interop/trunk/src/site/xhtml5/crypto.signText/index.xhtml5 Sun Sep 19 14:39:36 2021
@@ -47,11 +47,11 @@
<form id="createform" method="POST" action="">
<p>
<label>Enter text to sign:</label>
- <textarea name="tobesigned" id="name">I read the terms and conditions.</textarea>
+ <textarea name="tobesigned">I read the terms and conditions.</textarea>
</p>
<p>
<label>Resulting signed text:</label>
- <textarea name="signed" id="result"></textarea>
+ <textarea name="signed"></textarea>
</p>
<p>
<button id="submit" type="button" onclick="javascript:return signRequest(form);">Sign</button>
@@ -59,6 +59,31 @@
</form>
+ </div>
+ </section>
+ <section>
+ <header>
+ <h3>Detection</h3>
+ </header>
+ <div class="content">
+
+ <p>
+ To detect presence of the API, call <code>crypto.signText()</code> without
+ any parameters. If you receive a <code>Promise</code> in return, the new
+ API is present..
+ </p>
+
+ <form id="detectform" method="POST" action="">
+ <p>
+ <label>Response from API detection:</label>
+ <textarea name="detected"></textarea>
+ </p>
+ <p>
+ <button id="submit" type="button" onclick="javascript:return detectRequest(form);">Detect</button>
+ </p>
+
+ </form>
+
</div>
</section>
<section>
@@ -73,14 +98,14 @@
following code shows the legacy behaviour, and should not be used in modern code.
</p>
- <form id="createform" method="POST" action="">
+ <form id="legacyform" method="POST" action="">
<p>
<label>Enter text to sign:</label>
- <textarea name="tobelegacysigned" id="name">I read the terms and conditions.</textarea>
+ <textarea name="tobelegacysigned">I read the terms and conditions.</textarea>
</p>
<p>
<label>Resulting signed text:</label>
- <textarea name="legacysigned" id="result"></textarea>
+ <textarea name="legacysigned"></textarea>
</p>
<p>
<button id="submit" type="button" onclick="javascript:return signLegacyRequest(form);">Legacy Sign</button>
More information about the rs-commit
mailing list