Fix lint issues.

This commit is contained in:
Bronley 2021-07-09 15:16:43 -04:00
parent fa2452c037
commit acdb635f7a
6 changed files with 37 additions and 33 deletions

View File

@ -14,7 +14,7 @@ sub onTextChanged()
minChars = m.top.minChars minChars = m.top.minChars
if minChars = invalid then minChars = 50 if minChars = invalid then minChars = 50
while m.top.text.Len() < minChars while m.top.text.Len() < minChars
if addSpaceAfter then if addSpaceAfter
m.top.text = m.top.text + Chr(160) m.top.text = m.top.text + Chr(160)
else else
m.top.text = Chr(160) + m.top.text m.top.text = Chr(160) + m.top.text

View File

@ -1,28 +1,28 @@
function init() as void sub init() as void
m.poster = m.top.findNode("poster") m.poster = m.top.findNode("poster")
m.name = m.top.findNode("name") m.name = m.top.findNode("name")
m.baseUrl = m.top.findNode("baseUrl") m.baseUrl = m.top.findNode("baseUrl")
m.labels = m.top.findNode("labels") m.labels = m.top.findNode("labels")
setTextColor(0) setTextColor(0)
end function end sub
function itemContentChanged() as void sub itemContentChanged() as void
server = m.top.itemContent server = m.top.itemContent
m.poster.uri = server.iconUrl m.poster.uri = server.iconUrl
m.name.text = server.name m.name.text = server.name
m.baseUrl.text = server.baseUrl m.baseUrl.text = server.baseUrl
end function end sub
function onFocusPercentChange(event) sub onFocusPercentChange(event)
'print "focusPercentChange: " ; event.getData() 'print "focusPercentChange: " ; event.getData()
setTextColor(event.getData()) setTextColor(event.getData())
end function end sub
function setTextColor(percentFocused) sub setTextColor(percentFocused)
white = "0xffffffff" white = "0xffffffff"
black = "0x00000099" black = "0x00000099"
if percentFocused > .4 then if percentFocused > .4
color = black color = black
else else
color = white color = white
@ -32,4 +32,4 @@ function setTextColor(percentFocused)
for each child in children for each child in children
child.color = color child.color = color
end for end for
end function end sub

View File

@ -51,7 +51,7 @@ function GetServersViaSSDP()
msg = Wait(maxTimeMs - elapsed, port) msg = Wait(maxTimeMs - elapsed, port)
if Type (msg) = "roSocketEvent" and msg.GetSocketId() = ssdp.GetId() and ssdp.IsReadable() then if Type (msg) = "roSocketEvent" and msg.GetSocketId() = ssdp.GetId() and ssdp.IsReadable()
recvStr = ssdp.ReceiveStr(4096) recvStr = ssdp.ReceiveStr(4096)
match = CreateObject("roRegex", "\r\nLocation:\s*(.*?)\s*\r\n", "i").Match(recvStr) match = CreateObject("roRegex", "\r\nLocation:\s*(.*?)\s*\r\n", "i").Match(recvStr)
@ -73,11 +73,11 @@ function GetServersViaSSDP()
responseText = http.GetToString() responseText = http.GetToString()
xml = CreateObject("roXMLElement") xml = CreateObject("roXMLElement")
'if we successfully parsed the response, process it 'if we successfully parsed the response, process it
if xml.Parse(responseText) then if xml.Parse(responseText)
deviceNode = xml.GetNamedElementsCi("device")[0] deviceNode = xml.GetNamedElementsCi("device")[0]
manufacturer = deviceNode.GetNamedElementsCi("manufacturer").GetText() manufacturer = deviceNode.GetNamedElementsCi("manufacturer").GetText()
'only process jellyfin servers 'only process jellyfin servers
if lcase(manufacturer) = "jellyfin" then if lcase(manufacturer) = "jellyfin"
'find the largest icon 'find the largest icon
width = 0 width = 0
result = invalid result = invalid
@ -96,7 +96,7 @@ function GetServersViaSSDP()
iconWidth: iconNode.GetNamedElementsCi("width")[0].GetText().ToInt(), iconWidth: iconNode.GetNamedElementsCi("width")[0].GetText().ToInt(),
iconHeight: iconNode.GetNamedElementsCi("height")[0].GetText().ToInt() iconHeight: iconNode.GetNamedElementsCi("height")[0].GetText().ToInt()
} }
if baseUrl <> invalid and loopResult.iconWidth > width then if baseUrl <> invalid and loopResult.iconWidth > width
result = loopResult result = loopResult
end if end if
end for end for

View File

