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 I = arg => arg;
const K = arg => () => arg;

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

const suggest_word = value => () =>
  suggest(value)
    .chain(Future.of)
    .filter(confirm_word)
    .map(update_search);

const search_word = word =>
  search(word)
    .altchain(() => search_name(word))
    .altchain(suggest_word(word))
    .map(format)
    .cata(I, K('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 Nothing() {
  return {
    map: Nothing,
    chain: Nothing,
    ap: Nothing,
    cata: function(just_path, nothing_path) {
      return nothing_path();
    },
    
    alt: function(arg) {
      return arg;
    },
    altchain: function(fn) {
      return fn();
    },
    filter: Nothing,

    is_just: false,
    is_nothing: true
  };
}

function Just(value) {
  return {
    map: function(fn) {
      return Maybe(fn(value));
    },
    chain: function(fn) {
      return fn(value);
    },
    ap: function(functor) {
      return functor.map(function(fn) {
        return fn(value);
      });
    },
    cata: function(just_path, nothing_path) {
      return just_path(value);
    },
    
    alt: function() {
      return Just(value);
    },
    altchain: function() {
      return Just(value);
    },
    filter: function(predicate) {
      return predicate(value) 
        ? Just(value)
        : Nothing();
    },

    is_just: true,
    is_nothing: false
  };
}

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

  return Just(value);
}

function Future(val) {
  if (typeof val.then !== 'function') {
    var promise = Promise.resolve(val);
  } else {
    var promise = val;
  }

  return {
    map: function(fn) {
      return Future(promise.then(fn));
    },
    ap: function(functor) {
      return functor.map(function(fn) {
        return promise.then(fn);
      });
    },
    cata: function(success, err) {
      return promise.then(success).catch(err);
    },
    
    alt: function(value) {
      return Future(promise.catch(function() {
        return value;
      }));
    },
    altchain: function(fn) {
      return Future(promise.catch(fn));
    },
    filter: function(predicate) {
      var fn = function(value) {
        var result = predicate(value);
        if(result.then) {
          return result.then(function(real) {
            return real ? value : Promise.reject(false);
          });
        }

        return result ? value : Promise.reject(false);
      }
      
      return Future(promise.then(fn));
    },

    is_future: true
  };
}

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

// The arguments here should be flipped
// but i'm only using it once so it doesn't matter.
function unpack(M, fallback) {
  return M.cata(I, K(fallback));
}

function tap(fn, arg) {
  if (arguments.length === 1) {
    return tap.bind(this, fn);
  }

  return fn(arg), arg;
}

function pipe() {
  var fns = arguments;

  return function() {
    var acc = fns[0].apply(this, arguments);

    for (var i = 1; i < fns.length; i++) {
      acc = fns[i](acc);
    }

    return acc;
  };
}

// 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