steveosoule
1/16/2015 - 12:51 AM

Dev Site Link Update

Dev Site Link Update

// Make all links & forms to main site stay on the dev site
$(window).load(function() {
	var https_to_http = false;
	var live_domain = 'www.example.com';
	var dev_domain = 'dev.example.com';


	$('a').each(function(){
		var $this = $(this),
		href = $this.attr('href');
		if(href !== undefined){
			href = href.replace(live_domain,dev_domain);
			href = https_to_http ? href.replace('https://' + dev_domain,'http://' + dev_domain) : href;
			$this.attr('href', href);
		}
	});
	$('form').each(function(){
		var $this = $(this),
		action = $this.attr('action');
		if(action !== undefined){
			action = action.replace(live_domain, dev_domain);
			action = https_to_http ? action.replace('https://' + dev_domain,'http://' + dev_domain) : action;
			$this.attr('action', action);
		}
	});
});