Screen snippet (#55)

* adds screen snippet feature

* update return api

* udpate unit tests
This commit is contained in:
Lynn
2017-04-11 11:58:35 -07:00
committed by GitHub
parent 1e6dfec68c
commit 6b99dc541e
6 changed files with 309 additions and 0 deletions

View File

@@ -40,6 +40,12 @@
<button id='inc-badge'>increment badge count</button>
<br>
<button id='clear-badge'>clear badge count</button>
<br>
<hr>
<p>Screen Snippet (note: currently only works on mac):</p>
<button id='snippet'>get snippet</button>
<p>snippet output:</p>
<image id='snippet-img'/>
</body>
<script>
var notfEl = document.getElementById('notf');
@@ -100,5 +106,27 @@
SYM_API.setBadgeCount(0);
});
var snippetButton = document.getElementById('snippet');
snippetButton.addEventListener('click', function() {
let snippet = new SYM_API.ScreenSnippet();
snippet
.capture()
.then(gotSnippet)
.catch(snippetError);
function gotSnippet(rsp) {
if (rsp && rsp.data && rsp.type) {
var dataUrl = 'data:' + rsp.type + ',' + rsp.data;
var img = document.getElementById('snippet-img');
img.src = dataUrl;
}
}
function snippetError(err) {
alert('error getting snippet', err);
}
});
</script>
</html>