Disable debug data in Angular unless debug mode is enabled
Performaaance!
This commit is contained in:
parent
b94d64f80f
commit
79ebead64f
1 changed files with 14 additions and 1 deletions
|
@ -2,6 +2,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch']);
|
var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch']);
|
||||||
|
weechat.config(['$compileProvider', function ($compileProvider) {
|
||||||
|
$compileProvider.debugInfoEnabled(false);
|
||||||
|
}]);
|
||||||
|
|
||||||
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', 'notifications', 'utils', function ($rootScope, $scope, $store, $timeout, $log, models, connection, notifications, utils) {
|
weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', 'notifications', 'utils', function ($rootScope, $scope, $store, $timeout, $log, models, connection, notifications, utils) {
|
||||||
|
|
||||||
|
@ -63,13 +66,23 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
|
|
||||||
// Enable debug mode if "?debug=1" or "?debug=true" is set
|
// Enable debug mode if "?debug=1" or "?debug=true" is set
|
||||||
(function() {
|
(function() {
|
||||||
|
var hasReloaded = false;
|
||||||
window.location.search.substring(1).split('&').forEach(function(f) {
|
window.location.search.substring(1).split('&').forEach(function(f) {
|
||||||
var segs = f.split('=');
|
var segs = f.split('=');
|
||||||
if (segs[0] === "debug" && ["true", "1"].indexOf(segs[1]) != -1) {
|
if (segs[0] === "debug" && ["true", "1"].indexOf(segs[1]) != -1) {
|
||||||
$rootScope.debugMode = true;
|
$rootScope.debugMode = true;
|
||||||
return;
|
} else if (segs[0] === "debugReload" && segs[1] === "1") {
|
||||||
|
hasReloaded = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// If we haven't reloaded yet, do an angular reload with debug infos
|
||||||
|
// store whether this has happened yet in a GET parameter
|
||||||
|
if ($rootScope.debugMode && !hasReloaded) {
|
||||||
|
document.location.search += "&debugReload=1";
|
||||||
|
setTimeout(function() {
|
||||||
|
angular.reloadWithDebugInfo();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue