mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Added debug tools for adding/removing items
This commit is contained in:
1 parent
f886fe3e95
commit
04aba1eef1
2 files changed
+35
-2
No files matched your search
@@ -215,7 +215,12 @@ var recievedItemStatistics = new averagedTimeSeries({
|
||||
app.post("/api/place", function(req, res) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
let x = req.body;
|
||||
let x;
|
||||
try {
|
||||
x = JSON.parse(req.body);
|
||||
} catch (e) {
|
||||
x = req.body;
|
||||
}
|
||||
if(!x.instanceName) {
|
||||
x.instanceName = "unknown";
|
||||
}
|
||||
|
||||
+29
-1
@@ -20,6 +20,33 @@ function ensureSetting(setting, type, defaultSetting) {
|
||||
localStorage.settings = JSON.stringify(settings)
|
||||
}
|
||||
|
||||
// debug tools
|
||||
|
||||
debugTools = {
|
||||
addItem: function(name, count){
|
||||
console.log(`Attempting to add ${count} ${name}`)
|
||||
postJSON("api/place", {
|
||||
instanceName: "debug",
|
||||
unique: "debug",
|
||||
name: name,
|
||||
count: count,
|
||||
}, function(data){
|
||||
console.log(data);
|
||||
});
|
||||
},
|
||||
removeItem: function(name, count){
|
||||
console.log(name)
|
||||
postJSON("api/remove", {
|
||||
instanceName: "debug",
|
||||
unique: "debug",
|
||||
name: name,
|
||||
count: count,
|
||||
}, function(data){
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var g = {}
|
||||
contents = {
|
||||
"iron-plate":100,
|
||||
@@ -57,6 +84,7 @@ function getJSON(url, callback) {
|
||||
function postJSON(url, data, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', url, true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||
xhr.responseType = 'json';
|
||||
xhr.onload = function() {
|
||||
var status = xhr.status;
|
||||
@@ -70,7 +98,7 @@ function postJSON(url, data, callback) {
|
||||
xhr.onerror = function(e){
|
||||
callback(e);
|
||||
};
|
||||
xhr.send(data);
|
||||
xhr.send(JSON.stringify(data));
|
||||
};
|
||||
// return Boolean
|
||||
function isJSON(string){
|
||||
|
||||
Reference in new issue
Block a user