<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div>
при вводе код конвертируется препроцессором написанным на javascript, меняйте на здоровье
<br>
<textarea id="ta1" oninput="edit()">
#preprocessor "please_make_this_dll.dll"
// пример
// локальные переменные $x и $y - имена поменять
sub(fn1, $x, $y)
// возвращаемое значение - имя поменять
$ret = $x * $x + $y * $y
end_sub
for ($x = 0, $x < 5)
for ($y = 0, $y < 5)
// вызов функции - сохранить возвращаемое
// значение во временную переменную
$s = $s + fn1($x, $y)
end_cyc
end_cyc
// пример 2
sub(fn2, $i)
// возвращаемой значение - имя всегда $ret
$ret = $i * ($i + 1)
end_sub
// развёртка функций должна поддерживать многократную
// вложенность
$v1 = fn2(1) + fn2(fn2(fn2(fn2(1))))
// встроенные функции не должны развёртываться
$v2 = fn2(cos(sin(fn2(1))))
// мой старый говнокод, содержащий функции, в качестве примера
$x = 662
$y = 388
logclear()
getscreen
colormode(6)
sub(clid, $c)
$ret = $c
if ($c = 4145087)
$ret = 1
end_if
if ($c = 16760703)
$ret = 2
end_if
if ($c = 8388415)
$ret = 3
end_if
if ($c = 12582911)
$ret = 4
end_if
if ($c = 4194303)
$ret = 7
end_if
if ($c = 8372223)
$ret = 8
end_if
if ($c = 16777215)
$ret = 5
end_if
end_sub
for($i=0,$i<200)
$arr[$i] = 0
end_cyc
$rowlen = 12
$firstnum = $rowlen*2 + 2
for($j=0,$j<8)
$s = ""
for($i=0,$i<8)
clid(pxl($x+40*$i,$y+40*$j))
$c = $_clid_ret
//print($i, " ", $j," ", $c)
//move($x+40*$i,$y+40*$j)
$arr[$j+$rowlen*$i+$firstnum] = $c
$s = strconcat($s, $c)
//wait(2)
end_cyc
print($s)
end_cyc
sub(at, $i, $j)
$ret = $arr[26 + 12 * $i + $j]
end_sub
sub(dirh, $i, $j, $c)
$ret = 0
if (at($i, $j) ! $c)
$v1 = (at($i-1, $j)=$c) * (1 + (at($i-2, $j)=$c))
$v2 = (at($i+1, $j)=$c) * (1 + (at($i+2, $j)=$c))
$v3 = (at($i, $j-1)=$c) + (at($i, $j+1)=$c)
$ret = ($v3 > 0) + $v1 + $v2 - ($v3 = 0)*($v1+$v2=4)
end_if
end_sub
sub(dirv, $i, $j, $c)
$ret = 0
if (at($i, $j) ! $c)
$v1 = (at($i, $j+1)=$c) * (1 + (at($i, $j+2)=$c))
$v2 = (at($i, $j-1)=$c) * (1 + (at($i, $j-2)=$c))
$v3 = (at($i+1, $j)=$c) + (at($i-1, $j)=$c)
$ret = ($v3 > 0) + $v1 + $v2 - ($v3 = 0)*($v1+$v2=4)
end_if
end_sub
print()
for($j=0,$j<8)
$s = ""
for($i=0,$i<8)
$s = strconcat($s, at($i, $j))
//wait(2)
end_cyc
print($s)
end_cyc
print()
for($j=0,$j<8)
$s = ""
for($i=0,$i<8)
$mx = 0
$c = 0
for($m=1,$m<9)
$v = dirh($i,$j, $m)
if ($v > $mx)
$mx = $v
$c = $m
end_if
$v = dirv($i,$j, $m)
if ($v > $mx)
$mx = $v
$c = $m
end_if
end_cyc
$v = $mx
$s = strconcat($s, ($v>2)*$c )
//wait(2)
end_cyc
print($s)
end_cyc
print()
halt
</textarea>
<textarea id="ta2"></textarea>
</div>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |