From 51e5817cbd64ad078d4c84ebb278c76845af13e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 22 Dec 2014 21:14:28 +0100 Subject: [PATCH] Fix debug mode manipulating window.location.search isn't reliable --- js/glowingbear.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/js/glowingbear.js b/js/glowingbear.js index 688833e..1e7fc3a 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1,7 +1,10 @@ (function() { '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'], function($compileProvider) { + // hacky way to be able to find out if we're in debug mode + weechat.compileProvider = $compileProvider; +}); weechat.config(['$compileProvider', function ($compileProvider) { // hack to determine whether we're executing the tests if (typeof(it) === "undefined" && typeof(describe) === "undefined") { @@ -69,22 +72,16 @@ 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; - } 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); + if ($rootScope.debugMode && !weechat.compileProvider.debugInfoEnabled()) { + angular.reloadWithDebugInfo(); } })();