mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Merge branch 'search'
This commit is contained in:
commit
d859cb554a
1 file changed
+12
-8
+12
-8
@@ -3,9 +3,13 @@ _lastData = [];
|
|||||||
function drawcontents(data) {
|
function drawcontents(data) {
|
||||||
data = data || _lastData; //Cache data so we can drawcontents without waiting for the server, for the search box.
|
data = data || _lastData; //Cache data so we can drawcontents without waiting for the server, for the search box.
|
||||||
_lastData = data;
|
_lastData = data;
|
||||||
|
|
||||||
const search = new RegExp(document.querySelector("#search").value, 'i');
|
// allow searching for multiple criteria separated by space
|
||||||
data = data.filter(function(item) {
|
var searchArgs = document.querySelector("#search").value;
|
||||||
|
searchArgs = searchArgs.trim();
|
||||||
|
searchArgs = '(' + searchArgs.replace(/ +/g,")|(") + ')';
|
||||||
|
const search = new RegExp(searchArgs, 'i');
|
||||||
|
data = data.filter(function(item) {
|
||||||
return search.test(item.name);
|
return search.test(item.name);
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -77,13 +81,13 @@ function sortByKey(array, key) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelector("#search").addEventListener('input', function() {
|
document.querySelector("#search").addEventListener('input', function() {
|
||||||
drawcontents();
|
drawcontents();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make graph of cluster IO items
|
// Make graph of cluster IO items
|
||||||
/*getJSON("/api/getStats", function(err, data){
|
/*getJSON("/api/getStats", function(err, data){
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
function getItemStatData(item, callback){
|
function getItemStatData(item, callback){
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
@@ -121,7 +125,7 @@ function makeItemGraphs(itemName){
|
|||||||
console.log("Making chart for "+instanceID+"'s "+statistic+" statistic");
|
console.log("Making chart for "+instanceID+"'s "+statistic+" statistic");
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
let xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
|
let xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
|
||||||
xmlhttp.open("POST", "/api/getStats");
|
xmlhttp.open("POST", "/api/getStats");
|
||||||
xmlhttp.setRequestHeader("Content-Type", "application/json");
|
xmlhttp.setRequestHeader("Content-Type", "application/json");
|
||||||
xmlhttp.onreadystatechange = function(){
|
xmlhttp.onreadystatechange = function(){
|
||||||
@@ -191,7 +195,7 @@ function drawChart(selector, chartData, title) {
|
|||||||
e.dataSeries.visible = false;
|
e.dataSeries.visible = false;
|
||||||
} else {
|
} else {
|
||||||
e.dataSeries.visible = true;
|
e.dataSeries.visible = true;
|
||||||
}
|
}
|
||||||
e.chart.render();
|
e.chart.render();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -201,4 +205,4 @@ function drawChart(selector, chartData, title) {
|
|||||||
// console.log(chart)
|
// console.log(chart)
|
||||||
chart.render();
|
chart.render();
|
||||||
return chart;
|
return chart;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user