Fossil SCM
Fix the previous checkin to actually compute the work value. This slows it down by a tiny fraction of a second but it's still effectively instant. This calculation can be moved up a level into the C code to turn this back into an instant operation, but leaving it on the client seems like a reasonable choice.
Commit
c27cfa9f6077e1a79c9d33a8e1470d89627b0e8b753cd3761735caf8d96a7109
Parent
b765e6526781ad6…
1 file changed
+9
+9
| --- src/robot.c | ||
| +++ src/robot.c | ||
| @@ -98,15 +98,24 @@ | ||
| 98 | 98 | @ <h1 id="x1">Checking to see if you are a robot<span id="x2"></span></h1> |
| 99 | 99 | @ <form method="GET" id="x6"> |
| 100 | 100 | @ <p id="x3" style="visibility:hidden;">\ |
| 101 | 101 | @ Press <input type="submit" id="x5" value="Ok" focus> to continue</p> |
| 102 | 102 | cgi_query_parameters_to_hidden(); |
| 103 | + k = 800 + h2%99; | |
| 104 | + h2 = (k*k + k)/2; | |
| 103 | 105 | @ <input id="x4" type="hidden" name="proof" value="0"> |
| 104 | 106 | @ </form> |
| 105 | 107 | @ <script nonce='%s(style_nonce())'> |
| 106 | 108 | @ window.addEventListener('load',function(ev){ |
| 107 | 109 | @ const E = (x)=>document.getElementById(x); |
| 110 | + @ let h = %u(h1-h2); | |
| 111 | + @ let a = %u(k); | |
| 112 | + @ const x4 = E("x4"); | |
| 113 | + @ for( ; a>0; --a ) { | |
| 114 | + @ h += a; | |
| 115 | + @ } | |
| 116 | + @ x4.value = h; | |
| 108 | 117 | @ const gcs = window.getComputedStyle(document.body); |
| 109 | 118 | @ if( gcs.zIndex==='0' ) { |
| 110 | 119 | @ E("x3").style.visibility="visible"; |
| 111 | 120 | @ E("x2").textContent=""; |
| 112 | 121 | @ E("x1").textContent="All clear"; |
| 113 | 122 |
| --- src/robot.c | |
| +++ src/robot.c | |
| @@ -98,15 +98,24 @@ | |
| 98 | @ <h1 id="x1">Checking to see if you are a robot<span id="x2"></span></h1> |
| 99 | @ <form method="GET" id="x6"> |
| 100 | @ <p id="x3" style="visibility:hidden;">\ |
| 101 | @ Press <input type="submit" id="x5" value="Ok" focus> to continue</p> |
| 102 | cgi_query_parameters_to_hidden(); |
| 103 | @ <input id="x4" type="hidden" name="proof" value="0"> |
| 104 | @ </form> |
| 105 | @ <script nonce='%s(style_nonce())'> |
| 106 | @ window.addEventListener('load',function(ev){ |
| 107 | @ const E = (x)=>document.getElementById(x); |
| 108 | @ const gcs = window.getComputedStyle(document.body); |
| 109 | @ if( gcs.zIndex==='0' ) { |
| 110 | @ E("x3").style.visibility="visible"; |
| 111 | @ E("x2").textContent=""; |
| 112 | @ E("x1").textContent="All clear"; |
| 113 |
| --- src/robot.c | |
| +++ src/robot.c | |
| @@ -98,15 +98,24 @@ | |
| 98 | @ <h1 id="x1">Checking to see if you are a robot<span id="x2"></span></h1> |
| 99 | @ <form method="GET" id="x6"> |
| 100 | @ <p id="x3" style="visibility:hidden;">\ |
| 101 | @ Press <input type="submit" id="x5" value="Ok" focus> to continue</p> |
| 102 | cgi_query_parameters_to_hidden(); |
| 103 | k = 800 + h2%99; |
| 104 | h2 = (k*k + k)/2; |
| 105 | @ <input id="x4" type="hidden" name="proof" value="0"> |
| 106 | @ </form> |
| 107 | @ <script nonce='%s(style_nonce())'> |
| 108 | @ window.addEventListener('load',function(ev){ |
| 109 | @ const E = (x)=>document.getElementById(x); |
| 110 | @ let h = %u(h1-h2); |
| 111 | @ let a = %u(k); |
| 112 | @ const x4 = E("x4"); |
| 113 | @ for( ; a>0; --a ) { |
| 114 | @ h += a; |
| 115 | @ } |
| 116 | @ x4.value = h; |
| 117 | @ const gcs = window.getComputedStyle(document.body); |
| 118 | @ if( gcs.zIndex==='0' ) { |
| 119 | @ E("x3").style.visibility="visible"; |
| 120 | @ E("x2").textContent=""; |
| 121 | @ E("x1").textContent="All clear"; |
| 122 |