2019-06-28 17:50:02 +00:00
|
|
|
local Ansi = require('opus.ansi')
|
|
|
|
local Config = require('opus.config')
|
|
|
|
local UI = require('opus.ui')
|
2019-03-22 05:40:29 +00:00
|
|
|
|
2019-03-23 16:20:48 +00:00
|
|
|
if _G.http.websocket then
|
2019-06-18 19:19:24 +00:00
|
|
|
local config = Config.load('cloud')
|
2019-03-22 05:40:29 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
local tab = UI.Tab {
|
2020-04-27 01:39:58 +00:00
|
|
|
title = 'Cloud',
|
2019-11-08 05:50:11 +00:00
|
|
|
description = 'Cloud Catcher options',
|
2020-04-22 04:40:59 +00:00
|
|
|
[1] = UI.Window {
|
|
|
|
x = 2, y = 2, ex = -2, ey = 4,
|
|
|
|
},
|
2019-06-18 19:19:24 +00:00
|
|
|
key = UI.TextEntry {
|
2020-04-22 04:40:59 +00:00
|
|
|
x = 3, ex = -3, y = 3,
|
2019-06-18 19:19:24 +00:00
|
|
|
limit = 32,
|
|
|
|
value = config.key,
|
|
|
|
shadowText = 'Cloud key',
|
|
|
|
accelerators = {
|
|
|
|
enter = 'update_key',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
button = UI.Button {
|
2020-04-22 04:40:59 +00:00
|
|
|
x = -8, ex = -2, y = -2,
|
|
|
|
text = 'Apply',
|
2019-06-18 19:19:24 +00:00
|
|
|
event = 'update_key',
|
|
|
|
},
|
|
|
|
labelText = UI.TextArea {
|
2020-04-22 04:40:59 +00:00
|
|
|
x = 2, ex = -2, y = 5, ey = -4,
|
|
|
|
textColor = 'yellow',
|
|
|
|
backgroundColor = 'black',
|
|
|
|
marginLeft = 1, marginRight = 1, marginTop = 1,
|
2019-06-18 19:19:24 +00:00
|
|
|
value = string.format(
|
2019-03-28 11:29:01 +00:00
|
|
|
[[Use a non-changing cloud key. Note that only a single computer can use this session at one time.
|
|
|
|
To obtain a key, visit:
|
|
|
|
%shttps://cloud-catcher.squiddev.cc%s then bookmark:
|
|
|
|
%shttps://cloud-catcher.squiddev.cc/?id=KEY
|
2019-06-18 19:19:24 +00:00
|
|
|
]],
|
|
|
|
Ansi.white, Ansi.reset, Ansi.white),
|
|
|
|
},
|
|
|
|
}
|
2019-03-22 05:40:29 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
function tab:eventHandler(event)
|
|
|
|
if event.type == 'update_key' then
|
2019-12-11 16:18:02 +00:00
|
|
|
if self.key.value then
|
2019-06-18 19:19:24 +00:00
|
|
|
config.key = self.key.value
|
|
|
|
else
|
|
|
|
config.key = nil
|
|
|
|
end
|
|
|
|
Config.update('cloud', config)
|
|
|
|
self:emit({ type = 'success_message', message = 'Updated' })
|
|
|
|
end
|
|
|
|
end
|
2019-03-22 05:40:29 +00:00
|
|
|
|
2019-06-18 19:19:24 +00:00
|
|
|
return tab
|
2019-03-23 16:20:48 +00:00
|
|
|
end
|
2019-03-22 05:40:29 +00:00
|
|
|
|