-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d5dd9a
commit 80a998e
Showing
4 changed files
with
73 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>JSWhat Browser Example</title> | ||
|
||
<script src="../dist/index.js"></script> | ||
<script> | ||
function whatIsThis() { | ||
const results = document.getElementById('results'); | ||
const textbox = document.getElementById('textbox'); | ||
|
||
const text = textbox.value; | ||
results.innerHTML = ''; | ||
|
||
const result = what.is(text); | ||
const mapped = result.map((m) => { | ||
return [ | ||
`Identified as: ${m.name}`, | ||
`Matched at: ${m.matched}`, | ||
`Description: ${m.description}`, | ||
`Tags: ${m.tags.join(', ')}`, | ||
].join('<br>'); | ||
}); | ||
|
||
results.innerHTML = 'Results: ' + result.length + '<br><br>' + mapped.join('<br><br>'); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<p>Type something into the text input below and press 'WHAT?'</p> | ||
<input id="textbox" type="text" style="width: 35%" /> | ||
<button onclick="whatIsThis()">WHAT?</button> | ||
<br /> | ||
<br /> | ||
<span id="results"> </span> | ||
</body> | ||
</html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>JSWhat Browser Example</title> | ||
|
||
<script src="../dist/index.js"></script> | ||
<!-- <script src="https://unpkg.com/[email protected]/dist/index.js"></script> --> | ||
|
||
<script> | ||
function whatIsThis() { | ||
const results = document.getElementById('results'); | ||
const input = document.getElementById('textbox'); | ||
results.innerHTML = ''; | ||
|
||
// The module will be defined as 'what' | ||
const result = what.is(input.value); | ||
|
||
const mapped = result.map((m) => { | ||
return [ | ||
`Identified as: ${m.name}`, | ||
`Matched at: ${m.matched}`, | ||
`Description: ${m.description}`, | ||
`Tags: ${m.tags.join(', ')}`, | ||
].join('<br>'); | ||
}); | ||
|
||
results.innerHTML = 'Results: ' + | ||
result.length + '\n\n' + | ||
mapped.join('\n\n'); | ||
} | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<p>Type something into the text input below and press 'WHAT?!'</p> | ||
<input id="textbox" type="text" style="width:35%" /> | ||
<button onclick="whatIsThis()">WHAT?!</button> | ||
<br/><br/> | ||
<span id="results" style="white-space: pre-wrap;" /> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const what = require('..'); | ||
// const what = require('jswhat'); | ||
|
||
// General usage | ||
const match = what.is('[email protected]')[0]; | ||
console.log('Simply match an email only\n', match.matched); | ||
|
||
// Search with a string | ||
var matches = what.is('[email protected] [email protected] [email protected]', { search: true }); | ||
const sMatched = matches.map((m) => m.matched); | ||
console.log('\nFind every possible match within\n', sMatched.join(', ')); | ||
|
||
// Filter the output by a name, short name, category or tag | ||
const fOptions = { search: true, filter: ['Email'] }; | ||
const filtered = what.is('[email protected] [email protected] [email protected]', fOptions); | ||
const fMatched = filtered.map((m) => m.matched); | ||
console.log('\nOnly match possible email addresses\n', fMatched.join(', ')); | ||
|
||
// Exclude a name, short name, category or tag | ||
const eOptions = { search: true, exclude: ['URL', 'YouTube'] }; | ||
const excluded = what.is('[email protected] [email protected] https://youtube.com/pewdiepie', eOptions); | ||
const eMatched = excluded.map((m) => m.matched); | ||
console.log('\nExclude a property from the results, in this case URLs and YouTube related\n', eMatched.join(', ')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const what = require('../'); | ||
import what from '..'; | ||
// import what from 'jswhat'; | ||
|
||
// General usage | ||
const match = what.is('[email protected]')[0]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import * as what from '../'; | ||
import what from '..'; | ||
// import what from 'jswhat'; | ||
|
||
// General usage | ||
const match = what.is('[email protected]')[0]; | ||
|