Comments (2)
I do a simple regex replace/highlight. Here's the code that inserts the relevant class:
function hl(needle, haystack, cl) {
var reg = new RegExp(needle, 'gi');
return haystack.replace(reg, function(str) {
return '<span class="' + cl + '">' + str + '</span>'
});
}
function addMessage(msg) {
var msgs = $('.prompt .message');
var count = msgs.length;
msg = hl('GET|POST', msg, 'purple');
msg = hl('HTTP\/1\.1|HTTP\/1\.0', msg, 'orange');
msg = hl(':80', msg, 'red');
msg = hl('\\[.*\\]', msg, 'green');
msg = hl('(?:[0-9]{1,3}\.){3}[0-9]{1,3}', msg, 'blue');
if (count == 20)
msgs.first().remove();
$('<div />', {
'class': 'message'
})
.html(msg)
.appendTo($('.prompt'));
}
Hope that helps.
from gwsocket.
Closing this. Feel free to reopen it if needed.
from gwsocket.
Related Issues (20)
- Serving files via sendfile HOT 2
- Using in multible domains on one port HOT 3
- Fails to compile with OpenSSL 1.1.0 or newer HOT 3
- gwsocket+apache: status 200 instead of 101 HOT 2
- Strict protocol parsing HOT 7
- Support for multiple instances? HOT 8
- Is webshell considered to be integrated into the project? HOT 2
- Feature request - client version of gwsocket (same style as gwsocket, but client, not server)
- " unrecognized option `--ssl-cert' " HOT 13
- make fails on Ubuntu 20. HOT 3
- TAR Download broken HOT 2
- -Wno-missing-field-initializers on SPARC machine HOT 5
- Help with FIFO Error. Bad address HOT 11
- gwsocket as a library HOT 7
- gwsocket.io: :( Nope, the connection is out. Try again later! HOT 2
- Typo on the webpage HOT 1
- windows bianries?
- API to disconnect client in strict mode HOT 3
- feedback
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwsocket.