|
14 | 14 | #:ui-widget) |
15 | 15 | (:import-from #:reblocks/page |
16 | 16 | #:init-page) |
| 17 | + (:import-from #:reblocks/request |
| 18 | + #:get-parameter) |
17 | 19 | (:export #:start |
18 | 20 | #:stop |
19 | 21 | #:*notes* |
|
62 | 64 | (update table)) |
63 | 65 |
|
64 | 66 | (defmethod render ((table table)) |
| 67 | + (let ((url-prop (get-parameter "prop"))) |
| 68 | + (when (and url-prop (string/= url-prop "") (string/= url-prop (prop table))) |
| 69 | + (update-table table url-prop))) |
65 | 70 | (reblocks/html:with-html () |
66 | 71 | (:h1 :align "center" "Lisp Inference Truth Table System") |
67 | 72 | (:div :align "center" |
68 | 73 | (reblocks-ui/form:with-html-form (:POST (lambda (&key prop &allow-other-keys) |
69 | 74 | (update-table table prop))) |
70 | 75 | (:input :type "text" |
| 76 | + :id "prop-input" |
71 | 77 | :name "prop" |
72 | 78 | :placeholder (prop table)) |
73 | 79 | (:input :type "submit" |
74 | | - :value "Eval")) |
| 80 | + :value "Eval") |
| 81 | + (:input :type "button" |
| 82 | + :value "Share" |
| 83 | + :onclick " |
| 84 | +var prop = document.getElementById('prop-input').value || document.getElementById('prop-input').placeholder; |
| 85 | +var url = window.location.origin + window.location.pathname + '?prop=' + encodeURIComponent(prop); |
| 86 | +var shareUrlInput = document.getElementById('share-url'); |
| 87 | +shareUrlInput.value = url; |
| 88 | +shareUrlInput.style.display = 'block'; |
| 89 | +try { |
| 90 | + navigator.clipboard.writeText(url).then(function() { |
| 91 | + /* clipboard successfully set */ |
| 92 | + }, function() { |
| 93 | + /* clipboard write failed */ |
| 94 | + }); |
| 95 | +} catch (e) { |
| 96 | + // ignore |
| 97 | +} |
| 98 | +")) |
| 99 | + (:input :type "text" :id "share-url" :style "display: none; width: 100%; margin-top: 10px;" :readonly "readonly") |
75 | 100 | (:pre :style "font-size: 25px" (truth table)) |
76 | 101 | (:pre (format nil "Operators: ~a" inference:*valid-operators*))) |
77 | 102 | (:p "Some notes: " |
|
92 | 117 |
|
93 | 118 | (defmethod reblocks/page:init-page ((app truth-table) (url-path string) expire-at) |
94 | 119 | (declare (ignorable app url-path expire-at)) |
95 | | - (create-table *proposition*)) |
| 120 | + (let ((prop (get-parameter "prop"))) |
| 121 | + (create-table (if (or (null prop) (string= prop "")) |
| 122 | + *proposition* |
| 123 | + prop)))) |
96 | 124 |
|
97 | 125 | (defun start (&optional (port *port*)) |
98 | 126 | (reblocks/debug:on) |
|
0 commit comments