Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

154 lines (143 sloc) 6.442 kb
<!DOCTYPE html>
<html lang="en" manifest="src/app.appcache">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="src/bundle.css">
<title>Elevator simulator: use JavaScript to implement your destination dispatch algorithm — elevato.rs</title>
</head>
<body data-elevators="" data-floors="">
<main>
<div class="column column-building">
<div class="building">
<dl class="shaft">
<dt class="elevator" data-at-floor="1">#0</dt>
<dd class="floor" data-level="10"></dd>
<dd class="floor" data-level="9"></dd>
<dd class="floor" data-level="8"></dd>
<dd class="floor" data-level="7"></dd>
<dd class="floor" data-level="6"></dd>
<dd class="floor" data-level="5"></dd>
<dd class="floor" data-level="4"></dd>
<dd class="floor" data-level="3"></dd>
<dd class="floor" data-level="2"></dd>
<dd class="floor" data-level="1"></dd>
</dl><dl class="shaft">
<dt class="elevator" data-at-floor="1">#1</dt>
<dd class="floor" data-level="10"></dd>
<dd class="floor" data-level="9"></dd>
<dd class="floor" data-level="8"></dd>
<dd class="floor" data-level="7"></dd>
<dd class="floor" data-level="6"></dd>
<dd class="floor" data-level="5"></dd>
<dd class="floor" data-level="4"></dd>
<dd class="floor" data-level="3"></dd>
<dd class="floor" data-level="2"></dd>
<dd class="floor" data-level="1"></dd>
</dl><dl class="shaft">
<dt class="elevator" data-at-floor="1">#2</dt>
<dd class="floor" data-level="10"></dd>
<dd class="floor" data-level="9"></dd>
<dd class="floor" data-level="8"></dd>
<dd class="floor" data-level="7"></dd>
<dd class="floor" data-level="6"></dd>
<dd class="floor" data-level="5"></dd>
<dd class="floor" data-level="4"></dd>
<dd class="floor" data-level="3"></dd>
<dd class="floor" data-level="2"></dd>
<dd class="floor" data-level="1"></dd>
</dl><dl class="shaft">
<dt class="elevator" data-at-floor="1">#3</dt>
<dd class="floor" data-level="10"></dd>
<dd class="floor" data-level="9"></dd>
<dd class="floor" data-level="8"></dd>
<dd class="floor" data-level="7"></dd>
<dd class="floor" data-level="6"></dd>
<dd class="floor" data-level="5"></dd>
<dd class="floor" data-level="4"></dd>
<dd class="floor" data-level="3"></dd>
<dd class="floor" data-level="2"></dd>
<dd class="floor" data-level="1"></dd>
</dl>
</div>
</div>
<div class="column column-code">
<div id="level-selector">
<select name="level" id="level">
<option value="">Select your scenario</option>
<optgroup label="Introduction">
<option value="1">One elevator, one request</option>
<option value="2">One elevator, two requests very close, one a bit later</option>
<option value="3">Two elevators, two requests very close</option>
</optgroup>
<optgroup label="challenge">
<option value="4">Two elevators, lots of requests</option>
<option value="5">Three elevators, lots of requests</option>
<option value="6">Three elevators, random</option>
<option value="7">Four elevators, lots of requests</option>
</optgroup>
</select>
<button id="run-code">▸ Run this scenario</button>
<button id="stop-code">■ Stop</button>
</div>
<textarea id="editor" cols="30" rows="10">// called each time someone requests an elevator
function onFloorRequest(floorNumber, elevators) {
elevators[0].moveTo(floorNumber);
}
// called each time an elevator becomes idle
function onElevatorIdle(elevator, elevators) {
if (elevator.requestedAt.length){
console.log('elevators['+elevator.id+'] still have to go to', elevator.requestedAt);
}
else{
console.log('elevators['+elevator.id+'] is now idle');
}
}</textarea>
<div id="cheatsheet">
<h2>Cheatsheet</h2>
<dl class="tips-list">
<dt class="tips-list__item">
<code>floorNumber</code>
<span class="tips-list__item--type">Number</span></dt>
<dd>Étage demandé vers lequel on doit envoyer un ascenseur.</dd>
<dt class="tips-list__item">
<code>elevators</code>
<span class="tips-list__item--type">Object[]</span></dt>
<dd>Liste des ascenseurs disponibles. Le nombre varie en fonction des scénarios.</dd>
<dt class="tips-list__item">
<code>elevators[x]</code>
<span class="tips-list__item--type">Object</span></dt>
<dd>Objet représentant un ascenseur.</dd>
<dt class="tips-list__item">
<code>elevators[x].moveTo</code>
<span class="tips-list__item--type">Function</span></dt>
<dd>Demande à l'ascenseur de se rendre à l'étage spécifié.</dd>
<dt class="tips-list__item">
<code>elevators[x].nextFloor</code>
<span class="tips-list__item--type">Number</span></dt>
<dd>Étage vers lequel l'ascenseur se rend.</dd>
<dt class="tips-list__item">
<code>elevators[x].previousFloor</code>
<span class="tips-list__item--type">Number</span></dt>
<dd>Étage de provenance de l'ascenseur.</dd>
<dt class="tips-list__item">
<code>elevators[x].requestedAt</code>
<span class="tips-list__item--type">Number[]</span></dt>
<dd>Liste des étages que l'ascenseur doit servir.</dd>
</dl>
</div>
</div>
</main>
<footer>
<p>
Made with <span class="love">♥</span> at <a href="http://mozillafestival.org/">Mozilla Festival 2013</a>
by <a href="https://twitter.com/DavidBruant" rel="author">David Bruant</a>
and <a href="https://twitter.com/oncletom" rel="author">Thomas Parisot</a>
<a href="https://github.com/oncletom/elevato.rs/issues">Contribute an idea</a>
or
<a href="https://github.com/oncletom/elevato.rs/issues">report an issue</a>
</p>
</footer>
<script src="src/bundle.js" async></script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.