Merge pull request #11166 from craftxbox/highlight-regex

Highlight string now uses regex
This commit is contained in:
variableundefined
2019-06-26 20:10:12 +08:00
committed by GitHub
3 changed files with 3 additions and 18 deletions
@@ -15,7 +15,6 @@
<!-- The following script(s) require IE9 or above -->
<!--[if gte IE 9]><!-->
<script type="text/javascript" src="jquery.mark.min.js"></script>
<script type="text/javascript" src="unicode_9_annotations.json"></script>
<script type="text/javascript" src="twemoji.min.js"></script>
<!--<![endif]-->
+3 -10
View File
@@ -157,13 +157,10 @@ function setHighlightColor(match) {
//Highlights words based on user settings
function highlightTerms(el) {
var element = $(el)
if(!(element.mark)) { // mark.js isn't loaded; give up
return
}
for (var i = 0; i < opts.highlightTerms.length; i++) { //Each highlight term
if(opts.highlightTerms[i]) {
element.mark(opts.highlightTerms[i], {"element" : "span", "each" : setHighlightColor});
var rexp = new RegExp("("+opts.highlightTerms[i]+")","gmi")
el.innerHTML = el.innerHTML.replace(rexp,"<span style=\"background-color:"+opts.highlightColor+"\">$1</span>")
}
}
}
@@ -965,10 +962,6 @@ $(function() {
});
$('#highlightTerm').click(function(e) {
if(!($().mark)) {
internalOutput('<span class="internal boldnshit">Highlighting is disabled. You are probably using Internet Explorer 8 and need to update.</span>', 'internal');
return;
}
if ($('.popup .highlightTerm').is(':visible')) {return;}
var termInputs = '';
for (var i = 0; i < opts.highlightLimit; i++) {
@@ -976,7 +969,7 @@ $(function() {
}
var popupContent = '<div class="head">String Highlighting</div>' +
'<div class="highlightPopup" id="highlightPopup">' +
'<div>Choose up to '+opts.highlightLimit+' strings that will highlight the line when they appear in chat.</div>' +
'<div>Choose up to '+opts.highlightLimit+' strings that will highlight the line when they appear in chat.<br>Regex compatible<br><a href="" onclick="window.open(\'https://nanotrasen.se/wiki/index.php/Guide_to_Regex\')">See here for details</a></div>' +
'<form id="highlightTermForm">' +
termInputs +
'<div><input type="text" name="highlightColor" id="highlightColor" class="highlightColor" '+
File diff suppressed because one or more lines are too long