2013-08-28 16:53:55 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
2014-02-03 18:43:03 +00:00
|
|
|
(typeof habitrpg !== 'undefined' ? habitrpg : habitrpgStatic)
|
|
|
|
|
.controller("FooterCtrl", ['$scope', '$rootScope', 'User', '$http', 'Notification', 'API_URL',
|
2013-10-31 22:14:19 +00:00
|
|
|
function($scope, $rootScope, User, $http, Notification, API_URL) {
|
2013-08-28 16:53:55 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
External Scripts
|
|
|
|
|
JS files not needed right away (google charts) or entirely optional (analytics)
|
|
|
|
|
Each file gets loaded async via $.getScript, so it doesn't bog page-load
|
|
|
|
|
*/
|
|
|
|
|
$scope.deferredScripts = function(){
|
|
|
|
|
|
|
|
|
|
// Stripe
|
|
|
|
|
$.getScript('//checkout.stripe.com/v2/checkout.js');
|
|
|
|
|
|
|
|
|
|
// Google Analytics, only in production
|
|
|
|
|
if (window.env.NODE_ENV === 'production') {
|
2014-02-03 18:06:10 +00:00
|
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
|
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
|
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
|
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
2014-02-10 18:35:33 +00:00
|
|
|
ga('create', window.env.GA_ID, 'habitrpg.com');
|
2014-02-03 18:06:10 +00:00
|
|
|
ga('send', 'pageview');
|
2013-08-28 16:53:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scripts only for desktop
|
|
|
|
|
if (!window.env.IS_MOBILE) {
|
|
|
|
|
// Add This
|
|
|
|
|
$.getScript("//s7.addthis.com/js/250/addthis_widget.js#pubid=lefnire");
|
|
|
|
|
|
|
|
|
|
// Google Charts
|
|
|
|
|
$.getScript("//www.google.com/jsapi", function() {
|
|
|
|
|
google.load("visualization", "1", {
|
|
|
|
|
packages: ["corechart"],
|
|
|
|
|
callback: function() {}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-10-31 22:14:19 +00:00
|
|
|
}
|
2013-08-28 16:53:55 +00:00
|
|
|
|
2013-10-31 22:14:19 +00:00
|
|
|
/**
|
|
|
|
|
* Debug functions. Note that the server route for gems is only available if process.env.DEBUG=true
|
|
|
|
|
*/
|
2014-06-16 19:25:34 +00:00
|
|
|
if (_.contains(['development','test'],window.env.NODE_ENV)) {
|
2014-02-03 18:42:23 +00:00
|
|
|
$scope.addMissedDay = function(){
|
|
|
|
|
if (!confirm("Are you sure you want to reset the day?")) return;
|
|
|
|
|
var dayBefore = moment(User.user.lastCron).subtract('days', 1).toDate();
|
|
|
|
|
User.set({'lastCron': dayBefore});
|
|
|
|
|
Notification.text('-1 day, remember to refresh');
|
|
|
|
|
}
|
|
|
|
|
$scope.addTenGems = function(){
|
|
|
|
|
$http.post(API_URL + '/api/v2/user/addTenGems').success(function(){
|
|
|
|
|
User.log({});
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
$scope.addLevelsAndGold = function(){
|
|
|
|
|
User.set({
|
|
|
|
|
'stats.exp': User.user.stats.exp + 10000,
|
|
|
|
|
'stats.gp': User.user.stats.gp + 10000,
|
|
|
|
|
'stats.mp': User.user.stats.mp + 10000
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
$scope.addOneLevel = function(){
|
|
|
|
|
User.set({
|
|
|
|
|
'stats.exp': User.user.stats.exp + (Math.round(((Math.pow(User.user.stats.lvl, 2) * 0.25) + (10 * User.user.stats.lvl) + 139.75) / 10) * 10)
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-31 04:56:01 +00:00
|
|
|
}
|
2014-02-03 18:42:23 +00:00
|
|
|
|
2013-08-28 16:53:55 +00:00
|
|
|
}])
|