Adding Java direct to page (editor)
-
I’m using Woocommerce and Storefront theme. I’ve added a simple java countdown timer to a single page direct in the (text) editor. It works but was wondering:
1. Should it work? I assumed WordPress would delete it upon saving.
2. Can it cause any security issues?<script> function makeMeTwoDigits(n){ return (n < 10 ? "0" : "") + n; } // Set the date we're counting down to var countDownDate = new Date("oct 20, 2019 15:37:25").getTime(); // Update the count down every 1 second var x = setInterval(function() { // Get today's date and time var now = new Date().getTime(); // Find the distance between now and the count down date var distance = countDownDate - now; // Time calculations for days, hours, minutes and seconds var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); // Output the result in an element with id="dhms" document.getElementById("dhms").innerHTML = "<div class='dhmsnums'>" + makeMeTwoDigits(days) + "<span class='dhmstext'>d</span></div>" + "<div class='dhmsnums'>" + makeMeTwoDigits(hours) + "<span class='dhmstext'>h</span></div>" + "<div class='dhmsnums'>" + makeMeTwoDigits(minutes) + "<span class='dhmstext'>m</span></div>" + "<div class='dhmsnums'>" + makeMeTwoDigits(seconds) + "<span class='dhmstext'>s</span></div>"; // If the count down is over, write some text if (distance < 0) { clearInterval(x); document.getElementById("dhms").innerHTML = "EXPIRED"; } }, 1000); </script>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Adding Java direct to page (editor)’ is closed to new replies.