Post getvars + fixed colors.py valid hex

This commit is contained in:
l_samenv
2024-09-04 12:56:35 +02:00
parent 9112b5db05
commit 35a02e8fa7
4 changed files with 50 additions and 8 deletions

View File

@ -270,6 +270,34 @@ function reqJSON(s, url, successHandler, errorHandler) {
xhr.send();
}
function reqJSONPOST(s, url, parameters, successHandler, errorHandler) {
var xhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest()
: new ActiveXObject('Microsoft.XMLHTTP');
if (debugCommunication) {
console.log("%cto server (reqJSON): " + url,
"color:white;background:lightgreen");
}
xhr.open('post', url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
// console.log(xhr)
var status;
var data;
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-readystate
if (xhr.readyState == 4) { // `DONE`
status = xhr.status;
if (status == 200) {
data = JSON.parse(xhr.responseText);
successHandler && successHandler(s, data);
} else {
errorHandler && errorHandler(status);
}
}
};
xhr.send(parameters);
}
function successHandler(s, message) {
// Handles incoming XMLHttp-messages depending on type of message.
// s: slide number or -1 for replacing slide in all slider instances
@ -350,8 +378,8 @@ function successHandler(s, message) {
begin = timeRange[0] - timeRange[1];
select.value = begin;
// Server-request for variable-list.*/
reqJSON(0, "http://" + hostPort + "/getvars?time=" + timeRange + "&userconfiguration=" + encodeURIComponent(JSON.stringify(getFormattedUserConfigurationFromLocalStorage())) + "&id="
+ clientID, successHandler, errorHandler);
reqJSONPOST(0, "http://" + hostPort + "/getvars", "time=" + timeRange + "&userconfiguration=" + JSON.stringify(getFormattedUserConfigurationFromLocalStorage()) + "&id="
+ clientID, successHandler, errorHandler);
break;
// Response to a "getvars"-server-request.
case "var_list":