From acdb635f7a156fa2dca328007f788300b4cde5ab Mon Sep 17 00:00:00 2001 From: Bronley Date: Fri, 9 Jul 2021 15:16:43 -0400 Subject: [PATCH] Fix lint issues. --- components/JFButton.brs | 2 +- components/config/JFServer.brs | 18 +++++++++--------- components/config/SSDPTask.brs | 8 ++++---- components/config/SetServerScreen.brs | 12 +++++++----- source/ShowScenes.brs | 6 ++++-- source/utils/misc.brs | 24 ++++++++++++------------ 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/components/JFButton.brs b/components/JFButton.brs index 43cc926c..603482e1 100644 --- a/components/JFButton.brs +++ b/components/JFButton.brs @@ -14,7 +14,7 @@ sub onTextChanged() minChars = m.top.minChars if minChars = invalid then minChars = 50 while m.top.text.Len() < minChars - if addSpaceAfter then + if addSpaceAfter m.top.text = m.top.text + Chr(160) else m.top.text = Chr(160) + m.top.text diff --git a/components/config/JFServer.brs b/components/config/JFServer.brs index ff34d29d..c9c3f698 100644 --- a/components/config/JFServer.brs +++ b/components/config/JFServer.brs @@ -1,28 +1,28 @@ -function init() as void +sub init() as void m.poster = m.top.findNode("poster") m.name = m.top.findNode("name") m.baseUrl = m.top.findNode("baseUrl") m.labels = m.top.findNode("labels") setTextColor(0) -end function +end sub -function itemContentChanged() as void +sub itemContentChanged() as void server = m.top.itemContent m.poster.uri = server.iconUrl m.name.text = server.name m.baseUrl.text = server.baseUrl -end function +end sub -function onFocusPercentChange(event) +sub onFocusPercentChange(event) 'print "focusPercentChange: " ; event.getData() setTextColor(event.getData()) -end function +end sub -function setTextColor(percentFocused) +sub setTextColor(percentFocused) white = "0xffffffff" black = "0x00000099" - if percentFocused > .4 then + if percentFocused > .4 color = black else color = white @@ -32,4 +32,4 @@ function setTextColor(percentFocused) for each child in children child.color = color end for -end function +end sub diff --git a/components/config/SSDPTask.brs b/components/config/SSDPTask.brs index 397b08c8..0c728247 100644 --- a/components/config/SSDPTask.brs +++ b/components/config/SSDPTask.brs @@ -51,7 +51,7 @@ function GetServersViaSSDP() 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) match = CreateObject("roRegex", "\r\nLocation:\s*(.*?)\s*\r\n", "i").Match(recvStr) @@ -73,11 +73,11 @@ function GetServersViaSSDP() responseText = http.GetToString() xml = CreateObject("roXMLElement") 'if we successfully parsed the response, process it - if xml.Parse(responseText) then + if xml.Parse(responseText) deviceNode = xml.GetNamedElementsCi("device")[0] manufacturer = deviceNode.GetNamedElementsCi("manufacturer").GetText() 'only process jellyfin servers - if lcase(manufacturer) = "jellyfin" then + if lcase(manufacturer) = "jellyfin" 'find the largest icon width = 0 result = invalid @@ -96,7 +96,7 @@ function GetServersViaSSDP() iconWidth: iconNode.GetNamedElementsCi("width")[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 end if end for diff --git a/components/config/SetServerScreen.brs b/components/config/SetServerScreen.brs index 2ddfc1af..7e20711e 100644 --- a/components/config/SetServerScreen.brs +++ b/components/config/SetServerScreen.brs @@ -20,7 +20,7 @@ function onKeyEvent(key as string, press as boolean) as boolean if not press then return 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.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 @@ -47,12 +47,12 @@ function onKeyEvent(key as string, press as boolean) as boolean return handled end function -function ScanForServers() +sub ScanForServers() m.ssdpScanner = CreateObject("roSGNode", "SSDPTask") 'run the task m.ssdpScanner.observeField("content", "ScanForServersComplete") m.ssdpScanner.control = "RUN" -end function +end sub sub ScanForServersComplete(event) servers = event.getData() @@ -66,7 +66,7 @@ sub ScanForServersComplete(event) m.spinner.visible = false end sub -function ShowKeyboard() +sub ShowKeyboard() dialog = createObject("roSGNode", "KeyboardDialog") dialog.title = "Enter the server name or ip address" dialog.buttons = [tr("OK"), tr("Cancel")] @@ -76,7 +76,7 @@ function ShowKeyboard() m.dialog = dialog dialog.observeField("buttonSelected", "onDialogButton") -end function +end sub function onDialogButton() d = m.dialog @@ -89,5 +89,7 @@ function onDialogButton() else if button_text = tr("Cancel") m.dialog.close = true return true + else + return false end if end function diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs index 00e9d57c..3fbc98fa 100644 --- a/source/ShowScenes.brs +++ b/source/ShowScenes.brs @@ -24,7 +24,7 @@ function CreateServerGroup() if node = "submit" serverUrl = standardize_jellyfin_url(screen.serverUrl) '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("password", "") end if @@ -47,7 +47,8 @@ function CreateServerGroup() else if serverInfoResult.Error <> invalid and serverInfoResult.Error ' If server redirected received, update the URL if serverInfoResult.UpdatedUrl <> invalid - server_hostname.value = serverInfoResult.UpdatedUrl + serverUrl = serverInfoResult.UpdatedUrl + set_setting("server", serverUrl) end if ' Display Error Message to user message = tr("Error: ") @@ -66,6 +67,7 @@ function CreateServerGroup() ' Just hide it when done, in case we need to come back screen.visible = false + return "" end function function CreateUserSelectGroup(users = []) diff --git a/source/utils/misc.brs b/source/utils/misc.brs index 6d8a0b7e..e4a14694 100644 --- a/source/utils/misc.brs +++ b/source/utils/misc.brs @@ -31,11 +31,11 @@ end function function ticksToHuman(ticks as longinteger) as string totalSeconds = int(ticks / 10000000) hours = stri(int(totalSeconds / 3600)).trim() - minutes = stri(int((totalSeconds - (val(hours)*3600))/60)).trim() - seconds = stri(totalSeconds - (val(hours)*3600) - (val(minutes)*60)).trim() + minutes = stri(int((totalSeconds - (val(hours) * 3600)) / 60)).trim() + seconds = stri(totalSeconds - (val(hours) * 3600) - (val(minutes) * 60)).trim() if val(hours) > 0 and val(minutes) < 10 then minutes = "0" + minutes if val(seconds) < 10 then seconds = "0" + seconds - r="" + r = "" if val(hours) > 0 then r = hours + ":" r = r + minutes + ":" + seconds return r @@ -70,10 +70,10 @@ end function function div_ceiling(a as integer, b as integer) as integer if a < b then return 1 - if int(a/b) = a/b - return a/b + if int(a / b) = a / b + return a / b end if - return a/b + 1 + return a / b + 1 end function 'Returns the item selected or -1 on backpress or other unhandled closure of dialog. @@ -137,7 +137,7 @@ function show_dialog(message as string, options = [], defaultSelection = 0) as i end function function message_dialog(message = "" as string) - return show_dialog(message,["OK"]) + return show_dialog(message, ["OK"]) end function function option_dialog(options, message = "", defaultSelection = 0) as integer @@ -151,13 +151,13 @@ end function function standardize_jellyfin_url(url as string) 'Append default ports 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 end if 'Check to make sure entry has no extra slashes before adding default ports. - if Instr(0, url, "/") = maxSlashes then - if url.len() > 5 and mid(url, url.len() - 4, 1) <> ":" and mid(url, url.len() - 5, 1) <> ":" then - if left(url, 5) = "https" then + if Instr(0, url, "/") = maxSlashes + if url.len() > 5 and mid(url, url.len() - 4, 1) <> ":" and mid(url, url.len() - 5, 1) <> ":" + if left(url, 5) = "https" url = url + ":8920" else url = url + ":8096" @@ -165,7 +165,7 @@ function standardize_jellyfin_url(url as string) end if end if 'Append http:// to server - if left(url, 4) <> "http" then + if left(url, 4) <> "http" url = "http://" + url end if return url