diff --git a/README.md b/README.md index ba40b6f..a13fa7a 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Easy Session Manager allows you to manage your Firefox session by backing up or # Download https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/ -# Version: 0.2.3.6 -* Updated in place tab loading logic +# Version: 0.2.3.7 +* Added unhandled error handler to display any uncaught errors to the user. # Images diff --git a/src/manifest.json b/src/manifest.json index dda09da..0466b8a 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Easy Session Manager", - "version": "0.2.3.6", + "version": "0.2.3.7", "description": "Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.", "browser_specific_settings": { diff --git a/src/scripts/events.js b/src/scripts/events.js index cc081c0..b6631b6 100644 --- a/src/scripts/events.js +++ b/src/scripts/events.js @@ -1,4 +1,20 @@ -getSavedSessionIDs(); +window.onload = (eve) => { + console.log("Loaded..."); + getSavedSessionIDs(); +} + +window.onerror = function(msg, url, line, col, error) { + // Note that col & error are new to the HTML 5 spec and may not be supported in every browser. + let suppressErrorAlert = false; + let extra = !col ? '' : '\ncolumn: ' + col; + extra += !error ? '' : '\nerror: ' + error; + const data = `Error: ${msg} \nurl: ${url} \nline: ${line} ${extra}` + + messageWindow("danger", data, "", -1); + + // If you return true, then error alerts (like in older versions of Internet Explorer) will be suppressed. + return suppressErrorAlert; +}; document.addEventListener("click", (e) => { if (e.button == 0) { // Left click diff --git a/src/scripts/session-manager.js b/src/scripts/session-manager.js index bee4cf1..c3e2299 100644 --- a/src/scripts/session-manager.js +++ b/src/scripts/session-manager.js @@ -254,8 +254,7 @@ const loadSession = (json = null, replaceTabs = false) => { url: store[i].link, index: i + 1 } - : { }; - + : { }; tabsApi.create(createOption).catch( async (e) => { createOption.url = returnReplaceURL( @@ -264,7 +263,7 @@ const loadSession = (json = null, replaceTabs = false) => { store[i].link, "../images/icons/error.png" ); - + await tabsApi.create(createOption); }); } diff --git a/src/scripts/utils.js b/src/scripts/utils.js index f0d39ed..65e31f5 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.js @@ -1,7 +1,7 @@ let selectedItem = null; -const messageWindow = (type = "warning", message = "No message passed in...", target = "") => { +const messageWindow = (type = "warning", message = "No message passed in...", target = "", timeout = 3200) => { let pTag = document.createElement("P"); let text = document.createTextNode(message); let gutter = document.getElementById("message-gutter"); @@ -14,9 +14,11 @@ const messageWindow = (type = "warning", message = "No message passed in...", ta pTag.appendChild(text); gutter.prepend(pTag); + timeout = (timeout === -1) ? 6200 : (timeout > 0) ? timeout : 3200; + setTimeout(function () { clearChildNodes(gutter); - }, 3200); + }, timeout); }