mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 22:27:13 +02:00
Add dialog + location + window JS examples
This commit is contained in:
parent
9a44b2b2fb
commit
45beeaa8d5
3 changed files with 30 additions and 0 deletions
7
examples/dialogExample.js
Normal file
7
examples/dialogExample.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
Window.alert("This is an alert box");
|
||||
|
||||
var confirmed = Window.confirm("This is a confirmation dialog")
|
||||
Window.alert("Your response was: " + confirmed);
|
||||
|
||||
var prompt = Window.prompt("This is a prompt dialog", "This is the default text");
|
||||
Window.alert("Your response was: " + prompt);
|
11
examples/locationExample.js
Normal file
11
examples/locationExample.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
var goto = Window.prompt("Where would you like to go? (ex. @username, #location, 1.0,500.3,100.2)");
|
||||
var url = "hifi://" + goto;
|
||||
print("Going to: " + url);
|
||||
location = url;
|
||||
|
||||
// If the destination location is a user or named location the new location may not be set by the time execution reaches here
|
||||
// because it requires an asynchronous lookup. Coordinate changes should be be reflected immediately, though. (ex: hifi://0,0,0)
|
||||
print("URL: " + location.href);
|
||||
print("Protocol: " + location.protocol);
|
||||
print("Hostname: " + location.hostname);
|
||||
print("Pathname: " + location.pathname);
|
12
examples/windowExample.js
Normal file
12
examples/windowExample.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
var width = 0,
|
||||
height = 0;
|
||||
|
||||
function onUpdate(dt) {
|
||||
if (width != Window.innerWidth || height != Window.innerHeight) {
|
||||
width = Window.innerWidth;
|
||||
height = Window.innerHeight;
|
||||
print("New window dimensions: " + width + ", " + height);
|
||||
}
|
||||
}
|
||||
|
||||
Script.update.connect(onUpdate);
|
Loading…
Reference in a new issue