Skip to content

Instantly share code, notes, and snippets.

View ray-peters's full-sized avatar

Ray Peters ray-peters

  • San Francisco, CA
View GitHub Profile
@ray-peters
ray-peters / uberGlobalize
Last active August 29, 2015 14:07
Translates currency symbols for ONTRAPORT order forms.
(function(){
// jQuery is required to run this snippet
// They are provided above from reliable CDNs if your page doesn't already have them added.
var uberGlobalize = (function(){
var cloudFlareCDN = "//cdnjs.cloudflare.com/ajax/libs/globalize/0.1.1/cultures",
currentCulture = "",
previousCulture = "",
getCurrencySymbol = function( culture ) {
// Defaults to USD buck symbol
@ray-peters
ray-peters / protected-storage.js
Last active September 18, 2015 04:43
Protected Storage
/**
* QuickStorage and ProtectedStorage
* @brief A caching control mechanism
* @author Ray Peters <[email protected]>
*/
function QuickStorage(){
this._cache = {};
}
QuickStorage.prototype.setItem = function( key, val ) {
// This design pattern allows you to wait without hogging up resources like
// setInterval, nor giving you an errand like clearInterval() after it's done
function doStuff(){
if ( !something.isReady ) {
setTimeout( doStuff, 50 );
return;
}
// Actually do the stuff you need to wait for
@ray-peters
ray-peters / gist:228b825d3fb4be6b22e1
Last active September 8, 2015 15:52
Patient Zero
// HOW TO USE: Click start from scratch and be looking at the "Add Block" box
// CONFIGURATIONS
var SPLIT_TEST_INDEX = 0;
var optEditor = ontraport.window.panel.currentPane.components.editor_component,
optEditorModel = optEditor.options.model,
BlockStylesModel = ontraport.Models.Objects.getModel( 131 ),
BlockTypes = ontraport.Models.Objects.getModel( 132 ),
_def = $.Deferred();
@ray-peters
ray-peters / gist:a1bd72db9f72bcc8f817
Last active August 29, 2015 14:25
Translate ONTRAPORT Orderforms
/**
* @brief - ONTRAPORT Orderform Translation Script
* @author Ray Peters - <[email protected]>
*/
;( function(){
// TRANSLATION MAP
var TRANSLATIONS = {
"One-time payment of": "Pago por única vez de",
@ray-peters
ray-peters / optv2__uber-globalize.js
Last active February 9, 2016 21:15
OPTv2 uberGlobalize Code
/* @author Ray Peters <[email protected]> */
jQuery( document ).ready( function(){
/* CUSTOMIZATIONS */
/* A list of cultures available @ http://cdnjs.com/libraries/globalize */
/* A list of cultures to try and load is available on the left-most column of @ http://download1.parallels.com/SiteBuilder/Windows/docs/3.2/en_US/sitebulder-3.2-win-sdk-localization-pack-creation-guide/30801.htm */
/* Common country codes -- AUSTRALIA: en-AU, GREAT BRITAIN: en-GB */
var COUNTRY_CODE = "en-GB";
@ray-peters
ray-peters / generic-uberglobalize.js
Last active February 17, 2016 21:31
generic uber globalize
(function(){
// jQuery is required to run this snippet
// They are provided above from reliable CDNs if your page doesn't already have them added.
var _uberGlobalize = ( function(){
var cloudFlareCDN = "//cdnjs.cloudflare.com/ajax/libs/globalize/0.1.1/cultures",
currentCulture = "",
previousCulture = "",
getCurrencySymbol = function( culture ) {
// Defaults to USD buck symbol
@ray-peters
ray-peters / allImagesLoaded.js
Last active September 10, 2015 22:29
Emits an event when all the images have finished loading
$( document ).ready( function(){
// Interesting thing happens when you have so many images on the page.
// Count them and wait for every onload event to fire.
var $images = $( "img" ),
imagesLoadedHandler = function(){
var totalImagesToLoad = $images.length,
imageLoadedCount = 0;
return function(){
/**
* How to use:
* Step 1: Navigate to the given template you're curious about and paste this in the console.
* Step 2: ???
* Step 3: Profit
*
* @author Jonathan Preston <[email protected]>, Ray Peters <[email protected]>
*/
/* place this in footer scripts */
$( document ).ready( function() {
$(".container:has(form[action*='form_processor.php'])" )
.attr( "id", "signup-form" )
.attr( "name", "signup-form" );
$( "a[href*='jump-to-signup-form']" ).attr( "href", "#signup-form" );
} );
/* name your link URL something like: http://jump-to-signup-form.com */