Difference between revisions of "JS"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
 
 
<!-- GIDEROSOBJ:JS -->
 
<!-- GIDEROSOBJ:JS -->
'''<translate>Supported platforms</translate>:''' [[File:Platform html5.png]]<br/>
+
'''Supported platforms:''' [[File:Platform html5.png]]<br/>
'''<translate>Available since</translate>:''' in development<br/>
+
'''Available since:''' 2019.1<br/>
  
=== <translate>Description</translate> ===
+
=== Description ===
<translate>Run JavaScript code.</translate>
+
Runs JavaScript code.
 +
 
 +
=== Example ===
 +
'''Get/Set'''
 +
<syntaxhighlight lang="lua">
 +
-- sets a variable and a listener
 +
JS.eval([[
 +
document.isPause = false;
 +
document.addEventListener('visibilitychange', function() {
 +
if (document.visibilityState == 'hidden')
 +
document.isPause = true;
 +
else
 +
document.isPause = false;
 +
});
 +
]])
 +
 +
-- gets the value of a variable
 +
print(JS.eval("document.isPause"))
 +
</syntaxhighlight>
  
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/JS.eval|JS.eval]] ''Execute the given Javascript code'' <br/><!-- GIDEROSMTD:JS.eval(code) Execute the given Javascript code -->
+
[[JS.eval]] ''executes the given JavaScript code''<br/><!--GIDEROSMTD:JS.eval(code) executes the given JavaScript code-->
  
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
  
=== <translate>Events</translate> ===
+
=== Events ===
=== <translate>Constants</translate> ===
+
=== Constants ===
 
|}
 
|}
  
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 15:30, 13 July 2023

Supported platforms: Platform html5.png
Available since: 2019.1

Description

Runs JavaScript code.

Example

Get/Set

-- sets a variable and a listener
JS.eval([[
	document.isPause = false;
	document.addEventListener('visibilitychange', function() {
		if (document.visibilityState == 'hidden')
			document.isPause = true;
		else
			document.isPause = false;
	});
]])
 
-- gets the value of a variable
print(JS.eval("document.isPause"))

Methods

JS.eval executes the given JavaScript code

Events

Constants