Add dialog + location + window JS examples

This commit is contained in:
Ryan Huffman 2014-04-30 09:45:53 -07:00
parent 9a44b2b2fb
commit 45beeaa8d5
3 changed files with 30 additions and 0 deletions

View 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);

View 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
View 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);