Skip to content

Instantly share code, notes, and snippets.

@dralletje
Last active December 8, 2020 16:12
Show Gist options
  • Save dralletje/07e06af8f329c6bd9a0105fca40a283d to your computer and use it in GitHub Desktop.
Save dralletje/07e06af8f329c6bd9a0105fca40a283d to your computer and use it in GitHub Desktop.
### A Pluto.jl notebook ###
# v0.12.16
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
el
end
end
# ╔═╡ 64788292-396f-11eb-2811-496a68065593
@bind run_code html"""<script>
let button = html`<button>YOUR TEXT</button>`
button.value = "dont_run"
button.addEventListener('click', () => {
button.value = "run";
button.dispatchEvent(new CustomEvent('input'))
setTimeout(() => {
button.value = "dont_run";
button.dispatchEvent(new CustomEvent('input'))
})
})
return button
</script>"""
# ╔═╡ 6489629e-396f-11eb-09d2-4db93badfee5
# This cell is just to see the internals, you can remove this
run_code
# ╔═╡ 6479337c-396f-11eb-169a-f368ae319bee
thing_you_are_mutating = []
# ╔═╡ 6490e828-396f-11eb-011c-d3aead13118a
begin
run_code === "run" && begin
push!(thing_you_are_mutating, time())
end
# Return the thing, so Pluto will show the latest version here
thing_you_are_mutating
end
# ╔═╡ Cell order:
# ╠═64788292-396f-11eb-2811-496a68065593
# ╠═6489629e-396f-11eb-09d2-4db93badfee5
# ╠═6479337c-396f-11eb-169a-f368ae319bee
# ╠═6490e828-396f-11eb-011c-d3aead13118a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment