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

              
                <link rel="stylesheet" href="https://unpkg.com/vex-js@4.1.0/dist/css/vex.css">
<link rel="stylesheet" href="https://unpkg.com/vex-js@4.1.0/dist/css/vex-theme-default.css">

<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/fuzzy-search@3.0.1/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)
    .map(Future.from_val)
    .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', async function(ev) {
  ev.preventDefault();
  window.result.innerHTML = await 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 new Promise((resolve, reject) => {
    vex.dialog.confirm({
      message: `Did you mean ${value}?`,
      callback: resolve
    });
  });
}

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_future || 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: () => Maybe(thing),
    tap: fun => (fun(thing), Maybe(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`
  };
}

function Future(promise_thing) {
  return {
    map: fun => Future(promise_thing.then(map_future(fun))),
    and_then: fun => Future(promise_thing.then(map_future(fun))),
    or_else: fun => Future(promise_thing.catch(fun)),
    tap: fun => Future(promise_thing.then(val => (fun(val), val))),
    unwrap_or: arg => promise_thing.catch(val => arg),

    filter: fun => Future(promise_thing.then(filter_future(fun))),

    is_just: false,
    is_nothing: false,
    is_future: true,
    inspect: () => `<Promise>`
  };
}

Future.from_val = function(val) {
  return Future(Promise.resolve(val));
};

function map_future(fun) {
  return val => {
    let promise_content = val;

    if (Maybe(promise_content).is_nothing) {
      Promise.reject();
      return;
    }

    if (promise_content.is_just) {
      promise_content = val.unwrap_or();
    }

    const result = Maybe(fun(promise_content));

    if (result.is_just) {
      return result.unwrap_or();
    }

    return Promise.reject();
  };
}

function filter_future(predicate_fun) {
  return val => {
    const result = predicate_fun(val);

    if (result.then) {
      const return_result = predicate_res =>
        predicate_res ? val : Promise.reject();

      return result.then(return_result);
    }

    return result ? val : Promise.reject();
  };
}

// what are you doing here? Get out!!
vex.defaultOptions.className = 'vex-theme-default';

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