gui: Show Javascript error indicator on dev builds, remove logging of missing translations
This commit is contained in:
committed by
Jakob Borg
parent
181939c841
commit
492e92d65d
13
gui/default/syncthing/development/logbar.html
Normal file
13
gui/default/syncthing/development/logbar.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="dev-top-bar" id="dev-top-bar">
|
||||
<link href="assets/css/dev.css" rel="stylesheet">
|
||||
<div class="row">
|
||||
<div class="col-xs-4"><b>DEV</b></div>
|
||||
<div id="log" class="col-xs-8">
|
||||
<span>
|
||||
JS:
|
||||
<span class="dev-error fa fa-exclamation-triangle"> errors <span id="log_error">0</span></span>
|
||||
<span class="dev-warn fa fa-frown-o"> warn <span id="log_warn">0</span></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
39
gui/default/syncthing/development/logbar.js
Normal file
39
gui/default/syncthing/development/logbar.js
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
function intercept(method, handler) {
|
||||
var console = window.console;
|
||||
var original = console[method];
|
||||
console[method] = function () {
|
||||
handler(method);
|
||||
// do sneaky stuff
|
||||
if (original.apply) {
|
||||
// Do this for normal browsers
|
||||
original.apply(console, arguments);
|
||||
} else {
|
||||
// Do this for IE
|
||||
var message = Array.prototype.slice.apply(arguments).join(' ');
|
||||
original(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function handleConsoleCall(type) {
|
||||
var element = document.querySelector('#log_' + type);
|
||||
if (element) {
|
||||
if (!element.classList.contains("hasCount")) {
|
||||
element.classList.add("hasCount");
|
||||
}
|
||||
|
||||
var devTopBar = document.querySelector('#dev-top-bar');
|
||||
devTopBar.style.display = 'block';
|
||||
|
||||
element.innerHTML = parseInt(element.innerHTML) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (window.console) {
|
||||
var methods = ['error', 'warn'];
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
intercept(methods[i], handleConsoleCall);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user