Anonymous edits have been disabled on the wiki. If you want to contribute please login or create an account.


Warning for game developers: PCGamingWiki staff members will only ever reach out to you using the official press@pcgamingwiki.com mail address.
Be aware of scammers claiming to be representatives or affiliates of PCGamingWiki who promise a PCGW page for a game key.

Difference between revisions of "MediaWiki:Common.js"

From PCGamingWiki, the wiki about fixing PC games
(update to affiliate scheme)
Line 13: Line 13:
  
 
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', 'gamersgate.com', 'newegg.com');
+
var CJ_Domains = new Array('greenmangaming.com', 'gamersgate.co.uk', 'gamefly.com', 'gamefly.co.uk', 'gamersgate.com', 'newegg.com');
 
var LinkShare = '';
 
var LinkShare = '';
 
var LinkShare_Domains = new Array('origin.com');
 
var LinkShare_Domains = new Array('origin.com');

Revision as of 07:37, 22 February 2014

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.com', 'gamefly.co.uk', 'gamersgate.com', 'newegg.com');
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*='" + storeDomain + "']").bind('click keypress mouseup', function(event) {
		event.preventDefault();
		var link = this.href;
		var newLink;
		if(before) {
			newLink = affTag + link
		} else {
			var queryParam = link.indexOf("?") !== -1 ? '&' : '?';
			newLink = link + queryParam + affTag;
		}
		if (storeDomain==CJ_Domains[0]) {
  			newLink =  newLink + "?gmgr=jivalane";
		} 
		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);
});