Files
JellyCAT/app/js/search.js
2024-02-17 23:28:02 +01:00

53 lines
1.6 KiB
JavaScript

// /\_/|
// { ' ' } JellyCAT
// \____\
function checkLogin() {
if (atv.localStorage['jellyfin_loggedin'] === '1') {
renderSearchScreen();
} else {
console.log("No authenticated user.");
renderLoginRequestScreen();
}
}
function renderSearchScreen() {
xmlstr = '<?xml version="1.0" encoding="UTF-8"?>' +
'<atv>' +
' <head>' +
' <script src="http://jcathost.dns/js/jcm.js"/>' +
' <script src="http://jcathost.dns/js/searchfuncs.js"/>' +
' </head>' +
' <body>' +
' <search id="com.jellycat.search">' +
' <header>' +
' <simpleHeader accessibilityLabel="Search">' +
' <title>Search</title>' +
' </simpleHeader>' +
' </header>' +
' <baseURL>http://jcathost.dns/xml/sni.xml?s=</baseURL>' +
' </search>' +
' </body>' +
'</atv>';
xmlDoc = atv.parseXML(xmlstr);
atv.loadAndSwapXML(xmlDoc);
}
function renderLoginRequestScreen() {
xmlstr = '<?xml version="1.0" encoding="UTF-8"?>' +
'<atv>' +
' <head>' +
' <script src="http://jcathost.dns/js/jcm.js"/>' +
' <script src="http://jcathost.dns/js/search.js"/>' +
' </head>' +
' <body>' +
' <dialog id="com.jellycat.pleaselogin-dialog">' +
' <title>Not Connected</title>' +
' <description>Please go to the settings tab and add a Jellyfin Server.</description>' +
' </dialog>' +
' </body>' +
'</atv>';
xmlDoc = atv.parseXML(xmlstr);
atv.loadAndSwapXML(xmlDoc);
}