Skip to content

Commit

Permalink
Merge branch 'master' of github.com:karan/navi
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Goel committed Jul 20, 2014
2 parents 3535e1a + e2697e4 commit b4659ea
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 35 deletions.
24 changes: 0 additions & 24 deletions private/data/problems.json

This file was deleted.

12 changes: 12 additions & 0 deletions webapp/css/base.css
Expand Up @@ -161,3 +161,15 @@ body {
.navi-back-button:hover {
cursor: pointer;
}

#flash-message {
background: #2ecc71;
width: 30%;
padding: 40px;
font-weight: bold;
text-align: center;
color: #2a2c2b;
position: absolute; top:100px;left:50%;
margin-left: -15%;
z-index: 20;
}
3 changes: 3 additions & 0 deletions webapp/html/index.html
Expand Up @@ -12,6 +12,7 @@
</head>
<body>
<div id="app">
<div id="flash-message" style="display:none"></div>
<!-- PROFILE SCREEN -->
<div id="profile" data-bind="visible: isProfileVisible(), with: VM.profile" style="display: none">
<div class="top-bar">
Expand All @@ -28,6 +29,7 @@ <h2 class="center-title console-text">
</span>
</h2>
<h3 class="center-subtitle console-text" data-bind="text: points.text"></h3>
<h3 class="center-subtitle console-text" data-bind="text: solved.text"></h3>
</div>

<!-- CODING SCREEN -->
Expand Down Expand Up @@ -103,6 +105,7 @@ <h2 class="center-title console-text">
<script src="../js/model.screentype.js"></script>
<script src="../js/model.mode.js"></script>
<script src="../js/model.blinker.js"></script>
<script src="../js/model.flashmessage.js"></script>
<script src="../js/model.typer.js"></script>
<script src="../js/model.facebook.js"></script>
<script src="../js/model.firepad.js"></script>
Expand Down
6 changes: 6 additions & 0 deletions webapp/js/model.facebook.js
@@ -1,6 +1,12 @@
function Facebook() {
var self = this;

self.getUserData = function(callback) {
$.getJSON('/user', function(data) {
callback(data);
})
};

self.connectToFriend = function(callback) {
// See README.md
$.getJSON("/start?option=friend", function(data) {
Expand Down
13 changes: 13 additions & 0 deletions webapp/js/model.flashmessage.js
@@ -0,0 +1,13 @@
function FlashMessage(domId, delayTime) {
var self = this;
var element = document.getElementById(domId);
var delay = delayTime;

self.setMessage = function(str) {
element.innerHTML = str;
};

self.flash = function() {
$(element).fadeIn('slow').delay(delay).fadeOut('slow');
}
}
10 changes: 4 additions & 6 deletions webapp/js/model.tester.js
Expand Up @@ -6,11 +6,9 @@ function Tester() {
var RETURN = ' return ';
var END_FUNCTION = '})();';



var makeCode = function(test) {
return START_FUNCTION +
code +
return START_FUNCTION +
code +
RETURN +
test.getTestExpression() +
END_FUNCTION;
Expand Down Expand Up @@ -40,8 +38,8 @@ function Tester() {
var pass = false;
var result = null;
try {
result = eval(makeCode(self.tests()[i]));
pass = result == self.tests()[i].getExpected();
result = eval(makeCode(self.tests()[i]));
pass = result == self.tests()[i].getExpected();
} catch (e) {
pass = false;
result = null;
Expand Down
2 changes: 1 addition & 1 deletion webapp/js/viewmodel.choose.js
Expand Up @@ -59,7 +59,7 @@ function ChooseViewModel() {

self.onClickProfile = function() {
cursor.stop();
app.setScreen(SCREEN_TYPE.PROFILE);
app.setScreen(SCREEN_TYPE.PROFILE, true);
};


Expand Down
17 changes: 13 additions & 4 deletions webapp/js/viewmodel.profile.js
@@ -1,9 +1,11 @@
function ProfileViewModel() {
var self = this;
var facebook = new Facebook();
var cursor = new Blinker('profile-title-cursor', 500);
var flashMessage = new FlashMessage('flash-message', 1000);
self.title = new Typer('');
self.points = new Typer('');

self.solved = new Typer('');

self.onClickProfile = function() {
// Nada?
Expand All @@ -14,11 +16,18 @@ function ProfileViewModel() {
app.setScreen(SCREEN_TYPE.CHOOSE);
};

self.onSwitchTo = function(done) {
self.onSwitchTo = function(done, newData) {
if(newData) {
flashMessage.setMessage('Congratulations! You have increased your score!');
flashMessage.flash();
}
self.title.write(app.getUser().name, 50, function() {
self.points.write('Score: ' + app.getUser().score, 50);
facebook.getUserData(function(data) {
self.points.write('Score: ' + data.score, 50, function() {
self.solved.write('Problems Solved: ' + data.problems_solved, 50);
});
});
});
console.log(app.getUser());
cursor.start()
done();
};
Expand Down

0 comments on commit b4659ea

Please sign in to comment.