[rs-commit] r85 - 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
Tue Sep 20 19:41:18 CEST 2022


Author: minfrin at redwax.eu
Date: Tue Sep 20 19:41:18 2022
New Revision: 85

Log:
Add a combined legacy and new implentation.

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	Tue Sep 20 19:41:18 2022
@@ -30,4 +30,19 @@
   }
 }
 
+function signCombinedRequest(form) {
+  if (crypto.signText) {
+    value = crypto.signText(form['tobecombinedsigned'].value, 'ask');
+    if (typeof value === 'string') {
+      form['combinedsigned'].value = value;
+    }
+    else {
+      value.then(response => { form['combinedsigned'].value = response }).catch(error => {alert(error)});
+    }
+    return true;
+  }
+  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	Tue Sep 20 19:41:18 2022
@@ -116,6 +116,36 @@
             </section>
             <section>
               <header>
+                <h3>Combined Form</h3>
+              </header>
+              <div class="content">
+
+                <p>
+                  The following form detects the return value from <code>crypto.signText()</code>.
+                  If we detect a <code>string</code>, we populate the field immediately, otherwise
+                  we resolve the promise returned. This form should work on both new and legacy
+                  browsers.
+                </p>
+
+                <form id="combinedform" method="POST" action="">
+                  <p>
+                    <label>Enter text to sign:</label>
+                    <textarea name="tobecombinedsigned">I read the terms and conditions.</textarea>
+                  </p>
+                  <p>
+                    <label>Resulting signed text:</label>
+                    <textarea name="combinedsigned"></textarea>
+                  </p>
+                  <p>
+                    <button id="submit" type="button" onclick="javascript:return signCombinedRequest(form);">Combined Sign</button>
+                  </p>
+
+                </form>
+
+              </div>
+            </section>
+            <section>
+              <header>
                 <h3>
                   Javascript
                 </h3>
@@ -154,7 +184,22 @@
     alert('An implementation of crypto.signText() is not installed in this browser.');
   }
 }
-]]></code>
+
+function signCombinedRequest(form) {
+  if (crypto.signText) {
+    value = crypto.signText(form['tobecombinedsigned'].value, 'ask');
+    if (typeof value === 'string') {
+      form['combinedsigned'].value = value;
+    }
+    else {
+      value.then(response => { form['combinedsigned'].value = response }).catch(error => {alert(error)});
+    }
+    return true;
+  }
+  else {
+    alert('An implementation of crypto.signText() is not installed in this browser.');
+  }
+}]]></code>
                 </pre>
               </div>
             </section>



More information about the rs-commit mailing list