chef 3749 Posted January 31, 2020 Author Share Posted January 31, 2020 I updated the Link on the OP with a plugin DLL which handles both types of time. Link to comment Share on other sites More sharing options...
chef 3749 Posted January 31, 2020 Author Share Posted January 31, 2020 @@chef Québec use 24h too I don't get to visit Quebec as often as I should. Montreal a la meilleure .... (how to you say food again... com'on Chef...) ... au monde, et j'ai mangé à Paris. Broken French... bad Canadian Chef... bad. 1 Link to comment Share on other sites More sharing options...
chef 3749 Posted February 9, 2020 Author Share Posted February 9, 2020 This new version of the code will draw the upTime Element on the dashboard. Slowly hacking my way to a version which will have to have limited edits when the server updates. upTime() function upTime() { var ApiClient = function(endpoint) { return new Promise((resolve, reject) => { var url = window.location.href.split("/web")[0] + "/emby"; var xhr = new XMLHttpRequest(); xhr.open('GET', url + endpoint, true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200) { try { resolve(JSON.parse(xhr.responseText)); } catch (err) {} } else { reject(xhr.status); } } }; xhr.send(); }); } var upTimeCounter; ready(".localUrl", (element) => { clearInterval(upTimeCounter); // Create a the upTime Element var upTimeNode = document.createElement('p'); upTimeNode.id = 'upTime'; // Insert the upTime node before the #localUrl node element.parentNode.insertBefore(upTimeNode, element); ApiClient('/GetSystemUptimeData').then((json) => { upTimeNode.innerHTML = 'Up Time: ' + json['UpTimeDays'] + ' Days ' + json['UpTimeHours'] + ' Hours' }); upTimeCounter = setInterval(() => { console.log('update uptime'); ApiClient('/GetSystemUptimeData').then((json) => { upTimeNode.innerHTML = 'Up Time: ' + json['UpTimeDays'] + ' Days ' + json['UpTimeHours'] + ' Hours' }) }, 60 * 60 * 60) }) } (function(win) { 'use strict'; var listeners = [], doc = win.document, MutationObserver = win.MutationObserver || win.WebKitMutationObserver, observer; function ready(selector, fn) { // Store the selector and callback to be monitored listeners.push({ selector: selector, fn: fn }); if (!observer) { // Watch for changes in the document observer = new MutationObserver(function(mutations) { check() }); observer.observe(doc.documentElement, { childList: true, subtree: true, attributes: true, attributeOldValue: true, }); } // Check if the element is currently in the DOM check(); } function check() { // Check the DOM for elements matching a stored selector for (var i = 0, len = listeners.length, listener, elements; i < len; i++) { listener = listeners[i]; // Query for elements matching the specified selector elements = doc.querySelectorAll(listener.selector); for (var j = 0, jLen = elements.length, element; j < jLen; j++) { element = elements[j]; // Make sure the callback isn't invoked with the // same element more than once if (!element.ready) { element.ready = true; // Invoke the callback with the element listener.fn.call(element, element); } } } } // Expose `ready` win.ready = ready; })(this); Link to comment Share on other sites More sharing options...
chef 3749 Posted February 9, 2020 Author Share Posted February 9, 2020 you could also cut and paste this script link in your index.html after you install the plugin: <script src="https://rawcdn.githack.com/chefbennyj1/Emby.UpTime/fc490d73a699e51c84ba9dbab0095a91be0a6e7e/UpTime.js"></script> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now