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
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