0

Using DroidScript remote, I loaded a JS table demo and tried to run on my android phone. While the program in question runs well in the web demo, and while other programs compile and run well on my device (phone), I can not make the table run on my device (phone). The program seems to compile (no errors), but the screen remains black. Here is the debug. Looks like the program skips all commands:

> App.GetModel( )
-> SM-G920F
App.FileExists( /Sys/ga.js )
-> true
App.FileExists( /Sys/ga.js )
-> true

and this is the code:

function OnStart()
{
    var body = document.body,
        tbl  = document.createElement('table');
    tbl.style.width  = '100px';
    tbl.style.border = '1px solid black';
    for(var i = 0; i < 3; i++)
    {
        var tr = tbl.insertRow();
        for(var j = 0; j < 2; j++)
        {
            if(i == 2 && j == 1)
            {
                break;
            } 
            else 
            {
                var td = tr.insertCell();
                td.appendChild(document.createTextNode('Cell'));
                td.style.border = '1px solid black';
                if(i == 1 && j == 1)
                {
                    td.setAttribute('rowSpan', '2');
                }
            }
        }
    }
    body.appendChild(tbl);
}
samtal
  • 131
  • 2
  • 12

1 Answers1

1

The screen remains black, just because DroidScript doesn't have a body. I mean that even if your code has no syntax errors, you can't use document elements or body for displaying. You can create elements like document.createElement("script"); or document.createElement("audio");but you can not display the.

You have to use the android objects by calling app.CreateLayout, app.CreateText, app.CreateImage, etc. If you still want to use the body and all document objects, you can just create a new "HTML" project instead of javascript.