Unverified Commit 0150b803 authored by cgm78's avatar cgm78 Committed by GitHub
Browse files

Adding Final autocomplete files

parent e0e99840
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
// Logs query events into the console.
document.querySelector("#autoComplete").addEventListener("autoComplete", function(event) {
    console.log(event.detail);
  });

/**
 * @class autoComplete
 * @classdesc Declares a new autocomplete that is ran when the user enters more data into the autocomplete box.
 */
var newAutocomplete = new autoComplete({
    //Defines the data that will be returned inside of the autocomplete.
    /**
     * @property data
     * @description Gets JSON array of features.
     */
    data: { 
      //Gets data source for autocomplete asyncronusly.
      src: async () => {
@@ -81,13 +80,6 @@ var newAutocomplete = new autoComplete({
        //Displays result items as list items.
        element: "li"
    },
    /*noResults: () => {                     // Action script on noResults      | (Optional)
        const result = document.createElement("li");
        result.setAttribute("class", "no_result");
        result.setAttribute("tabindex", "1");
        result.innerHTML = "No Results";
        document.querySelector("#autoComplete_list").appendChild(result);
    },*/

    /**
     * @function onSelection
+14 −13
Original line number Diff line number Diff line
	//Declares global variable name array.
	var nameArray = [];      

	//Pushs data onto nameArray variable.
@@ -7,18 +6,18 @@
	var index = 0;
	//While the feature at the current index is not null.
    while (data.features[index] != null){
		//Log the feature name.
		console.log(data.features[index].properties.clean_feature + " " + index);
		//Push the json object at the current index onto nameArray.
		nameArray.push(data.features[index].properties);
		//Increment index.
        index++;
         }
	}
	
	function getServer(){
	//Ajax call to WFS server with the features/data need.
		$.ajax({
			//URL of WFS server.
		url: "https://wms.wr.usgs.gov/cgi-bin/mapserv?map=/var/www/html/mapfiles/earth/moon_nomen_wfs.map&service=WFS&version=1.1.0&&TYPENAME=MOON_POINT&REQUEST=getfeature&PropertyName=clean_feature&outputformat=application/json;%20subtype=geojson&Filter=%3CFilter%3E%3CPropertyIsLike%20wildcard=%27*%27%20singleChar=%27.%27%20escape=%27!%27%3E%3CPropertyName%3Eclean_feature%3C/PropertyName%3E%3CLiteral%3EA*%3C/Literal%3E%3C/PropertyIsLike%3E%3C/Filter%3E",
			url: ("https://wms.wr.usgs.gov/cgi-bin/mapserv?map=/var/www/html/mapfiles/earth/moon_nomen_wfs.map&service=WFS&version=1.1.0&&TYPENAME=MOON_POINT&REQUEST=getfeature&PropertyName=clean_feature&outputformat=application/json;%20subtype=geojson&Filter=%3CFilter%3E%3CPropertyIsLike%20wildcard=%27*%27%20singleChar=%27.%27%20escape=%27!%27%3E%3CPropertyName%3Eclean_feature%3C/PropertyName%3E%3CLiteral%3EA*%3C/Literal%3E%3C/PropertyIsLike%3E%3C/Filter%3E"),
			//Data type of file on WFS server/above URL.
			dataType: 'json',
			//When the server is successfully connect to, run loadGeoJson function.
@@ -26,3 +25,5 @@
			//Timeout on connection to server (WILL NEED TO LOWER WHEN NEW SERVER IS AVAILABLE).
			timeout : 50000
			});
	}
	getServer();
 No newline at end of file
+5 −5

File changed.

Contains only whitespace changes.