tests/Leaflet/sl-application.js
/* ============================
** Build a SLurl validation
** ============================
** Makes sure there are slurl coordinates input before we attempt to generate a SLurl */
Build a SLurl validation
Makes sure there are slurl coordinates input before we attempt to generate a SLurl
Build a SLurl validation Makes sure there are slurl coordinates input before we attempt to generate a SLurl
function slurlBuildValidator()
{
	$('input#generate-slurl').click(function(){
		$('#build-location div.slurl-error').remove(); 
		var intX = parseFloat($('#x').val());
		var intY = parseFloat($('#y').val());
		var intZ = parseFloat($('#z').val());
		var imgRegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
		if($('#windowImage').val())	{
			var imgCheck = $('#windowImage').val().search(imgRegExp);
		}
		else {
			var imgCheck = 0;
		}
		if(!$('#region').val() 
			|| ( isNaN($('#x').val()) || isNaN(intX) || intX<0 || intX>256 )
			|| ( isNaN($('#y').val()) || isNaN(intY) || intY<0 || intY>256 )
			|| ( isNaN($('#z').val()) || isNaN(intZ) )
			|| ( $('#windowImage').val() != '' && imgCheck == -1 )
			) {
			var error_content = "";
			if(	!$('#region').val() ) {
				error_content += "<p>A valid SLurl must contain a region name and x,y,z coordinates. Please make sure that each of these fields are properly filled in.</p>";
			}
			if( isNaN($('#x').val()) || isNaN($('#y').val()) || isNaN($('#z').val()) || isNaN(intX) || isNaN(intY) || isNaN(intZ) || intX > 256 || intY > 256) {
				error_content += "<p>The x and y coordinates must each contain numbers between 0 and 256 to be valid. z index must be between -99 and 999. All coordinates (x,y,z) must be numeric.</p>";
			}
			if( intX<0 || intY<0) {
				error_content += "<p>The x and y coordinates must be positive numbers.</p>";
			}			
			if(imgCheck == -1) {
					error_content += "<p>Window Image must be a fully qualified url to a hosted image.";
					error_content += "( <strong>Example: </strong><em>http://www.yoursite.com/images/yourImage.jpg</em> )</p>";
			}
			$('#build-location legend').after('<div class="slurl-error"><h4>We\'re having trouble creating your SLurl</h4>'+ error_content +'</div>');
			document.getElementById('slurl-builder').scrollTop=0;
		} else {
			build_url();
		}
	})
}
function slurlBuildValidator ( ) { $ ( 'input#generate-slurl' ) . click ( function ( ) { $ ( '#build-location div.slurl-error' ) . remove ( ) ; var intX = parseFloat ( $ ( '#x' ) . val ( ) ) ; var intY = parseFloat ( $ ( '#y' ) . val ( ) ) ; var intZ = parseFloat ( $ ( '#z' ) . val ( ) ) ; var imgRegExp = / (ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))? / ; if ( $ ( '#windowImage' ) . val ( ) ) { var imgCheck = $ ( '#windowImage' ) . val ( ) . search ( imgRegExp ) ; } else { var imgCheck = 0 ; } if ( ! $ ( '#region' ) . val ( ) || ( isNaN ( $ ( '#x' ) . val ( ) ) || isNaN ( intX ) || intX < 0 || intX > 256 ) || ( isNaN ( $ ( '#y' ) . val ( ) ) || isNaN ( intY ) || intY < 0 || intY > 256 ) || ( isNaN ( $ ( '#z' ) . val ( ) ) || isNaN ( intZ ) ) || ( $ ( '#windowImage' ) . val ( ) != '' && imgCheck == - 1 ) ) { var error_content = "" ; if ( ! $ ( '#region' ) . val ( ) ) { error_content += "<p>A valid SLurl must contain a region name and x,y,z coordinates. Please make sure that each of these fields are properly filled in.</p>" ; } if ( isNaN ( $ ( '#x' ) . val ( ) ) || isNaN ( $ ( '#y' ) . val ( ) ) || isNaN ( $ ( '#z' ) . val ( ) ) || isNaN ( intX ) || isNaN ( intY ) || isNaN ( intZ ) || intX > 256 || intY > 256 ) { error_content += "<p>The x and y coordinates must each contain numbers between 0 and 256 to be valid. z index must be between -99 and 999. All coordinates (x,y,z) must be numeric.</p>" ; } if ( intX < 0 || intY < 0 ) { error_content += "<p>The x and y coordinates must be positive numbers.</p>" ; } if ( imgCheck == - 1 ) { error_content += "<p>Window Image must be a fully qualified url to a hosted image." ; error_content += "( <strong>Example: </strong><em>http://www.yoursite.com/images/yourImage.jpg</em> )</p>" ; } $ ( '#build-location legend' ) . after ( '<div class="slurl-error"><h4>We\'re having trouble creating your SLurl</h4>' + error_content + '</div>' ) ; document . getElementById ( 'slurl-builder' ) . scrollTop = 0 ; } else { build_url ( ) ; } } ) }
Build a SLurl validation
Makes sure there are slurl coordinates input before we attempt to generate a SLurl
Build a SLurl validation Makes sure there are slurl coordinates input before we attempt to generate a SLurl
//remove the error message if there is one