Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function ($, window, document) {
- $(document).ready(function () {
- var queryParams = getQueryParams(document.location.search)
- var storedParams = storeParams(queryParams)
- var urlAttachment = createURLAttachment(storedParams)
- history.pushState(null, '', location.href.split('?')[0])
- $('.pricing-table-button').each(function () {
- $(this).attr('href', $(this).attr('href') + '&' + urlAttachment)
- })
- $('a').each(function () {
- var href = $(this).attr('href')
- if (href && (href.search('envato') || href.search('themeforest') || href.search('codecanyon') || href.search('graphicriver') || href.search('audiojungle') || href.search('videohive') || href.search('3docean') || href.search('photodune'))) {
- $(this).attr('href', $(this).attr('href') + '&' + urlAttachment)
- }
- })
- })
- function getQueryParams (qs) {
- qs = qs.split('+').join(' ')
- var params = {}
- var tokens
- var re = /[?&]?([^=]+)=([^&]*)/g
- while (tokens = re.exec(qs)) {
- params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2])
- }
- return params
- }
- function getCookie (cName) {
- var i; var x; var y; var ARRcookies = document.cookie.split(';')
- for (i = 0; i < ARRcookies.length; i++) {
- x = ARRcookies[i].substr(0, ARRcookies[i].indexOf('='))
- y = ARRcookies[i].substr(ARRcookies[i].indexOf('=') + 1)
- x = x.replace(/^\s+|\s+$/g, '')
- if (x === cName) {
- return unescape(y)
- }
- }
- }
- function storeParams (p) {
- var cookieName = 'urlparams'
- if (p.gclid) {
- var today = new Date()
- var expires = new Date(today.getTime() + 60 * 24 * 60 * 60 * 1000)
- var data = { gclid: '' }
- if (p.gclid) data.gclid = p.gclid
- document.cookie = cookieName + '=' + JSON.stringify(data) + '; expires=' + expires
- }
- var c = getCookie(cookieName)
- if (c) return JSON.parse(c)
- return undefined
- }
- function createURLAttachment (p) {
- if (!p) return ''
- var attachment = ''
- if (p.gclid) attachment += 'gclid=' + p.gclid + '&'
- attachment = attachment.substr(0, attachment.length - 1)
- return attachment
- }
- })(jQuery, window, document)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement