Last active
August 29, 2015 14:20
-
-
Save salsalabs/21408623f76f66259e28 to your computer and use it in GitHub Desktop.
Script to change the <title> tag based on the Salsa page type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// Script to change the <title> tag based on the type of Salsa page | |
// being displayed. | |
// @see https://salsasupport.zendesk.com/entries/67436410 | |
$(function() { | |
m = window.location.href.match('(\\w+)_KEY'); | |
var locator = null; | |
if (m != null && m.length > 0) { | |
switch(m[1]) { | |
case 'action': | |
locator = "#info-page h1:first-of"; | |
break; | |
case 'donate_page': | |
// Note that you'll need to add "donation-title" to the title | |
// for a donation page. See the doc. | |
locator = '#salsa .donation-title'; | |
break; | |
case 'event': | |
locator = ".event_view h1"; | |
break; | |
case 'signup_page': | |
locator = 'form[name=data] h2:first-of'; | |
break; | |
case 'unsubscribe_page': | |
locator = 'h3.title'; | |
break; | |
default: | |
console.log ("---------------------------------------------------------------------"); | |
console.log("\nThere's not a locator yet for a " + m[1] + " page."); | |
console.log("Please send this message to support@salsalabs.com at your convenience."); | |
console.log("\nThanks!\n"); | |
console.log ("---------------------------------------------------------------------") | |
break; | |
} | |
if (locator != null) { | |
document.title = $(locator).html(); | |
} | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment