| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- function getClock() {
- var d = new Date();
- nhour = d.getHours();
- nmin = d.getMinutes();
-
- if (nhour <= 9) {
- nhour = '0' + nhour;
- }
- if (nmin <= 9) {
- nmin = '0' + nmin;
- }
- document.getElementById('clock').innerHTML = nhour + ':' + nmin + ' Uhr';
- setTimeout(getClock, 1000);
- }
- jQuery(document).ready(function ($) {
- var themeVersion = '2.8';
- // Check für JS-Installation entfernen
- $('#hdr').addClass('js-installed');
- // attr WEB hiddenroom input -> Ansicht anpassen
- if ($('#hdr .maininput').length == 0) {
- $('#hdr').hide();
- $('#content').css({top: '10px'});
- }
- // Add version to logo
- $('#logo').append(
- $('<span class="theme-version">' + themeVersion + '</span>')
- ).append(
- $('<span id="clock"></span>')
- );
- // Add clock
- window.addEventListener('load', getClock, false);
- // Clear spaces
- $('#content .devType, #menu .room a').each(function() {
- $(this).html($(this).html().replace(/ /g, ''));
- });
- $('#content > br').remove();
- $('.makeSelect').parent().find('br').remove();
- // Add missing classes for elements
- $('.SVGplot').prevAll('a').addClass('plot-nav');
- // Icon selection
- $('button.dist').wrapAll('<div class="icons"/>');
- $('button.dist').css({width: '50px', height: '50px', margin: '5px', padding: '0'});
- $('button.dist > *').css({maxWidth: '40px', maxHeight: '40px', display: 'block', margin: '0px auto'});
- $('input[type=text][name=icon-filter]').keyup(function() {
- var val = $(this).val().toLowerCase();
- if (val.length === 0) {
- jQuery('button.dist').show();
- } else {
- jQuery('button.dist').hide().filter(function() {
- return $(this).attr('title').toLowerCase().indexOf(val) > -1;
- }).show();
- }
- });
- // Links in der Navigation hinzufügen
- var $navElement = jQuery('#menu .room').last().find('tbody');
- $navElement.append(
- $('<tr><td><div><a class="custom-menu-entry" href="https://github.com/klein0r/fhem-style-haus-automatisierung/issues/">Theme-Fehler melden (v' + themeVersion + ')</a></div></td></tr>')
- );
- // Automatische Breite für HDR Input
- $('#hdr input.maininput').css({width: $('#content').width() + 'px'});
- $(window).resize(function() {
- $('#hdr input.maininput').css({width: $('#content').width() + 'px'});
- });
- // Klick auf Error-Message blendet diese aus
- $('body').on('click', '#errmsg', function() {
- $(this).hide();
- });
- $('.roomoverview .col1, .makeTable .col1').each(function(index) {
- $(this).parent().addClass('first-table-column');
- });
- // hide elements by name
- if (document.URL.indexOf("showall") != -1) {
- //don't hide anything
- } else {
- $("div.devType:contains('-hidden')").parent('td').hide();
- }
- (function($, window, document, undefined) {
- 'use strict';
- var elSelector = '#hdr, #logo',
- elClassHidden = 'header--hidden',
- throttleTimeout = 50,
- $element = $(elSelector);
- if (!$element.length) return true;
- var $window = $(window),
- wHeight = 0,
- wScrollCurrent = 0,
- wScrollBefore = 0,
- wScrollDiff = 0,
- $document = $(document),
- dHeight = 0,
- throttle = function(delay, fn) {
- var last, deferTimer;
- return function() {
- var context = this, args = arguments, now = +new Date;
- if(last && now < last + delay) {
- clearTimeout(deferTimer);
- deferTimer = setTimeout(
- function() {
- last = now;
- fn.apply(context, args);
- },
- delay
- );
- } else {
- last = now;
- fn.apply(context, args);
- }
- };
- };
- $window.on('scroll', throttle(throttleTimeout, function() {
- dHeight = $document.height();
- wHeight = $window.height();
- wScrollCurrent = $window.scrollTop();
- wScrollDiff = wScrollBefore - wScrollCurrent;
- if (wScrollCurrent <= 50) {
- $element.removeClass(elClassHidden);
- } else if (wScrollDiff > 0 && $element.hasClass(elClassHidden)) {
- $element.removeClass(elClassHidden);
- } else if (wScrollDiff < 0) {
- if (wScrollCurrent + wHeight >= dHeight && $element.hasClass(elClassHidden)) {
- $element.removeClass(elClassHidden);
- } else {
- $element.addClass(elClassHidden);
- }
- }
- wScrollBefore = wScrollCurrent;
- }));
- })(jQuery, window, document);
- });
|