| 1 |
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> |
| 2 |
<head> |
| 3 |
<title>dojox.gfx: Career Aptitude Test</title> |
| 4 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 |
<style type="text/css"> |
| 6 |
@import "../../../dojo/resources/dojo.css"; |
| 7 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 8 |
</style> |
| 9 |
<script type="text/javascript" src="../../../dojo/dojo.js"></script> |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
<script type="text/javascript"> |
| 20 |
|
| 21 |
dojo.require("dojox.gfx"); |
| 22 |
dojo.require("dojox.gfx.move"); |
| 23 |
dojo.require("dojox.gfx.fx"); |
| 24 |
dojo.require("dojo.colors"); |
| 25 |
dojo.require("dojo.fx"); |
| 26 |
|
| 27 |
var g = dojox.gfx, m = g.matrix; |
| 28 |
|
| 29 |
var container, surface, surface_size, |
| 30 |
vat, freezer, broiler, score, startTime, endTime; |
| 31 |
|
| 32 |
var totalItems = 10, goodItems = 0, badItems = 0; |
| 33 |
|
| 34 |
var radius = 30, // pixels |
| 35 |
slowRate = 10, // speed in ms per pixel |
| 36 |
fastRate = 2, // speed in ms per pixel |
| 37 |
freezeTime = 5000, // ms |
| 38 |
frostTime = 2000, // ms |
| 39 |
broilTime = 5000, // ms |
| 40 |
burnTime = 2000, // ms |
| 41 |
pulseTime = 200; // ms |
| 42 |
|
| 43 |
function getRand(from, to){ |
| 44 |
return Math.random() * (to - from) + from; |
| 45 |
} |
| 46 |
|
| 47 |
function inRect(rect, crd){ |
| 48 |
return rect.x <= crd.x && crd.x < rect.x + rect.width && |
| 49 |
rect.y <= crd.y && crd.y < rect.y + rect.height; |
| 50 |
} |
| 51 |
|
| 52 |
function getCenter(circle){ |
| 53 |
var shape = circle.getShape(), matrix = circle.getTransform(); |
| 54 |
return m.multiplyPoint(matrix ? matrix : m.identity, shape.cx, shape.cy); |
| 55 |
} |
| 56 |
|
| 57 |
function getDuration(x1, y1, x2, y2, rate){ |
| 58 |
return Math.floor(Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) * rate); |
| 59 |
} |
| 60 |
|
| 61 |
function updateScore(){ |
| 62 |
var shape = score.getShape(); |
| 63 |
endTime = (new Date()).getTime(); |
| 64 |
shape.text = goodItems + " item" + (goodItems != 1 ? "s" : "") + |
| 65 |
" in " + ((endTime - startTime) / 1000) + "s" |
| 66 |
score.setShape(shape); |
| 67 |
|
| 68 |
if(goodItems + badItems != totalItems){ return; } |
| 69 |
|
| 70 |
var rating = goodItems / (endTime - startTime) * 60000 * (40 - radius) / 10; |
| 71 |
dojo.byId("result_pass").style.display = badItems || rating < 5 ? "none" : ""; |
| 72 |
dojo.byId("result_dollar").innerHTML = rating.toFixed(2); |
| 73 |
dojo.byId("result_but").style.display = badItems ? "" : "none"; |
| 74 |
dojo.byId("result_waste").innerHTML = (badItems * 5).toFixed(2); |
| 75 |
dojo.byId("result_and").style.display = badItems ? "none" : ""; |
| 76 |
dojo.byId("result_fail").style.display = badItems ? "" : "none"; |
| 77 |
if(!badItems){ |
| 78 |
var pos; |
| 79 |
if(rating < 1){ |
| 80 |
pos = "Junior Speciment Flipper"; |
| 81 |
}else if(rating < 2){ |
| 82 |
pos = "Senior Speciment Flipper"; |
| 83 |
}else if(rating < 4){ |
| 84 |
pos = "Shift Supervisor"; |
| 85 |
}else if(rating < 6){ |
| 86 |
pos = "Joint Manager"; |
| 87 |
}else if(rating < 8){ |
| 88 |
pos = "Night Director"; |
| 89 |
}else if(rating < 10){ |
| 90 |
pos = "Morning Director"; |
| 91 |
}else if(rating < 12){ |
| 92 |
pos = "Vice President"; |
| 93 |
}else if(rating < 14){ |
| 94 |
pos = "Senior Vice President"; |
| 95 |
}else if(rating < 16){ |
| 96 |
pos = "Chief of Something"; |
| 97 |
}else{ |
| 98 |
pos = "Nominal President"; |
| 99 |
} |
| 100 |
dojo.byId("result_pos").innerHTML = pos; |
| 101 |
} |
| 102 |
var anim1 = dojo.fx.wipeOut({ |
| 103 |
node: "gfx_holder", |
| 104 |
duration: 500, |
| 105 |
delay: 1000 |
| 106 |
}), |
| 107 |
anim2 = dojo.fx.wipeIn({ |
| 108 |
node: "result", |
| 109 |
duration: 500, |
| 110 |
delay: 1000 |
| 111 |
}); |
| 112 |
anim1.play(); |
| 113 |
anim2.play(); |
| 114 |
} |
| 115 |
|
| 116 |
function showStatus(circle, text){ |
| 117 |
var c = getCenter(circle), |
| 118 |
status = surface.createText({}); |
| 119 |
status.moveToBack().setFill(new dojo.Color([0, 0, 0, 0.5])) |
| 120 |
.setFont({family: "serif", variant: "small-caps", weight: "bold"}) |
| 121 |
.setShape({x: c.x, y: c.y, text: text, align: "middle"}); |
| 122 |
var anim = dojo.fx.combine([ |
| 123 |
g.fx.animateFill({ |
| 124 |
shape: status, |
| 125 |
duration: 3000, |
| 126 |
color: {end: "transparent"} |
| 127 |
}), |
| 128 |
g.fx.animateTransform({ |
| 129 |
shape: status, |
| 130 |
duration: 3000, |
| 131 |
transform: [ |
| 132 |
{name: "translate", start: [0, 0], end: [0, 300]}, |
| 133 |
{name: "original"} |
| 134 |
] |
| 135 |
}) |
| 136 |
]); |
| 137 |
dojo.connect(anim, "onEnd", function(){ status.removeShape(); }); |
| 138 |
anim.play(); |
| 139 |
} |
| 140 |
|
| 141 |
function moveToPile(shape, bad){ |
| 142 |
if(shape.moveable){ |
| 143 |
shape.moveable.destroy(); |
| 144 |
delete shape.moveable; |
| 145 |
} |
| 146 |
|
| 147 |
var oldColor = shape.getFill(), c = getCenter(shape), |
| 148 |
newX = 80 + (bad ? badItems++ : goodItems++) * 2.25 * 10, |
| 149 |
newY = bad ? 445 : 415, |
| 150 |
duration = getDuration(newX, newY, c.x, c.y, fastRate), |
| 151 |
anim = dojo.fx.chain([ |
| 152 |
g.fx.animateFill({ |
| 153 |
shape: shape, |
| 154 |
duration: 250, |
| 155 |
color: {end: "transparent"} |
| 156 |
}), |
| 157 |
g.fx.animateTransform({ |
| 158 |
shape: shape, |
| 159 |
duration: duration, |
| 160 |
transform: [ |
| 161 |
{name: "translate", start: [0, 0], end: [newX - c.x, newY - c.y]}, |
| 162 |
{name: "original"} |
| 163 |
] |
| 164 |
}), |
| 165 |
g.fx.animateFill({ |
| 166 |
shape: shape, |
| 167 |
duration: 250, |
| 168 |
color: {end: oldColor} |
| 169 |
}), |
| 170 |
g.fx.animateTransform({ |
| 171 |
shape: shape, |
| 172 |
duration: duration, |
| 173 |
transform: [ |
| 174 |
{name: "scaleAt", start: [1, newX, newY], end: [10 / radius, newX, newY]}, |
| 175 |
{name: "original"} |
| 176 |
] |
| 177 |
}) |
| 178 |
]); |
| 179 |
dojo.connect(anim, "onEnd", updateScore); |
| 180 |
anim.play(); |
| 181 |
} |
| 182 |
|
| 183 |
function repeatMove(){ |
| 184 |
var rect = vat.getShape(), c = getCenter(this), |
| 185 |
x = getRand(rect.x + radius, rect.x + rect.width - radius), |
| 186 |
y = getRand(rect.y + radius, rect.y + rect.height - radius), |
| 187 |
duration = getDuration(x, y, c.x, c.y, slowRate); |
| 188 |
this.anim = g.fx.animateTransform({ |
| 189 |
duration: duration, |
| 190 |
shape: this, |
| 191 |
transform: [ |
| 192 |
{name: "translate", start: [0, 0], end: [x - c.x, y - c.y]}, |
| 193 |
{name: "original"} |
| 194 |
] |
| 195 |
}); |
| 196 |
dojo.connect(this.anim, "onEnd", this, repeatMove); |
| 197 |
this.anim.play(); |
| 198 |
} |
| 199 |
|
| 200 |
function repeatFrost(){ |
| 201 |
this.status = "frozen"; |
| 202 |
this.setStroke({color: "orange", width: 3}); |
| 203 |
showStatus(this, "Ready"); |
| 204 |
this.anim = g.fx.animateFill({ |
| 205 |
duration: frostTime, |
| 206 |
shape: this, |
| 207 |
color: {end: "white"} |
| 208 |
}); |
| 209 |
// calculate a shift |
| 210 |
var dx = getRand(-radius, radius) / 2, dy = getRand(-radius, radius) / 2, sign = 1; |
| 211 |
this.applyLeftTransform({dx: -dx / 2, dy: -dy / 2}); |
| 212 |
dojo.connect(this.anim, "onAnimate", this, function(){ |
| 213 |
this.applyLeftTransform({dx: sign * dx, dy: sign * dy}); |
| 214 |
sign = -sign; |
| 215 |
}); |
| 216 |
dojo.connect(this.anim, "onEnd", this, function(){ |
| 217 |
showStatus(this, "Frozen"); |
| 218 |
moveToPile(this, true); |
| 219 |
}); |
| 220 |
this.anim.play(); |
| 221 |
} |
| 222 |
|
| 223 |
function repeatFreeze(){ |
| 224 |
this.status = "freezing"; |
| 225 |
this.setStroke({color: "black", width: 3}); |
| 226 |
this.anim = g.fx.animateFill({ |
| 227 |
duration: freezeTime, |
| 228 |
shape: this, |
| 229 |
color: {end: "blue"} |
| 230 |
}); |
| 231 |
// calculate a shift |
| 232 |
var dx = getRand(-radius, radius) / 2, dy = getRand(-radius, radius) / 2, sign = 1; |
| 233 |
this.applyLeftTransform({dx: -dx / 2, dy: -dy / 2}); |
| 234 |
dojo.connect(this.anim, "onAnimate", this, function(){ |
| 235 |
this.applyLeftTransform({dx: sign * dx, dy: sign * dy}); |
| 236 |
sign = -sign; |
| 237 |
}); |
| 238 |
dojo.connect(this.anim, "onEnd", this, repeatFrost); |
| 239 |
this.anim.play(); |
| 240 |
} |
| 241 |
|
| 242 |
function repeatBurn(){ |
| 243 |
this.status = "burnt"; |
| 244 |
this.setStroke({color: "orange", width: 3}); |
| 245 |
showStatus(this, "Done"); |
| 246 |
var anim1 = g.fx.animateFill({ |
| 247 |
duration: burnTime, |
| 248 |
shape: this, |
| 249 |
color: {end: "black"} |
| 250 |
}); |
| 251 |
var anim2 = new dojo.Animation({ |
| 252 |
duration: freezeTime, |
| 253 |
curve: [0, freezeTime] |
| 254 |
}); |
| 255 |
var matrix = this.getTransform(), c = getCenter(this); |
| 256 |
dojo.connect(anim2, "onAnimate", this, function(val){ |
| 257 |
var scale = (val % pulseTime) / pulseTime / 4 + 1; |
| 258 |
this.setTransform([m.scaleAt(scale, c), matrix]); |
| 259 |
}); |
| 260 |
this.anim = dojo.fx.combine([anim1, anim2]); |
| 261 |
dojo.connect(this.anim, "onEnd", this, function(){ |
| 262 |
showStatus(this, "Burnt"); |
| 263 |
moveToPile(this, true); |
| 264 |
}); |
| 265 |
this.anim.play(); |
| 266 |
} |
| 267 |
|
| 268 |
function repeatBroil(){ |
| 269 |
this.status = "broiling"; |
| 270 |
this.setStroke({color: "black", width: 3}); |
| 271 |
var anim1 = g.fx.animateFill({ |
| 272 |
duration: broilTime, |
| 273 |
shape: this, |
| 274 |
color: {end: "red"} |
| 275 |
}); |
| 276 |
var anim2 = new dojo.Animation({ |
| 277 |
duration: freezeTime, |
| 278 |
curve: [0, freezeTime] |
| 279 |
}); |
| 280 |
var matrix = this.getTransform(), c = getCenter(this); |
| 281 |
dojo.connect(anim2, "onAnimate", this, function(val){ |
| 282 |
var scale = (val % pulseTime) / pulseTime / 4 + 1; |
| 283 |
this.setTransform([m.scaleAt(scale, c), matrix]); |
| 284 |
}); |
| 285 |
this.anim = dojo.fx.combine([anim1, anim2]); |
| 286 |
dojo.connect(this.anim, "onEnd", this, repeatBurn); |
| 287 |
this.anim.play(); |
| 288 |
} |
| 289 |
|
| 290 |
function drag(mover){ |
| 291 |
var shape = mover.shape; |
| 292 |
shape.anim.stop(); |
| 293 |
shape.anim = null; |
| 294 |
} |
| 295 |
|
| 296 |
function drop(mover){ |
| 297 |
var c = getCenter(mover.shape); |
| 298 |
do{ // break block |
| 299 |
if(inRect(vat.getShape(), c)){ |
| 300 |
if(mover.shape.status == "fresh"){ |
| 301 |
repeatMove.call(mover.shape); |
| 302 |
return; |
| 303 |
} |
| 304 |
break; |
| 305 |
} |
| 306 |
if(inRect(freezer.getShape(), c)){ |
| 307 |
if(mover.shape.status == "fresh"){ |
| 308 |
repeatFreeze.call(mover.shape); |
| 309 |
return; |
| 310 |
} |
| 311 |
break; |
| 312 |
} |
| 313 |
if(inRect(broiler.getShape(), c)){ |
| 314 |
if(mover.shape.status == "frozen"){ |
| 315 |
repeatBroil.call(mover.shape); |
| 316 |
return; |
| 317 |
} |
| 318 |
break; |
| 319 |
} |
| 320 |
if(mover.shape.status == "burnt"){ |
| 321 |
moveToPile(mover.shape, false); // good |
| 322 |
return; |
| 323 |
} |
| 324 |
}while(false); |
| 325 |
moveToPile(mover.shape, true); // bad |
| 326 |
} |
| 327 |
|
| 328 |
function makePatties(n){ |
| 329 |
var rect = vat.getShape(); |
| 330 |
for(var i = 0; i < n; ++i){ |
| 331 |
var cx = getRand(rect.x + radius, rect.x + rect.width - radius), |
| 332 |
cy = getRand(rect.y + radius, rect.y + rect.height - radius), |
| 333 |
patty = surface.createCircle({ |
| 334 |
cx: cx, cy: cy, r: radius |
| 335 |
}).setFill("green").setStroke({ |
| 336 |
color: "black", |
| 337 |
width: 3 |
| 338 |
}); |
| 339 |
patty.status = "fresh"; |
| 340 |
patty.moveable = new g.Moveable(patty); |
| 341 |
repeatMove.call(patty); |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
function initGfx(){ |
| 346 |
container = dojo.byId("gfx_holder"); |
| 347 |
surface = g.createSurface(container, 500, 500); |
| 348 |
surface_size = {width: 500, height: 500}; |
| 349 |
|
| 350 |
vat = surface.createRect({x: 10, y: 210, width: 480, height: 180}) |
| 351 |
.setStroke({color: "black", width: 7, join: "round"}); |
| 352 |
surface.createText({x: 15, y: 230, text: "Ye Olde Vat v3.2"}) |
| 353 |
.setFill("black"); |
| 354 |
|
| 355 |
freezer = surface.createRect({x: 10, y: 10, width: 230, height: 180}) |
| 356 |
.setStroke({color: "blue", width: 7, join: "round"}); |
| 357 |
surface.createText({x: 15, y: 30, text: "Deep Freeze 7000"}) |
| 358 |
.setFill("blue"); |
| 359 |
|
| 360 |
broiler = surface.createRect({x: 260, y: 10, width: 230, height: 180}) |
| 361 |
.setStroke({color: "red", width: 7, join: "round"}); |
| 362 |
surface.createText({x: 265, y: 30, text: "Hellfire Broiler A4"}) |
| 363 |
.setFill("red"); |
| 364 |
|
| 365 |
surface.createText({x: 15, y: 420, text: "Good:"}) |
| 366 |
.setFont({weight: "bold"}).setFill("green"); |
| 367 |
surface.createText({x: 15, y: 450, text: "Bad:"}) |
| 368 |
.setFont({weight: "bold"}).setFill("red"); |
| 369 |
surface.createText({x: 15, y: 480, text: "Total:"}) |
| 370 |
.setFont({weight: "bold"}).setFill("black"); |
| 371 |
score = surface.createText({x: 80, y: 485, text: "0"}) |
| 372 |
.setFont({weight: "bold", size: "24pt"}).setFill("black"); |
| 373 |
surface.createText({x: 120, y: 460, text: "DROP HERE!"}) |
| 374 |
.setFont({size: "50px"}) |
| 375 |
.setFill(new dojo.Color([0, 0, 0, 0.1])).moveToBack(); |
| 376 |
|
| 377 |
dojo.subscribe("/gfx/move/start", drag); |
| 378 |
dojo.subscribe("/gfx/move/stop", drop); |
| 379 |
makePatties(totalItems); |
| 380 |
|
| 381 |
startTime = (new Date()).getTime(); |
| 382 |
|
| 383 |
// cancel text selection and text dragging |
| 384 |
dojo.connect(container, "ondragstart", dojo, "stopEvent"); |
| 385 |
dojo.connect(container, "onselectstart", dojo, "stopEvent"); |
| 386 |
} |
| 387 |
|
| 388 |
//dojo.addOnLoad(initGfx); |
| 389 |
|
| 390 |
function startTest(level){ |
| 391 |
radius = level; |
| 392 |
var anim = dojo.fx.wipeOut({ |
| 393 |
node: "explanation", |
| 394 |
duration: 500 |
| 395 |
}); |
| 396 |
dojo.connect(anim, "onEnd", function(){ |
| 397 |
dojo.byId("gfx_holder").style.display = ""; |
| 398 |
initGfx(); |
| 399 |
}); |
| 400 |
anim.play(); |
| 401 |
} |
| 402 |
|
| 403 |
</script> |
| 404 |
|
| 405 |
<style type="text/css"> |
| 406 |
.movable { cursor: pointer; } |
| 407 |
</style> |
| 408 |
|
| 409 |
</head> |
| 410 |
<body> |
| 411 |
<h1>dojox.gfx: Career Aptitude Test</h1> |
| 412 |
<p>Warning: Canvas renderer doesn't implement event handling.</p> |
| 413 |
|
| 414 |
<div id="explanation"> |
| 415 |
<p>Thank you for your interest in <em>"I can't believe it's manure" Eateries™</em> |
| 416 |
and for submitting your resume for our review. While this is an automated response, |
| 417 |
please be assured that every resume is reviewed by us, and forwarded to the hiring |
| 418 |
managers if the skills fit our needs.</p> |
| 419 |
<p>In order order to evaluate your skills we ask you to take a career aptitude test. |
| 420 |
You will have an exciting chance to operate one of our state-of-the-art workstations |
| 421 |
remotely. Don't forget: |
| 422 |
</p> |
| 423 |
<ol> |
| 424 |
<li>Fish out a live speciment of <em>dung-42</em> from the container.</li> |
| 425 |
<li>Freeze it until you see an orange glow to kill the elements and make it less green.</li> |
| 426 |
<li>Broil it until you see the orange glow again, and drop it on the table below.</li> |
| 427 |
<li>You have to process all items without wasting resources and in minimal time.</li> |
| 428 |
</ol> |
| 429 |
<p>Warnings: don't overfreeze, don't overheat, don't drop the speciment, don't change the sequence, |
| 430 |
don't touch the speciment in heating and freezing chambers until it is's ready.</p> |
| 431 |
<p>Use your head and your mouse!</p> |
| 432 |
<p>Please select the desired position:</p> |
| 433 |
<table> |
| 434 |
<tr> |
| 435 |
<td>Workstation Supervisor </td> |
| 436 |
<td><button onclick="startTest(30);">Apply</button></td> |
| 437 |
</tr> |
| 438 |
<tr> |
| 439 |
<td>Shift Director </td> |
| 440 |
<td><button onclick="startTest(20);">Apply</button></td> |
| 441 |
</tr> |
| 442 |
<tr> |
| 443 |
<td>Vice President #49653 </td> |
| 444 |
<td><button onclick="startTest(10);">Apply</button></td> |
| 445 |
</tr> |
| 446 |
</table> |
| 447 |
</div> |
| 448 |
|
| 449 |
<div id="gfx_holder" style="width: 500px; height: 500px; display: none;"></div> |
| 450 |
|
| 451 |
<div id="result" style="display: none;"> |
| 452 |
<p id="result_pass"><strong>Impressive! Please contact us immediately.</strong></p> |
| 453 |
<p>You have made $<span id="result_dollar"></span> per minute for us. |
| 454 |
<span id="result_but">But you wasted $<span id="result_waste"></span> in materials.</span> |
| 455 |
<span id="result_and">It qualifies you to be a <em id="result_pos"></em>.</span> |
| 456 |
</p> |
| 457 |
<p id="result_fail">Should our hiring managers have an interest in your skills and |
| 458 |
capabilities, they will contact you directly. In addition, we will keep |
| 459 |
your resume on file for one year.</p> |
| 460 |
</div> |
| 461 |
|
| 462 |
</body> |
| 463 |
</html> |