From 01b8d129794a5b3f1878f6d878f3961abc58bb85 Mon Sep 17 00:00:00 2001 From: Tyler Bean Date: Mon, 27 Jun 2022 18:50:07 -0500 Subject: [PATCH] wrap select/deselect funcs in try/catch block --- code-payload.js | 20 +++++++++++++++----- statusio-selector.user.js | 20 +++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/code-payload.js b/code-payload.js index e61ab0f..d258591 100644 --- a/code-payload.js +++ b/code-payload.js @@ -6,7 +6,7 @@ // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js // @grant GM_addStyle // @grant GM_setClipboard -// @version 0.0.12 +// @version 0.0.13 // ==/UserScript== // draw frame @@ -1768,12 +1768,22 @@ function checkButtonColor(buttonName) { return color; }; function selectCheckbox(box) { - box.filter("A")[0].classList.add("checked"); - box.filter("INPUT")[0].checked = true; + try { + box.filter("A")[0].classList.add("checked"); + box.filter("INPUT")[0].checked = true; + } catch (e) { + console.log(box + " does not appear to exist"); + } + }; function deselectCheckbox(box) { - box.filter("A")[0].classList.remove("checked"); - box.filter("INPUT")[0].checked = false; + try { + box.filter("A")[0].classList.remove("checked"); + box.filter("INPUT")[0].checked = false; + } catch (e) { + console.log(box + " does not appear to exist"); + } + }; function apply() { if (debugFlag == true) { diff --git a/statusio-selector.user.js b/statusio-selector.user.js index 9b416fe..2b9cde7 100644 --- a/statusio-selector.user.js +++ b/statusio-selector.user.js @@ -4,7 +4,7 @@ // @description Effort to simplify configuration of incidents/maintenance windows // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js -// @version 0.0.12 +// @version 0.0.13 // @downloadUrl https://gitea.frijole.lol/o0beaner/js-statusio-selector/raw/branch/main/statusio-selector.user.js // @updateURL https://gitea.frijole.lol/o0beaner/js-statusio-selector/raw/branch/main/statusio-selector.user.js // @include /^https?://app\.status\.io/dashboard/.*/?(maintenance|incident)/create$/ @@ -1804,12 +1804,22 @@ function checkButtonColor(buttonName) { return color; }; function selectCheckbox(box) { - box.filter("A")[0].classList.add("checked"); - box.filter("INPUT")[0].checked = true; + try { + box.filter("A")[0].classList.add("checked"); + box.filter("INPUT")[0].checked = true; + } catch (e) { + console.log(box + " does not appear to exist"); + } + }; function deselectCheckbox(box) { - box.filter("A")[0].classList.remove("checked"); - box.filter("INPUT")[0].checked = false; + try { + box.filter("A")[0].classList.remove("checked"); + box.filter("INPUT")[0].checked = false; + } catch (e) { + console.log(box + " does not appear to exist"); + } + }; function apply() { if (debugFlag == true) {