Skip to content

Instantly share code, notes, and snippets.

View TastyToast's full-sized avatar

Donnie Conner TastyToast

View GitHub Profile
@TastyToast
TastyToast / videogateyoutube.html
Created May 2, 2012 20:36
Video Gate Content with YouTube
<script type="text/javascript" src="https://s3.amazonaws.com/wildfireapp/assets/swfobject.js"></script>
<div id="video-container">
<div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.
</div>
</div>
<script type="text/javascript" src="https://s3.amazonaws.com/wildfireapp/assets/swfobject.js"></script>
@TastyToast
TastyToast / openlinkinewwindow.js
Created May 4, 2012 21:33
Open link in new window with pure javascript
<script type="text/javascript">
window.onload = function(){
var anchors = document.getElementById('main_tab_sponsor').getElementsByTagName('a');
for (var i=0; i<anchors.length; i++){
anchors[i].setAttribute('target', '_blank');
anchors[i].setAttribute('href', "http://www.myurl.com")
}
}
</script>
@TastyToast
TastyToast / jquery.truncatelines.js
Created May 11, 2012 22:48 — forked from cscheng/jquery.truncatelines.js
A simple jQuery plugin to truncate a piece of text to a predefined amount of lines. It assumes pixel values of both the container and its line-height. Useful when you have multiple boxes with text in your design that require equal heights.
$.fn.truncateLines = function(options) {
options = $.extend($.fn.truncateLines.defaults, options);
return this.each(function(index, container) {
container = $(container);
var containerLineHeight = Math.ceil(parseFloat(container.css('line-height')));
var maxHeight = options.lines * containerLineHeight;
var truncated = false;
var truncatedText = $.trim(container.text());
var overflowRatio = container.height() / maxHeight;
@TastyToast
TastyToast / tweet.liquid
Created May 22, 2012 18:41 — forked from andershaig/tweet.liquid
Twitter Intents with Rawtext
<button id="tweet_button">Click to Tweet</button>
<script type="text/javascript">
{% plugin rawtext tweet_url %}
{% plugin rawtext tweet_text %}
{% plugin rawtext tweet_hashtags %}
var params = {};
{% if tweet_url %}
@TastyToast
TastyToast / sharing.liquid
Created May 22, 2012 18:45 — forked from andershaig/sharing.liquid
Sharing Popup using Facebook's Share Method
<script type="text/javascript">
$(document).ready( function () {
var url = encodeURIComponent('https://www.youtube.com/watch?v=ya7OVaIu7Yg');
var title = encodeURIComponent('This is my super awesome title');
var full_url = 'http://www.facebook.com/sharer.php?u=' + url + '&t=' + title;
$('#method1').click( function (e) {
e.preventDefault();
window.open(full_url);
});
@TastyToast
TastyToast / formatDate
Created May 24, 2012 17:32
Formatting the date for page manager sweeps
<div id="start-date">
{{ my_sweeps.start_date }}
</div>
<script src="https://s3.amazonaws.com/wildfireapp/assets/momentjs/moment.min.js" type="text/javascript"></script>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
function formatDate(date) {
formattedDate = date.text();
@TastyToast
TastyToast / konamicode.js
Created May 31, 2012 23:53
Konami Code!
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ) {
$(document).unbind('keydown',arguments.callee);
@TastyToast
TastyToast / wmode.js
Created May 31, 2012 23:55
Changing WMode with jQuery
$("embed").attr("wmode", "opaque");
var embedTag;
$("embed").each(function(i) {
embedTag = $(this).attr("outerHTML");
if ((embedTag != null) && (embedTag.length > 0)) {
embedTag = embedTag.replace(/embed /gi, "embed wmode="opaque" ");
$(this).attr("outerHTML", embedTag);
} else {
$(this).wrap("<div></div>");
}
@TastyToast
TastyToast / timeDifference.html
Last active October 5, 2015 18:18
Show elements based on difference in time with moment.js
<script src="https://s3.amazonaws.com/wildfireapp/assets/momentjs/moment.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var currentDate = moment().utc();
//Time is set to PST (UTC minus 8 for time zone offset)
//var startDate = moment('1-24-2013 14 -08:00', 'MM-DD-YYYY HH Z').utc();
// Start Date should be set in following format: 1-24-2013
// Start Time should be set in 24 hour format. So, for 2pm, use following: 14
@TastyToast
TastyToast / birthday_arrange.js
Created June 29, 2012 21:17
Arrange birthday fields in page manager
//CHANGE ORDER OF BIRTHDAY SELECTS
var birthdayFields = [];
birthdayFields = $('.engagements_field_birthday').find('select');
//ARRANGE SELECTS
function arraymove(arr, fromIndex, toIndex) {
element = arr[fromIndex];
arr.splice(fromIndex,1);
arr.splice(toIndex,0,element);
};