You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
playground: update URL when clicking an example
This commit is contained in:
@@ -104,6 +104,10 @@ Click an example to run it in the terminal:
|
|||||||
document.querySelectorAll('.playground-example').forEach(function(btn) {
|
document.querySelectorAll('.playground-example').forEach(function(btn) {
|
||||||
btn.addEventListener('click', function() {
|
btn.addEventListener('click', function() {
|
||||||
var cmd = btn.textContent;
|
var cmd = btn.textContent;
|
||||||
|
// Reflect the clicked example in the URL so it can be shared/bookmarked.
|
||||||
|
var url = new URL(window.location.href);
|
||||||
|
url.searchParams.set('cmd', cmd);
|
||||||
|
history.replaceState(null, '', url);
|
||||||
document.getElementById('wasm-playground').scrollIntoView({ behavior: 'smooth' });
|
document.getElementById('wasm-playground').scrollIntoView({ behavior: 'smooth' });
|
||||||
if (window.runInTerminal) {
|
if (window.runInTerminal) {
|
||||||
window.runInTerminal(cmd);
|
window.runInTerminal(cmd);
|
||||||
|
|||||||
Reference in New Issue
Block a user