Skip to content

Commit

Permalink
Replace filter with simpleSearch()
Browse files Browse the repository at this point in the history
  • Loading branch information
negbie committed May 23, 2021
1 parent e5e2bb7 commit 1edfd67
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cp openssl-${openssl}/include/openssl/*.h ../openssl/include
sed -ri 's/<openssl\/(.*)>/"\1"/g' ../openssl/include/*

if [ ! -d "opus-${opus}" ]; then
wget "http://downloads.xiph.org/releases/opus/opus-${opus}.tar.gz"
wget "https://archive.mozilla.org/pub/opus/opus-${opus}.tar.gz"
tar -xzf opus-${opus}.tar.gz
fi
cd opus-${opus}; ./configure; make clean; make -j4; cd ..
Expand Down
2 changes: 1 addition & 1 deletion libbaresip/baresip/include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ const char *ua_outbound(const struct ua *ua);
struct call *ua_call(const struct ua *ua);
struct list *ua_calls(const struct ua *ua);
enum presence_status ua_presence_status(const struct ua *ua);
void ua_presence_status_set(struct ua *ua, const enum presence_status status);
void ua_presence_status_set(struct ua *ua, enum presence_status status);
void ua_set_catchall(struct ua *ua, bool enabled);
int ua_add_xhdr_filter(struct ua *ua, const char *hdr_name);
int ua_set_custom_hdrs(struct ua *ua, struct list *custom_hdrs);
Expand Down
Binary file modified libbaresip/baresip/libbaresip.a
Binary file not shown.
Binary file modified libbaresip/openssl/libcrypto.a
Binary file not shown.
Binary file modified libbaresip/re/libre.a
Binary file not shown.
38 changes: 28 additions & 10 deletions ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,28 @@ var homeTemplate = template.Must(template.New("").Parse(`
<head>
<meta charset="utf-8">
<script type="text/javascript">
function simpleSearch() {
var input = document.getElementById("search");
if (input.length < 1) {
return;
}
var filter = input.value.toLowerCase();
var nodes = document.getElementsByClassName('list');
for (i = 0; i < nodes.length; i++) {
if (nodes[i].innerText.toLowerCase().includes(filter)) {
nodes[i].style.display = "block";
} else {
nodes[i].style.display = "none";
}
}
}
window.onload = function () {
var conn;
var msg = document.getElementById("msg");
var log = document.getElementById("log");
var msg = document.getElementById("command");
var log = document.getElementById("output");
function appendLog(item) {
var doScroll = log.scrollTop > log.scrollHeight - log.clientHeight - 1;
Expand All @@ -221,13 +239,14 @@ window.onload = function () {
}
document.getElementById("form").onsubmit = function () {
log.scrollTop = log.scrollHeight;
log.scrollTop = log.scrollHeight;
if (!conn) {
return false;
}
if (!msg.value) {
return false;
}
simpleSearch();
conn.send(msg.value);
msg.value = "";
return false;
Expand All @@ -241,25 +260,24 @@ window.onload = function () {
appendLog(item);
};
conn.onmessage = function (evt) {
var filter = document.getElementById("filter");
var messages = evt.data.split('\n');
for (var i = 0; i < messages.length; i++) {
if (messages[i].length < 10) {
continue;
}
if (!messages[i].includes(filter.value)) {
continue;
}
var item = document.createElement("div");
item.classList.add('list');
var j = JSON.parse(messages[i]);
var d = new Date().toLocaleString()
j["time"] = d;
if (j.hasOwnProperty("data")) {
j["data"] = j["data"].trim().replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
}
item.innerText = JSON.stringify(j, undefined, 2);
appendLog(item);
simpleSearch();
}
};
} else {
Expand All @@ -275,8 +293,8 @@ window.onload = function () {
<table border="1">
<tr><td valign="top" width="20%">
<form id="form">
<input type="text" id="msg" size="45" autofocus placeholder="Please enter one of the below commands here"><br>
<input type="text" id="filter" size="45" placeholder="Optional text to filter messages"><br>
<input type="text" id="command" size="60" autofocus placeholder="Please enter one of the below commands here"><br>
<input type="text" id="search" size="60" onkeyup="simpleSearch()" placeholder="Please type a search term here"><br>
<input type="submit" value="Enter"><br>
</form>
Expand Down Expand Up @@ -323,7 +341,7 @@ window.onload = function () {
</td><td valign="top" width="80%">
<pre>
<div id="log" style="line-height: 1.7;max-height: 85vh;overflow-y: scroll;"></div>
<div id="output" class="list" style="line-height: 1.7;max-height: 85vh;overflow-y: scroll;"></div>
</pre>
</td></tr></table>
</body>
Expand Down

0 comments on commit 1edfd67

Please sign in to comment.