move some common parts in common.js
This commit is contained in:
		@ -66,10 +66,7 @@ Buy one widget
 | 
			
		||||
        <div class="alert-success text-center" id="card-success" role="alert"></div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <hr>
 | 
			
		||||
    <a href="javascript:void(0)"
 | 
			
		||||
       id="pay-button"
 | 
			
		||||
       class="btn btn-primary"
 | 
			
		||||
       onclick="val({{.API}})">Charge Card</a>
 | 
			
		||||
    <a href="javascript:void(0)" id="pay-button" class="btn btn-primary">Charge Card</a>
 | 
			
		||||
    <div class="text-center d-none" id="processing-payment">
 | 
			
		||||
        <div class="spinner-border text-primary" role="status">
 | 
			
		||||
            <span class="visually-hidden">Loading...</span>
 | 
			
		||||
@ -95,6 +92,13 @@ Buy one widget
 | 
			
		||||
{{ end }}
 | 
			
		||||
{{ define "js" }}
 | 
			
		||||
<script src="https://js.stripe.com/v3/"></script>
 | 
			
		||||
<script src="/static/js/stripe.js"></script>
 | 
			
		||||
<script>stripeInit('{{.StripePubKey}}');</script>
 | 
			
		||||
<script type="module" src="/static/js/stripe.js"></script>
 | 
			
		||||
<script type="module">
 | 
			
		||||
    import {stripeInit} from "/static/js/common.js";
 | 
			
		||||
    import {val} from "/static/js/stripe.js"
 | 
			
		||||
    stripeInit('{{.StripePubKey}}');
 | 
			
		||||
    document.getElementById("pay-button").addEventListener("click", () => {
 | 
			
		||||
        val({{.API}});
 | 
			
		||||
    })
 | 
			
		||||
</script>
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
@ -49,10 +49,7 @@ Virtual Terminal
 | 
			
		||||
        <div class="alert-success text-center" id="card-success" role="alert"></div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <hr>
 | 
			
		||||
    <a href="javascript:void(0)"
 | 
			
		||||
       id="pay-button"
 | 
			
		||||
       class="btn btn-primary"
 | 
			
		||||
       onclick="val({{.API}})">Charge Card</a>
 | 
			
		||||
    <a href="javascript:void(0)" id="pay-button" class="btn btn-primary">Charge Card</a>
 | 
			
		||||
    <div class="text-center d-none" id="processing-payment">
 | 
			
		||||
        <div class="spinner-border text-primary" role="status">
 | 
			
		||||
            <span class="visually-hidden">Loading...</span>
 | 
			
		||||
@ -78,8 +75,10 @@ Virtual Terminal
 | 
			
		||||
{{ end }}
 | 
			
		||||
{{ define "js" }}
 | 
			
		||||
<script src="https://js.stripe.com/v3/"></script>
 | 
			
		||||
<script src="/static/js/stripe.js"></script>
 | 
			
		||||
<script>
 | 
			
		||||
<script type="module" src="/static/js/stripe.js"></script>
 | 
			
		||||
<script type="module">
 | 
			
		||||
    import {stripeInit} from "/static/js/common.js";
 | 
			
		||||
    import {val} from "/static/js/stripe.js"
 | 
			
		||||
    stripeInit('{{.StripePubKey}}');
 | 
			
		||||
    document.getElementById("charge_amount").addEventListener("change", (evt) => {
 | 
			
		||||
        if (evt.target.value !== "") {
 | 
			
		||||
@ -88,13 +87,10 @@ Virtual Terminal
 | 
			
		||||
            document.getElementById("amount").value = 0;
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    // function termVal() {
 | 
			
		||||
    //     const chargeAmount = document.getElementById("charge_amount");
 | 
			
		||||
    //     if (chargeAmount.value !== "") {
 | 
			
		||||
    //         document.getElementById("amount").value = parseInt((chargeAmount.value * 100), 10);
 | 
			
		||||
    //     } else {
 | 
			
		||||
    //         document.getElementById("amount").value = 0;
 | 
			
		||||
    //     }
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    document.getElementById("pay-button").addEventListener("click", () => {
 | 
			
		||||
        val({{.API}});
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user