Mercurial > hg > orthanc-stone
diff Platforms/Wasm/WasmWebService.js @ 315:aad37d0b6407 am-2
Added LayerWidget::RemoveLayer + DELETE commands in WebService
author | am@osimis.io |
---|---|
date | Fri, 05 Oct 2018 10:38:16 +0200 |
parents | 14ef1227120f |
children | aee3d7941c9b |
line wrap: on
line diff
--- a/Platforms/Wasm/WasmWebService.js Wed Oct 03 17:14:17 2018 +0200 +++ b/Platforms/Wasm/WasmWebService.js Fri Oct 05 10:38:16 2018 +0200 @@ -57,5 +57,34 @@ } xhr.send(new Uint8ClampedArray(HEAPU8.buffer, body, bodySize)); + }, + + WasmWebService_DeleteAsync: function(callableSuccess, callableFailure, url, headersInJsonString, payload, timeoutInSeconds) { + var xhr = new XMLHttpRequest(); + var url_ = UTF8ToString(url); + var headersInJsonString_ = UTF8ToString(headersInJsonString); + xhr.open('DELETE', url_, true); + xhr.timeout = timeoutInSeconds * 1000; + xhr.responseType = 'arraybuffer'; + xhr.setRequestHeader('Content-type', 'application/octet-stream'); + + var headers = JSON.parse(headersInJsonString_); + for (var key in headers) { + xhr.setRequestHeader(key, headers[key]); + } + + xhr.onreadystatechange = function() { + if (this.readyState == XMLHttpRequest.DONE) { + if (xhr.status === 200) { + WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response), + this.response.byteLength, payload); + } else { + WasmWebService_NotifyError(callableFailure, url_, payload); + } + } + } + + xhr.send(); } + });