[SOLVED] Html view failure in milestone build 2.4 M6

error
openhab2
milestone
Tags: #<Tag:0x00007f013fc5df90> #<Tag:0x00007f013fc5de50> #<Tag:0x00007f013fc5dd10>

(Martin Puff) #1

Hello community,

i have a problem with the Milestone build, i have a html file added to the gui, but the view is broken, it was working with 2.3, now i am on 2.4 M6 and this is my first milestone build i have installed.

in 2.3 it looks like:

this is the code of the html file:

<html class="ui-icons-enabled">
<script>
    var openHabianPI = "192.168.178.81"
    function getParam(param)
    {
        var qs = (function(a) {
            if (a == "") return {};
            var b = {};
            for (var i = 0; i < a.length; ++i) {
                var p=a[i].split('=', 2);
                if (p.length == 1)
                    b[p[0]] = "";
                else
                    b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
            }
            return b;
        })(window.location.search.substr(1).split('&'));       
        return qs[param]
    }
    function httpGet(theUrl)
    {
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.onreadystatechange = function() {
    		if (this.readyState == 4 && this.status == 200) {
		    	document.getElementById('textInput').value = xmlHttp.responseText;
		    }
		};
        xmlHttp.open("GET", theUrl, true);
        xmlHttp.setRequestHeader("Accept", "text/plain");
        xmlHttp.send();
        return 
    }
    function httpPut(theUrl, theValue)
    {
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.open("POST", theUrl, true);
        xmlHttp.setRequestHeader("Content-type", "text/plain");
        xmlHttp.setRequestHeader("Accept", "application/json");
        xmlHttp.send(theValue)
    }
	function sendValue()
	{
        url = "http://" + openHabianPI + ":8080/rest/items/" + getParam('item');
        httpPut(url, document.getElementById('textInput').value)
    }
	function getValue()
	{
        url = "http://" + openHabianPI + ":8080/rest/items/" + getParam('item') + "/state";
        httpGet(url)
    }
</script>
<head>

	<link rel="stylesheet" type="text/css" href="../basicui/mdl/material.min.css" />
	<link rel="stylesheet" type="text/css" href="../basicui/material-icons.css" />
	<link rel="stylesheet" type="text/css" href="../basicui/roboto.css" />
	<link rel="stylesheet" type="text/css" href="../basicui/smarthome.css" />
	<script src="../basicui/mdl/material.min.js"></script>
	
	<style>
		form {
			margin-bottom: 0;
		}
		.mdl-form__row {
			border-bottom-style: none;
			height: auto;
			padding-top: 0;
			padding-right: 0;
			padding-bottom: 0;
			padding-left: 0;
		}
	</style>
</head>
<body class="mdl-color-text--grey-700" data-icon-type="svg">
	<form action="JavaScript:sendValue()">
		<div class="mdl-form__row mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet">
			<span class="mdl-form__icon">
				<img data-icon="text" src="../icon/text?format=svg" />
			</span>
			<div class="mdl-form__label" id=label>
			</div>
			<div>
                <input type="text" name="textInput" id="textInput">
			</div>
			<div>
				<input type="submit" value="Submit">
			</div>
		</div>
		<script>
			document.getElementById('label').innerHTML = getParam('label');
			document.getElementById('textInput').value = getValue()
		</script>
	</form>
</body>
</html>

[OH 2.4.0 M7] Testing Results
[OH 2.4.0 M7] Testing Results
[OH 2.4.0 M7] Testing Results
(Angelos) #2

anything in the log of openhab or any hint when using F12 (developer tools) in Chrome?

How does your sitemap entry look like?

Can you load it up using http://192.168.178.81/static/whatever.html ?

I cannot reproduce this. It works on my test M7 system


(Martin Puff) #3


(Angelos) #4

so… it works when calling it from static
it should work on your sitemap also then
how does the sitemap entry look like?


(Martin Puff) #5

today i have installed a fresh openhab 2.4M7, now it works