Skip to content

Instantly share code, notes, and snippets.

Salsalabs salsalabs

Block or report user

Report or block salsalabs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
salsalabs / action_swap_header_content.html
Last active Sep 10, 2019
Use a modification observer to show one set of content on the first (address) page of a targeted action, and another set of content on the second (letter/legislators) page.
View action_swap_header_content.html
<!-- BEGIN Hide/show parts of the action header based on the workflow step being viewed. -->
<script type="text/javascript">
// NOTE: The basis for this script is described in exquisite detail on this page:
// The body of the script is copied as-is. The only real changes are modify()
// and the parameters to waitForElement.
(() => {
// Function to change an element on a targeted action page.
// If the current page is not a targeted action, then the desired element already appears on
salsalabs / credit_card_year_update.html
Created Sep 5, 2019
Script to replace the contents of a credit card year dropdown with a current list of years. Particularly helpful on Salsa storefront checkout pages, where the year ranges from 2013 to 2023.
View credit_card_year_update.html
<!-- BEGIN: Replace the credit card year dropdown with a current list of years. -->
<script type="text/javascript">
$(document).ready(function() {
var e = $('select[name="ccExpYear"]');
if (e.length != 0) {
$("option", e).remove();
var year = new Date().getFullYear();
for (var i = 0; i < 16; i++) {
var v = year + i;
salsalabs / donation_summary_for_donation_page.html
Last active Sep 3, 2019
SalsaScript to summary the count and total donations made by a single donation page. The results are stored as variables donationCount and donationAmount as Javascript global variables.
View donation_summary_for_donation_page.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
salsalabs / set_dropdown_default.html
Created Aug 28, 2019
Script to set the default value for a <select> (dropdown). The script contains a field name and an option name for a Salsa client.
View set_dropdown_default.html
<script type="javascript">
//Script to look for a specific value in a <select> (dropdown). If found
//then make it the default.
document.addEventListener(function() {
var e = document.querySelector('select[name="auswahl_spendenzweck"]');
if (e != null) {
var option = e.querySelector('option[value="Da wo es am nötigsten ist"]');
if (option != null) {
option.selected = true;
salsalabs / hide_fed_country_muni.html
Created May 1, 2019
Hide federal, country and municipal legislators in the legislative_lookup.
View hide_fed_country_muni.html
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
if (window.location.href.indexOf('getLocal4.jsp') != -1) {
var a = Array.from(document.querySelectorAll('div[id^=officials]'))
a = a.filter(function(e) {
return /officials_S/.test( ? false : true;
a.forEach(function(e) { = 'none';
//Hide two trailing <br> tags.
salsalabs / flat_10_dollar_shipping.html
Created May 1, 2019
Script to add a flat $10.00 shipping and handling to a storefront checkout if the merchandise total is $50 or less.
View flat_10_dollar_shipping.html
<script type="text/javascript">
$(document).ready(function() {
var shippingAndHandling = 10.00;
if (window.location.href.indexOf('/shop/checkOut.jsp') != -1) {
var s = $('input[name=sub]').val();
s = parseFloat(s);
if (s < 50.00) {
var t = s + shippingAndHandling;
salsalabs / default_receive_email_to_unsubscribed.html
Created Mar 26, 2019
Script to set the default value of a Receive_Email field in a Classic form to -3. All other fields named "Receive_Email" are removed to avoid confusion.
View default_receive_email_to_unsubscribed.html
<!-- BEGIN Default Receive_Email to unsubscribed. -->
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
// Remove hard-coded Receive_Email hidden inputs. That will leave the
// Receive_Email dropdown that the user can see.
var a = document.querySelectorAll('input[name=Receive_Email]');
a.forEach(function(e) {
// Set the default value for the Receive Email dropdown.
salsalabs / action_invalid_address_highlight.html
Created Feb 20, 2019
CSS to highlight the "invalid address" message in targeted actions.
View action_invalid_address_highlight.html
<!-- SalsaStaff 273659: BEGIN highlight for the address error in a targeted action. -->
<style type="text/css">
#notEnoughData {
padding-bottom: 20px;
color: red;
<!-- SalsaStaff 273659: END highlight for the address error in a targeted action. -->
salsalabs / custom_column_option_values.sql
Created Jan 18, 2019
Query to retrieve custom column option values. Useful for creating cusotm fields in Engage when importing form Classic.
View custom_column_option_values.sql
select cc.label, cc.type, cco.value
from custom_column cc
left outer join custom_column_option cco
on cco.custom_column_KEY = cc.custom_column_KEY
where cc.organization_KEY = 51035
and cco.organization_KEY = 51035
order by cc.label, cco.value;
salsalabs / redirect_non-secure_signup_pages.html
Created Jan 10, 2019
Script to redirect non-secure signup page URLs to the secure version. Install this script just after the <head> tag in your template(s).
View redirect_non-secure_signup_pages.html
<!-- BEGIN redirect non-secure signup pages to secure URLs. -->
<script type="text/javascript">
if (window.location.href.indexOf('signup?signup_page_KEY=') != -1) {
if (window.location.protocol == 'http:') {
window.location.protocol = 'https:';
<!-- END redirect non-secure signup pages to secure URLs. -->
You can’t perform that action at this time.