Last modified: 2011-01-05 21:59:07 UTC
Currently we the following js to selecr a variable destination page. function goToDonationPage( mode ) { var url = '{{{banner-url-2010}}}?utm_medium=sitenotice&utm_campaign={{{campaign}}}&utm_source={{{banner}}}'; if ( mode && mode.length ) { url += '_' + mode; } var targets = String( '{{{targets}}}' ).split(','); if ( targets.length ) { url += '&' + targets[Math.floor( Math.random() * targets.length )].replace(/^\s+|\s+$/, ''); } window.location = url; } While functionally this does what we want it creates a link that is a js function making it not right clickable. If we could run the js on page load, create a link, and then present that link to the user .. we would have a normal html link with all the properties that people are used to.
Do we use "mode" in the function? This fixes the issue: <code> var rewrite_url = function() { var url = '{{{banner-url-2010}}}?utm_medium=sitenotice&utm_campaign={{{campaign}}}&utm_source={{{banner}}}'; var targets = String( '{{{targets}}' ).split(','); if ( targets.length ) { url += '&' + targets[Math.floor( Math.random() * targets.length )].replace(/^\s+|\s+$/, ''); } $j(".fundraiser-banner a.variable_lp").attr("href",url); } $j(document).ready(rewrite_url); </code> Also, in order to invoke this, the link needs to have the class "varialbe_lp" appended to it, so it will look like this <a class="variable_lp">{{{donate-text2}}}</a>
Addendum...just to be super-safe, let's have it be this: <code> var rewrite_url = function() { var url = '{{{banner-url-2010}}}?utm_medium=sitenotice&utm_campaign={{{campaign}}}&utm_source={{{banner}}}'; var targets = String( '{{{targets}}' ).split(','); if ( targets.length ) { url += '&' + targets[Math.floor( Math.random() * targets.length )].replace(/^\s+|\s+$/, ''); } $j(".fundraiser-banner a.variable_lp").attr("href",url); } if($j){ $j(document).ready(rewrite_url); } </code> and put a default URL into the banner pointing to something sensible, like https://payments.wikimedia.org/index.php/Special:PayflowProGateway
I'm re-opening this as our current solution is starting to clutter up our JS. Can we get this into the CN interface?
If we were to implement this in a sane way it would involve added fundraising specific user-interface components to CentralNotice, something we haven't done yet. Is it OK to make CentralNotice that Wikimedia specific?
This has been fixed in all the banners I know about. If we want to add some UI for this, a new bug should be opened.