Created
January 13, 2017 02:58
-
-
Save dsignr/5902d668adec8fb109d9eb9a7d8d5568 to your computer and use it in GitHub Desktop.
Simple split test
This file contains hidden or 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 siteEvent; | |
var siteSplit; | |
jQuery(function() { | |
siteEvent = function(c, a, l, v) { | |
dataLayer.push({ | |
'event': 'siteEvent', | |
'siteEventCategory': c, | |
'siteEventAction': a, | |
'siteEventLabel': l, | |
'siteEventValue': v | |
}); | |
}; | |
var swipeFiles = { | |
content: { | |
headlines: ["a", "b", "C"], | |
descriptions: ["a", "b", "c"], | |
backgrounds: ["a", "b", "c"], | |
icons: ["a", "b", "c"] | |
}, | |
actions: { | |
headlines: { | |
set: function(headline) { | |
$('*[data-split-headline]').text(headline); | |
} | |
}, | |
descriptions: { | |
set: function(description) { | |
$('*[data-split-description]').text(description); | |
} | |
}, | |
backgrounds: { | |
set: function(background) { | |
//TODO | |
} | |
}, | |
icons: { | |
set: function(icon) { | |
//TODO | |
} | |
} | |
} | |
} | |
function generateSplitElement(element) { | |
console.log(store.get(element)); | |
if (store.get(element) == null) { | |
var max = swipeFiles.content[element + "s"].length - 1 | |
var randomNumber = Math.floor(Math.random() * (max + 1)); | |
var swipe = swipeFiles.content[element + "s"][randomNumber]; | |
store.set(element, swipe); | |
console.log(element, swipe); | |
} else { | |
var swipe = store.get(element); | |
swipeFiles.actions[element + "s"].set(swipe); | |
} | |
} | |
var splitHeadline = store.get("headline"); | |
var splitDescription = store.get("description"); | |
var splitBackground = store.get("background"); | |
var splitIcon = store.get("icon"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment