Master style override

Yes, i can. I used a template node with the following code:

<script id="titleScript" type="text/javascript">
    //
    if(/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
        // Talking to phone or tablet
        $('#clock').remove();
        var toolbar = $('.md-toolbar-tools');
        var div = $('<div/>');
        var q = $('<p/ id="clock">');
        $('#titleScript').parent().hide();
        div.append(q);
        div[0].style.margin = '5px 5px 5px auto';
        toolbar.append(div);
        //
        function displayTitle(lh) {
            q.text(lh); 
        }
        function upTime() {
            var d = new Date();
            q.text(d.toLocaleTimeString('nl-NL',{hour:'2-digit',minute:'2-digit'}));
        }
        //
        (function(scope) {
            scope.$watch('msg.payload', function(data) {});
            setInterval(upTime,10000);
        })(scope);
    } else {
        // Talking to real hardware
        $('#clock').remove();
        var toolbar = $('.md-toolbar-tools');
        var div = $('<div/>');
        var p = $('<p/ id="clock">');
        var t1 = "komt";
        var t2 = "komt";
        $('#titleScript').parent().hide();
        div.append(p);
        div[0].style.margin = '5px 5px 5px auto';
        toolbar.append(div);
        //
        function displayTitle(lh) {
            p.text(lh); 
        }
        function upTime() {
            var d = new Date();
            p.text("Temperatuur buiten: " + t1 + "°C, -binnen: " + t2 + "°C,  actuele tijd: " + d.toLocaleTimeString('nl-NL',{ hour:'2-digit',minute:'2-digit'}));
        }
        //
        (function(scope) {
            scope.$watch('msg.payload', function(data) {
                t1 = data.t1;
                t2 = data.t2;
            });
            setInterval(upTime,10000);
        })(scope);
    }
</script>

image

The content of function node "t1" could look like this:

var new_msg = {payload: {t1: "", t2: ""}};
new_msg.payload.t1 = global.get ('outside_temp');
new_msg.payload.t2 = msg.payload;
return new_msg;

That's all. I'd like to hear about improvements.

1 Like