From 84379860b6302de2340e5efff9dfbcbe42e68f1b Mon Sep 17 00:00:00 2001 From: craftxbox Date: Wed, 26 Jun 2019 14:22:58 -0230 Subject: [PATCH 01/10] a cardinal sin amongst men: using webeditor. --- goon/browserassets/js/browserOutput.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 03eabaffeef..8239261b904 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -41,6 +41,7 @@ var opts = { 'suppressOptionsClose': false, //Whether or not we should be hiding the suboptions menu 'highlightTerms': [], 'highlightLimit': 5, + 'highlightEscapeRegex':true, 'highlightColor': '#FFFF00', //The color of the highlighted message 'pingDisabled': false, //Has the user disabled the ping counter @@ -159,7 +160,7 @@ function setHighlightColor(match) { function highlightTerms(el) { for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term if(opts.highlightTerms[i]) { - var rexp = new RegExp("("+opts.highlightTerms[i]+")","gmi") + var rexp = new RegExp("("+opts.highlightEscapeRegex?opts.highlightTerms[i].replace(new RegExp("([^a-zA-Z0-9])","gmi"),"\\$1"):opts.highlightTerms[i]+")","gmi") el.innerHTML = el.innerHTML.replace(rexp,"$1") } } @@ -606,6 +607,10 @@ $(function() { opts.highlightColor = savedConfig.shighlightColor; internalOutput('Loaded highlight color of: '+savedConfig.shighlightColor+'', 'internal'); } + if (savedConfig.shighlightEscapeRegex) { + opts.highlightEscapeRegex = savedConfig.shighlightEscapeRegex; + internalOutput('Loaded highlight regex enable of: '+savedConfig.shighlightEscapeRegex+'', 'internal'); + } if (savedConfig.shideSpam) { opts.hideSpam = $.parseJSON(savedConfig.shideSpam); internalOutput('Loaded hide spam preference of: ' + savedConfig.shideSpam + '', 'internal'); @@ -969,7 +974,9 @@ $(function() { } var popupContent = '
String Highlighting
' + '
' + - '
Choose up to '+opts.highlightLimit+' strings that will highlight the line when they appear in chat.
Regex compatible
See here for details
' + + '
Choose up to '+opts.highlightLimit+' strings that will highlight the line when they appear in chat.
'+ + 'Regex Enabled'+ + '
See here for details
' + '
' + termInputs + '
Date: Wed, 26 Jun 2019 22:42:35 -0230 Subject: [PATCH 02/10] regex enable/disable checkbox --- goon/browserassets/js/browserOutput.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 8239261b904..8d8e20d25e5 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -160,7 +160,10 @@ function setHighlightColor(match) { function highlightTerms(el) { for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term if(opts.highlightTerms[i]) { - var rexp = new RegExp("("+opts.highlightEscapeRegex?opts.highlightTerms[i].replace(new RegExp("([^a-zA-Z0-9])","gmi"),"\\$1"):opts.highlightTerms[i]+")","gmi") + var rexp = new RegExp("("+opts.highlightTerms[i]+")","gmi") + if(opts.highlightEscapeRegex){ + rexp = new RegExp("("+opts.highlightTerms[i].replace(new RegExp("([^a-zA-Z0-9])","gmi"),"\\$1")+")","gmi") + } el.innerHTML = el.innerHTML.replace(rexp,"$1") } } @@ -570,6 +573,7 @@ $(function() { 'spingDisabled': getCookie('pingdisabled'), 'shighlightTerms': getCookie('highlightterms'), 'shighlightColor': getCookie('highlightcolor'), + 'shighlightEscapeRegex': getCookie('highlightescaperegex'), 'shideSpam': getCookie('hidespam'), 'darkChat': getCookie('darkChat'), }; @@ -975,7 +979,7 @@ $(function() { var popupContent = '
String Highlighting
' + '
' + '
Choose up to '+opts.highlightLimit+' strings that will highlight the line when they appear in chat.
'+ - 'Regex Enabled'+ + 'Regex Enabled'+ '
See here for details
' + '' + termInputs + @@ -986,7 +990,6 @@ $(function() { '
'; createPopup(popupContent, 250); }); - $('body').on('keyup', '#highlightColor', function() { var color = $('#highlightColor').val(); color = color.trim(); @@ -1014,7 +1017,7 @@ $(function() { } var color = $('#highlightColor').val(); - opts.highlightEnableRegex = !($('#highlightRegexEnable').checked) + opts.highlightEscapeRegex = !(document.getElementById('highlightregexenable').checked) color = color.trim(); if (color == '' || color.charAt(0) != '#') { opts.highlightColor = '#FFFF00'; @@ -1024,6 +1027,7 @@ $(function() { var $popup = $('#highlightPopup').closest('.popup'); $popup.remove(); + setCookie('highlightescaperegex', opts.highlightEscapeRegex,365) setCookie('highlightterms', JSON.stringify(opts.highlightTerms), 365); setCookie('highlightcolor', opts.highlightColor, 365); }); From 4ccebc413371df189a8d3a4561d8fc1dc312df3a Mon Sep 17 00:00:00 2001 From: craftxbox Date: Thu, 15 Aug 2019 19:46:02 -0230 Subject: [PATCH 03/10] h --- goon/browserassets/js/browserOutput.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 8d8e20d25e5..962809eae68 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -41,7 +41,7 @@ var opts = { 'suppressOptionsClose': false, //Whether or not we should be hiding the suboptions menu 'highlightTerms': [], 'highlightLimit': 5, - 'highlightEscapeRegex':true, + 'highlightRegexEnable':false, 'highlightColor': '#FFFF00', //The color of the highlighted message 'pingDisabled': false, //Has the user disabled the ping counter @@ -161,7 +161,7 @@ function highlightTerms(el) { for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term if(opts.highlightTerms[i]) { var rexp = new RegExp("("+opts.highlightTerms[i]+")","gmi") - if(opts.highlightEscapeRegex){ + if(!opts.highlightRegexEnable){ rexp = new RegExp("("+opts.highlightTerms[i].replace(new RegExp("([^a-zA-Z0-9])","gmi"),"\\$1")+")","gmi") } el.innerHTML = el.innerHTML.replace(rexp,"$1") @@ -573,7 +573,7 @@ $(function() { 'spingDisabled': getCookie('pingdisabled'), 'shighlightTerms': getCookie('highlightterms'), 'shighlightColor': getCookie('highlightcolor'), - 'shighlightEscapeRegex': getCookie('highlightescaperegex'), + 'shighlightRegexEnable': getCookie('highlightregexenable'), 'shideSpam': getCookie('hidespam'), 'darkChat': getCookie('darkChat'), }; @@ -611,9 +611,9 @@ $(function() { opts.highlightColor = savedConfig.shighlightColor; internalOutput('Loaded highlight color of: '+savedConfig.shighlightColor+'', 'internal'); } - if (savedConfig.shighlightEscapeRegex) { - opts.highlightEscapeRegex = savedConfig.shighlightEscapeRegex; - internalOutput('Loaded highlight regex enable of: '+savedConfig.shighlightEscapeRegex+'', 'internal'); + if (savedConfig.shighlightRegexEnable) { + opts.highlightRegexEnable = savedConfig.shighlightRegexEnable; + internalOutput('Loaded highlight regex enable of: '+savedConfig.shighlightRegexEnable+'', 'internal'); } if (savedConfig.shideSpam) { opts.hideSpam = $.parseJSON(savedConfig.shideSpam); @@ -979,7 +979,7 @@ $(function() { var popupContent = '
String Highlighting
' + '
' + '
Choose up to '+opts.highlightLimit+' strings that will highlight the line when they appear in chat.
'+ - 'Regex Enabled'+ + 'Enable Regex'+ '
See here for details
' + '' + termInputs + @@ -989,6 +989,7 @@ $(function() { '' + '
'; createPopup(popupContent, 250); + document.querySelector(".popup #highlightRegexEnable").checked = opts.highlightRegexEnable; }); $('body').on('keyup', '#highlightColor', function() { var color = $('#highlightColor').val(); @@ -1017,7 +1018,7 @@ $(function() { } var color = $('#highlightColor').val(); - opts.highlightEscapeRegex = !(document.getElementById('highlightregexenable').checked) + opts.highlightRegexEnable = document.querySelector("#highlightRegexEnable").checked color = color.trim(); if (color == '' || color.charAt(0) != '#') { opts.highlightColor = '#FFFF00'; @@ -1027,7 +1028,7 @@ $(function() { var $popup = $('#highlightPopup').closest('.popup'); $popup.remove(); - setCookie('highlightescaperegex', opts.highlightEscapeRegex,365) + setCookie('highlightregexenable', opts.highlightRegexEnable,365) setCookie('highlightterms', JSON.stringify(opts.highlightTerms), 365); setCookie('highlightcolor', opts.highlightColor, 365); }); From ec2eeeff502609a537c385ed380f0d79a207c1c0 Mon Sep 17 00:00:00 2001 From: craftxbox Date: Mon, 7 Oct 2019 20:54:43 -0230 Subject: [PATCH 04/10] lets try this again --- goon/browserassets/js/browserOutput.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 962809eae68..565a3535982 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -160,11 +160,13 @@ function setHighlightColor(match) { function highlightTerms(el) { for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term if(opts.highlightTerms[i]) { - var rexp = new RegExp("("+opts.highlightTerms[i]+")","gmi") + var rexp = new RegExp(opts.highlightTerms[i],"gmi") if(!opts.highlightRegexEnable){ rexp = new RegExp("("+opts.highlightTerms[i].replace(new RegExp("([^a-zA-Z0-9])","gmi"),"\\$1")+")","gmi") + el.innerText = el.innerText.replace(rexp,"$1") //disabling regex disables html matching too + continue; } - el.innerHTML = el.innerHTML.replace(rexp,"$1") + el.innerHTML = el.innerHTML.replace(rexp,"$0") //i cant figure out a proper, non snowflakey way to let people select the group that gets highlighted } } } From bf131ecdb283fafa4a20df176fb2c5af496cc5fd Mon Sep 17 00:00:00 2001 From: craftxbox Date: Sun, 27 Oct 2019 17:01:40 -0230 Subject: [PATCH 05/10] fix all the shit --- goon/browserassets/js/browserOutput.js | 33 ++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 565a3535982..f700d2ff028 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -72,6 +72,8 @@ var opts = { 'enableEmoji': true }; +var regexHasError = false; //variable to check if regex has excepted + function outerHTML(el) { var wrap = document.createElement('div'); wrap.appendChild(el.cloneNode(true)); @@ -91,6 +93,19 @@ if (typeof String.prototype.trim !== 'function') { }; } +//Polyfill for string.prototype.includes. Why the fuck. Just why the fuck. +if (!String.prototype.includes) { + String.prototype.includes = function(search, start) { + 'use strict'; + + if (search instanceof RegExp) { + throw TypeError('first argument must not be a RegExp'); + } + if (start === undefined) { start = 0; } + return this.indexOf(search, start) !== -1; + }; +} + //Shit fucking piece of crap that doesn't work god fuckin damn it function linkify(text) { var rex = /((?:$1") //disabling regex disables html matching too + if(el.innerText.toString().toLowerCase().includes(opts.highlightTerms[i].toLowerCase())) //match normally + el.innerHTML = ''+el.innerHTML+'' //encloseincludes continue; } + var rexp; + try{ + rexp = new RegExp(opts.highlightTerms[i],"gmi") + } catch(e){ + el.innerHTML+='
Your highlight regex - '+opts.highlightTerms[i]+' - is malformed. Thrown exception: '+e+'' + regexHasError = true; + return; + } el.innerHTML = el.innerHTML.replace(rexp,"$0") //i cant figure out a proper, non snowflakey way to let people select the group that gets highlighted } } @@ -575,7 +598,7 @@ $(function() { 'spingDisabled': getCookie('pingdisabled'), 'shighlightTerms': getCookie('highlightterms'), 'shighlightColor': getCookie('highlightcolor'), - 'shighlightRegexEnable': getCookie('highlightregexenable'), + 'shighlightRegexEnable': getCookie('highlightregexenable') == "true", 'shideSpam': getCookie('hidespam'), 'darkChat': getCookie('darkChat'), }; @@ -1027,6 +1050,8 @@ $(function() { } else { opts.highlightColor = color; } + regexHasError = false; //they changed the regex so it might be valid now + var $popup = $('#highlightPopup').closest('.popup'); $popup.remove(); From 2d97f55b16561e93a0b07ff78f571970d0c385aa Mon Sep 17 00:00:00 2001 From: craftxbox Date: Mon, 4 Nov 2019 00:30:09 -0330 Subject: [PATCH 06/10] my hatred for ie is immesurable --- goon/browserassets/js/browserOutput.js | 64 +++++++++++++++++++++----- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 094e8258562..b94734040bb 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -171,25 +171,67 @@ function setHighlightColor(match) { match.style.background = opts.highlightColor } +function escapeRegex(input){ // put this in a function incase it ever needs to be used elsewhere, makes code cleaner + return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + //Highlights words based on user settings function highlightTerms(el) { if(regexHasError) return; //just stop right there ig the regex is gonna except + function highlightRecursor(element,term){ //recursor function to do the highlighting proper + var regex = new RegExp("("+term+")","gi") + function replace(str) { + return str.replace(regex,'$&') + } + var s='' + var work=element.innerHTML; + var work_lc=work.toLowerCase() + var ind=0; + while(ind < work_lc.length) { + console.log(s); + var next_term=work_lc.substring(ind).search(regex); + if(next_term!=-1)next_term+=ind; + var next_tag =work_lc.indexOf('<',ind) + if(next_tag == -1) { + s+=replace(work.substring(ind)); + break; + } + else if(next_term==-1) { + s+=work.substring(ind) + break; + } + else if(next_tag < next_term) { + var temp=work_lc.indexOf('>',next_tag) + s+=work.substring(ind,temp+1); + ind=temp+1; + } + else { + s+=replace(work.substring(ind,next_tag)); + ind=next_tag + } + } + + element.innerHTML=s; + } + for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term if(opts.highlightTerms[i]) { if(!opts.highlightRegexEnable){ - if(el.innerText.toString().toLowerCase().includes(opts.highlightTerms[i].toLowerCase())) //match normally - el.innerHTML = ''+el.innerHTML+'' //encloseincludes - continue; + var innerTerms = opts.highlightTerms[i].split(" ") + for(var a in innerTerms){ + highlightRecursor(el,escapeRegex(innerTerms[a])) + } } - var rexp; - try{ - rexp = new RegExp(opts.highlightTerms[i],"gmi") - } catch(e){ - el.innerHTML+='
Your highlight regex - '+opts.highlightTerms[i]+' - is malformed. Thrown exception: '+e+'' - regexHasError = true; - return; + else { + try{ + new RegExp(opts.highlightTerms[i],"gmi") // check to make sure the pattern wont cause issues + } catch(e){ + el.innerHTML+='
Your highlight regex pattern - '+opts.highlightTerms[i]+' - is malformed.
Your highlights have been disabled until they are next edited
Thrown exception: '+e+'
' + regexHasError = true; + return; + } + highlightRecursor(el,opts.highlightTerms[i]) } - el.innerHTML = el.innerHTML.replace(rexp,"$0") //i cant figure out a proper, non snowflakey way to let people select the group that gets highlighted } } } From 89b9508378c1224275c5b29eb9afb32dbc501c32 Mon Sep 17 00:00:00 2001 From: craftxbox Date: Mon, 4 Nov 2019 18:16:41 -0330 Subject: [PATCH 07/10] remove the dumb bits and make the highlight color change retroactively upon change --- goon/browserassets/js/browserOutput.js | 45 ++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index b94734040bb..9508f669bc3 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -166,9 +166,12 @@ function emojiparse(el) { } } -// Colorizes the highlight spans -function setHighlightColor(match) { - match.style.background = opts.highlightColor +// Recolorizes the highlight spans +function setHighlightColor() { + var highlightspans = document.getElementsByClassName("highlight") + for(var i in highlightspans){ + highlightspans[i].setAttribute("style","background-color:"+opts.highlightColor) + } } function escapeRegex(input){ // put this in a function incase it ever needs to be used elsewhere, makes code cleaner @@ -177,21 +180,25 @@ function escapeRegex(input){ // put this in a function incase it ever needs to b //Highlights words based on user settings function highlightTerms(el) { + if(regexHasError) return; //just stop right there ig the regex is gonna except + function highlightRecursor(element,term){ //recursor function to do the highlighting proper var regex = new RegExp("("+term+")","gi") + function replace(str) { - return str.replace(regex,'$&') + return str.replace(regex,'$&') } + var s='' var work=element.innerHTML; - var work_lc=work.toLowerCase() var ind=0; - while(ind < work_lc.length) { - console.log(s); - var next_term=work_lc.substring(ind).search(regex); - if(next_term!=-1)next_term+=ind; - var next_tag =work_lc.indexOf('<',ind) + + while(ind < work.length) { + + var next_term=work.substring(ind).search(regex); + if(next_term!=-1)next_term+=ind; + var next_tag =work.indexOf('<',ind) if(next_tag == -1) { s+=replace(work.substring(ind)); break; @@ -201,7 +208,7 @@ function highlightTerms(el) { break; } else if(next_tag < next_term) { - var temp=work_lc.indexOf('>',next_tag) + var temp=work.indexOf('>',next_tag) s+=work.substring(ind,temp+1); ind=temp+1; } @@ -1084,13 +1091,17 @@ $(function() { count++; } - var color = $('#highlightColor').val(); opts.highlightRegexEnable = document.querySelector("#highlightRegexEnable").checked - color = color.trim(); - if (color == '' || color.charAt(0) != '#') { - opts.highlightColor = '#FFFF00'; - } else { - opts.highlightColor = color; + + var color = $('#highlightColor').val(); + if(color != opts.highlightColor) { // did the color even change? + color = color.trim(); + if (color == '' || color.charAt(0) != '#') { + opts.highlightColor = '#FFFF00'; + } else { + opts.highlightColor = color; + } + setHighlightColor(); } regexHasError = false; //they changed the regex so it might be valid now From ea8472f038c681a204085ee1e404cfc85808ebea Mon Sep 17 00:00:00 2001 From: craftxbox Date: Mon, 4 Nov 2019 18:46:23 -0330 Subject: [PATCH 08/10] do the onedit pattern check simply --- goon/browserassets/js/browserOutput.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 9508f669bc3..3c266fc023e 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -1103,7 +1103,9 @@ $(function() { } setHighlightColor(); } + regexHasError = false; //they changed the regex so it might be valid now + internalOutput('Highlights have been updated.',"internal") // simplest way to test if pattern works, why reinvent the wheel? var $popup = $('#highlightPopup').closest('.popup'); $popup.remove(); From 964e23bb48a7fc9b98be724f6513946b8938e59b Mon Sep 17 00:00:00 2001 From: craftxbox Date: Mon, 13 Apr 2020 00:23:15 -0230 Subject: [PATCH 09/10] styling fixes --- goon/browserassets/js/browserOutput.js | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index 3c266fc023e..d20d2eb239e 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -174,51 +174,51 @@ function setHighlightColor() { } } -function escapeRegex(input){ // put this in a function incase it ever needs to be used elsewhere, makes code cleaner +function escapeRegexCharacters(input){ //escapes any characters that could be interpreted as regex patterns, potentially causing patterns to break if not escaped return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } //Highlights words based on user settings function highlightTerms(el) { - if(regexHasError) return; //just stop right there ig the regex is gonna except + if (regexHasError) return; //just stop right there ig the regex is gonna except function highlightRecursor(element,term){ //recursor function to do the highlighting proper - var regex = new RegExp("("+term+")","gi") + var regex = new RegExp(term,"gi"); function replace(str) { - return str.replace(regex,'$&') + return str.replace(regex,'$&'); } - var s='' - var work=element.innerHTML; - var ind=0; + var s = ''; + var work = element.innerHTML; + var ind = 0; while(ind < work.length) { - var next_term=work.substring(ind).search(regex); - if(next_term!=-1)next_term+=ind; - var next_tag =work.indexOf('<',ind) + var next_term = work.substring(ind).search(regex); + if(next_term != -1) next_term += ind; + var next_tag = work.indexOf('<',ind); if(next_tag == -1) { s+=replace(work.substring(ind)); break; } else if(next_term==-1) { - s+=work.substring(ind) + s += work.substring(ind); break; } else if(next_tag < next_term) { - var temp=work.indexOf('>',next_tag) - s+=work.substring(ind,temp+1); - ind=temp+1; + var temp = work.indexOf('>',next_tag); + s += work.substring(ind,temp+1); + ind = temp+1; } else { - s+=replace(work.substring(ind,next_tag)); - ind=next_tag + s += replace(work.substring(ind,next_tag)); + ind = next_tag; } } - element.innerHTML=s; + element.innerHTML = s; } for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term @@ -226,18 +226,18 @@ function highlightTerms(el) { if(!opts.highlightRegexEnable){ var innerTerms = opts.highlightTerms[i].split(" ") for(var a in innerTerms){ - highlightRecursor(el,escapeRegex(innerTerms[a])) + highlightRecursor(el, escapeRegexCharacters(innerTerms[a])) } } else { try{ - new RegExp(opts.highlightTerms[i],"gmi") // check to make sure the pattern wont cause issues + new RegExp(opts.highlightTerms[i],"gmi"); // check to make sure the pattern wont cause issues } catch(e){ - el.innerHTML+='
Your highlight regex pattern - '+opts.highlightTerms[i]+' - is malformed.
Your highlights have been disabled until they are next edited
Thrown exception: '+e+'
' + el.innerHTML += '
Your highlight regex pattern - '+opts.highlightTerms[i]+' - is malformed.
Your highlights have been disabled until they are next edited
Thrown exception: '+e+'
'; regexHasError = true; return; } - highlightRecursor(el,opts.highlightTerms[i]) + highlightRecursor(el, opts.highlightTerms[i]); } } } From c9f1a997bd2e4c6adbac6604dfb69ce9f0f8b115 Mon Sep 17 00:00:00 2001 From: craftxbox Date: Mon, 13 Apr 2020 00:25:48 -0230 Subject: [PATCH 10/10] extra styling fixes --- goon/browserassets/js/browserOutput.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/goon/browserassets/js/browserOutput.js b/goon/browserassets/js/browserOutput.js index d20d2eb239e..20162e8d3ca 100644 --- a/goon/browserassets/js/browserOutput.js +++ b/goon/browserassets/js/browserOutput.js @@ -183,11 +183,11 @@ function highlightTerms(el) { if (regexHasError) return; //just stop right there ig the regex is gonna except - function highlightRecursor(element,term){ //recursor function to do the highlighting proper - var regex = new RegExp(term,"gi"); + function highlightRecursor(element, term){ //recursor function to do the highlighting proper + var regex = new RegExp(term, "gi"); function replace(str) { - return str.replace(regex,'$&'); + return str.replace(regex, '$&'); } var s = ''; @@ -198,7 +198,7 @@ function highlightTerms(el) { var next_term = work.substring(ind).search(regex); if(next_term != -1) next_term += ind; - var next_tag = work.indexOf('<',ind); + var next_tag = work.indexOf('<', ind); if(next_tag == -1) { s+=replace(work.substring(ind)); break; @@ -208,12 +208,12 @@ function highlightTerms(el) { break; } else if(next_tag < next_term) { - var temp = work.indexOf('>',next_tag); + var temp = work.indexOf('>', next_tag); s += work.substring(ind,temp+1); ind = temp+1; } else { - s += replace(work.substring(ind,next_tag)); + s += replace(work.substring(ind, next_tag)); ind = next_tag; } } @@ -231,9 +231,9 @@ function highlightTerms(el) { } else { try{ - new RegExp(opts.highlightTerms[i],"gmi"); // check to make sure the pattern wont cause issues + new RegExp(opts.highlightTerms[i], "gmi"); // check to make sure the pattern wont cause issues } catch(e){ - el.innerHTML += '
Your highlight regex pattern - '+opts.highlightTerms[i]+' - is malformed.
Your highlights have been disabled until they are next edited
Thrown exception: '+e+'
'; + el.innerHTML += '
Your highlight regex pattern -- ' + opts.highlightTerms[i] + ' -- is malformed.
Your highlights have been disabled until they are next edited
Thrown exception: '+e+'
'; regexHasError = true; return; }