Add error log window
Try and fix issue with iOS file extension selector
This commit is contained in:
parent
220ac2e1b0
commit
0b13ab1ebd
@ -34,8 +34,9 @@
|
||||
document.body.style.setProperty('--color-dark', stored_theme.colors.dark);
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
window.ErrorLog = [];
|
||||
window.onerror = (message, file, line) => {
|
||||
window.ErrorLog.push({message, file, line})
|
||||
if (typeof Blockbench != 'undefined' && Blockbench.setup_successful) return;
|
||||
|
||||
let error_element = document.querySelector('#loading_error_detail');
|
||||
|
@ -46,7 +46,7 @@ Object.assign(Blockbench, {
|
||||
Blockbench.read(fileNames, options, cb)
|
||||
} else {
|
||||
let isIOS = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
|
||||
(navigator.userAgent.includes("Mac") && "ontouchend" in document);
|
||||
(navigator.userAgent && navigator.userAgent.includes("Mac") && "ontouchend" in document);
|
||||
|
||||
if (isIOS && options.extensions && options.extensions.length > 1) {
|
||||
let options = [];
|
||||
@ -59,10 +59,10 @@ Object.assign(Blockbench, {
|
||||
form: {
|
||||
extension: {label: 'File Type', type: 'select', options}
|
||||
},
|
||||
onConfirm({extension}) {
|
||||
onConfirm(formResult) {
|
||||
$('<input '+
|
||||
'type="file'+
|
||||
'" accept=".'+extension+
|
||||
'" accept=".'+formResult.extension+
|
||||
'" multiple="'+(options.multiple === true)+
|
||||
'">').on('change', function(e) {
|
||||
Blockbench.read(this.files, options, cb)
|
||||
|
@ -905,6 +905,17 @@ const MenuBar = {
|
||||
Blockbench.openLink('https://www.blockbench.net/wiki/api/index');
|
||||
}},
|
||||
'open_dev_tools',
|
||||
{name: 'Error Log', condition: () => window.ErrorLog.length, icon: 'error', color: 'red', keybind: {toString: () => window.ErrorLog.length.toString()}, click() {
|
||||
let lines = window.ErrorLog.slice(0, 64).map((error) => {
|
||||
return Interface.createElement('p', {}, `${error.message}\n - In .${error.file.split(location.origin).join('')} : ${error.line}`);
|
||||
})
|
||||
new Dialog({
|
||||
id: 'error_log',
|
||||
title: 'Error Log',
|
||||
lines,
|
||||
singleButton: true
|
||||
}).show();
|
||||
}},
|
||||
{name: 'menu.help.developer.reset_storage', icon: 'fas.fa-hdd', click: () => {
|
||||
if (confirm(tl('menu.help.developer.reset_storage.confirm'))) {
|
||||
localStorage.clear()
|
||||
|
Loading…
x
Reference in New Issue
Block a user