diff options
Diffstat (limited to 'frontend/src/utils.js')
-rw-r--r-- | frontend/src/utils.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/frontend/src/utils.js b/frontend/src/utils.js index 06414ac..0f0927e 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -18,15 +18,15 @@ const timeRegex = /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/; export function createCurlCommand(subCommand, method = null, json = null, data = null) { - const full = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); + const full = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); let contentType = null; let content = null; if (json != null) { - contentType = ' -H "Content-Type: application/json" \\\n'; + contentType = " -H \"Content-Type: application/json\" \\\n"; content = ` -d '${JSON.stringify(json)}'`; } else if (data != null) { - contentType = ' -H "Content-Type: multipart/form-data" \\\n'; + contentType = " -H \"Content-Type: multipart/form-data\" \\\n"; content = " " + Object.entries(data).map(([key, value]) => `-F "${key}=${value}"`).join(" \\\n "); } @@ -66,13 +66,13 @@ export function timeToTimestamp(time) { let d = new Date(); let matches = time.match(timeRegex); - if (matches[1] !== undefined) { + if (matches[1]) { d.setHours(matches[1]); } - if (matches[2] !== undefined) { + if (matches[2]) { d.setMinutes(matches[2]); } - if (matches[3] !== undefined) { + if (matches[3]) { d.setSeconds(matches[3]); } @@ -84,7 +84,7 @@ export function timestampToTime(timestamp) { let hours = d.getHours(); let minutes = "0" + d.getMinutes(); let seconds = "0" + d.getSeconds(); - return hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2); + return hours + ":" + minutes.substr(-2) + ":" + seconds.substr(-2); } export function timestampToDateTime(timestamp) { @@ -100,7 +100,7 @@ export function dateTimeToTime(dateTime) { let hours = dateTime.getHours(); let minutes = "0" + dateTime.getMinutes(); let seconds = "0" + dateTime.getSeconds(); - return hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2); + return hours + ":" + minutes.substr(-2) + ":" + seconds.substr(-2); } export function durationBetween(from, to) { @@ -131,7 +131,7 @@ export function randomClassName() { export function getHeaderValue(request, key) { if (request && request.headers) { - return request.headers[Object.keys(request.headers).find(k => k.toLowerCase() === key.toLowerCase())]; + return request.headers[Object.keys(request.headers).find((k) => k.toLowerCase() === key.toLowerCase())]; } return undefined; } @@ -154,7 +154,7 @@ export function updateParams(urlParams, payload) { params.delete(key); } else if (Array.isArray(value)) { params.delete(key); - value.forEach(v => params.append(key, v)); + value.forEach((v) => params.append(key, v)); } else { params.set(key, value); } |