Skip to content

Instantly share code, notes, and snippets.

View TastyToast's full-sized avatar

Donnie Conner TastyToast

View GitHub Profile
@TastyToast
TastyToast / comparehandlebars.js
Created March 21, 2013 00:11
Comparison Helper for handlebars.js
// Comparison Helper for handlebars.js
// Pass in two values that you want and specify what the operator should be
// e.g. {{#compare val1 val2 operator="=="}}{{/compare}}
Handlebars.registerHelper('compare', function(lvalue, rvalue, options) {
if (arguments.length < 3)
throw new Error("Handlerbars Helper 'compare' needs 2 parameters");
operator = options.hash.operator || "==";
@TastyToast
TastyToast / handebars.html
Last active December 15, 2015 05:09
Handlebars Example
{% raw %}
<script type="text/x-handlebars-template" id="gallery-template">
{{#each cards}}
<div class="entry" data-index="{{itemIndex}}">
{{{image}}}
<div class="share-btns">
<div class="fbshare"><a href="#">Share</a></div>
<div class="tweet-btn"><a href="#">Tweet</a></div>
{{{shareActions}}}
</div>
@TastyToast
TastyToast / fblogin-onebutton.js
Last active December 15, 2015 03:19
Login and Get Perms with a click of a button
// LOGIN AND GET PERMS WHEN THE USER CLICKS <div id="yes"><a></a></div>
(function($){
var app = app || {
init: function(){
console.log("INIT");
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
@TastyToast
TastyToast / reverseArrSwap.js
Created March 15, 2013 03:50
Return Reversed Array (Swap method)
function temporarySwap(array)
{
var left = null;
var right = null;
var length = array.length;
for (left = 0, right = length - 1; left < right; left += 1, right -= 1)
{
var temporary = array[left];
array[left] = array[right];
array[right] = temporary;
{% plugin rawtext desktop_url %}
<script type="text/javascript">
top.location.href="{{ desktop_url }}";
</script>
@TastyToast
TastyToast / handlebars-debug-helper.js
Created March 7, 2013 01:34
Handlebars Debug helper
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
console.log(this);
if (optionalValue) {
console.log("Value");
console.log("====================");
console.log(optionalValue);
}
@TastyToast
TastyToast / debug-handlebars.js
Created March 1, 2013 19:12
Debugging helper for Handlebars
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
console.log(this);
if (optionalValue) {
console.log("Value"); console.log("===================="); console.log(optionalValue);
}
});
@TastyToast
TastyToast / handlebars-truncate-helper.js
Last active April 21, 2021 09:08
Truncate helper for Handlebars.js
Handlebars.registerHelper ('truncate', function (str, len) {
if (str.length > len) {
var new_str = str.substr (0, len+1);
while (new_str.length) {
var ch = new_str.substr ( -1 );
new_str = new_str.substr ( 0, -1 );
if (ch == ' ') {
break;
@TastyToast
TastyToast / localstorageexample.html
Last active December 11, 2015 13:58
Using Local Storage with cookies
<script src="https://s3.amazonaws.com/wildfireapp/assets/jstorage.min.js"></script>
<div class="sweeps-tab tab clearfix">
<div class="header">
<h1>Buy one get one FREE. Kodak 5x7 folded greeting card. Register for your FREE COUPON!</h1>
</div>
<div class="left-col">
<div class="sweeps-container cvs" style="display: none;" data-store="cvs">
{% plugin sweeps cvs_sweeps %}
{% marker cvs_sweeps %}
@TastyToast
TastyToast / timeline-videos.html
Created January 14, 2013 22:24
Playable videos in Facebook Timeline
<a href="#">Click me</a>
<object width="420" height="315"><param name="movie" value="http://www.youtube.com/v/EzNhaLUT520?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/EzNhaLUT520?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<script type="text/javascript">
(function($){
$(document).bind('afterfbinit', function(){
$('a').on('click', function(e){
e.preventDefault();
FB.ui({