Skip to content

Instantly share code, notes, and snippets.

@salsalabs
salsalabs / change_in_memory_of.html
Created May 8, 2014 16:35
Change the content and CSS ID of the "in memory of" prompt.
<!-- Style and script to change the contents of the "in memory of" message
on a Salsa donation page. See (SalsaCommons link here.) -->
<style type="text/css">
#was-in-memory-of {
padding-top: 20px;
font-size: 12pt;
color: red;
}
</style>
<script type="text/javascript">
@salsalabs
salsalabs / q_answers_from_url.html
Last active August 29, 2015 14:01
Clicks answers in a questionnaire based on queries in the URL.
<script type="text/javascript">
$(document).ready(function () {
// SalsaStaff 88363: Click options in the checkbox/radio button
// questions based on queries passed in the URL. The general form of
// a query is `&Qm=n`, where `m` is the question number and `n` is
// the answer number. Both `m` and `n` are cardinal integers.
//
// @note This GIST contains guard logic to work on a single questoinnaire
// because the script must go into a template.
//
@salsalabs
salsalabs / profile_manager_mods_1.html
Created May 14, 2014 15:11
This is a script that modifies the contents of the profile manager page. See the comments for more details.
<script type="text/javascript">
$(document).ready(function() {
if (RegExp('profile/login').test(window.location.href)) {
$('a[onclick*=forgotpassword]')
.html("Click here to receive your password.")
.click(function() {
$('.login form').eq(0).hide();
$('.login table').eq(0).hide();
$('a[onclick*=forgotpassword]').hide();
var x = $('#forgotpassword').html()
@salsalabs
salsalabs / sample_authentication.text
Last active August 29, 2015 14:01
This is a sample of an API authentication URL, broken down for legibility. See https://salsasupport.zendesk.com/entries/23529436-Authenticating
[API URL]/api/authenticate.sjs
?xml
&email=[email]
&password=[password]
&organization_KEY=[number]
&chapter_KEY=[number]
@salsalabs
salsalabs / upload_validation.html
Last active August 29, 2015 14:01
This script makes sure that a Salsa upload page has both a file and a file name before the upload is submitted. An alert is displayed if the file is missing. If the file is missing and the name is empty, then the script uses the basename of the file as the name.
<!-- Add client-side validation and defaulting to any upload page. -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
if (/upload_page_KEY=\d+/.test(window.location.href)) {
$('#upload_page').submit(function () {
var file = $('*[name=file]').val();
if (file.length == 0 || file == 'No file selected.') {
alert('Please click the Browser button to choose a file before submitting this form.');
return(false);
@salsalabs
salsalabs / forced_redirect.html
Created May 21, 2014 21:21
Redirect to another URL whenever the URL for a page is clicked.
<script type="text/javascript">
// Replace `URL` with the URL where you want the user to go.
// Please keep all punctuation intact!
window.location = "URL";
</script>
@salsalabs
salsalabs / basic_login.txt
Last active August 29, 2015 14:01
Sample basic login URL, on multiple lines to improve legibility.
https://sample.salsalabs.com/api/authenticate.sjs
?xml
&[email protected]
&password=yourpass
@salsalabs
salsalabs / authenticate_org_key.txt
Created May 21, 2014 22:53
Login specifying an organization_KEY to disambiguate the login credentials. On several lines to aid legibility.
https://sample.salsalabs.com/api/authenticate.sjs
?json
&[email protected]
&password=yourpass
&organization_KEY=12345
@salsalabs
salsalabs / authenticate_org_chapter.txt
Created May 21, 2014 22:55
Authenticate with both organization_KEY and chapter_KEY to disambiguate credentials. On several lines to aid legibility.
https://big_org.salsalabs.com/api/authenticate.sjs
?xml
&[email protected]
&password=yourpass
&organization_KEY=12345
&chapter_KEY=1234
@salsalabs
salsalabs / salsa_sample.php
Last active August 29, 2015 14:01
Sample of using the Salsa API in PHP. Note that cookies must be passed to every call after authentication!
<?php
// See https://salsasupport.zendesk.com/entries/23514381-Definitions-for-common-terms
// to find out to retrieve the API URL in $url.
$url = "https://API_URL/api";
$username = ""; # Campaign Manager username goes here
$password = ""; # Campaign Manager password goes here
// Method #1 for building post objects to send to Salsa
$authfields["email"] = $username;