From d9b0ed7c10d90b46e1ca17281d80d835664190a1 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Thu, 5 Oct 2023 09:27:09 -0400 Subject: [PATCH 1/2] Only look for CMD-K shortcuts --- emhttp/plugins/gui.search/gui_search.page | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/gui.search/gui_search.page b/emhttp/plugins/gui.search/gui_search.page index 20323cbe1..46c532448 100755 --- a/emhttp/plugins/gui.search/gui_search.page +++ b/emhttp/plugins/gui.search/gui_search.page @@ -57,7 +57,7 @@ function setupGUIsearch() { if (navigator.appVersion.indexOf("Mac")!=-1) { window.addEventListener('keydown', function (e) { - if (e.metaKey && e.keyCode == 75) { + if (!e.altKey && e.metaKey && e.keyCode == 75) { e.preventDefault(); e.stopPropagation(); if ( $("#guiSearchBoxSpan").is(":visible") ) { @@ -71,7 +71,7 @@ function setupGUIsearch() { }); } else { window.addEventListener('keydown', function (e) { - if (e.ctrlKey && e.keyCode == 75) { + if (!e.altKey && e.ctrlKey && e.keyCode == 75) { e.preventDefault(); e.stopPropagation(); if ( $("#guiSearchBoxSpan").is(":visible") ) { @@ -177,4 +177,4 @@ if (browserName !== "Chrome" && browserName !== "Edge") { /* */ function(){function e(t){n(this,e),this.ctx=t,this.ie=!1;var r=window.navigator.userAgent;(r.indexOf("MSIE")>-1||r.indexOf("Trident")>-1)&&(this.ie=!0)}return o(e,[{key:"log",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"debug",r=this.opt.log;this.opt.debug&&"object"===t(r)&&"function"==typeof r[n]&&r[n]("mark.js: ".concat(e))}},{key:"getSeparatedKeywords",value:function(e){var t=this,n=[];return e.forEach(function(e){t.opt.separateWordSearch?e.split(" ").forEach(function(e){e.trim()&&-1===n.indexOf(e)&&n.push(e)}):e.trim()&&-1===n.indexOf(e)&&n.push(e)}),{keywords:n.sort(function(e,t){return t.length-e.length}),length:n.length}}},{key:"isNumeric",value:function(e){return Number(parseFloat(e))==e}},{key:"checkRanges",value:function(e){var t=this;if(!Array.isArray(e)||"[object Object]"!==Object.prototype.toString.call(e[0]))return this.log("markRanges() will only accept an array of objects"),this.opt.noMatch(e),[];var n=[],r=0;return e.sort(function(e,t){return e.start-t.start}).forEach(function(e){var o=t.callNoMatchOnInvalidRanges(e,r),i=o.start,a=o.end;o.valid&&(e.start=i,e.length=a-i,n.push(e),r=a)}),n}},{key:"callNoMatchOnInvalidRanges",value:function(e,t){var n,r,o=!1;return e&&void 0!==e.start?(r=(n=parseInt(e.start,10))+parseInt(e.length,10),this.isNumeric(e.start)&&this.isNumeric(e.length)&&r-t>0&&r-n>0?o=!0:(this.log("Ignoring invalid or overlapping range: "+"".concat(JSON.stringify(e))),this.opt.noMatch(e))):(this.log("Ignoring invalid range: ".concat(JSON.stringify(e))),this.opt.noMatch(e)),{start:n,end:r,valid:o}}},{key:"checkWhitespaceRanges",value:function(e,t,n){var r,o=!0,i=n.length,a=t-i,s=parseInt(e.start,10)-a;return(r=(s=s>i?i:s)+parseInt(e.length,10))>i&&(r=i,this.log("End range automatically set to the max value of ".concat(i))),s<0||r-s<0||s>i||r>i?(o=!1,this.log("Invalid range: ".concat(JSON.stringify(e))),this.opt.noMatch(e)):""===n.substring(s,r).replace(/\s+/g,"")&&(o=!1,this.log("Skipping whitespace only range: "+JSON.stringify(e)),this.opt.noMatch(e)),{start:s,end:r,valid:o}}},{key:"getTextNodes",value:function(e){var t=this,n="",r=[];this.iterator.forEachNode(NodeFilter.SHOW_TEXT,function(e){r.push({start:n.length,end:(n+=e.textContent).length,node:e})},function(e){return t.matchesExclude(e.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},function(){e({value:n,nodes:r})})}},{key:"matchesExclude",value:function(e){return a.matches(e,this.opt.exclude.concat(["script","style","title","head","html"]))}},{key:"wrapRangeInTextNode",value:function(e,t,n){var r=this.opt.element?this.opt.element:"mark",o=e.splitText(t),i=o.splitText(n-t),a=document.createElement(r);return a.setAttribute("data-markjs","true"),this.opt.className&&a.setAttribute("class",this.opt.className),a.textContent=o.textContent,o.parentNode.replaceChild(a,o),i}},{key:"wrapRangeInMappedTextNode",value:function(e,t,n,r,o){var i=this;e.nodes.every(function(a,s){var c=e.nodes[s+1];if(void 0===c||c.start>t){if(!r(a.node))return!1;var u=t-a.start,l=(n>a.end?a.end:n)-a.start,h=e.value.substr(0,a.start),f=e.value.substr(l+a.start);if(a.node=i.wrapRangeInTextNode(a.node,u,l),e.value=h+f,e.nodes.forEach(function(t,n){n>=s&&(e.nodes[n].start>0&&n!==s&&(e.nodes[n].start-=l),e.nodes[n].end-=l)}),n-=l,o(a.node.previousSibling,a.start),!(n>a.end))return!1;t=a.end}return!0})}},{key:"wrapGroups",value:function(e,t,n,r){return r((e=this.wrapRangeInTextNode(e,t,t+n)).previousSibling),e}},{key:"separateGroups",value:function(e,t,n,r,o){for(var i=t.length,a=1;a-1&&r(t[a],e)&&(e=this.wrapGroups(e,s,t[a].length,o))}return e}},{key:"wrapMatches",value:function(e,t,n,r,o){var i=this,a=0===t?0:t+1;this.getTextNodes(function(t){t.nodes.forEach(function(t){var o;for(t=t.node;null!==(o=e.exec(t.textContent))&&""!==o[a];){if(i.opt.separateGroups)t=i.separateGroups(t,o,a,n,r);else{if(!n(o[a],t))continue;var s=o.index;if(0!==a)for(var c=1;c \ No newline at end of file + From 6e0879abce646bf235daeb9310fa8798b57c2d42 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Thu, 5 Oct 2023 19:48:23 -0400 Subject: [PATCH 2/2] Update gui_search.page --- emhttp/plugins/gui.search/gui_search.page | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/gui.search/gui_search.page b/emhttp/plugins/gui.search/gui_search.page index 46c532448..cf93192ec 100755 --- a/emhttp/plugins/gui.search/gui_search.page +++ b/emhttp/plugins/gui.search/gui_search.page @@ -57,7 +57,7 @@ function setupGUIsearch() { if (navigator.appVersion.indexOf("Mac")!=-1) { window.addEventListener('keydown', function (e) { - if (!e.altKey && e.metaKey && e.keyCode == 75) { + if (!e.shiftKey && !e.altKey && e.metaKey && e.keyCode == 75) { e.preventDefault(); e.stopPropagation(); if ( $("#guiSearchBoxSpan").is(":visible") ) { @@ -71,7 +71,7 @@ function setupGUIsearch() { }); } else { window.addEventListener('keydown', function (e) { - if (!e.altKey && e.ctrlKey && e.keyCode == 75) { + if (!e.shiftKey && !e.altKey && e.ctrlKey && e.keyCode == 75) { e.preventDefault(); e.stopPropagation(); if ( $("#guiSearchBoxSpan").is(":visible") ) {