Difference between revisions of "Template:2012FR/Form-section/Processing/Default"

From Donate
Jump to navigation Jump to search
(Created page with "<html> <script> function redirectPayment (legacyPaymentMethod) { // wrapper for redirectPayment2() // using old method parameters // until buttons can be updated ...")
 
Line 68: Line 68:
 
}
 
}
 
var form = document.paypalcontribution; // we should really change this some day
 
var form = document.paypalcontribution; // we should really change this some day
var language = $("input[name='language']").val();
 
 
 
 
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
 
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
 
 
 
var params = {
 
var params = {
'uselang' : language,
+
'uselang' : $("input[name='language']").val(),
'language' : language,
+
'language' : $("input[name='language']").val(),
'currency' : $("input[name='currency_code']").val(),
+
'currency' : $("input[name='currency_code']").val(),
'country' : $("input[name='country']").val(),
+
'country' : $("input[name='country']").val(),
 
'paymentmethod' : paymentMethod
 
'paymentmethod' : paymentMethod
 
};
 
};
Line 100: Line 99:
 
 
 
form.action = paymentsURL + '?' + $.param(params);
 
form.action = paymentsURL + '?' + $.param(params);
form.utm_source.value = '{{{banner}}}.no-LP' + '.' + paymentMethod;
 
 
form.payment_method.value = paymentMethod;
 
form.payment_method.value = paymentMethod;
 
if( paymentSubMethod != '' ){
 
if( paymentSubMethod != '' ){
Line 114: Line 112:
   
 
function addAnalytics () {
 
function addAnalytics () {
// this code makes sure parameters used are accessible to analytics
+
// stuffs parameters into utm_source to make them available for analytics
   
  +
var form = document.paypalcontribution;
document.paypalcontribution.utm_source.value = getQuerystring( 'utm_source' ) + '.';
 
  +
 
form.utm_source.value = getQuerystring( 'utm_source' ) + '.';
   
 
if(getQuerystring( 'template' ) == '') {
 
if(getQuerystring( 'template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'template' ).replace("Lp-layout-","") + '~';
+
form.utm_source.value += getQuerystring( 'template' ).replace("Lp-layout-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'appeal-template' ) == '') {
 
if(getQuerystring( 'appeal-template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'appeal-template' ).replace("Appeal-template-","") + '~';
+
form.utm_source.value += getQuerystring( 'appeal-template' ).replace("Appeal-template-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'appeal' ) == '') {
 
if(getQuerystring( 'appeal' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'appeal' ).replace("Appeal-","") + '~';
+
form.utm_source.value += getQuerystring( 'appeal' ).replace("Appeal-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'form-template' ) == '') {
 
if(getQuerystring( 'form-template' ) == '') {
document.paypalcontribution.utm_source.value += 'default' + '~';
+
form.utm_source.value += 'default' + '~';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'form-template' ).replace("Form-template-","") + '~';
+
form.utm_source.value += getQuerystring( 'form-template' ).replace("Form-template-","") + '~';
 
}
 
}
   
 
if(getQuerystring( 'form-countryspecific' ) == '') {
 
if(getQuerystring( 'form-countryspecific' ) == '') {
document.paypalcontribution.utm_source.value += 'control';
+
form.utm_source.value += 'control';
 
} else {
 
} else {
document.paypalcontribution.utm_source.value += getQuerystring( 'form-countryspecific' ).replace("Form-countryspecific-","");
+
form.utm_source.value += getQuerystring( 'form-countryspecific' ).replace("Form-countryspecific-","");
 
}
 
}
   
document.paypalcontribution.utm_source.value += '.' + paymentType;
+
form.utm_source.value += '.' + form.payment_method.value;
document.paypalcontribution.utm_campaign.value = getQuerystring( 'utm_campaign' );
+
form.utm_campaign.value = getQuerystring( 'utm_campaign' );
 
}
 
}
 
</script>
 
</script>

Revision as of 13:01, 16 October 2013