adding quicklisp and sbcl to add parenscript possibly
These are all just testing pieces but possible changes to add
This commit is contained in:
		
							parent
							
								
									cb9f3ca324
								
							
						
					
					
						commit
						4242f0d05a
					
				
					 9 changed files with 1888 additions and 69 deletions
				
			
		
							
								
								
									
										2
									
								
								deps.edn
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								deps.edn
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					{:deps {org.clojure/clojurescript {:mvn/version "1.11.54"}
 | 
				
			||||||
 | 
					        thheller/shadow-cljs {:mvn/version "2.23.3"}}}
 | 
				
			||||||
| 
						 | 
					@ -1,17 +1,9 @@
 | 
				
			||||||
{{ $formClasses := "bg-neutral-500 text-neutral-50 placeholder-neutral-300 focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 focus:ring-offset-transparent m-2 p-3 rounded-lg hover:bg-neutral-500 checked:text-neutral-500" }}
 | 
					{{ $formClasses := "bg-neutral-500 text-neutral-50 placeholder-neutral-300 focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 focus:ring-offset-transparent m-2 p-3 rounded-lg hover:bg-neutral-500 checked:text-neutral-500" }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script src="/js/forms.js"></script>
 | 
					<!-- <script src="/js/forms.js"></script> -->
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
 function submitForm(e) {
 | 
					 function validate(data) {
 | 
				
			||||||
     e.preventDefault();
 | 
					     console.log("validating");
 | 
				
			||||||
     const form = document.getElementById('form');
 | 
					 | 
				
			||||||
     const data = new FormData(form);
 | 
					 | 
				
			||||||
     
 | 
					 | 
				
			||||||
     console.log(data.get("birthdate"));
 | 
					 | 
				
			||||||
     const birthdate = new Date(data.get("birthdate"));
 | 
					 | 
				
			||||||
     const age = calculate_age(birthdate);
 | 
					 | 
				
			||||||
     data.append("age", age);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
     if (data.get("tetanus-shot") === "") {
 | 
					     if (data.get("tetanus-shot") === "") {
 | 
				
			||||||
         console.warn("NO DATE FOR TETANUS SHOT");
 | 
					         console.warn("NO DATE FOR TETANUS SHOT");
 | 
				
			||||||
         data.set("tetanus-shot", "1111-11-11");
 | 
					         data.set("tetanus-shot", "1111-11-11");
 | 
				
			||||||
| 
						 | 
					@ -52,20 +44,40 @@
 | 
				
			||||||
         document.getElementById('warning-image').style.margin = '0';
 | 
					         document.getElementById('warning-image').style.margin = '0';
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     if (!document.getElementById("agreement").unchecked) {
 | 
				
			||||||
 | 
					         document.getElementById('warning').style.visibility = 'visible';
 | 
				
			||||||
 | 
					         document.getElementById('warning').style.height = '';
 | 
				
			||||||
 | 
					         document.getElementById('warning').style.margin = '';
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 function submitForm(e) {
 | 
				
			||||||
 | 
					     e.preventDefault();
 | 
				
			||||||
 | 
					     const form = document.getElementById('form');
 | 
				
			||||||
 | 
					     const data = new FormData(form);
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					     console.log(data.get("birthdate"));
 | 
				
			||||||
 | 
					     const birthdate = new Date(data.get("birthdate"));
 | 
				
			||||||
 | 
					     const age = calculate_age(birthdate);
 | 
				
			||||||
 | 
					     data.append("age", age);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     validate(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     let req = new Request();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     var xhr = new XMLHttpRequest();
 | 
					     var xhr = new XMLHttpRequest();
 | 
				
			||||||
     xhr.onreadystatechange = function() {
 | 
					     xhr.onreadystatechange = function() {
 | 
				
			||||||
         if (this.readyState == 4 && this.status == 200) {
 | 
					         if (this.readyState == 4 && this.status == 200) {
 | 
				
			||||||
             if (mtRegistration === 'now')
 | 
					             /* if (mtRegistration === 'now')
 | 
				
			||||||
                 window.location.href = 'https://secure.myvanco.com/L-Z772/campaign/C-13DM3';
 | 
					              *     window.location.href = 'https://secure.myvanco.com/L-Z772/campaign/C-13DM3';
 | 
				
			||||||
             else if (registration === 'now')
 | 
					              * else if (registration === 'now')
 | 
				
			||||||
                 window.location.href = 'https://secure.myvanco.com/L-Z772/campaign/C-13JPJ';
 | 
					              *     window.location.href = 'https://secure.myvanco.com/L-Z772/campaign/C-13JPJ';
 | 
				
			||||||
             else if (registration === 'full')
 | 
					              * else if (registration === 'full')
 | 
				
			||||||
                 window.location.href = 'https://secure.myvanco.com/L-Z772/campaign/C-13JQE';
 | 
					              *     window.location.href = 'https://secure.myvanco.com/L-Z772/campaign/C-13JQE';
 | 
				
			||||||
             else
 | 
					              * else
 | 
				
			||||||
                 window.location.href = '/thankyou/';
 | 
					              *     window.location.href = '/thankyou/'; */
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
     };
 | 
					     };
 | 
				
			||||||
     xhr.open("POST", "https://n8n.tfcconnection.org/webhook/health-form");
 | 
					     xhr.open("POST", "https://n8n.tfcconnection.org/webhook-test/testy");
 | 
				
			||||||
     xhr.send(data);
 | 
					     xhr.send(data);
 | 
				
			||||||
     console.log(data);
 | 
					     console.log(data);
 | 
				
			||||||
     console.log("Hallo!");
 | 
					     console.log("Hallo!");
 | 
				
			||||||
| 
						 | 
					@ -140,7 +152,7 @@
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div id="health-form" class="form text-lg w-full">
 | 
					<div id="health-form" class="form text-lg w-full">
 | 
				
			||||||
  <form id='form' onsubmit="submitForm(event)" autocomplete="on" method="post" target="_parent" class="w-full items-center flex flex-wrap">
 | 
					  <form id='form' onsubmit="submitForm(event);" autocomplete="on" method="post" target="_parent" class="w-full items-center flex flex-wrap">
 | 
				
			||||||
    <h3 class="basis-full">2023-2024 Health Form</h3>
 | 
					    <h3 class="basis-full">2023-2024 Health Form</h3>
 | 
				
			||||||
    <div class="basis-full flex flex-wrap my-4">
 | 
					    <div class="basis-full flex flex-wrap my-4">
 | 
				
			||||||
      <label for="firstname" class="basis-full">What is your first and last name?</label>
 | 
					      <label for="firstname" class="basis-full">What is your first and last name?</label>
 | 
				
			||||||
| 
						 | 
					@ -402,7 +414,7 @@
 | 
				
			||||||
    <div id="warning" class="basis-full mt-10 flex px-4 py-3 rounded-lg bg-[#ef4444] dark:bg-[#ef4444]">
 | 
					    <div id="warning" class="basis-full mt-10 flex px-4 py-3 rounded-lg bg-[#ef4444] dark:bg-[#ef4444]">
 | 
				
			||||||
        <span class="text-[#fca5a5] ltr:pr-3 rtl:pl-3 content-right float-right">
 | 
					        <span class="text-[#fca5a5] ltr:pr-3 rtl:pl-3 content-right float-right">
 | 
				
			||||||
            {{ partial "icon.html" (.Get 0 | default "triangle-exclamation") }}
 | 
					            {{ partial "icon.html" (.Get 0 | default "triangle-exclamation") }}
 | 
				
			||||||
            Make sure you have uploaded a copy of your insurance card.
 | 
					            You have not agreed to the liability release. Please have a guardian read and agree to it first.
 | 
				
			||||||
        </span>
 | 
					        </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1757
									
								
								quicklisp.lisp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1757
									
								
								quicklisp.lisp
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
{:source-paths ["src"]
 | 
					{:source-paths ["src"]
 | 
				
			||||||
 :dependencies [[clj-http "3.12.3"]]
 | 
					 :dependencies [[cljs-http "0.1.46"]
 | 
				
			||||||
 | 
					                [binaryage/oops "0.7.2"]]
 | 
				
			||||||
 :builds {:app {:target :browser
 | 
					 :builds {:app {:target :browser
 | 
				
			||||||
                :output-dir "static/js"
 | 
					                :output-dir "static/js"
 | 
				
			||||||
                :asset-path "/js"
 | 
					                :asset-path "/js"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,7 @@ mkShell rec {
 | 
				
			||||||
    clojure
 | 
					    clojure
 | 
				
			||||||
    clojure-lsp
 | 
					    clojure-lsp
 | 
				
			||||||
    clj-kondo
 | 
					    clj-kondo
 | 
				
			||||||
 | 
					    sbcl
 | 
				
			||||||
  ];
 | 
					  ];
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  shellHook = ''
 | 
					  shellHook = ''
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,34 @@
 | 
				
			||||||
(ns forms
 | 
					(ns forms)
 | 
				
			||||||
  (:require [clj-http.client :as client]))
 | 
					(def log "logs everything to the javascript console" (.-log js/console))
 | 
				
			||||||
(def log (.-log js/console))
 | 
					
 | 
				
			||||||
 | 
					(defn startup []
 | 
				
			||||||
 | 
					  (def form (js/document.getElementById "form"))
 | 
				
			||||||
 | 
					  (log form)
 | 
				
			||||||
 | 
					  (def data (js/FormData. form))
 | 
				
			||||||
 | 
					  (log data)
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defn calc-age [dob]
 | 
					(defn calc-age [dob]
 | 
				
			||||||
  (let [diff-ms (- js/Date.now dob.getTime)
 | 
					  (log "HELLO CHICKENS!")
 | 
				
			||||||
 | 
					  (log dob)
 | 
				
			||||||
 | 
					  (log "HELLO CHICKENS!")
 | 
				
			||||||
 | 
					  (let [diff-ms (- js/Date. dob.getTime)
 | 
				
			||||||
        age-dt (js/Date. diff-ms)]
 | 
					        age-dt (js/Date. diff-ms)]
 | 
				
			||||||
 | 
					    (log diff-ms)
 | 
				
			||||||
 | 
					    (log age-dt)
 | 
				
			||||||
    (js/Math.abs (- age-dt.getUTCFullyYear 1970))))
 | 
					    (js/Math.abs (- age-dt.getUTCFullyYear 1970))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(defn submit-form [e]
 | 
					(defn ^:export submitform [e]
 | 
				
			||||||
  ;; (e.preventDefault)
 | 
					 | 
				
			||||||
  (let [form (js/document.getElementById "form")
 | 
					  (let [form (js/document.getElementById "form")
 | 
				
			||||||
        data (js/FormData. form)
 | 
					        data (js/FormData. form)
 | 
				
			||||||
        birthdate (js/Date. (get data "birthdate"))
 | 
					        birthdate (js/Date. (get data "birthdate"))
 | 
				
			||||||
        age (calc-age birthdate)]
 | 
					        age (calc-age birthdate)]
 | 
				
			||||||
    (data.append "age" age)
 | 
					    (set! data.age age)
 | 
				
			||||||
 | 
					    (log "HERE IS BIRTHDATE")
 | 
				
			||||||
 | 
					    (log "birthdate" (get data "birtdate"))
 | 
				
			||||||
 | 
					    (log (get data "tetanus-shot"))
 | 
				
			||||||
 | 
					    (if (= (get data "tetanus-shot") "")
 | 
				
			||||||
 | 
					      (set! data.-tetanus-shot "1111-11-11"))
 | 
				
			||||||
    (log data)))
 | 
					    (log data)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(js/document.addEventListener "DOMContentLoaded" submit-form)
 | 
					(js/document.addEventListener "DOMContentLoaded" startup)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/health-form.lisp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/health-form.lisp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					;; (load "~/quicklisp/setup.lisp")
 | 
				
			||||||
 | 
					;; (ql:quickload :parenscript)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defpackage tfcconnection
 | 
				
			||||||
 | 
					  (:use #:ps))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(in-package :tfcconnection)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(defun submit-form ()
 | 
				
			||||||
 | 
					  ((@ console log) "hello world")
 | 
				
			||||||
 | 
					  (let ((form ((@ document get-element-by-id) "form"))
 | 
				
			||||||
 | 
					        (data (new (*form-data form))))
 | 
				
			||||||
 | 
					    ((@ console log) form)))
 | 
				
			||||||
 | 
					(defun validate (data)
 | 
				
			||||||
 | 
					  ((@ console log) "validating")
 | 
				
			||||||
 | 
					  (if (= ((@ data get) "tetanus-shot") "")
 | 
				
			||||||
 | 
					      ((@ console warn) "NO DATE FOR TETANUS SHOT")
 | 
				
			||||||
 | 
					      ((@ data set) "tetanus-shot" "1111-11-11")))
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										13
									
								
								static/js/health-form.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								static/js/health-form.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					defpackage(tfcconnection, 'use'(ps));
 | 
				
			||||||
 | 
					function submitForm() {
 | 
				
			||||||
 | 
					    console.log('hello world');
 | 
				
			||||||
 | 
					    var form13 = document.getElementById('form');
 | 
				
			||||||
 | 
					    var data = new FormData(form);
 | 
				
			||||||
 | 
					    __PS_MV_REG = [];
 | 
				
			||||||
 | 
					    return console.log(form13);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					function validate(data) {
 | 
				
			||||||
 | 
					    console.log('validating');
 | 
				
			||||||
 | 
					    __PS_MV_REG = [];
 | 
				
			||||||
 | 
					    return data.get('tetanus-shot') === '' ? console.warn('NO DATE FOR TETANUS SHOT') : data.set('tetanus-shot', '1111-11-11');
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue