Skip to content

Commit 50d4aaa

Browse files
committed
Adds better logging and zen quotes
To give the shuso encouragement we will print out a cool Zen quote and advise on what to do next.
1 parent 36657c7 commit 50d4aaa

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

jskoans.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ <h1 id="qunit-header">JavaScript Koans</h1>
3030
<h2 id="qunit-banner"></h2>
3131
<h2 id="qunit-userAgent"></h2>
3232
<h3 class="welcome_message">To begin, find the file 'topics/about_asserts.js', and complete the tests.</h3>
33+
<h3 id="zen-help" style="display: none;"></h3>
3334
<ol id="qunit-tests"></ol>
3435
<div id="qunit-fixture">test markup, will be hidden</div>
3536
</body>

support/koans.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ Array.prototype.equalTo = function(compareTo) {
1616

1717
(function() {
1818

19+
var lastAssertLogReason, ignoreFurtherFailures = false;
20+
var zenMessages = [
21+
"The path to enlightenment has many stones",
22+
"Do not stray from your path, for enlightenment comes with perseverance",
23+
"The only Zen you find on tops of mountains is the Zen you bring there",
24+
"Enlightenment occurs when someone becomes inspired by information and uses it to enhance their life",
25+
"Be master of mind rather than mastered by mind",
26+
"Zen is not some kind of excitement, but concentration on our usual everyday routine",
27+
"I think self-awareness is probably the most important thing towards being a champion",
28+
"The reward of all action is to be found in enlightenment",
29+
"lasting enlightenment can be achieved only through persistent exercise of real love",
30+
"The real meaning of enlightenment is to gaze with undimmed eyes on all darkness",
31+
"Do not think you will necessarily be aware of your own enlightenment",
32+
"Enlightenment must come little by little - otherwise it would overwhelm",
33+
"The greatest gift is to give people your enlightenment, to share it. It has to be the greatest",
34+
"In the beginner's mind there are many possibilities, but in the expert's mind there are few",
35+
"Only the hand that erases can write the true thing",
36+
"Enlightenment is ego's ultimate disappointment",
37+
"Man suffers only because he takes seriously what the gods made for fun",
38+
"It is easy to believe we are each waves and forget we are also the ocean",
39+
"Working out is my biggest hobby. It's my Zen hour. I just zone out",
40+
"A self-motivation is an enlightenment of mind, empowerment of heart and enrichment of soul to arise, awake and ascend to achieve the noble and coveted goal even if it entails walking on its enervating path all alone"
41+
];
42+
1943
QUnit.config.reorder = false;
2044

2145
QUnit.done(function(results) {
@@ -34,4 +58,25 @@ Array.prototype.equalTo = function(compareTo) {
3458
}
3559
});
3660

61+
QUnit.log(function(result) {
62+
lastAssertLogReason = result.message;
63+
});
64+
65+
QUnit.testDone(function(result) {
66+
var message;
67+
if (!ignoreFurtherFailures && result.failed > 0) {
68+
ignoreFurtherFailures = true;
69+
message = "" + randomZenMessage() + "\nTry meditating on this: " + result.module + ": " + result.name + " (" + lastAssertLogReason + ")";
70+
$("#zen-help").html(message.replace(/\n/g, "<br /><br />"));
71+
console.log(message);
72+
}
73+
});
74+
75+
function randomZenMessage() {
76+
var randomIndex = Math.floor(Math.random() * zenMessages.length);
77+
var zenMessage = zenMessages[randomIndex];
78+
zenMessage = zenMessage.charAt(0).toUpperCase() + zenMessage.substr(1);
79+
return "" + zenMessage + ".";
80+
}
81+
3782
})();

0 commit comments

Comments
 (0)