1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-15 05:55:18 +00:00
harbour-sailfin/qml/Utils.js
Chris Josten a358caf13e Fixed few bugs related to login/logout
* Pressing the logout button now brings the setup page up again
* Removing a server and readding one of which the hash of the address
  has a higher value than the previous one does no longer cause the
  application to request a login each time you open it.
* The method for deciding if the user is in setup has been changed. It
  now checks if a page in the pageStack has the property _isSetupPage,
  which works better than manually keeping track of state.
2020-09-27 00:42:20 +02:00

40 lines
1.2 KiB
JavaScript

.pragma library
/**
* Converts miliseconds to a h:mm:ss format
*/
function timeToText(time) {
if (time < 0) return "??:??:??"
var hours = Math.floor(time / (60 * 60 * 1000))
var left = time % (60 * 60 * 1000)
var minutes = Math.floor(left / (60 * 1000))
left = time % (60 * 1000)
var seconds = Math.floor(left / 1000)
return hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "")+ seconds
}
function ticksToText(ticks) {
return timeToText(ticks / 10000);
}
function itemImageUrl(baseUrl, item, type, options) {
if (!item.ImageTags[type]) { return "" }
return itemModelImageUrl(baseUrl, item.Id, item.ImageTags[type], type, options)
}
function itemModelImageUrl(baseUrl, itemId, tag, type, options) {
if (tag == undefined) return ""
var extraQuery = "";
for (var prop in options) {
if (options.hasOwnProperty(prop)) {
extraQuery += "&" + prop + "=" + options[prop];
}
}
return baseUrl + "/Items/" + itemId + "/Images/" + type + "?tag=" + tag + extraQuery
}
function usePortraitCover(itemType) {
return ["Series", "Movie"].indexOf(itemType) >= 0
}