<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://unpkg.com/chance@1.0.8/dist/chance.min.js"></script>
<script src="https://unpkg.com/lodash@4.17.4/lodash.min.js"></script>
<script src="https://unpkg.com/kefir@3.7.1/dist/kefir.min.js"></script>
<script src="https://unpkg.com/react@15.5.4/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15.5.4/dist/react-dom.js"></script>
</head>
<body>
<main/>
dfdf*
</body>
</html>
const
commitGenerator = (function(CHARSET){ return ()=> _.range(7).map(()=> _.sample(CHARSET)).join(''); })("abcdefgh0123456789".split('')),
formatTime = (span)=> [60*60*1000, 60*1000, 1000].reduce((function(currentSpan){ return (acc, multiplier)=> {
let part = ~~(currentSpan/multiplier);
currentSpan -= part * multiplier;
return acc.concat([part]);
};
})(span) ,[]).map(_.partial(_.padStart, _, 2, '0')).join(':'),
randomChance = ()=> chance[_.sample(["name", "sentence", "email", "ip", "ipv6", "url"])]();
Kefir
.combine(_.range(10).map((id)=> {
let baseEnvironment = {
id,
create: Date.now() - _.random(1000*60*60*24),
name: chance.word({ syllables: 10 }),
user_name: chance.name({ middle: false }),
user_email: chance.email(),
state: _.sample(["run", "stop"]),
type: _.sample(["service", "image", "composition"]),
commit: commitGenerator(),
branch: chance.word()
};
return Kefir.repeat((index) => Kefir.later(index === 0 ? 0 : _.random(5000), randomChance()))
.merge(Kefir.later(0, _.range(8).map(randomChance)).flatten())
.map((line)=> [_.sample(["> ", "* ", " ", ""]), line].join(''))
.slidingWindow(8)
.map((log) => _.assign(baseEnvironment, { log }))
}))
.combine(Kefir.fromPoll(1000, Date.now))
.throttle(200)
.onValue(([environment, now])=> {
const [ul, li, div, span, h1, figure, img, figcaption, pre] = ["ul", "li", "div", "span", "h1", "figure", "img", "figcaption", "pre"].map((elName)=> (attrs = {}, structChildren = [], children = undefined)=> React.createElement(elName, attrs, children, structChildren));
ReactDOM.render(
ul({ className: "environments" }, [], environment.map(
({ id, name, user_name, user_email, state, type, commit, branch, log, create })=> li({ key: id }, [
div({ className: ["environment", state, type].join(' ') }, [
h1({}, [
name,
span({ className: "properties" }, [
span({ className: "repository_commit" }, [ commit ]),
span({ className: "repository_branch" }, [ branch ])
])
]),
figure({}, [
img({ src: `https://robohash.org/${commit}.png?size=150x150` }, []),
figcaption({}, [user_name])
]),
pre({}, [div({}, [formatTime(now - create)]), log.map((line)=> span({ className: ["a","e","i","o","u"].includes(_.flow(_.first, _.lowerCase)(line)) ? "error" : "ok" }, [line]))])
])
]))
)
, document.querySelector('main'));
});
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. |