Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 2 made on Tuesday November 9, 2010 at 23:36
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,006
That is correct. You won't see your .js files unless you put a comment like is in the Philips unprotected libraries at the top. i.e. the comment is metadata that tells PEP what the file is. :-)

What are the limitations with eval() that you are experiencing? You can declare classes/functions/variables, etc... just fine if you utilize the undocumented eval() member function of Object. FYI, Activities, Pages, and Widgets are all Javascript Objects in that these classes use prototype inheritance from the base Javascript Object class.

Instead of using:
eval(mylabel);

use:

CF.activity().eval(mylabel);

which causes the activity scope to be the root scope for the eval.

If you use eval(mylabel) standalone, the scope that is used is not accessible unless you return it using "this;" as the last statement of script block (see usage of c being returned below).

So, consider this label content:

var a = 125;
var b = 234;
var c = {};
c.a = a;
c.b = b;
c; // this last line causes the object inside 'c' to be returned as result of eval.

If you then execute:
var d = eval(labelcontent);

d will contain an object with member fields a and b.

However, if you execute:

var d = CF.activity().eval(labelcontent);

and then do a toSource() on the activity as in:

CF.activity().toSource();

I believe you will see the member fields a, b, c, and of course d.

Note that eval() as a member function of an object (scope in this case) is not well documented and it is not documented in Flanagan or on the web but the current JS interpreter (Spidermonkey) allows this to work just fine.

Good luck and maybe you could edit the subject of your post to state something like:
"Libraries - Are they just .js files? - Advanced use of eval()".

Thanks
Lyndel
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse