From fb250c3b677095bf65553ab998e98e8cb6e459b8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 5 May 2015 03:45:55 -0400 Subject: import webcam via postmessage --- js/ui/controls.js | 8 ++++++++ webcam.html | 4 ++++ 2 files changed, 12 insertions(+) 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; }