Skip to content

Instantly share code, notes, and snippets.

// Load JS from external source
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js" type="text/javascript"></script>
// Add inline JS
<script type="text/javascript">
$('#message').append("Message generated on " + Date.now());
</script>
// Loads Handlebars library since the message content is using Handlebars templates
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.1/handlebars.min.js" type="text/javascript"></script>
<div id="message">
<p>Hello staff - the top seller yesterday was {{data.query2.FullName}} with ${{data.query1.amount}} - <em>well done!</em></p>
<p>The Best Sale was:</p>
<ul>
{{#each data.query3}}
{{Item_Name__c}}: {{Total_Unit_Quantity_Needed__c}} {{Default_Unit_Name__c}} (${{PBSI__Total_Price__c}})
{{/each}}
</ul>
</div>
<div class="body pricetag" >
<header class="title">
<ul id="brand">
<li class="vendor italo"><img src=""></li>
<li class="vendor co-host"><img src="{PBSI__PBSI_Item__c3.Vendor_Logo_URL__c.0}"></li>
<li><h1 contenteditable="true" data-pricetag-tile="{PBSI__PBSI_Item__c3.Collection__c.0}"><span class="collection lower">{PBSI__PBSI_Item__c3.Collection__c.0} Collection</span></h1></li>
</ul>
@smcllns
smcllns / gist:1136491
Created August 10, 2011 10:05
Brian Cray's Time on Site logger
<script type="text/javascript">
// from http://briancray.com/
(function (tos) {
window.setInterval(function () {
// Every 10,000 milliseconds, calculate the time
tos = (function (t) {
return t[0] == 50 ? (parseInt(t[1]) + 1) + ':00' : (t[1] || '0') + ':' + (parseInt(t[0]) + 10);
@smcllns
smcllns / gist:1136488
Created August 10, 2011 10:01
Tracking outbound links with Google Analytics
< script type = "text/javascript" >
(function($) {
$(function() {
$('a[href^="http"]:not([href*="' + document.domain + '"])').click(function(e) {
// When a user clicks an external link
if ($(this).attr('target') !== '_blank') {
e.preventDefault();