mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +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) {
|
app.post("/api/place", function(req, res) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
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) {
|
if(!x.instanceName) {
|
||||||
x.instanceName = "unknown";
|
x.instanceName = "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-1
@@ -20,6 +20,33 @@ function ensureSetting(setting, type, defaultSetting) {
|
|||||||
localStorage.settings = JSON.stringify(settings)
|
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 = {}
|
var g = {}
|
||||||
contents = {
|
contents = {
|
||||||
"iron-plate":100,
|
"iron-plate":100,
|
||||||
@@ -57,6 +84,7 @@ function getJSON(url, callback) {
|
|||||||
function postJSON(url, data, callback) {
|
function postJSON(url, data, callback) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', url, true);
|
xhr.open('POST', url, true);
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
var status = xhr.status;
|
var status = xhr.status;
|
||||||
@@ -70,7 +98,7 @@ function postJSON(url, data, callback) {
|
|||||||
xhr.onerror = function(e){
|
xhr.onerror = function(e){
|
||||||
callback(e);
|
callback(e);
|
||||||
};
|
};
|
||||||
xhr.send(data);
|
xhr.send(JSON.stringify(data));
|
||||||
};
|
};
|
||||||
// return Boolean
|
// return Boolean
|
||||||
function isJSON(string){
|
function isJSON(string){
|
||||||
|
|||||||
Reference in new issue
Block a user