Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created September 22, 2018 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/b2822e40d35ca199eaedcc15e72bc11a to your computer and use it in GitHub Desktop.
Save enjalot/b2822e40d35ca199eaedcc15e72bc11a to your computer and use it in GitHub Desktop.
vocab [UNLISTED]
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<textarea id="input"></textarea>
<div id="text">Hello, I am Nathan</div>
<script>
var vocab = [];
// Feel free to change or delete any of the code you see in this editor!
d3.select("#input").on("input", function() {
console.log("input", this.value)
d3.select("#text").text(this.value)
})
d3.select("#text").on("mouseup", function() {
console.log("selection", window.getSelection() )
console.log(window.getSelection().toString())
var selected = window.getSelection()
var word = selected.toString()
// lookup in CEDICT
// add to data structure
//vocab.push( { word: word, definition: definition })
// rerender table with new word
})
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment