diff options
Diffstat (limited to 'js/record.js')
| -rw-r--r-- | js/record.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/js/record.js b/js/record.js index 143891c..dd7357a 100644 --- a/js/record.js +++ b/js/record.js @@ -1,4 +1,6 @@ (function(){ + if (document.getElementById("gif-recorder")) return; + var canvases = document.getElementsByTagName("canvas") if (canvases.length == 0) { alert("no canvas found"); return; } @@ -25,6 +27,7 @@ document.body.parentNode.style.height = "100%" // var template = document.getElementById("template").innerHTML var el = document.createElement("div") + el.id = "gif-recorder" // el.innerHTML = template el.innerHTML = UI_TEMPLATE document.body.appendChild(el) @@ -99,16 +102,18 @@ controls.style.display = "block" document.getElementById("record").focus() } - function _int(el){ return parseInt(el.value) } - function _float(el){ return parseFloat(el.value) } + function _int(el){ return parseInt(typeof el == "string" ? document.getElementById(el).value : el.value) } + function _float(el){ return parseFloat(typeof el == "string" ? document.getElementById(el).value : el.value) } function show(id){ document.getElementById(id).style.display="block" } function hide(id){ document.getElementById(id).style.display="none" } function enable(id){ document.getElementById(id).removeAttribute("disabled") } function disable(id){ document.getElementById(id).setAttribute("disabled","disabled") } function px(n){ return (~~n) + "px" } - function record(){ + function record(e){ + e.stopPropagation() count = _int("framecount") delay = _float("framedelay") * 1000 + console.log(count, delay) if (isNaN(count) || isNaN(delay)) return done = 0 frame_t = 0 @@ -181,7 +186,8 @@ enable("record") enable("save") } - function save (){ + function save (e){ + e.stopPropagation() if (! lastGif) return; var filename = (window.location.host + window.location.pathname).replace(/[^a-zA-Z0-9]/g,"-").replace(/-+/,"-") var blob = dataUriToBlob(lastGif) |
