DmitrMakeev
commited on
Commit
•
f761278
1
Parent(s):
696812e
Update app.py
Browse files
app.py
CHANGED
@@ -1833,6 +1833,108 @@ def add_data_gc_in():
|
|
1833 |
|
1834 |
|
1835 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1836 |
|
1837 |
|
1838 |
|
|
|
1833 |
|
1834 |
|
1835 |
|
1836 |
+
|
1837 |
+
@app.route('/tl_help.js')
|
1838 |
+
def serve_vk_bridge():
|
1839 |
+
function mySuccessFunction(form) {
|
1840 |
+
if (!form) return;
|
1841 |
+
if (form instanceof jQuery) {
|
1842 |
+
form = form.get(0);
|
1843 |
+
}
|
1844 |
+
|
1845 |
+
|
1846 |
+
var obj = {};
|
1847 |
+
var inputs = form.elements;
|
1848 |
+
Array.prototype.forEach.call(inputs, function(input) {
|
1849 |
+
if (input.type === 'radio') {
|
1850 |
+
if (input.checked) obj[input.name] = input.value;
|
1851 |
+
} else {
|
1852 |
+
obj[input.name] = input.value;
|
1853 |
+
}
|
1854 |
+
});
|
1855 |
+
|
1856 |
+
|
1857 |
+
var email = obj["Email"] || "";
|
1858 |
+
var phone = obj["Phone"] || "";
|
1859 |
+
var name = obj["Name"] || "";
|
1860 |
+
|
1861 |
+
console.log("name:", name);
|
1862 |
+
console.log("email:", email);
|
1863 |
+
console.log("phone:", phone);
|
1864 |
+
|
1865 |
+
|
1866 |
+
var urlParams = new URLSearchParams(window.location.search);
|
1867 |
+
var utm_source = urlParams.get('utm_source') || "0";
|
1868 |
+
var utm_medium = urlParams.get('utm_medium') || "0";
|
1869 |
+
var utm_campaign = urlParams.get('utm_campaign') || "0";
|
1870 |
+
var utm_content = urlParams.get('utm_content') || "0";
|
1871 |
+
var utm_term = urlParams.get('utm_term') || "0";
|
1872 |
+
var gcpc = urlParams.get('gcpc') || "0";
|
1873 |
+
|
1874 |
+
|
1875 |
+
|
1876 |
+
var redirectUrl;
|
1877 |
+
if (form.id === formId1) {
|
1878 |
+
redirectUrl = new URL(redirectUrl1);
|
1879 |
+
} else if (form.id === formId2) {
|
1880 |
+
redirectUrl = new URL(redirectUrl2);
|
1881 |
+
} else if (form.id === formId3) {
|
1882 |
+
redirectUrl = new URL(redirectUrl3);
|
1883 |
+
} else {
|
1884 |
+
console.error('Неизвестный ID формы:', form.id);
|
1885 |
+
return;
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
|
1889 |
+
var queryString = '?ups=' + encodeURIComponent(ups);
|
1890 |
+
queryString += '&name=' + encodeURIComponent(name);
|
1891 |
+
queryString += '&email=' + encodeURIComponent(email);
|
1892 |
+
queryString += '&phone=' + encodeURIComponent(phone);
|
1893 |
+
queryString += '&utm_source=' + encodeURIComponent(utm_source);
|
1894 |
+
queryString += '&utm_medium=' + encodeURIComponent(utm_medium);
|
1895 |
+
queryString += '&utm_campaign=' + encodeURIComponent(utm_campaign);
|
1896 |
+
queryString += '&utm_content=' + encodeURIComponent(utm_content);
|
1897 |
+
queryString += '&utm_term=' + encodeURIComponent(utm_term);
|
1898 |
+
queryString += '&gcpc=' + encodeURIComponent(gcpc);
|
1899 |
+
|
1900 |
+
|
1901 |
+
console.log('Сформированный URL:', redirectUrl.toString() + queryString);
|
1902 |
+
|
1903 |
+
|
1904 |
+
window.open(redirectUrl.toString() + queryString, '_blank');
|
1905 |
+
}
|
1906 |
+
|
1907 |
+
if (document.readyState !== 'loading') {
|
1908 |
+
us_sendFormAfterSuccess();
|
1909 |
+
} else {
|
1910 |
+
document.addEventListener('DOMContentLoaded', us_sendFormAfterSuccess);
|
1911 |
+
}
|
1912 |
+
|
1913 |
+
function us_sendFormAfterSuccess() {
|
1914 |
+
var forms = document.querySelectorAll('.js-form-proccess');
|
1915 |
+
Array.prototype.forEach.call(forms, function(form) {
|
1916 |
+
form.addEventListener('tildaform:aftersuccess', function(e) {
|
1917 |
+
e.preventDefault();
|
1918 |
+
mySuccessFunction(form);
|
1919 |
+
});
|
1920 |
+
});
|
1921 |
+
}
|
1922 |
+
"""
|
1923 |
+
return Response(script_content, mimetype='application/javascript')
|
1924 |
+
|
1925 |
+
|
1926 |
+
|
1927 |
+
|
1928 |
+
|
1929 |
+
|
1930 |
+
|
1931 |
+
|
1932 |
+
|
1933 |
+
|
1934 |
+
|
1935 |
+
|
1936 |
+
|
1937 |
+
|
1938 |
|
1939 |
|
1940 |
|