Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <form id="search_form">
  <label for="search_input">Search a word</label>
  <input id="search_input" type="text">
  <button type="submit">Submit</button>
</form>

<div id="result"></div>

              
            
!

CSS

              
                
              
            
!

JS

              
                import FuzzySearch from 'https://unpkg.com/[email protected]/src/FuzzySearch.js'

const entries = data();
const fzf = new FuzzySearch(Object.keys(entries), [], {
  caseSensitive: false,
  sort: true
});

const search = create_search(entries, true);
const search_name = create_search(entries, false);
const update_input = val => (window.search_form[0].value = val);

const suggest_word = value => () =>
  suggest(value)
    .filter(confirm_word)
    .tap(update_input)
    .map(search);

const search_word = word =>
  search(word)
    .or_else(() => search_name(word))
    .or_else(suggest_word(word))
    .map(format)
    .unwrap_or('word not found');

window.search_form.addEventListener('submit', function(ev) {
  ev.preventDefault();
  window.result.innerHTML = search_word(ev.target[0].value);
});

// Utilities
function create_search(data, exact) {
  return input => {
    const word = exact ? input : capitalize(input);
    return Maybe(data[word]);
  };
}

function suggest(word) {
  const matches = fzf.search(word);
  return Maybe(matches[0]);
}

function confirm_word(value) {
  return confirm(`Did you mean ${value}`);
}

function capitalize(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
}

function format(results) {
  return results.join('<br>');
}

function Maybe(the_thing) {
  if (the_thing === null || the_thing === undefined || the_thing.is_nothing) {
    return Nothing();
  }

  if (the_thing.is_just) {
    return the_thing;
  }

  return Just(the_thing);
}

function Just(thing) {
  return {
    map: fun => Maybe(fun(thing)),
    and_then: fun => fun(thing),
    or_else: () => Just(thing),
    tap: fun => (fun(thing), Just(thing)),
    unwrap_or: () => thing,

    filter: predicate_fun => (predicate_fun(thing) ? Maybe(thing) : Nothing()),

    is_just: true,
    is_nothing: false,
    inspect: () => `Just(${thing})`
  };
}

function Nothing() {
  return {
    map: Nothing,
    and_then: Nothing,
    or_else: fun => fun(),
    tap: Nothing,
    unwrap_or: arg => arg,

    filter: Nothing,

    is_just: false,
    is_nothing: true,
    inspect: () => `Nothing`
  };
}


// what are you doing here? Get out!!
function data() {
  return {
    "abandoned industrial site": ["Site that cannot be used for any purpose, being contaminated by pollutants."], 
    "abandoned vehicle": ["A vehicle that has been discarded in the environment, urban or otherwise, often found wrecked, destroyed, damaged or with a major component part stolen or missing."],
    "abiotic factor": ["Physical, chemical and other non-living environmental factor."],
    "access road": ["Any street or narrow stretch of paved surface that leads to a specific destination, such as a main highway."],
    "access to the sea": ["The ability to bring goods to and from a port that is able to harbor sea faring vessels."],
    "accident": ["An unexpected, unfortunate mishap, failure or loss with the potential for harming human life, property or the environment.", "An event that happens suddenly or by chance without an apparent cause."], 
    "accumulator": ["A rechargeable device for storing electrical energy in the form of chemical energy, consisting of one or more separate secondary cells.\\n(Source: CED)"], 
    "acidification": ["Addition of an acid to a solution until the pH falls below 7."], 
    "acidity": ["The state of being acid that is of being capable of transferring a hydrogen ion in solution."], 
    "acidity degree": ["The amount of acid present in a solution, often expressed in terms of pH."], 
    "acid rain": ["Rain having a pH less than 5.6."], 
    "acid": ["A compound capable of transferring a hydrogen ion in solution.", "Being harsh or corrosive in tone.", "Having an acid, sharp or tangy taste.", "A powerful hallucinogenic drug manufactured from lysergic acid.", "Having a pH less than 7, or being sour, or having the strength to neutralize  alkalis, or turning a litmus paper red."],
    "acoustic filter": ["A device employed to reject sound in a particular range of frequencies while passing sound in another range of frequencies."],
    "acoustic insulation": ["The process of preventing the transmission of sound by surrounding with a nonconducting material."],
    "acoustic level": ["Physical quantity of sound measured, usually expressed in decibels.\\n(Source: KORENa)"],
    "Paris": ["The capital and largest city of France."]
  };
}
              
            
!
999px

Console