Last active
June 16, 2017 22:08
-
-
Save salsalabs/224e9970a4d3d923ec996adbda3c62a3 to your computer and use it in GitHub Desktop.
Script to add an alternative to CURRENT_DATE to your Salsa page. The date is formatted like "November 5, 2017", making it perfect for autoresponses and thank you pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- BEGIN Add a pretty version of today's date in a field called 'alt_comment_date field. --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.13/moment-timezone-with-data.js"></script> | |
<script type="text/javascript"> | |
document.addEventListener("DOMContentLoaded", function() { | |
var target = document.querySelector("#put-alt-current-date-here"); | |
if (target == null) { return; } | |
var e = document.querySelector('input[name=alt_current_date]'); | |
e.value = moment.tz('America/New_York').format('MMMM D, YYYY'); | |
document.querySelector('.salsa form').appendChild(e); | |
}); | |
</script> | |
<div style="display: none;"> | |
<input type="hidden" name="alt_current_date" /> | |
</div> | |
<!-- END Add a pretty version of today's date in a field called 'alt_comment_date field. --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment