2015-07-31 21:21:28 +02:00
|
|
|
if not pocket or not term.isColor() then
|
|
|
|
print("sPhone is only for Advanced Pocket Computers!")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local files = {
|
|
|
|
["src/sPhone.lua"] = "/.sPhone/sPhone",
|
2015-08-19 11:45:35 +02:00
|
|
|
|
2015-07-31 21:21:28 +02:00
|
|
|
["src/apis/sha256.lua"] = "/.sPhone/apis/sha256",
|
|
|
|
["src/apis/sertextext.lua"] = "/.sPhone/apis/sertextext",
|
|
|
|
["src/apis/graphics.lua"] = "/.sPhone/apis/graphics",
|
2015-08-19 11:45:35 +02:00
|
|
|
["src/apis/ui.lua"] = "/.sPhone/apis/ui",
|
|
|
|
|
|
|
|
["src/apps/system/settings.lua"] = "/.sPhone/apps/system/settings",
|
|
|
|
["src/apps/cstwallet.lua"] = "/.sPhone/apps/cstwallet",
|
|
|
|
["src/apps/cst/api.lua"] = "/.sPhone/apps/cst/api",
|
|
|
|
|
|
|
|
["src/apps/sms.lua"] = "/.sPhone/apps/sms",
|
|
|
|
["src/apps/gps.lua"] = "/.sPhone/apps/gps",
|
|
|
|
|
|
|
|
["src/interfaces/login"] = "/.sPhone/interfaces/login",
|
|
|
|
|
|
|
|
|
2015-07-31 21:39:45 +02:00
|
|
|
["src/startup"] = "/startup",
|
2015-07-31 21:21:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local githubUser = "Sertex-Team"
|
|
|
|
local githubRepo = "sPhone"
|
|
|
|
local githubBranch = "master"
|
|
|
|
|
|
|
|
|
|
|
|
local function clear()
|
|
|
|
term.setBackgroundColor(colors.white)
|
2015-07-31 21:26:59 +02:00
|
|
|
term.clear()
|
|
|
|
term.setCursorPos(1, 1)
|
|
|
|
term.setTextColor(colors.black)
|
2015-07-31 21:21:28 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function center(text)
|
|
|
|
local w, h = term.getSize()
|
|
|
|
local x, y = term.getCursorPos()
|
2015-07-31 21:35:04 +02:00
|
|
|
term.setCursorPos(math.ceil(w/2), y)
|
2015-07-31 21:21:28 +02:00
|
|
|
write(text)
|
|
|
|
end
|
|
|
|
|
2015-07-31 21:35:04 +02:00
|
|
|
function spiral(y,time) -- made by BadCoder_
|
|
|
|
time = tonumber(time) * 2
|
|
|
|
|
|
|
|
frames = {
|
|
|
|
"/",
|
|
|
|
"-",
|
|
|
|
"\\",
|
|
|
|
"|"
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor = 1
|
|
|
|
timer = nil
|
|
|
|
|
|
|
|
for i = 1 , tonumber(time) do
|
|
|
|
|
|
|
|
center(y, frames[cursor])
|
|
|
|
|
|
|
|
timer = os.startTimer(.5)
|
|
|
|
|
|
|
|
while true do
|
|
|
|
local e = {os.pullEvent()}
|
|
|
|
|
|
|
|
if e[1] == "timer" and e[2] == timer then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
cursor = cursor + 1
|
|
|
|
|
|
|
|
if cursor > #frames then
|
|
|
|
cursor = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-31 21:21:28 +02:00
|
|
|
local function httpGet(url, save)
|
|
|
|
if not url then
|
|
|
|
error("not enough arguments, expected 1 or 2", 2)
|
|
|
|
end
|
|
|
|
local remote = http.get(url)
|
|
|
|
if not remote then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
local text = remote.readAll()
|
|
|
|
remote.close()
|
|
|
|
if save then
|
|
|
|
local file = fs.open(save, "w")
|
|
|
|
file.write(text)
|
|
|
|
file.close()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return text
|
|
|
|
end
|
|
|
|
|
|
|
|
local function get(user, repo, bran, path, save)
|
|
|
|
if not user or not repo or not bran or not path then
|
|
|
|
error("not enough arguments, expected 4 or 5", 2)
|
|
|
|
end
|
|
|
|
local url = "https://raw.github.com/"..user.."/"..repo.."/"..bran.."/"..path
|
|
|
|
local remote = http.get(url)
|
|
|
|
if not remote then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
local text = remote.readAll()
|
|
|
|
remote.close()
|
|
|
|
if save then
|
|
|
|
local file = fs.open(save, "w")
|
|
|
|
file.write(text)
|
|
|
|
file.close()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return text
|
|
|
|
end
|
|
|
|
|
|
|
|
local function getFile(file, target)
|
|
|
|
return get(githubUser, githubRepo, githubBranch, file, target)
|
|
|
|
end
|
|
|
|
|
|
|
|
shell.setDir("")
|
|
|
|
|
|
|
|
clear()
|
|
|
|
|
|
|
|
local fileCount = 0
|
|
|
|
for _ in pairs(files) do
|
|
|
|
fileCount = fileCount + 1
|
|
|
|
end
|
|
|
|
local filesDownloaded = 0
|
|
|
|
|
|
|
|
local w, h = term.getSize()
|
|
|
|
|
|
|
|
for k, v in pairs(files) do
|
|
|
|
term.setTextColor(colors.black)
|
|
|
|
term.setBackgroundColor(colors.white)
|
|
|
|
clear()
|
|
|
|
term.setCursorPos(2, 2)
|
2015-07-31 21:35:26 +02:00
|
|
|
print("sPhone")
|
2015-07-31 21:21:28 +02:00
|
|
|
print("")
|
2015-07-31 21:35:04 +02:00
|
|
|
print(" Getting files")
|
2015-07-31 21:21:28 +02:00
|
|
|
term.setCursorPos(2, h - 1)
|
|
|
|
local ok = k:sub(1, 4) == "ext:" and httpGet(k:sub(5), v) or getFile(k, v)
|
|
|
|
if not ok then
|
|
|
|
if term.isColor() then
|
|
|
|
term.setTextColor(colors.red)
|
|
|
|
end
|
|
|
|
term.setCursorPos(2, 6)
|
|
|
|
print("Error getting file:")
|
|
|
|
term.setCursorPos(2, 7)
|
|
|
|
print(k)
|
|
|
|
sleep(1)
|
|
|
|
end
|
|
|
|
filesDownloaded = filesDownloaded + 1
|
|
|
|
end
|
|
|
|
clear()
|
|
|
|
term.setCursorPos(2, 2)
|
2015-07-31 21:35:26 +02:00
|
|
|
print("sPhone")
|
2015-07-31 21:21:28 +02:00
|
|
|
print("")
|
2015-07-31 21:35:04 +02:00
|
|
|
print(" sPhone installed!")
|
|
|
|
print("")
|
|
|
|
spiral(9, 2)
|
2015-07-31 21:21:28 +02:00
|
|
|
os.reboot()
|