diff --git a/examples/dialogExample.js b/examples/dialogExample.js new file mode 100644 index 0000000000..144b681950 --- /dev/null +++ b/examples/dialogExample.js @@ -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); diff --git a/examples/locationExample.js b/examples/locationExample.js new file mode 100644 index 0000000000..7530a3e3b6 --- /dev/null +++ b/examples/locationExample.js @@ -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); diff --git a/examples/windowExample.js b/examples/windowExample.js new file mode 100644 index 0000000000..afde83591d --- /dev/null +++ b/examples/windowExample.js @@ -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);