[rs-commit] r15 - 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:26:54 CEST 2021


Author: minfrin at redwax.eu
Date: Sun Sep 19 14:26:53 2021
New Revision: 15

Log:
Add implementation of legacy signtext.

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:26:53 2021
@@ -12,7 +12,7 @@
 
 function signLegacyRequest(form) {
   if (crypto.signText) {
-    form['signed'].value = crypto.signText(form['tobesigned'].value, 'ask');
+    form['legacysigned'].value = crypto.signText(form['tobelegacysigned'].value, 'ask');
     return true;
   }
   else {

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:26:53 2021
@@ -63,6 +63,35 @@
             </section>
             <section>
               <header>
+                <h3>Legacy Form</h3>
+              </header>
+              <div class="content">
+
+                <p>
+                  The original <code>crypto.signText()</code> as implemented by Netscape and then
+                  Firefox returned a <code>string</code> instead of a <code>Promise</code>. The
+                  following code shows the legacy behaviour.
+                </p>
+
+                <form id="createform" method="POST" action="">
+                  <p>
+                    <label>Enter text to sign:</label>
+                    <textarea name="tobelegacysigned" id="name">I read the terms and conditions.</textarea>
+                  </p>
+                  <p>
+                    <label>Resulting signed text:</label>
+                    <textarea name="legacysigned" id="result"></textarea>
+                  </p>
+                  <p>
+                    <button id="submit" type="button" onclick="javascript:return signLegacyRequest(form);">Sign</button>
+                  </p>
+
+                </form>
+
+              </div>
+            </section>
+            <section>
+              <header>
                 <h3>
                   Javascript
                 </h3>
@@ -70,11 +99,20 @@
               <div class="content">
                 <p>
                   The javascript used to trigger the <code>crypto.signText()</code>
-                  functionality can be downloaded <a href="signtext.js">here</a>, and is included
+                  functionality can be downloaded <a href="signtext-form.js">here</a>, and is included
                   for reference below.
                 </p>
                 <pre>
 <code><![CDATA[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 signLegacyRequest(form) {
   if (crypto.signText) {
     form['signed'].value = crypto.signText(form['tobesigned'].value, 'ask');
     return true;



More information about the rs-commit mailing list