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 dynamic IDs from elements in Optimizely's visual editor | |
Note: The optimizely_evaluate comments ensure the IDs aren't removed on the live site and should not be omitted. | |
*/ | |
/* _optimizely_evaluate=editor_only */ | |
$("[id*='string']").each(function() { | |
$(this).removeAttr('id'); | |
} | |
}); |
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 hyperlinks from text using jQuery | |
The contents() function includes child text nodes. | |
https://api.jquery.com/contents/ | |
*/ | |
$("elem").contents().unwrap(); |
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
/* | |
Send an Optimizely page view tracking call in AngularJS | |
*/ | |
window.scope = window.angular.element(document).find('body').scope(); | |
window.scope.$on('$locationChangeSuccess', function(event, next, current) { | |
window['optimizely'] = window['optimizely'] || []; | |
window.optimizely.push(['trackEvent', next]); | |
}); |
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
// Prevent submission unless checked | |
$("form").bind('submit',function(event) { | |
if(!$("input[type=checkbox]").is(":checked")) { | |
event.preventDefault(); | |
// Do something | |
} | |
}); |
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
// jshint esversion: 6 | |
'use strict'; | |
const _ = require('lodash'); | |
const request = require('request-promise'); | |
const artist = process.argv[2]; | |
let options = { |
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 Counter = React.createClass({ | |
getInitialState: function() { | |
return { | |
count: 0 | |
} | |
}, | |
incrementCount: function() { | |
this.setState({ | |
count: this.state.count + 1 | |
}) |
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
/* | |
* Fetch API | |
* https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | |
*/ | |
const uri = 'https://api.spotify.com/v1/albums/21KIagsx1ZvYcv0sVkEAWv/tracks'; | |
const req = new Request(uri, { | |
method: 'get', | |
headers: new Headers({ |
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 callbackFn(activate, options) { | |
// Interval in ms for polling Demandbase visitor data | |
var POLL_INTERVAL = 50; | |
// Max number of poll attempts | |
var MAX_POLL_COUNT = 5; | |
var pollCount = 0; | |
function poll() { | |
pollCount++; |
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
/* | |
* https://developer.mozilla.org/en-US/Add-ons/Code_snippets/QuerySelector | |
*/ | |
function $ (selector, el) { | |
if (!el) {el = document;} | |
return el.querySelector(selector); | |
} | |
function $$ (selector, el) { | |
if (!el) {el = document;} |
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
window.optimizely.get('behavior') | |
.query({"version": "0.2", "filter": [{ | |
"field": ["type"], | |
"value": "pageview" | |
}] | |
}).length |
OlderNewer