Skip to content

Instantly share code, notes, and snippets.

@pet-ivanov
Last active October 25, 2017 10:38
Show Gist options
  • Select an option

  • Save pet-ivanov/c9a10f2ed55abd71a73585ddee7f3dc0 to your computer and use it in GitHub Desktop.

Select an option

Save pet-ivanov/c9a10f2ed55abd71a73585ddee7f3dc0 to your computer and use it in GitHub Desktop.

Revisions

  1. Vladimir V. Ivanov revised this gist Oct 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dc-api-jq.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ function getParameterByName(name, url) {
    }
    $(function() {
    var $ = jQuery = jquery_3_1_0;
    var THANKS_URL = 'thanks.positive.bio/?offer_id=75' // url страницы "спасибо"
    var THANKS_URL = 'http://thanks.positive.bio/?offer_id=75' // url страницы "спасибо"
    var TOKEN = 'TOKEN'

    $('form').submit(function() {
  2. Vladimir V. Ivanov revised this gist Oct 25, 2017. 1 changed file with 11 additions and 9 deletions.
    20 changes: 11 additions & 9 deletions dc-api-jq.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,18 @@
    <script type="text/javascript" src="https://yastatic.net/jquery/3.1.0/jquery.min.js"></script>
    <script>var jquery_3_1_0 = jQuery;</script>
    <script type="text/javascript">
    function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    results = regex.exec(url);
    results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    $(function () {
    var THANKS_URL = 'http://DOMAIN.com/thanks.html?ok=1' // url страницы "спасибо"
    $(function() {
    var $ = jQuery = jquery_3_1_0;
    var THANKS_URL = 'thanks.positive.bio/?offer_id=75' // url страницы "спасибо"
    var TOKEN = 'TOKEN'

    $('form').submit(function() {
    @@ -21,13 +23,13 @@ $(function () {
    token: TOKEN,
    name: $('[name="name"]', form).val(),
    phone: $('[name="phone"]', form).val(),
    aff_sub: getParameterByName('sub1'),
    aff_sub2: getParameterByName('sub2'),
    aff_sub3: getParameterByName('sub3'),
    aff_sub4: getParameterByName('sub4'),
    aff_sub5: getParameterByName('sub5'),
    aff_sub: getParameterByName('sub1'),
    aff_sub2: getParameterByName('sub2'),
    aff_sub3: getParameterByName('sub3'),
    aff_sub4: getParameterByName('sub4'),
    aff_sub5: getParameterByName('sub5'),
    },
    success: function (data) {
    success: function(data) {
    // редиректим на страницу "спасибо" с параметрами конверсии в URL
    if (data.response.success == 'true') {
    var conversion = data.response.conversions[0]
  3. Vladimir V. Ivanov revised this gist Aug 16, 2017. No changes.
  4. Vladimir V. Ivanov revised this gist Aug 16, 2017. 1 changed file with 43 additions and 43 deletions.
    86 changes: 43 additions & 43 deletions dc-api-jq.js
    Original file line number Diff line number Diff line change
    @@ -1,46 +1,46 @@
    <script type="text/javascript" src="https://yastatic.net/jquery/3.1.0/jquery.min.js"></script>
    <script type="text/javascript">
    function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    $(function () {
    var THANKS_URL = 'http://DOMAIN.com/thanks.html?ok=1' // url страницы "спасибо"
    var TOKEN = 'TOKEN'
    <script type="text/javascript" src="https://yastatic.net/jquery/3.1.0/jquery.min.js"></script>
    <script type="text/javascript">
    function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    $(function () {
    var THANKS_URL = 'http://DOMAIN.com/thanks.html?ok=1' // url страницы "спасибо"
    var TOKEN = 'TOKEN'

    $('form').submit(function() {
    var form = $(this)
    $.post({
    url: 'http://leads.api.drcash.me/sf',
    data: {
    token: TOKEN,
    name: $('[name="name"]', form).val(),
    phone: $('[name="phone"]', form).val(),
    aff_sub: getParameterByName('sub1'),
    aff_sub2: getParameterByName('sub2'),
    aff_sub3: getParameterByName('sub3'),
    aff_sub4: getParameterByName('sub4'),
    aff_sub5: getParameterByName('sub5'),
    },
    success: function (data) {
    // редиректим на страницу "спасибо" с параметрами конверсии в URL
    if (data.response.success == 'true') {
    var conversion = data.response.conversions[0]
    THANKS_URL += (THANKS_URL.indexOf('?') >= 0 ? '&' : '?') + $.param(conversion) // добавляем параметры
    window.location.replace(THANKS_URL); // редирект
    } else {
    console.error('При отправке конверсии произошла ошибка: ' + data.response.msg)
    }
    },
    dataType: 'json'
    })

    return false
    $('form').submit(function() {
    var form = $(this)
    $.post({
    url: 'http://leads.api.drcash.me/sf',
    data: {
    token: TOKEN,
    name: $('[name="name"]', form).val(),
    phone: $('[name="phone"]', form).val(),
    aff_sub: getParameterByName('sub1'),
    aff_sub2: getParameterByName('sub2'),
    aff_sub3: getParameterByName('sub3'),
    aff_sub4: getParameterByName('sub4'),
    aff_sub5: getParameterByName('sub5'),
    },
    success: function (data) {
    // редиректим на страницу "спасибо" с параметрами конверсии в URL
    if (data.response.success == 'true') {
    var conversion = data.response.conversions[0]
    THANKS_URL += (THANKS_URL.indexOf('?') >= 0 ? '&' : '?') + $.param(conversion) // добавляем параметры
    window.location.replace(THANKS_URL); // редирект
    } else {
    console.error('При отправке конверсии произошла ошибка: ' + data.response.msg)
    }
    },
    dataType: 'json'
    })

    return false
    })
    </script>
    })
    </script>
  5. Vladimir V. Ivanov renamed this gist Aug 16, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. Vladimir V. Ivanov renamed this gist Aug 16, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. Vladimir V. Ivanov revised this gist Jun 22, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    $(function () {
    var THANKS_URL = 'http://domain.com/thanks.html?ok=1' // url страницы "спасибо"
    var THANKS_URL = 'http://DOMAIN.com/thanks.html?ok=1' // url страницы "спасибо"
    var TOKEN = 'TOKEN'

    $('form').submit(function() {
  8. Vladimir V. Ivanov created this gist Jun 22, 2017.
    46 changes: 46 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    <script type="text/javascript" src="https://yastatic.net/jquery/3.1.0/jquery.min.js"></script>
    <script type="text/javascript">
    function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
    results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    $(function () {
    var THANKS_URL = 'http://domain.com/thanks.html?ok=1' // url страницы "спасибо"
    var TOKEN = 'TOKEN'

    $('form').submit(function() {
    var form = $(this)
    $.post({
    url: 'http://leads.api.drcash.me/sf',
    data: {
    token: TOKEN,
    name: $('[name="name"]', form).val(),
    phone: $('[name="phone"]', form).val(),
    aff_sub: getParameterByName('sub1'),
    aff_sub2: getParameterByName('sub2'),
    aff_sub3: getParameterByName('sub3'),
    aff_sub4: getParameterByName('sub4'),
    aff_sub5: getParameterByName('sub5'),
    },
    success: function (data) {
    // редиректим на страницу "спасибо" с параметрами конверсии в URL
    if (data.response.success == 'true') {
    var conversion = data.response.conversions[0]
    THANKS_URL += (THANKS_URL.indexOf('?') >= 0 ? '&' : '?') + $.param(conversion) // добавляем параметры
    window.location.replace(THANKS_URL); // редирект
    } else {
    console.error('При отправке конверсии произошла ошибка: ' + data.response.msg)
    }
    },
    dataType: 'json'
    })

    return false
    })
    })
    </script>