diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-05-05 03:45:55 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-05-05 03:45:55 -0400 |
| commit | fb250c3b677095bf65553ab998e98e8cb6e459b8 (patch) | |
| tree | 89b68167093d38e2315afb8c99371265a8ae463b | |
| parent | 0e4af74255a161ecaeb31cd831c33d9698ca1e9e (diff) | |
import webcam via postmessage
| -rw-r--r-- | js/ui/controls.js | 8 | ||||
| -rw-r--r-- | webcam.html | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/js/ui/controls.js b/js/ui/controls.js index fa2a240..734472d 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -93,7 +93,15 @@ var controls = (function(){ controls.webcam = new Tool (webcam_el) controls.webcam.load = function(){ + this.loaded = true webcam_close.addEventListener("click", function(){ controls.webcam.blur() }) + window.addEventListener("message", function(e){ + if (e.origin !== window.location.origin) return + controls.webcam.blur() + controls.circle.focus() + import_textarea.value = e.data + clipboard.import_colorcode() + }) } controls.webcam.use = function(){ if (! this.loaded) { diff --git a/webcam.html b/webcam.html index fe0d57b..edf4ddc 100644 --- a/webcam.html +++ b/webcam.html @@ -43,6 +43,7 @@ label.cbox { min-width: 50px; } <script src="http://asdf.us/dither/js/util.js"></script> <script src="js/color_code.js"></script> <script> + var width = parseInt( width_span.innerHTML = width_el.value ) var ratio = parseFloat( ratio_el.value ) var nn = $(nn_el).prop('checked') @@ -108,6 +109,9 @@ function save (){ MircColor.fromCanvas(camera, saveText, { width: width, ratio: ratio, neighbor: nn }) function saveText(rows) { text_style.value = MircColor.ascii(rows) + if (window.self !== window.top) { + window.parent.postMessage(text_style.value, "*"); + } } } nn_el.addEventListener('change', function(){ |
