Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <span class="center">(1) Enter City Name, (2) Drag and drop a json file</span>
<input type="text" id="city" name="city" value="atlanta"> 
<div id="drop_zone">Drop files here</div>
<output id="list"></output>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Roboto');
* {
  font-family: 'Roboto', sans-serif;
}
#drop_zone {
  color      : black;
  border     : 4px dashed black;
  padding    : 20px;
  width      : 500px;
  height     : 100px;
  text-align : center;
  margin     : 0 auto;
  background : rgb(233,233,233);
  box-shadow : 0px 8px 24px rgba(0,0,0,0.25);
  transition : all 400ms ease;
}
#drop_zone.active{
    box-shadow : 0px 8px 44px rgba(0,0,0,0.5);
    border-color: green;
}
#city{
  outline: none;
  padding: 7px;
  border: 3px solid black;
  font-size: 16px;
  margin: 10px auto;
  display: block;
}
.center{
  text-align:center;
  margin: 0 auto;
  display: block;
}
              
            
!

JS

              
                console.clear();

function handleFileSelect(e) {

  e.stopPropagation();
  e.preventDefault();

  var city = document.querySelector("#city").value.toLowerCase();
  var files = e.dataTransfer.files; 

    //======------====== FILE READING ======------======//
    var reader = new FileReader();
    reader.onerror = function(e){};
    reader.onprogress = function(e){}
    reader.onabort = function(e) {};
    reader.onloadstart = function(e){};
    reader.onload = function(e) {
      document.querySelector("#drop_zone").classList.remove("active");
      var json = e.target.result; // INPUT IS JSON TEXT FILE
      var edited_rows = [];
      json = JSON.parse(json);
      json.table_rows.rows.map(function(entry){
        if (entry[4].toLowerCase() == city ){
          edited_rows.push(entry);
        }
      });
      json.table_rows.rows = edited_rows;
      console.log(json);
      // DOWNLOAD FILE
      var element = document.createElement('a');
      element.setAttribute('href', 'data:text/plain;charset=utf-8,'+encodeURIComponent(JSON.stringify(json, null, "\t" )));
      element.setAttribute('download', "edited.json");
      element.style.display = 'none';
      document.body.appendChild(element);
      element.click();
      document.body.removeChild(element);     
    
    }
    reader.readAsText(files[0]);

  };

function handleDragOver(e) {
  document.querySelector("#drop_zone").classList.add("active");
  e.stopPropagation();
  e.preventDefault();
  e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}

var dropZone = document.getElementById('drop_zone');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleFileSelect, false);
dropZone.addEventListener('dragleave', function(){
  document.querySelector("#drop_zone").classList.remove("active");
}, false);


              
            
!
999px

Console