This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JSX { | |
static _indent = 0; | |
static createElement(type = '', props = null, ...child) { | |
return { | |
type, | |
props, | |
child | |
}; | |
} | |
static render({type, props, child}) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Omg</title> | |
</head> | |
<body> | |
<pre contenteditable> | |
</pre> | |
<p>X: <input type="number" value="3"></p> | |
<p>Y: <input type="number" value="5"></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// o <- end | |
// / \ n | |
// f g \ / | |
// \ / m n | |
// e \ / | |
// | p | | |
// h d \ / | |
// \ | l | |
// i c / | |
// \ | k |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<script> | |
(async function() { | |
const fetchImage = async (url) => { | |
const data = await fetch(url); | |
const buffer = await data.arrayBuffer(); | |
const blob = new Blob([buffer], { type: "image/png"}); | |
return blob; | |
} | |
const sendImage = (blob, url = "http://foo.com/submitform.php", name = "image.png") => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class ImageFactory { | |
static _index = 0; | |
static _colors = ["red", "orange", "yellow", "green", "skyblue", "blue", "cyan"]; | |
static _increment() { | |
const self = ImageFactory; | |
return self._index = (++self._index > self._colors.length - 1) ? 0 : self._index; | |
} | |
static createImage(height = 100, width = 100) { | |
const canvas = document.createElement("canvas"); | |
const context = canvas.getContext("2d"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Drag and drop</title> | |
<style> | |
.red { background-color: red; } | |
.green { background-color: green; } | |
.blue { background-color: blue; } | |
.root { position: fixed; } | |
.box { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Drag and drop</title> | |
<style> | |
.ball { | |
width: 200px; | |
height: 200px; | |
position: absolute; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Frame</title> | |
</head> | |
<body> | |
<button>Send message</button> | |
<script> | |
(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const visualize = (target) => { | |
const {x, y, height, width} = target.getBoundingClientRect(); | |
const div = document.createElement('div'); | |
[div.style.position, div.style.opacity, div.style.zIndex] = ['fixed', 0.5, 999]; | |
[div.style.backgroundColor, div.style.border] = ['green', '1px solid black']; | |
[div.style.height, div.style.width] = [`${height}px`, `${width}px`]; | |
[div.style.left, div.style.top] = [`${x}px`, `${y}px`]; | |
div.style.transition = 'opacity 0.5s'; | |
div.className = 'visualizer'; |
OlderNewer