Skip to content

Instantly share code, notes, and snippets.

View AlphaNerd's full-sized avatar
💭
Nerding as always

J.Coleman AlphaNerd

💭
Nerding as always
View GitHub Profile
@AlphaNerd
AlphaNerd / Header Image Swap
Created June 1, 2015 14:48
Basic header image swap script. Select target graphic and destination using CSS selectors.
var target = ".target div img";
var dest = "#header_img";
var link = jQuery(target).attr("src");
console.log(link);
jQuery(dest).css("backgroundImage","url('+link+')");
@AlphaNerd
AlphaNerd / gist:c43d1312ddde781edb25
Created May 27, 2015 18:14
Split phrase with jQuery and make first word different color. Then strip middle characters from date using substring().
///// ---------- DATE Split Color & Remove Middle Characters ---------- //////
jQuery('.mod_events_latest_date').each(function(i,val){
var wordArray = val.innerHTML.split(" ");
var string = wordArray[0];
var a = string.substring(0,1);
var b = string.substring(string.length-1,string.length);
var first = a += b;
var second = "";
if (wordArray.length > 2){
for (i=1;i<wordArray.length;i++){
@AlphaNerd
AlphaNerd / Title Splitter
Created May 27, 2015 14:16
Basic jQuery function to split Joomla tittles into multiple <span>. Used for multi-colored titles in Joomla where first word is different color than rest. Simply supply selector, and adjust phrase split.
jQuery('.home #bottom_in h3').each(function(i,val){
var titleWords = val.innerHTML.split(" ");
var first = titleWords[0] + " ";
var second = "";
if (titleWords.length > 2){
for (i=1;i<titleWords.length;i++){
second += titleWords[i]+" ";
}
}else{
second = titleWords[1];
@AlphaNerd
AlphaNerd / gist:48f6b1ff0f894d1ba5d3
Created April 1, 2015 19:17
Basic translation script for SimpleWeather.js - Translates to French once weather.currently is passed in to function.
var daysCast = 1;
jQuery.simpleWeather({
woeid: '2357536', //2357536
location: 'Shediac,NB',
unit: 'c',
success: function(weather) {
html = '<div id="an-todayImage"><img src="'+weather.forecast[0].image+'"/></div>';
html += '<div id="an-todayTemp" class="uk-width-small-1-2"><h1>'+weather.temp+'&deg;'+weather.units.temp+'</h1></div>';
html += '<div><ul style="padding-top:15px;padding-left:15px!important;"><li style="display:inline;margin-right:10px;"><b>'+weather.city+', '+weather.region+'</b><br></li>';
html += '<li style="display:inline;margin-right:10px;" class="currently">'+checkWXLang(weather.currently)+'</li>';