add reset button

Conflicts:
	lib/app/index.js
This commit is contained in:
Tyler Renelle 2012-10-24 20:51:50 -04:00
parent fe08c1e3cb
commit 677266acf5
3 changed files with 33 additions and 3 deletions

View file

@ -312,6 +312,17 @@ ready(function(model) {
model.set('_items.weapon', content.items.weapon[1]);
return model.set('_user.balance', model.get('_user.balance') - 0.50);
};
exports.reset = function(e, el) {
model.set('_user.tasks', {});
_.each(['habit', 'daily', 'todo', 'completed', 'reward'], function(type) {
model.set("_user." + type + "Ids", []);
return model.refList("_" + type + "List", "_user.tasks", "_user." + type + "Ids");
});
model.set('_user.stats.hp', 50);
model.set('_user.stats.money', 0);
model.set('_user.stats.exp', 0);
return model.set('_user.stats.lvl', 1);
};
setTimeout(scoring.cron, 1);
return setInterval(scoring.cron, 3600000);
});

View file

@ -263,6 +263,17 @@ ready (model) ->
model.set '_items.weapon', content.items.weapon[1]
model.set '_user.balance', (model.get('_user.balance') - 0.50)
exports.reset = (e, el) ->
model.set '_user.tasks', {}
_.each ['habit', 'daily', 'todo', 'completed', 'reward'], (type) ->
model.set "_user.#{type}Ids", []
model.refList "_#{type}List", "_user.tasks", "_user.#{type}Ids"
model.set('_user.stats.hp', 50)
model.set('_user.stats.money', 0)
model.set('_user.stats.exp', 0)
model.set('_user.stats.lvl', 1)
# ========== CRON ==========
# FIXME seems can't call scoring.cron() instantly, have to call after some time (2s here)

View file

@ -22,15 +22,23 @@
</button>
<ul class="dropdown-menu">
<li><a href="#settings-modal" data-toggle="modal">Settings</a></li>
<!-- FIXME href='/logout' isn't redirecting the page.. window.history? -->
<li><a href='/logout' onclick="window.location='/logout'">Logout</a></li>
<li><a href="#reset-modal" data-toggle="modal">Reset</a></li>
<li><a href='/logout'>Logout</a></li>
</ul>
</div>
<app:myModal modalId="settings-modal" header="Settings">
<strong>User ID</strong><br/>
<small>Copy this ID for use in third party applications.</small>
<pre class=prettyprint>{_user.id}</pre><br/>
</app:myModal>
<app:myModal modalId="reset-modal" header="Reset">
<p>This resets your entire account - your tasks will be deleted and your character will start over.</p>
<p>This is highly discouraged because you'll lose historical data, which is useful for graphing your progress over time. However, some people find it useful in the beginning after playing with the app for a while.</p>
<button data-dismiss="modal" x-bind=click:reset class="btn btn-danger btn-large">Reset</button>
</app:myModal>
{/}
</div>