Skip to content

Instantly share code, notes, and snippets.

@salsalabs
salsalabs / hidden_batch_code.html
Created July 14, 2014 21:16
Hidden batch code in donation pages
<input type="hidden" name="Batch_Code" value="123456">
@salsalabs
salsalabs / multi_line_custom_donation_display.html
Created July 17, 2014 16:44
Workaround to make multi-line custom donation fields appear as <textarea> tags.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
// See https://salsasupport.zendesk.com/forums/21464331
// Requires: Any fairly modern version of jQuery.
//
$(document).ready(function () {
// You do this. Put the API names of the multi-line donation custom fields
// between the quotes. Separate them with commas. If there is only one
// field name, simply type it between the quotes without any commas.
//
@salsalabs
salsalabs / change_event_transaction_type.html
Created July 17, 2014 18:18
Change transaction type in event pages
<script type="text/javascript">
// See https://salsasupport.zendesk.com/entries/33559170-Changing-transaction-type-in-an-event-page
$(document).ready(function() {
var eventKey = "YOUR_EVENT_KEY_HERE";
var transactionType = "YOUR_TRANSACTION_TYPE_HERE";
var regex = RegExp("checkout.sjs\\?event_KEY=" + eventKey);
if (regex.test(window.location.href)) {
var field = $('*[name=Transaction_Type]');
if (field.length == 0) {
@salsalabs
salsalabs / change_states_for_country.html
Last active November 9, 2022 19:22
Javascript to change the list of states when a country changes
<script type="text/javascript">
// Workaround to change the value of `State` select options from `CC+XX` to the
// state name. Bogus values will not show up in supporter records -- A Good Thing.
//
// @note The Salsa-provided `change` event handler is unbound by this code. It's
// the one that plants bogus values in the `State` select options, and doesn't
// need to run. To make this happen correctly, this script must appear *just before*
// the </body> tag in your template.
//
// @see https://help.salsalabs.com/entries/23796550
@salsalabs
salsalabs / most_recent_template.html
Last active August 29, 2015 14:04
An empty template with the SalsaScript necessary to retrieve the most recent donation for a supporter.
<!DOCTYPE html5>
<html>
<head>
<?
// This gets passed to Javascript, and will contain null or an object.
//
var mostRecentDonation = null;
// The supporter key is passed via &key=NUMBER in the URL.
//
var supporterKey = Request.getParameter('key');
@salsalabs
salsalabs / recurring_popup.html
Created July 30, 2014 17:26
Replace "what is this?" recurring popup with a different page
<script type="text/javascript">
$(document).ready(function () {
var windowUrl = 'http://wfc2.wiredforchange.com/o/8564/p/salsa/web/common/public/content?content_item_KEY=12215';
var clickHandler = function () {
window.open(windowUrl, 'pop1', 'toolbar=no,menubar=no,scrollbars=no,,width=500,height=200')
}
$('a.link-help')
.unbind('click')
.click(clickHandler)
})
@salsalabs
salsalabs / event_detail_autoresponse.html
Created August 4, 2014 19:42
SalsaScript that shows supporters the events that they've signed up for
<?
var supporterEvents = DB.getObjects( 'supporter_event', {
conditions: [ new Condition( 'supporter_KEY', '=', supporter.supporter_KEY) ],
orderBy: [ 'Date_Created' ]
});
if (!supporterEvents || supporterEvents.length== 0) { ?>
<div class="error">Sorry, but we coudn't find any event records... We'll get back to you on this.</div>
<? } else { ?>
<table>
<thead>
@salsalabs
salsalabs / hide_other_amount_field.html
Last active August 29, 2015 14:04
Script to hide the "other" field on donations pages.
<script type="text/javascript">
$(document).ready(function () {
$('.otherRow input').attr('disabled', true)
$('.otherRow').hide()
})
</script>
@salsalabs
salsalabs / template_hide_other_field.html
Created August 4, 2014 22:29
Script to hide the "other" field from a template
<script type="text/javascript">
$(document).ready(function () {
if (/donate_page_KEY=12345/.test(window.location.href)) {
$('.otherRow input').attr('disabled', true)
$('.otherRow').hide()
}
})
</script>
@salsalabs
salsalabs / ca_localize.html
Created August 6, 2014 00:37
Javascript to make Salsa pages less American and more Canadian
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// SalsaStaff 90508: Modify a Salsa donation page to make it appear to be more
// Canadian and less American.
//
// Function to handle modifications that are common to all languages.
//
function modifyCommon() {