Working with <HTMLInputElement> and console.log()

28 views
Skip to first unread message

Allan Yip

unread,
Dec 24, 2018, 8:05:32 AM12/24/18
to weinre
Hi all,

I have two devices on which I run my code. First one is my dev pc and the application is running on Node. Then second device is a signage device, which has support for HTML5, and Javascript es5. On this device I use WEINRE as remote debugger.

When I try to console log the following line, It's being displayed on the dev pc, which results in a number. But when I try this on the signage device (which is running the same JS version etc.) It's not displaying anything at all:

<HTMLInputElement>this.content.getElementsByTagName('body')[0].getElementsByTagName('par')[0]).children

I think it has something to do with the <HTMLInputElement>, on which I've never used before. The this.content contains a SMIL playlist for my application, which is legit as it's running on my dev pc running Node. 

Any idea what might be the problem? Is it even WEINRE related? I hope someone can help me out.


Thanks in advance!


Allan

Patrick Mueller

unread,
Dec 24, 2018, 10:11:54 AM12/24/18
to weinre
complete guess, that your signage device doesn't support whatever you are sending to `console.log()`.  You might want to wrap your code like this:

```
try {
   console.log(... whatever you are sending to console log ...)
} catch (err) {
   console.log('error occurred:", err.message)
}
```

Allan Yip

unread,
Dec 25, 2018, 6:12:02 AM12/25/18
to weinre


Op maandag 24 december 2018 16:11:54 UTC+1 schreef Patrick Mueller:
Hi Patrick,

Thanks for your reply!

Well I tried what you've suggested, and I indeed get an error; 

error occurred: undefined is not an object (evaluating 'messageParts[0].toString')

Could it be that WEINRE has some limitations in displaying certain limitations like diplaying <HTMLInputElement>?


Thanks in advance!


Allan

Allan Yip

unread,
Dec 25, 2018, 7:05:03 AM12/25/18
to weinre
Another strange thing, I've kinda sorted it out;

I'm trying to parse a string to a XML document. In both my signage device and my dev pc I run the same code

const parsedContent = new DOMParser().parseFromString(this.smilContent, "text/xml");

But the outcome doesn't look a like that much:

In Google Chrome:

20181225 Domparser parseFromString (Google Chrome).JPG


In WEINRE:

20181225 Domparser parseFromString (WEINRE).JPG


I'm not sure wether this is the same DOM, or that WEINRE/Google Chrome is doing something completely different with it?





Op maandag 24 december 2018 14:05:32 UTC+1 schreef Allan Yip:

Patrick Mueller

unread,
Dec 25, 2018, 7:40:15 AM12/25/18
to weinre
On Tuesday, December 25, 2018 at 6:12:02 AM UTC-5, Allan Yip wrote:
Could it be that WEINRE has some limitations in displaying certain limitations like diplaying <HTMLInputElement>?

No, it seems like your signage device is doing something different than your dev pc. 

Patrick Mueller

unread,
Dec 25, 2018, 7:43:13 AM12/25/18
to weinre
On Tuesday, December 25, 2018 at 7:05:03 AM UTC-5, Allan Yip wrote:
I'm trying to parse a string to a XML document. In both my signage device and my dev pc I run the same code

const parsedContent = new DOMParser().parseFromString(this.smilContent, "text/xml");

But the outcome doesn't look a like that much: 
...
I'm not sure wether this is the same DOM, or that WEINRE/Google Chrome is doing something completely different with it?

Hard to say; chrome may be "pretty printing" the parsed output, where weinre is showing it as an object.  The output in weinre looks like it parsed it successfully, so I guess try running some DOM methods against the output, I'm guessing they will behave the same. 

Allan Yip

unread,
Dec 27, 2018, 3:34:39 AM12/27/18
to weinre
Hi Patrick,

Did you have a merry Christmas? 

Well I tried what you suggested; truomg to run some DOM methods against it, but then we come to the part where the problem all starts. 

I'm trying to run the following:

const tags = (<HTMLInputElement>this.content.getElementsByTagName('body')[0].getElementsByTagName('par')[0]).children;
for (let i = 0; i < tags.length; i++) {

But the only thing I get is a 

Unhandled promise rejection TypeError: undefined is not an object (evaluating 'tags.length')

Works on dev pc though. 

I also tried 

const tags = (<HTMLInputElement>this.content.getElementsByTagName('body');
for (let i = 0; i < tags.length; i++) {

But get the same error message. 

A chunk of the beginning of the XML file:

<?xml version="1.0" encoding="iso-8859-1"?>
<smil screenshot="false">
<playlist id="24479" template="62-00000000000000" from_date="2018-01-26" to_date="2028-01-26" from_time="00:00:00"
to_time="23:59:00" weekdays="1,2,3,4,5,6,7" priority="">
<head>
<layout>
<root-layout xml:id="display:0" width="1920" height="1080" backgroundColor="#000000"/>
</layout>
</head>
<body>
<par>
<img src="filename.jpg" begin="0ms" fit="meet"
dur="150750ms" md5="7297ee6d86053c06ebb81194dcb604ff" region="Background318" size="414707"
content_id="27618"/>

Hope you have any clue of what is going wrong :-)



Op dinsdag 25 december 2018 13:43:13 UTC+1 schreef Patrick Mueller:

Patrick Mueller

unread,
Dec 27, 2018, 8:45:47 AM12/27/18
to weinre
On Thursday, December 27, 2018 at 3:34:39 AM UTC-5, Allan Yip wrote:
... 
Hope you have any clue of what is going wrong :-)

Sorry, no I don't. 
Reply all
Reply to author
Forward
0 new messages