Click here to Skip to main content
15,880,469 members
Articles / Programming Languages / XML

A Library for Writing/Building Scripts in C#

Rate me:
Please Sign up or sign in to vote.
4.15/5 (6 votes)
14 Oct 2008CPOL3 min read 54.4K   503   55  
Designed to make it easier to write scripts such as JavaScript in C#
//Default FeedBack Values
var ratings = 3;
var title = document.title;
var URL = location.href.replace(location.hash,"");
var version = 2007;

/*************************************************************************
 * Methods ********************************************************
 *************************************************************************/

function DeliveryType()
{
 	if (URL.indexOf("ms-help://")!=-1) {return("h");}
	else if (URL.indexOf(".chm::/")!=-1) {return("c");}
	else if (URL.indexOf("http://")!=-1) {return("w");}
	else if (URL.indexOf("file:")!=-1) {return("f");}
	else return("0");
}

function DeliverableValue(deliverable)
{
 	if (URL.indexOf("ms-help://")!=-1) 
	{
		delvalue  = location.href.slice(0,location.href.lastIndexOf("/html/"));
		delvalue  = delvalue.slice(delvalue.lastIndexOf("/")+1);
		return delvalue;
	}
	else return(deliverable);
}

function URLValue()
{
	if (URL.indexOf(".chm::")!=-1) 
	{
		a = URL;
		while (a.indexOf("\\") < a.indexOf(".chm::") || a.indexOf("//") > a.indexOf(".chm::")) 
		{
			if (a.indexOf("\\")==-1)
			{
				break;
			}
			a = a.substring(a.indexOf("\\")+1,a.length);
		}
		return("ms-its:"+a)
	}
	else if (URL.indexOf("file:///")!=-1) 
	{
		a = URL;

		b = a.substring(a.lastIndexOf("html")+5,a.length);
		return("file:///"+b);
	}
	else return(URL);
}

function GetLanguage()
{
	var langauge;
  	if(navigator.userAgent.indexOf("Firefox")!=-1)
  	{
  		var index = navigator.userAgent.indexOf('(');
   		var string = navigator.userAgent.substring(navigator.userAgent.indexOf('('), navigator.userAgent.length);
   		var splitString = string.split(';');
	   	language = splitString[3].substring(1, splitString[3].length);
  	}
  	else language = navigator.systemLanguage;
	return(language);
}


//---Gets topic rating.---
function GetRating()
{

	sRating = "0";
	for(var x = 0;x < 5;x++)
  	{
		if(document.formRating) {
		if(document.formRating.fbRating[x].checked) {sRating = x + 1;}}
		else return sRating;
  	}
	return sRating;
}

function SubmitFeedback(alias, product, deliverable, productVersion, documentationVersion, defaultBody, defaultSubject)
{
	var subject = defaultSubject
  		+ " ("
		+ "/1:"
  		+ product
  		+ "/2:"
  		+ productVersion
  		+ "/3:"
  		+ documentationVersion
  		+ "/4:"
  		+ DeliverableValue(deliverable)
  		+ "/5:"
  		+ URLValue()
  		+ "/6:"
  		+ GetRating() 
  		+ "/7:"
  		+ DeliveryType()
  		+ "/8:"
  		+ GetLanguage()
		+ "/9:"
  		+ version
		+ ")"; 
  
	location.href = "mailto:" + alias + "?subject=" + subject
	+ "&body=" + defaultBody;
}

function AltFeedback(src, title) {
	src.title=title;
	return;
	}

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)


Written By
Software Developer (Senior) Web Site Advantage
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions