Skip to content

Instantly share code, notes, and snippets.

@salsalabs
salsalabs / embed_signup.html
Last active November 11, 2016 16:22
Signup form in your web page
<form action="https://API_HOST/save" method="POST">
<input type="hidden" name="organization_KEY" value="5881"/>
<input type="hidden" name="chapter_KEY" value="887"/>
<input type="hidden" name="email_trigger_KEYS" value="12644,12656"/>
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="Receive_Email" value="1"/>
<label for="first_name">First Name:</label><input type="text" id="first_name" name="First_Name"/><br/>
<label for="last_name">Last Name:</label><input type="text" id="last_name" name="Last_Name"/><br/>
<label for="email">Email:</label><input type="text" id="email" name="Email"/><br/>
<style>.memberCode{display:none;}</style>
@salsalabs
salsalabs / embed_petition_signup.html
Last active August 29, 2015 13:56
Lines that make a signup page sign a petition.
<!-- Add these two lines to your form if you want a supporter to sign
the petition with action_KEY 12345. -->
<input type="hidden" name="link" value="action"/>
<input type="hidden" name="linkKey" value="12345"/>
@salsalabs
salsalabs / disable_welcome_back.html
Last active December 19, 2018 20:45
A script to disable Salsa's welcome back message. The supporter is logged out of the current page and returned to the same page. A flag is placed into session storage that this script doesn't loop forever. The script ignores pages that are part of a workflow or that have a displayed error.
<script type="text/javascript">
// Automatically log supporters out of Salsa pages, effectively disabling the
// Welcome Back Message. See https://help.salsalabs.com/hc/en-us/articles/223344487
// This script will not run if Salsa's returned an error.
if (document.querySelector('.error') == null) {
if (typeof window.sessionStorage.redirected == "string") {
delete window.sessionStorage.redirected;
} else {
var notThese = ['event/common.+checkout.sjs', 'guestReg', 'receipt.sjs',
@salsalabs
salsalabs / create_an_empty_template.html
Last active August 29, 2015 14:01
Create an empty template
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<!-- TemplateBeginEditable name="content" -->
<h1>Page content goes here...</h1>
<!-- TemplateEndEditable -->
</body>
@salsalabs
salsalabs / passing_an_amount_to_a_donation_page.html
Last active May 15, 2017 16:58
"Click" the applicable donation amount on a Salsa donation page when passing an amount via the URL. Also saves the amount so that it appears when errors happen on a donation page.
<script type="text/javascript">
(function () {
// SalsaStaff 81331: If "amount=number" is in the URL, then click the radio button
// for that amount. If a radio button does not exist, then put 'number' into the
// "other" field.
//
// This script captures the amount at submit and stores it in the browser's local
// storage. If there are errors passed back from Salsa, then the amount is retrieved
// from the browser's local storage. Local storage is cleaned after retrieving the value.
//
@salsalabs
salsalabs / picklists_as_radio_buttons.html
Created May 5, 2014 16:49
Convert a Salsa picklist from a dropdown to a list of radio buttons
<script type="text/javascript">
/*
* Script to convert a picklist <select> tag into a series of radio buttons.
*/
$(document).ready(function () {
var name = "tee_shirt_size";
var select = $('select[name="' + name + '"]');
if (select.length == 1) {
var id = select.attr('id');
var style = select.attr('class');
@salsalabs
salsalabs / hide_target_email_addresses.html
Last active August 29, 2015 14:01
Hide the email addresses on the letter page of an action. Updated to handle blind targeted actions and confirmation pages.
<script type="text/javascript">
// See https://help.salsalabs.com/entries/22876904-Hide-email-addresses-on-targeted-actions
$(document).ready(function() {
if (RegExp('action_KEY=NNNNN').test(window.location.href)) {
var checkExist = null;
var recipientChecker = function() {
if ($('.recipient').length > 0) {
$('.recipient .number').each(function() {
var x = $(this).html();
x = x.replace(RegExp('Email.+?</span>'), '');
@salsalabs
salsalabs / action_change_letter_label.html
Created May 7, 2014 15:04
Change the lable for the letter field in Salsa actions
<script type="text/javascript">
// See https://help.salsalabs.com/entries/22876904-Hide-email-addresses-on-targeted-actions
$(document).ready(function() {
if (RegExp('action_KEY=NNNNN').test(window.location.href)) {
var checkExist = null;
var recipientChecker = function() {
if ($('.recipient').length) {
clearInterval(checkExist);
$('label[for^=Content]').text("YOUR REPLACEMENT HERE");
}
@salsalabs
salsalabs / hide_view_respondents.html
Last active August 29, 2015 14:01
HIde "View Respondents" on distributed event
<script type="text/javascript">
// See https://help.salsalabs.com/entries/37087850-Hide-View-Respondents-on-distributed-event-page
$(document).ready(function() {
$('a[href*="profile/host.jsp?event_KEY="]').hide()
});
</script>
@salsalabs
salsalabs / validate_us_phone_number.html
Last active August 29, 2015 14:01
Validate at US phone number input field
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// FIELD_NAME can be Phone, Cell_Phone or the API name of a custom supporter field.
$('input[name=FIELD_NAME]').blur(function() {
if (!RegExp('\\d{3}-\\d{3}-\\d{4}').test($(this).val())) {
alert('Please provide a phone number like NNN-NNN-NNNN.');
return false;
}
return true;