diff --git a/octoserve/var/www/channellist.lua b/octoserve/var/www/channellist.lua index 6cd0bd7..6c2c38a 100644 --- a/octoserve/var/www/channellist.lua +++ b/octoserve/var/www/channellist.lua @@ -118,7 +118,7 @@ function Legacy2JSON() return data end -function CreateJSON(host) +function CreateJSON() local data = nil local file = io.open("/config/ChannelList.json") if file then @@ -130,9 +130,26 @@ function CreateJSON(host) return data end +function TransponderList(user) + local data = nil + local file + if user then + file = io.open("/config/TransponderList.json","r") + end + if not file then + file = io.open("/var/channels/TransponderList.json","r") + end + if file then + data = file:read("*a") + file:close() + end + return data +end + function LoadSourceList() local db = require("DataBase") local SourceList = {} + local f,c for _,f in ipairs(db.SourceList) do f.ChannelList = {} @@ -160,7 +177,15 @@ if method == "GET" then elseif string.match(query,"select=json") then filename = "ChannelList.json" contenttype = "application/json; charset=utf-8" - data = CreateJSON(host) + data = CreateJSON() + elseif string.match(query,"select=stl") then + filename = "TransponderList.json" + contenttype = "application/json; charset=utf-8" + data = TransponderList(false) + elseif string.match(query,"select=tl") then + filename = "TransponderList.json" + contenttype = "application/json; charset=utf-8" + data = TransponderList(true) end if data then diff --git a/octoserve/var/www/channellists.html b/octoserve/var/www/channellists.html index 5721303..c452624 100644 --- a/octoserve/var/www/channellists.html +++ b/octoserve/var/www/channellists.html @@ -1,4 +1,4 @@ - +
@@ -107,7 +107,9 @@ function DisableButtons(disabled) document.getElementById("ScanButton").disabled = disabled; document.getElementById("StatusButton").disabled = disabled; document.getElementById("DeleteButton").disabled = disabled; + document.getElementById("DeleteAllButton").disabled = disabled; document.getElementById("RestoreButton").disabled = disabled; + document.getElementById("UploadButton").disabled = disabled; } @@ -169,6 +171,16 @@ function ScanStatus(response) else document.getElementById("scantext").firstChild.nodeValue = "Previous channel list restored"; } + else if( s.status == "error" ) + { + document.getElementById("scancount").firstChild.nodeValue = "Error"; + document.getElementById("scantext").firstChild.nodeValue = s.msg; + } + else if( s.status == "updated" ) + { + document.getElementById("scancount").firstChild.nodeValue = "\u00A0"; + document.getElementById("scantext").firstChild.nodeValue = s.msg + " updated"; + } else if( s.status == "retry" ) { done = false; @@ -236,11 +248,12 @@ function PollStatus() GetStatus(); } -function DeleteScan() +function DeleteScan(all) { DisableButtons(true); + ScanReq.open("POST", "/channelscan.lua", true); ScanReq.setRequestHeader("Content-type","application/x-www-form-urlencoded"); - ScanReq.send("select=delete"); + ScanReq.send("select=delete" + (all ? "&all=true" : "")); } function RestoreScan() @@ -251,15 +264,32 @@ function RestoreScan() ScanReq.send("select=restore"); } + +function Uploader(event) +{ + event.preventDefault(); + document.getElementById("scancount").firstChild.nodeValue = "\u00A0"; + document.getElementById("scantext").firstChild.nodeValue = "\u00A0"; + var fileSelect = document.getElementById("UploadList"); + if( fileSelect.files.length > 0 ) + { + var formData = new FormData(); + formData.append('filename', fileSelect.files[0], fileSelect.files[0].name) + DisableButtons(true); + ScanReq.open("POST", "/channelscan.lua", true); + ScanReq.send(formData); + } +} + -