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 / hide_petition_signatures.html
Last active Feb 4, 2020
Provide a way to hide or show the Location information on a Salsa Classic petition that displays signatures.
View hide_petition_signatures.html
<!-- BEGIN Script to remove the city and state from petitions.
To remove cities and states from the petition, add the following HTML to the petition header.
<div style="display: none;" id="remove-petition-cities-and-states"></div>
To restore cities and states to a petition, remove the HTML.
<script type="text/javascript">
(function($) {
$(function() {
var e = $('#remove-petition-cities-and-states');
if (e.length == 0) {
salsalabs / event_change_optional_group_header.html
Last active Jan 22, 2020
Change the description for the optional groups on an Classic event page.
View event_change_optional_group_header.html
<script type="text/javascript">
(function($) {
$(document).ready(function() {
if (window.location.href.indexOf('event_KEY=89503') != -1) {
var e = $('#regForm2 > strong:nth-child(21)');
if (e.length > 0) {
e.html('Add me to the email subscriptions below to be notified of important alerts:');
salsalabs / submit_a_request_anchor_fix.js
Last active Jan 8, 2020
Zendesk "submit a request" mod to make suggestions appear in their own windows. Avoids a scan of the doc hijacking the "submit a request" window where someone may have typed something. Put this into script.js in the Zendesk theme.
View submit_a_request_anchor_fix.js
//Wait for suggestion links on a submit a request page. Called after DOM is loaded.
function modifySuggestionLinks() {
if (!RegExp('/requests(/new)*$').test(window.location.href)) {
const target = document.querySelector('div.suggestion-list');
if (target == null) {
//Create and configure a mutuation observer. Observe changes in div.suggestion-list's structure.
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.
You can’t perform that action at this time.