WET core

Questions or comments?

Work in progress

This page is a work in progress.

Purpose

Core WET object.

Working example

Language (wb.lang)

WET's language is derived from the html element's lang attribute. A formatted version of the page's language code is stored in the wb.lang variable.

By default, the variable's value will be derived from the first two characters of the page's language code. If a longer code is specified, it'll be re-used as the variable's value so long as it corresponds to one of WET's built-in languages (i.e. pt-BR for Portuguese [Brazilian] or zh-Hans for Chinese [Simplified]).

Implementations that want to provide custom i18n files for longer language codes (e.g. en-CA, en-US, etc) can do so by adding data-wb-core and data-lang-long="" attributes to WET's script element.

WET will also attempt to load an i18n file named after the variable. Plugins won't initialize if the i18n file fails to load.

Configuration

Type Option Description How to configure Values
HTML attribue data-wb-core Customizes WET's core variables. Use with other data-* attributes. Add a data-wb-core attribute to WET's script element None
HTML attribue data-lang-long Extends wb.lang's support for long language codes (> 2 characters). Use with the data-wb-core attribute. Add a data-wb-core attribute to WET's script element Space-separated BCP 47 language codes

JS API

wb.findPotentialPII(str, scope, opts) - Find most common Personal Identifiable Information (PII) in a string

Find most common Personal Identifiable Information (PII) in a string and return either the cleaned string either true/false

This function can have the following parameters

Working example


wb.findPotentialPII( "email:test@test.com, phone:123 123 1234", true )

It will return: "email:, phone:"


	wb.findPotentialPII( "email:test@test.com, phone:123 123 1234", false )

It will return: true


wb.findPotentialPII( "email:test@test.com, phone:123 123 1234", { email:1 }{ replaceWith: [REDACTED/CAVIARDÉ] } )

It will return:"email:[REDACTED/CAVIARDÉ], phone:123 123 1234"


wb.findPotentialPII( "email:test@test.com, phone:123 123 1234, numéro de cas 12345678", { "customCase":/\b(?:case[\s-]?number[\s\-\\.]?(?:\d{5,10}))|(?:numéro[\s-]?de[\s-]?cas[\s\-\\.]?(?:\d{5,10}))/ig }, { useFullBlock:1})

It will return: "phone:████████████, email:█████████████, postalCode:██████, ██████████████████████"

Native DOM event on ready

WET-BOEW triggers a native DOM event once all plugins have been initialized. The event is called wet-boew-ready.

Here is an example of how it can be used:

document.addEventListener( "wet-boew-ready", function( e ) {
	...code...
});

Source code

WET core source code on GitHub

Date modified: