Version 1.7

This commit is contained in:
OTCv8
2020-01-08 00:24:01 +01:00
parent 1d2bdf855d
commit 2a10e65ec0
42 changed files with 1157 additions and 563 deletions

View File

@@ -7,18 +7,27 @@ HTTP = {
}
function HTTP.get(url, callback)
if not g_http or not g_http.get then
return error("HTTP.get is not supported")
end
local operation = g_http.get(url, HTTP.timeout)
HTTP.operations[operation] = {type="get", url=url, callback=callback}
return operation
end
function HTTP.getJSON(url, callback)
if not g_http or not g_http.get then
return error("HTTP.getJSON is not supported")
end
local operation = g_http.get(url, HTTP.timeout)
HTTP.operations[operation] = {type="get", json=true, url=url, callback=callback}
return operation
end
function HTTP.post(url, data, callback)
if not g_http or not g_http.post then
return error("HTTP.post is not supported")
end
if type(data) == "table" then
data = json.encode(data)
end
@@ -28,6 +37,9 @@ function HTTP.post(url, data, callback)
end
function HTTP.postJSON(url, data, callback)
if not g_http or not g_http.post then
return error("HTTP.postJSON is not supported")
end
if type(data) == "table" then
data = json.encode(data)
end
@@ -37,12 +49,18 @@ function HTTP.postJSON(url, data, callback)
end
function HTTP.download(url, file, callback, progressCallback)
if not g_http or not g_http.download then
return error("HTTP.download is not supported")
end
local operation = g_http.download(url, file, HTTP.timeout)
HTTP.operations[operation] = {type="download", url=url, file=file, callback=callback, progressCallback=progressCallback}
return operation
end
function HTTP.downloadImage(url, callback)
if not g_http or not g_http.download then
return error("HTTP.downloadImage is not supported")
end
if HTTP.images[url] ~= nil then
if callback then
callback('/downloads/' .. HTTP.images[url], nil)
@@ -57,6 +75,9 @@ function HTTP.downloadImage(url, callback)
end
function HTTP.webSocket(url, callbacks, timeout, jsonWebsocket)
if not g_http or not g_http.ws then
return error("WebSocket is not supported")
end
if not timeout or timeout < 1 then
timeout = HTTP.websocketTimeout
end
@@ -84,6 +105,9 @@ end
HTTP.WebSocketJSON = HTTP.webSocketJSON
function HTTP.cancel(operationId)
if not g_http or not g_http.cancel then
return
end
return g_http.cancel(operationId)
end

View File

@@ -19,6 +19,10 @@ function UIComboBox:clearOptions()
self:clearText()
end
function UIComboBox:clear()
return self:clearOptions()
end
function UIComboBox:getOptionsCount()
return #self.options
end
@@ -108,12 +112,6 @@ function UIComboBox:removeOption(text)
end
end
function UIComboBox:clear()
self.options = {}
self.currentIndex = -1
self:setText("")
end
function UIComboBox:onMousePress(mousePos, mouseButton)
local menu
if self.menuScroll then