Difference between revisions of "MediaWiki:Common.js"
From PCGamingWiki, the wiki about fixing PC games
Line 14: | Line 14: | ||
var CJ = 'http://www.dpbolvw.net/click-6723194-10912384?url='; | var CJ = 'http://www.dpbolvw.net/click-6723194-10912384?url='; | ||
var CJ_Domains = new Array('greenmangaming.com', 'gamersgate.co.uk', 'gamefly.co.uk'); | var CJ_Domains = new Array('greenmangaming.com', 'gamersgate.co.uk', 'gamefly.co.uk'); | ||
+ | var LinkShare = ''; | ||
+ | var LinkShare_Domains = new Array('origin.com'); | ||
var Amazon = '?tag=pcgamingwiki-20'; | var Amazon = '?tag=pcgamingwiki-20'; | ||
+ | var AmazonUK = '?tag=pcgamingwiki-21'; | ||
var GoG = '?pp=708a77db476d737e54b8bf4663fc79b346d696d2'; | var GoG = '?pp=708a77db476d737e54b8bf4663fc79b346d696d2'; | ||
Line 37: | Line 40: | ||
$.each(CJ_Domains, function(index, domain) { | $.each(CJ_Domains, function(index, domain) { | ||
UpdateLinkRedirection(domain, CJ, true); | UpdateLinkRedirection(domain, CJ, true); | ||
+ | }); | ||
+ | //--Linkshare | ||
+ | $.each(LinkShare_Domains, function(index, domain) { | ||
+ | UpdateLinkRedirection(domain, LinkShare, true); | ||
}); | }); | ||
//--Amazon | //--Amazon | ||
UpdateLinkRedirection('amazon.com', Amazon, false); | UpdateLinkRedirection('amazon.com', Amazon, false); | ||
+ | UpdateLinkRedirection('amazon.co.uk', AmazonUK, false); | ||
//--GoG | //--GoG | ||
UpdateLinkRedirection('gog.com', GoG, false); | UpdateLinkRedirection('gog.com', GoG, false); | ||
}); | }); |
Revision as of 11:32, 5 January 2013
function addAnchorInHeaders() { $('span.mw-headline', '#mw-content-text').each(function() { var $this = $(this); if ($this.attr('id') !== undefined) { $('<span class="mw-linkhere"></span>').text(' • ').append( $('<a></a>').text('Link').attr({title: 'Link', href: '#'+$this.attr('id')}) ).appendTo(this); } }); } $(addAnchorInHeaders); var CJ = 'http://www.dpbolvw.net/click-6723194-10912384?url='; var CJ_Domains = new Array('greenmangaming.com', 'gamersgate.co.uk', 'gamefly.co.uk'); var LinkShare = ''; var LinkShare_Domains = new Array('origin.com'); var Amazon = '?tag=pcgamingwiki-20'; var AmazonUK = '?tag=pcgamingwiki-21'; var GoG = '?pp=708a77db476d737e54b8bf4663fc79b346d696d2'; function UpdateLinkRedirection(storeDomain, affTag, before) { $("a[href^='http://www." + storeDomain + "']").bind('click keypress', function(event) { event.preventDefault(); var link = this.href; var newLink = before ? affTag + link : link + affTag; var code = event.charCode || event.keyCode; var button = event.button; if((!code || (code && code == 13)) && (!button || (button && button == 0))) { window.location = newLink; } else if(button && button == 1) { window.open(newLink); } }); } $(document).ready(function() { //--CJ $.each(CJ_Domains, function(index, domain) { UpdateLinkRedirection(domain, CJ, true); }); //--Linkshare $.each(LinkShare_Domains, function(index, domain) { UpdateLinkRedirection(domain, LinkShare, true); }); //--Amazon UpdateLinkRedirection('amazon.com', Amazon, false); UpdateLinkRedirection('amazon.co.uk', AmazonUK, false); //--GoG UpdateLinkRedirection('gog.com', GoG, false); });