Click here to Skip to main content
15,886,030 members
Articles / Web Development / HTML

Object Oriented JavaScript Class Library in C#/.NET Style

Rate me:
Please Sign up or sign in to vote.
4.97/5 (166 votes)
10 Sep 2018CPOL12 min read 387K   356  
JavaScript class library which partly replicates Microsoft .NET Framework structure and functionality.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="-1" />
	<title>Jocys.com Password Generator</title>
	<link rel="stylesheet" type="text/css" href="../System.Web.UI.Interface.debug.css" />

	<script type="text/javascript" src="../System.debug.js"></script>

	<script type="text/javascript" src="../System.Security.Password.debug.js"></script>

	<script type="text/javascript" src="../System.Web.UI.HtmlControls.debug.js"></script>

	<script type="text/javascript" src="../System.Web.UI.Interface.debug.js"></script>

	<script type="text/javascript">
		var PassGen = null;
		
		function GenerateButton_Click(){
			// You need to include only "System.Security.Password.js" to generate paswords.
			document.getElementById("PasswordTextBox").value = PassGen.NewPassword().Text;
		}

		function PasswordTextBox_Focus(){
			var item = document.getElementById("PasswordTextBox");
			if (item.value.length == 0){
				item.value = PassGen.NewPassword().Text;
				item.select();
			}
		}

		var PasGenWindow;

		function PassGenButton_Click(){
			var url = "System.Security.Password.Frameset.htm?Field=PasswordTextBox";
			// Please note thatn MSIE 7 forces the presence of the Address Bar by default
			// A missing address bar creates a chance for a fraudster to forge an address of their own.
			// To help thwart that, IE7 will show the address bar on all internet windows to help users see where they are.
			// coming from Microsoft Internet Explorer Blog, Better Website Identification
			// Mozilla.org also intends to soon force the presence of the Location Bar in Firefox 3.
			PasGenWindow = window.open(url, "PassGenWindow", "channelmode=no,directories=no,fullscreen=no,width=850,height=600,location=no,menubar=no,resizable=yes,scrollbars=no,status=yes,titlebar=no,toolbar=no");
			PasGenWindow.focus();
		}

		Window_Load = function(){
			Trace.IsEnabled = true;
			Trace.Write("Demo Start");
			Trace.Write("----------------------------");
            PassGen = new System.Security.Password.Generator();
			document.getElementById("PasswordTextBox").onfocus = PasswordTextBox_Focus;
			document.getElementById("GenerateButton").onclick = GenerateButton_Click;
			document.getElementById("PassGenButton").onclick = PassGenButton_Click;
        }
        window.onload = Window_Load;
	</script>

</head>
<body style="font-family: Times New Roman">
	<div id="TraceLog" style="width: 100%; height: 200px;"></div>
	<p>
		Password:
		<input type="text" id="PasswordTextBox" size="36" />
		<input type="button" id="GenerateButton" value="Generate" />
		<input type="button" id="PassGenButton" value="Advanced..." />
		<br />
		<br />
		<b>Click [Advanced...] button to open Password Generator window.</b></p>
	<p>
		Click inside Password field to generate new password.<br />
		Click [Generate] to regenerate new password.<br />
		<br />
	</p>
	<pre><span id="GuidList""></span></pre>
	<p>
	You also can use <i>System.Security.Password.hta</i>System.Security.Password.hta</a>
	to run password generator as Windows application.
	<br />
	<br />
	You can download full source code here: <a href="http://www.jocys.com/Files/Software/JocysComPassGen.zip">
		JocysComPassGen.zip</a>
		</p>
</body>
</html>

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)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions