I am not a programmer (but try to create small programming solutions for my day-to-day work). This time I am trying to build a log analyzer that will highlight specific keywords on the log file(.txt) when it is opened on a browser. The log file will be on a log server and will have a specific URL. I want to use that URL on the log analyzer page and open that text file, once the text file is loaded the javascript will highlight the keywords that I have mentioned(static) on the javascript.
I tried using mark.js solution.
<body>
<h1>My First Heading</h1>
<p>Lorem ipsum dolor sit āmet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, nò sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie çonsequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit prāesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet</p>
<script>
var instance = new Mark(document.querySelector("body"));
instance.mark(["ipsum", "lorem"], {
"accuracy": "exactly"
});
$('mark').css({'background':'transparent' , 'color':'yellow'});
</script>
</body>
But mark.js only gives the option to highlight words with single-color code(in the above code I used yellow) but I want the keywords to be highlighted with different colors like for example the info keywords highlighted with yellow, error keywords highlighted with red and success keywords highlighted with green. What solution I can use here to accomplish my goal? any help is appreciated.
Also how I can open a text file using the URL and make the JS work on it. I tried the HTML OBJECT tag but then the javascript was not working on it (not highlighting).