@ -20,7 +20,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
if not press then return true if not press then return true
handled = true handled = true
if key = "OK" and m.serverPicker.hasFocus() then if key = "OK" and m.serverPicker.hasFocus()
m.top.serverUrl = m.serverPicker.content.getChild(m.serverPicker.itemFocused).baseUrl m.top.serverUrl = m.serverPicker.content.getChild(m.serverPicker.itemFocused).baseUrl
m.submit.setFocus(true) m.submit.setFocus(true)
'if the user pressed the down key and we are already at the last child of server picker, then change focus to the url textbox 'if the user pressed the down key and we are already at the last child of server picker, then change focus to the url textbox
@ -47,12 +47,12 @@ function onKeyEvent(key as string, press as boolean) as boolean
return handled return handled
end function end function
function ScanForServers() sub ScanForServers()
m.ssdpScanner = CreateObject("roSGNode", "SSDPTask") m.ssdpScanner = CreateObject("roSGNode", "SSDPTask")
'run the task 'run the task
m.ssdpScanner.observeField("content", "ScanForServersComplete") m.ssdpScanner.observeField("content", "ScanForServersComplete")
m.ssdpScanner.control = "RUN" m.ssdpScanner.control = "RUN"
end function end sub
sub ScanForServersComplete(event) sub ScanForServersComplete(event)
servers = event.getData() servers = event.getData()
@ -66,7 +66,7 @@ sub ScanForServersComplete(event)
m.spinner.visible = false m.spinner.visible = false
end sub end sub
function ShowKeyboard() sub ShowKeyboard()
dialog = createObject("roSGNode", "KeyboardDialog") dialog = createObject("roSGNode", "KeyboardDialog")
dialog.title = "Enter the server name or ip address" dialog.title = "Enter the server name or ip address"
dialog.buttons = [tr("OK"), tr("Cancel")] dialog.buttons = [tr("OK"), tr("Cancel")]
@ -76,7 +76,7 @@ function ShowKeyboard()
m.dialog = dialog m.dialog = dialog
dialog.observeField("buttonSelected", "onDialogButton") dialog.observeField("buttonSelected", "onDialogButton")
end function end sub
function onDialogButton() function onDialogButton()
d = m.dialog d = m.dialog
@ -89,5 +89,7 @@ function onDialogButton()
else if button_text = tr("Cancel") else if button_text = tr("Cancel")
m.dialog.close = true m.dialog.close = true
return true return true
else
return false
end if end if
end function end function

View File

@ -24,7 +24,7 @@ function CreateServerGroup()
if node = "submit" if node = "submit"
serverUrl = standardize_jellyfin_url(screen.serverUrl) serverUrl = standardize_jellyfin_url(screen.serverUrl)
'If this is a different server from what we know, reset username/password setting 'If this is a different server from what we know, reset username/password setting
if get_setting("server") <> serverUrl then if get_setting("server") <> serverUrl
set_setting("username", "") set_setting("username", "")
set_setting("password", "") set_setting("password", "")
end if end if
@ -47,7 +47,8 @@ function CreateServerGroup()
else if serverInfoResult.Error <> invalid and serverInfoResult.Error else if serverInfoResult.Error <> invalid and serverInfoResult.Error
' If server redirected received, update the URL ' If server redirected received, update the URL
if serverInfoResult.UpdatedUrl <> invalid if serverInfoResult.UpdatedUrl <> invalid
server_hostname.value = serverInfoResult.UpdatedUrl serverUrl = serverInfoResult.UpdatedUrl
set_setting("server", serverUrl)
end if end if
' Display Error Message to user ' Display Error Message to user
message = tr("Error: ") message = tr("Error: ")
@ -66,6 +67,7 @@ function CreateServerGroup()
' Just hide it when done, in case we need to come back ' Just hide it when done, in case we need to come back
screen.visible = false screen.visible = false
return ""
end function end function
function CreateUserSelectGroup(users = []) function CreateUserSelectGroup(users = [])

View File

@ -151,13 +151,13 @@ end function
function standardize_jellyfin_url(url as string) function standardize_jellyfin_url(url as string)
'Append default ports 'Append default ports
maxSlashes = 0 maxSlashes = 0
if left(url, 8) = "https://" or left(url, 7) = "http://" then if left(url, 8) = "https://" or left(url, 7) = "http://"
maxSlashes = 2 maxSlashes = 2
end if end if
'Check to make sure entry has no extra slashes before adding default ports. 'Check to make sure entry has no extra slashes before adding default ports.
if Instr(0, url, "/") = maxSlashes then if Instr(0, url, "/") = maxSlashes
if url.len() > 5 and mid(url, url.len() - 4, 1) <> ":" and mid(url, url.len() - 5, 1) <> ":" then if url.len() > 5 and mid(url, url.len() - 4, 1) <> ":" and mid(url, url.len() - 5, 1) <> ":"
if left(url, 5) = "https" then if left(url, 5) = "https"
url = url + ":8920" url = url + ":8920"
else else
url = url + ":8096" url = url + ":8096"
@ -165,7 +165,7 @@ function standardize_jellyfin_url(url as string)
end if end if
end if end if
'Append http:// to server 'Append http:// to server
if left(url, 4) <> "http" then if left(url, 4) <> "http"
url = "http://" + url url = "http://" + url
end if end if
return url return url