Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Difference between revisions of "Talk:Canvas Nasal/JavaScript Subset"

From FlightGear wiki
Jump to: navigation, search
(add old stub ...)
 
 
Line 1: Line 1:
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
if (typeof(0) == 'scalar') {
+
if(typeof(console) != 'object') {
 
console = {log: print};
 
console = {log: print};
 
}
 
}
Line 7: Line 7:
 
}
 
}
  
var runtime = compile("return (typeof(0)=='scalar')? 'nasal':'javascript';");
+
var runtime = compile("return (typeof(0)=='scalar')? 'nasal':'javascript';") ();
  
 
Wrapper = {
 
Wrapper = {
Line 23: Line 23:
  
  
console.log( runtime() );
+
console.log( runtime );
  
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 18:03, 30 January 2018

if(typeof(console) != 'object') {
console = {log: print};
}
else {
compile = eval("new Function('src','return new Function(src);')");
}

var runtime = compile("return (typeof(0)=='scalar')? 'nasal':'javascript';") ();

Wrapper = {

'nasal': {
 setprop: compile(0),
 getprop: compile(1),
 fgcommand: compile(2)
 },

'javascript': {
 }

};


console.log( runtime );