-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
77 lines (68 loc) · 1.8 KB
/
Copy pathmain.js
File metadata and controls
77 lines (68 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// function getInputValue(input) {
// var inputVal = document.getElementById(input).value;
// }
//
// function hasParameters(url) {
// url.includes('?')
// }
function addUrlDecorator() {
var connector,
url = document.getElementById('url-input').value;
if ( url.includes('?') ) {
connector = '&'
} else {
connector = '?'
};
return url + connector
}
function addUtmSource() {
var utmSource = document.getElementById('source-input').value;
if (utmSource != '') {
return 'utm_source=' + utmSource.split(' ').join('%20')
} else {
return ''
}
}
function addUtmMedium() {
var utmMedium = document.getElementById('medium-input').value;
if (utmMedium != '') {
return '&utm_medium=' + utmMedium.split(' ').join('%20')
} else {
return ''
}
}
function addUtmCampaign() {
var utmCampaign = document.getElementById('campaign-input').value;
if (utmCampaign != '') {
return '&utm_campaign=' + utmCampaign.split(' ').join('%20')
} else {
return ''
}
}
function addUtmContent() {
var utmContent = document.getElementById('content-input').value;
if (utmContent != '') {
return '&utm_content=' + utmContent.split(' ').join('%20')
} else {
return ''
}
}
function addUtmTerm() {
var utmTerm = document.getElementById('term-input').value;
if (utmTerm != '') {
return '&utm_term=' + utmTerm.split(' ').join('%20')
} else {
return ''
}
}
function createUtm() {
var utm = addUrlDecorator() + addUtmSource() + addUtmMedium() + addUtmCampaign() + addUtmContent() + addUtmTerm();
document.getElementById("utm").value = utm;
}
function copy() {
var utmValue = document.getElementById('utm'),
copyButtonValue = document.getElementById('copy');
utmValue.select();
document.execCommand('copy');
copyButtonValue.innerHTML = "UTM copiato";
}