From 79ebead64f713f488042c69f4cbb8dbe2637bde3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Fri, 31 Oct 2014 10:07:41 +0100 Subject: [PATCH] Disable debug data in Angular unless debug mode is enabled Performaaance! --- js/glowingbear.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 8a31781..66b9730 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -2,6 +2,9 @@ 'use strict'; 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) { @@ -63,13 +66,23 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Enable debug mode if "?debug=1" or "?debug=true" is set (function() { + var hasReloaded = false; window.location.search.substring(1).split('&').forEach(function(f) { var segs = f.split('='); if (segs[0] === "debug" && ["true", "1"].indexOf(segs[1]) != -1) { $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); + } })();