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
/** | |
* remove_from_array() | |
* Based on str param supplied, finds and removes matching item from array | |
* @param {Array} array Array to query | |
* @param {String} str String to look for | |
* @return {Bool} returns true after item is found and remove from array | |
*/ | |
function remove_from_array(array, str) { | |
var i; | |
for(i = 0; i < array.length; i++){ |
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
/** | |
* get_keys() | |
* @param {Array} data JSON array | |
* @param {String} label Value to return | |
* @return {Array} array of matched property | |
*/ | |
function get_keys(data, label) { | |
var key, values = []; | |
for(key in data){ | |
values.push(data[key][label]); |
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
;(function($) { | |
$.fn.microcarousel = function(options) { | |
var settings = $.extend({ | |
timer_latency : 40 | |
}, options); | |
return this.each(function() { | |
var timer, $wrapper = $(this); | |
$wrapper.children().addClass("slide"); |
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
<!DOCTYPE html> | |
<html lang="en-gb"> | |
<head> | |
<title>Animator</title> | |
<meta charset="utf-8" /> | |
<style> | |
.block{ | |
background: #ccc; | |
box-sizing: border-box; | |
height: 100px; |
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
<!DOCTYPE html> | |
<html lang="en-GB"> | |
<head> | |
<title>Simple JavaScript pagination</title> | |
<meta charset="UTF-8"> | |
<style> | |
div{ | |
position: relative; | |
} | |
#stage{ |
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
function getComputedStyle(elem, property, pseudoelem){ | |
return window.getComputedStyle(elem, (pseudoelem || null)).getPropertyValue(property); | |
}; | |
getComputedStyle(myElem, "height").width; | |
getComputedStyle(myElem, "height", ":after").width; |
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
function substitute(s, o){ | |
return s.replace( /{([^{}]*)}/g , | |
function (a, b) { | |
var r = o[b]; | |
return typeof r === 'string' || typeof r === 'number' ? r : a; | |
} | |
); | |
} | |
substitute("My name is {name} and I work at {workplace}",{ | |
name: "Justin Perry", |
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
* { | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
-ms-box-sizing: border-box; | |
box-sizing: border-box; | |
margin: 0; | |
padding: 0; | |
} | |
html { |
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
function log(){ | |
var debug = document.getElementById('debug'), | |
reverse = true, | |
log = Array.prototype.slice.call( arguments, 0 ).join('{join}').replace(/{join}/g, '<br>'); | |
debug.innerHTML = (reverse)? log + '<br>' + debug.innerHTML : debug.innerHTML + '<br>' + log; | |
} | |
log(myObject.name, myObject.thing, 'With a label: ' + myObject.label); |
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
var filter = '.png'; | |
var list = ['userimage105325.png','userimage669.jpg','userimage6929.png','userimage85818.gif']; | |
function filterArray(array, filter){ | |
var i, filteredArray = []; | |
filter = new RegExp(filter, 'g'); | |
for( i = 0, len = array.length; i < len; i++ ){ | |
if( array[i].toString().match(filter) ){ | |
filteredArray.push( array[i] ); | |
} |
OlderNewer