Multi-word channel-names and API-fixes

- Spaces and signs allowed in channel-name
- Added missing functioncalls in RESTApi
This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-31 14:45:21 +02:00
parent e3c15431c5
commit 82ac25c5d2
19 changed files with 275 additions and 137 deletions

View File

@@ -1,5 +1,23 @@
var Helper = {
logs: [],
decodeChannelName: function(str) {
var _fn = decodeURIComponent;
str = str.toUpperCase();
var toReturn = _fn(str.replace(/%5F/g, "_"));
toReturn = toReturn.toLowerCase().replace(/&/g, "&");
return toReturn.toLowerCase();
},
encodeChannelName: function(str) {
var _fn = encodeURIComponent;
var toReturn = _fn(str);
toReturn = toReturn.replace(/_/g, "%5F");
toReturn = toReturn.replace(/%26amp%3B/g, "%26").replace(/%26amp%3b/g, "%26");
toReturn = toReturn.toLowerCase();
return toReturn;
},
log: function(to_log) {
if(localStorage.debug === "true") {
console.log("------------ " + new Date() + " ------------");/*RemoveLogging:skip*/
@@ -315,12 +333,12 @@ var Helper = {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
if (xmlhttp.status == 200 || xmlhttp.status == 201 || xmlhttp.status == 202) {
obj.success(xmlhttp.responseText, xmlhttp);
}
else if(obj.hasOwnProperty("error")){
obj.error(xmlhttp);
}
if (xmlhttp.status == 200 || xmlhttp.status == 201 || xmlhttp.status == 202) {
obj.success(xmlhttp.responseText, xmlhttp);
}
else if(obj.hasOwnProperty("error")){
obj.error(xmlhttp);
}
}
};