mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-19 21:16:37 +07:00
journal: implement filtering in browse.html
This commit is contained in:
parent
082d0180f9
commit
1cd8a002ff
@ -6,7 +6,7 @@
|
|||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
div#divlogs, div#diventry {
|
div#divlogs, div#diventry {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-size: 8pt;
|
font-size: 7pt;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
margin: 2em 0em;
|
margin: 2em 0em;
|
||||||
@ -25,7 +25,7 @@
|
|||||||
background-color: #ededed;
|
background-color: #ededed;
|
||||||
color: #313739;
|
color: #313739;
|
||||||
font: message-box;
|
font: message-box;
|
||||||
margin: 5em;
|
margin: 3em;
|
||||||
}
|
}
|
||||||
td.timestamp {
|
td.timestamp {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
@ -82,16 +82,24 @@
|
|||||||
color: #818789;
|
color: #818789;
|
||||||
padding-top: 2em;
|
padding-top: 2em;
|
||||||
}
|
}
|
||||||
.key {
|
span.key {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #313739;
|
color: #313739;
|
||||||
}
|
}
|
||||||
form {
|
div#buttonnav {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
input {
|
button {
|
||||||
font-size: 18pt;
|
font-size: 18pt;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
width: 2em;
|
||||||
|
height: 2em;
|
||||||
|
}
|
||||||
|
div#filternav {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
width: 50em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@ -110,19 +118,27 @@
|
|||||||
<div id="usage"></div>
|
<div id="usage"></div>
|
||||||
<div id="showing"></div>
|
<div id="showing"></div>
|
||||||
|
|
||||||
|
<div id="filternav">
|
||||||
|
<select id="filter" onchange="onFilterChange(this);" onfocus="onFilterFocus(this);">
|
||||||
|
<option>No filter</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input id="boot" type="checkbox" onchange="onBootChange(this);">Only current boot</input>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="divlogs"><table id="tablelogs"></table></div>
|
<div id="divlogs"><table id="tablelogs"></table></div>
|
||||||
<a name="entry"></a>
|
<a name="entry"></a>
|
||||||
<div id="diventry"><table id="tableentry"></table></div>
|
<div id="diventry"><table id="tableentry"></table></div>
|
||||||
|
|
||||||
<form>
|
<div id="buttonnav">
|
||||||
<input id="head" type="button" value="⇤" onclick="entriesLoadHead();" title="First Page"/>
|
<button id="head" onclick="entriesLoadHead();" title="First Page">⇤</button>
|
||||||
<input id="previous" type="button" value="←" onclick="entriesLoadPrevious();" title="Previous Page"/>
|
<button id="previous" type="button" onclick="entriesLoadPrevious();" title="Previous Page"/>←</button>
|
||||||
<input id="next" type="button" value="→" onclick="entriesLoadNext();" title="Next Page"/>
|
<button id="next" type="button" onclick="entriesLoadNext();" title="Next Page"/>→</button>
|
||||||
<input id="tail" type="button" value="⇥" onclick="entriesLoadTail();" title="Last Page"/>
|
<button id="tail" type="button" onclick="entriesLoadTail();" title="Last Page"/>⇥</button>
|
||||||
|
|
||||||
<input id="more" type="button" value="+" onclick="entriesMore();" title="More Entries"/>
|
<button id="more" type="button" onclick="entriesMore();" title="More Entries"/>+</button>
|
||||||
<input id="less" type="button" value="-" onclick="entriesLess();" title="Fewer Entries"/>
|
<button id="less" type="button" onclick="entriesLess();" title="Fewer Entries"/>-</button>
|
||||||
</form>
|
</div>
|
||||||
|
|
||||||
<div id="keynav">
|
<div id="keynav">
|
||||||
<span class="key">g</span>: First Page
|
<span class="key">g</span>: First Page
|
||||||
@ -139,7 +155,7 @@
|
|||||||
|
|
||||||
function getNEntries() {
|
function getNEntries() {
|
||||||
var n;
|
var n;
|
||||||
n = window.localStorage["n_entries"];
|
n = localStorage["n_entries"];
|
||||||
if (n == null)
|
if (n == null)
|
||||||
return 50;
|
return 50;
|
||||||
n = parseInt(n);
|
n = parseInt(n);
|
||||||
@ -160,7 +176,7 @@
|
|||||||
return 10;
|
return 10;
|
||||||
if (n > 1000)
|
if (n > 1000)
|
||||||
return 1000;
|
return 1000;
|
||||||
window.localStorage["n_entries"] = n.toString();
|
localStorage["n_entries"] = n.toString();
|
||||||
showNEntries(n);
|
showNEntries(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,12 +237,24 @@
|
|||||||
function entriesLoad(range) {
|
function entriesLoad(range) {
|
||||||
|
|
||||||
if (range == null)
|
if (range == null)
|
||||||
range = window.localStorage["cursor"] + ":0";
|
range = localStorage["cursor"] + ":0";
|
||||||
if (range == null)
|
if (range == null)
|
||||||
range = "";
|
range = "";
|
||||||
|
|
||||||
|
var url = "/entries";
|
||||||
|
|
||||||
|
if (localStorage["filter"] != "" && localStorage["filter"] != null) {
|
||||||
|
url += "?_SYSTEMD_UNIT=" + escape(localStorage["filter"]);
|
||||||
|
|
||||||
|
if (localStorage["boot"] == "1")
|
||||||
|
url += "&boot";
|
||||||
|
} else {
|
||||||
|
if (localStorage["boot"] == "1")
|
||||||
|
url += "?boot";
|
||||||
|
}
|
||||||
|
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
request.open("GET", "/entries");
|
request.open("GET", url);
|
||||||
request.onreadystatechange = entriesOnResult;
|
request.onreadystatechange = entriesOnResult;
|
||||||
request.setRequestHeader("Accept", "application/json");
|
request.setRequestHeader("Accept", "application/json");
|
||||||
request.setRequestHeader("Range", "entries=" + range + ":" + getNEntries().toString());
|
request.setRequestHeader("Range", "entries=" + range + ":" + getNEntries().toString());
|
||||||
@ -266,8 +294,7 @@
|
|||||||
var lc = null;
|
var lc = null;
|
||||||
var fc = null;
|
var fc = null;
|
||||||
|
|
||||||
var i;
|
var i, l = event.currentTarget.responseText.split('\n');
|
||||||
var l = event.currentTarget.responseText.split('\n');
|
|
||||||
|
|
||||||
if (l.length <= 1) {
|
if (l.length <= 1) {
|
||||||
logs.innerHTML = '<tbody><tr><td colspan="3"><i>No further entries...</i></td></tr></tbody>';
|
logs.innerHTML = '<tbody><tr><td colspan="3"><i>No further entries...</i></td></tr></tbody>';
|
||||||
@ -337,7 +364,7 @@
|
|||||||
|
|
||||||
if (fc != null) {
|
if (fc != null) {
|
||||||
first_cursor = fc;
|
first_cursor = fc;
|
||||||
window.localStorage["cursor"] = fc;
|
localStorage["cursor"] = fc;
|
||||||
}
|
}
|
||||||
if (lc != null)
|
if (lc != null)
|
||||||
last_cursor = lc;
|
last_cursor = lc;
|
||||||
@ -423,14 +450,95 @@
|
|||||||
entriesLoadNext();
|
entriesLoadNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onResultFilterFocus(event) {
|
||||||
|
if ((event.currentTarget.readyState != 4) ||
|
||||||
|
(event.currentTarget.status != 200 && event.currentTarget.status != 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
f = document.getElementById("filter");
|
||||||
|
|
||||||
|
var l = event.currentTarget.responseText.split('\n');
|
||||||
|
var buf = '<option>No filter</option>';
|
||||||
|
var j = -1;
|
||||||
|
|
||||||
|
for (i in l) {
|
||||||
|
|
||||||
|
if (l[i] == '')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var d = JSON.parse(l[i]);
|
||||||
|
if (d._SYSTEMD_UNIT == undefined)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
buf += '<option value="' + escape(d._SYSTEMD_UNIT) + '">' + escapeHTML(d._SYSTEMD_UNIT) + '</option>';
|
||||||
|
|
||||||
|
if (d._SYSTEMD_UNIT == localStorage["filter"])
|
||||||
|
j = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j < 0) {
|
||||||
|
if (localStorage["filter"] != null && localStorage["filter"] != "") {
|
||||||
|
buf += '<option value="' + escape(localStorage["filter"]) + '">' + escapeHTML(localStorage["filter"]) + '</option>';
|
||||||
|
j = i + 1;
|
||||||
|
} else
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.innerHTML = buf;
|
||||||
|
f.selectedIndex = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFilterFocus(w) {
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.open("GET", "/fields/_SYSTEMD_UNIT");
|
||||||
|
request.onreadystatechange = onResultFilterFocus;
|
||||||
|
request.setRequestHeader("Accept", "application/json");
|
||||||
|
request.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFilterChange(w) {
|
||||||
|
if (w.selectedIndex <= 0)
|
||||||
|
localStorage["filter"] = "";
|
||||||
|
else
|
||||||
|
localStorage["filter"] = unescape(w.options[w.selectedIndex].value);
|
||||||
|
|
||||||
|
entriesLoadHead();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onBootChange(w) {
|
||||||
|
localStorage["boot"] = w.checked ? "1" : "0";
|
||||||
|
entriesLoadHead();
|
||||||
|
}
|
||||||
|
|
||||||
|
function initFilter() {
|
||||||
|
f = document.getElementById("filter");
|
||||||
|
|
||||||
|
var buf = '<option>No filter</option>';
|
||||||
|
|
||||||
|
var filter = localStorage["filter"];
|
||||||
|
if (filter != null && filter != "") {
|
||||||
|
buf += '<option value="' + escape(filter) + '">' + escapeHTML(filter) + '</option>';
|
||||||
|
j = 1;
|
||||||
|
} else
|
||||||
|
j = 0;
|
||||||
|
|
||||||
|
f.innerHTML = buf;
|
||||||
|
f.selectedIndex = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
function installHandlers() {
|
||||||
|
document.onkeyup = onKeyUp;
|
||||||
|
|
||||||
|
logs = document.getElementById("divlogs");
|
||||||
|
logs.addEventListener("mousewheel", onMouseWheel, false);
|
||||||
|
logs.addEventListener("DOMMouseScroll", onMouseWheel, false);
|
||||||
|
}
|
||||||
|
|
||||||
machineLoad();
|
machineLoad();
|
||||||
entriesLoad(null);
|
entriesLoad(null);
|
||||||
showNEntries(getNEntries());
|
showNEntries(getNEntries());
|
||||||
document.onkeyup = onKeyUp;
|
initFilter();
|
||||||
|
installHandlers();
|
||||||
logs = document.getElementById("divlogs");
|
|
||||||
logs.addEventListener("mousewheel", onMouseWheel, false);
|
|
||||||
logs.addEventListener("DOMMouseScroll", onMouseWheel, false);
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user