cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
                  <div class="section no-pad-bot yellow lighten-3">
        <div id="show-case" class="container">
            <div class="section">
                <!--   Icon Section   -->
                <div class="row">
                    <div class="col s12 m12">
                        <div class="icon-block">
                            <h2 class="center black-text light header subtitle"><i class="fa fa-file-code-o"></i> <a href="http://battuta.medunes.net" target="_blank">Battuta</a> Show case</h2>
                            <div class="col s4">
                                <label class="left-align" for="country">Country</label>
                                <select class="brwoser-default" id="country"></select>
                            </div>

                            <div class="col s4">
                                <label class="left-align" for="region">Region</label>
                                <select class="brwoser-default" id="region"></select>    
                            </div>

                            <div class="col s4">
                                 <label class="left-align" for="city">City</label>
                                <select class="autocomplete" id="city"></select>
                            </div>
                        </div>
                    </div>
                </div>
                 <div class="row">
                    <div class="col s2 m2"></div>  
                    <div class="col s6 m6">
                        <div id="location" class="orange lighten-1 black-text"></div>  
                    </div>  
                </div>
            </div>
        </div>
    </div>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Indie+Flower');

.section.no-pad-bot
{
	padding-bottom:14px !important;
}
#show-case a
{
  text-decoration: underline;
  color:#600;
}
#location
{
	white-space: nowrap !important;
}
            
          
!
            
              
 	//-------------------------------SELECT CASCADING-------------------------//
  	var currentCities=[];
// This is a demo API key that can only be used for a short period of time, and will be unavailable soon. You should rather request your API key (free)  from http://battuta.medunes.net/ 	
var BATTUTA_KEY="00000000000000000000000000000000"
  	// Populate country select box from battuta API
	url="https://battuta.medunes.net/api/country/all/?key="+BATTUTA_KEY+"&callback=?";
  	$.getJSON(url,function(countries)
  	{
  		console.log(countries);
      $('#country').material_select();
	    //loop through countries..
	    $.each(countries,function(key,country)
	    {
	        $("<option></option>")
	         				.attr("value",country.code)
	         				.append(country.name)
	                     	.appendTo($("#country"));
	       
	    }); 
	    // trigger "change" to fire the #state section update process
	    $("#country").material_select('update');
	    $("#country").trigger("change");
	    

  	});
    
    $("#country").on("change",function()
  	{
  	
  		countryCode=$("#country").val();
  		
  		// Populate country select box from battuta API
	    url="https://battuta.medunes.net/api/region/"
	    +countryCode
	    +"/all/?key="+BATTUTA_KEY+"&callback=?";

  		$.getJSON(url,function(regions)
  		{
  			$("#region option").remove();
		    //loop through regions..
		    $.each(regions,function(key,region)
		    {
		        $("<option></option>")
		         				.attr("value",region.region)
		         				.append(region.region)
		                     	.appendTo($("#region"));
		    });
		    // trigger "change" to fire the #state section update process
	    	$("#region").material_select('update');
	    	$("#region").trigger("change");
	    	
	    }); 
	    
  	});
  	$("#region").on("change",function()
  	{
  		
  		// Populate country select box from battuta API
  		countryCode=$("#country").val();
		region=$("#region").val();
	    url="https://battuta.medunes.net/api/city/"
	    +countryCode
	    +"/search/?region="
	    +region
	    +"&key="
	    +BATTUTA_KEY
	    +"&callback=?";
  		
  		$.getJSON(url,function(cities)
  		{
  			currentCities=cities;
        	var i=0;
        	$("#city option").remove();
        
		    //loop through regions..
		    $.each(cities,function(key,city)
		    {
		        $("<option></option>")
		         				.attr("value",i++)
		         				.append(city.city)
		                .appendTo($("#city"));
		    });
		    // trigger "change" to fire the #state section update process
	    	$("#city").material_select('update');
	    	$("#city").trigger("change");
	    	
	    }); 
	    
  	});	
  	$("#city").on("change",function()
  	{
      currentIndex=$("#city").val();
      currentCity=currentCities[currentIndex];
      city=currentCity.city;
      region=currentCity.region;
      country=currentCity.country;
      lat=currentCity.latitude;
      lng=currentCity.longitude;
      $("#location").html('<i class="fa fa-map-marker"></i> <strong> '+city+"/"+region+"</strong>("+lat+","+lng+")");
    });
   //-------------------------------END OF SELECT CASCADING-------------------------//
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console