Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Customise the VisualSVN Server browser view

, 17 Oct 2008 CPOL
How to... customise the VisualSVN Server browser view.
CustomVisualSVNServerXSLT.zip
CustomVisualSVNServerXSLT
explorer.png
svnindex.xsl
tsvn.png
/* 
The bits from init.js and core.js needed for the 'Open Folder with Windows Explorer' functionality.
*/
function BrowserIs () 
{
	var agt=navigator.userAgent.toLowerCase();
	this.osver=1.0;
	if (agt)
	{
		var stOSVer=agt.substring(agt.indexOf("windows ")+11);
		this.osver=parseFloat(stOSVer);
	}
	this.major=parseInt(navigator.appVersion);
	this.nav=((agt.indexOf('mozilla')!=-1)&&((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1)));
	this.nav6=this.nav && (this.major==5);
	this.nav6up=this.nav && (this.major >=5);
	this.nav7up=false;
	if (this.nav6up)
	{
		var navIdx=agt.indexOf("netscape/");
		if (navIdx >=0 )
			this.nav7up=parseInt(agt.substring(navIdx+9)) >=7;
	}
	this.ie=(agt.indexOf("msie")!=-1);
	this.aol=this.ie && agt.indexOf(" aol ")!=-1;
	if (this.ie)
		{
		var stIEVer=agt.substring(agt.indexOf("msie ")+5);
		this.iever=parseInt(stIEVer);
		this.verIEFull=parseFloat(stIEVer);
		}
	else
		this.iever=0;
	this.ie4up=this.ie && (this.major >=4);
	this.ie5up=this.ie && (this.iever >=5);
	this.ie55up=this.ie && (this.verIEFull >=5.5);
	this.ie6up=this.ie && (this.iever >=6);
	this.winnt=((agt.indexOf("winnt")!=-1)||(agt.indexOf("windows nt")!=-1));
	this.win32=((this.major >=4) && (navigator.platform=="Win32")) ||
		(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1);
	this.mac=(agt.indexOf("mac")!=-1);
	this.w3c=this.nav6up;
	this.safari=(agt.indexOf("safari")!=-1);
	this.safari125up=false;
	if (this.safari && this.major >=5)
	{
		var navIdx=agt.indexOf("safari/");
		if (navIdx >=0)
			this.safari125up=parseInt(agt.substring(navIdx+7)) >=125;
	}
}
var browseris=new BrowserIs();

var L_WebFoldersError_Text="Your client does not support opening this list with Windows Explorer.";
var L_WebFoldersRequired_Text="Please wait while Explorer View is loaded. If Explorer View does not appear, your browser may not support it.";

function SupportsNavigateHttpFolder()
{
	return (browseris.ie5up && browseris.win32);
}

var httpFolderTarget=null;
var httpFolderSource=null;
var httpFolderDiv=null;
function NavigateHttpFolderCore()
{
	if (httpFolderDiv==null)
	{
		httpFolderDiv=document.createElement('DIV');
		document.body.appendChild(httpFolderDiv);
		httpFolderDiv.onreadystatechange=NavigateHttpFolderCore;
		httpFolderDiv.addBehavior('#default#httpFolder');
	}
	if (httpFolderDiv.readyState=="complete")
	{
		httpFolderDiv.onreadystatechange=null;
		try
		{
			var targetFrame=document.frames.item(httpFolderTarget);
			if (targetFrame !=null)
			{
				targetFrame.document.body.innerText=L_WebFoldersRequired_Text;
			}
		}
		catch (e) {}
		var isOk=false;
		try
		{
			var ret="";
			ret=httpFolderDiv.navigateFrame(httpFolderSource,
				httpFolderTarget);
			if (ret=="OK")
				isOk=true;
		}
		catch (e) { }
		if (!isOk &&
			0==httpFolderSource.search("http://[a-zA-Z0-9\-\.]+(:80)?/"))
		{
			var sUrl=httpFolderSource
				.replace(/http:\/\/([a-zA-Z0-9\-\.]+)(:80)?[\/]/, "//$1/")
				.replace(/[\/]/g, "\\");
			var targetFrame=document.frames.item(httpFolderTarget);
			if (targetFrame !=null)
			{
				try
				{
						targetFrame.onload=null;
						targetFrame.document.location.href=sUrl;
						isOk=true;
				}
				catch (e) { }
			}
		}
		if (!isOk)
		{
			alert(L_WebFoldersError_Text);
		}
	}
}

function NavigateHttpFolder(urlSrc, frameTarget)
{
	if ('/'==urlSrc.charAt(0))
	{
		urlSrc=document.location.protocol+"//"+document.location.host+urlSrc;
	}
	httpFolderSource=urlSrc;
	httpFolderTarget=frameTarget;
	NavigateHttpFolderCore();
}

function NavigateHttpFolderIfSupported(urlSrc, frameTarget)
{
	if (SupportsNavigateHttpFolder())
	{
		NavigateHttpFolder(urlSrc, frameTarget);
	}
	else
	{
		alert(L_WebFoldersError_Text);
		window.history.back();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Riaan Lehmkuhl
Software Developer adhdForge
South Africa South Africa
Me, a disorder of the brain that results in a disruption in a person's thinking, mood, and ability to relate to others.
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141220.1 | Last Updated 17 Oct 2008
Article Copyright 2008 by Riaan Lehmkuhl
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid