diff options
Diffstat (limited to 'examples/scala-js/examples/helloworld')
6 files changed, 0 insertions, 170 deletions
diff --git a/examples/scala-js/examples/helloworld/HelloWorld.scala b/examples/scala-js/examples/helloworld/HelloWorld.scala deleted file mode 100644 index fd33060..0000000 --- a/examples/scala-js/examples/helloworld/HelloWorld.scala +++ /dev/null @@ -1,86 +0,0 @@ -/* Scala.js example code - * Public domain - * @author Sébastien Doeraene - */ - -package helloworld - -import scala.scalajs.js -import js.annotation.JSName - -object HelloWorld extends js.JSApp { - def main() { - if (!(!js.Dynamic.global.document) && - !(!js.Dynamic.global.document.getElementById("playground"))) { - sayHelloFromDOM() - sayHelloFromTypedDOM() - sayHelloFromJQuery() - sayHelloFromTypedJQuery() - } else { - println("Hello world!") - } - } - - def sayHelloFromDOM() { - val document = js.Dynamic.global.document - val playground = document.getElementById("playground") - - val newP = document.createElement("p") - newP.innerHTML = "Hello world! <i>-- DOM</i>" - playground.appendChild(newP) - } - - def sayHelloFromTypedDOM() { - val document = window.document - val playground = document.getElementById("playground") - - val newP = document.createElement("p") - newP.innerHTML = "Hello world! <i>-- typed DOM</i>" - playground.appendChild(newP) - } - - def sayHelloFromJQuery() { - // val $ is fine too, but not very recommended in Scala code - val jQuery = js.Dynamic.global.jQuery - val newP = jQuery("<p>").html("Hello world! <i>-- jQuery</i>") - newP.appendTo(jQuery("#playground")) - } - - def sayHelloFromTypedJQuery() { - val jQuery = helloworld.JQuery - val newP = jQuery("<p>").html("Hello world! <i>-- typed jQuery</i>") - newP.appendTo(jQuery("#playground")) - } -} - -object window extends js.GlobalScope { - val document: DOMDocument = js.native - - def alert(msg: String): Unit = js.native -} - -trait DOMDocument extends js.Object { - def getElementById(id: String): DOMElement = js.native - def createElement(tag: String): DOMElement = js.native -} - -trait DOMElement extends js.Object { - var innerHTML: String = js.native - - def appendChild(child: DOMElement): Unit = js.native -} - -@JSName("jQuery") -object JQuery extends js.Object { - def apply(selector: String): JQuery = js.native -} - -trait JQuery extends js.Object { - def text(value: String): JQuery = js.native - def text(): String = js.native - - def html(value: String): JQuery = js.native - def html(): String = js.native - - def appendTo(parent: JQuery): JQuery = js.native -} diff --git a/examples/scala-js/examples/helloworld/helloworld-2.10-fastopt.html b/examples/scala-js/examples/helloworld/helloworld-2.10-fastopt.html deleted file mode 100644 index 98b2705..0000000 --- a/examples/scala-js/examples/helloworld/helloworld-2.10-fastopt.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Hello world - Scala.js example</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> -</head> -<body> - -<div id="playground"> -</div> - -<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> - -<script type="text/javascript" src="./target/scala-2.10/helloworld-fastopt.js"></script> - -<script type="text/javascript" src="./target/scala-2.10/helloworld-launcher.js"></script> - -</body> -</html> diff --git a/examples/scala-js/examples/helloworld/helloworld-2.10.html b/examples/scala-js/examples/helloworld/helloworld-2.10.html deleted file mode 100644 index 80b00b9..0000000 --- a/examples/scala-js/examples/helloworld/helloworld-2.10.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Hello world - Scala.js example</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> -</head> -<body> - -<div id="playground"> -</div> - -<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> - -<script type="text/javascript" src="./target/scala-2.10/helloworld-opt.js"></script> - -<script type="text/javascript" src="./target/scala-2.10/helloworld-launcher.js"></script> - -</body> -</html> diff --git a/examples/scala-js/examples/helloworld/helloworld-2.11-fastopt.html b/examples/scala-js/examples/helloworld/helloworld-2.11-fastopt.html deleted file mode 100644 index dbf5598..0000000 --- a/examples/scala-js/examples/helloworld/helloworld-2.11-fastopt.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Hello world - Scala.js example</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> -</head> -<body> - -<div id="playground"> -</div> - -<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> - -<script type="text/javascript" src="./target/scala-2.11/helloworld-fastopt.js"></script> - -<script type="text/javascript" src="./target/scala-2.11/helloworld-launcher.js"></script> - -</body> -</html> diff --git a/examples/scala-js/examples/helloworld/helloworld-2.11.html b/examples/scala-js/examples/helloworld/helloworld-2.11.html deleted file mode 100644 index 9c9a3a1..0000000 --- a/examples/scala-js/examples/helloworld/helloworld-2.11.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Hello world - Scala.js example</title> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> -</head> -<body> - -<div id="playground"> -</div> - -<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> - -<script type="text/javascript" src="./target/scala-2.11/helloworld-opt.js"></script> - -<script type="text/javascript" src="./target/scala-2.11/helloworld-launcher.js"></script> - -</body> -</html> diff --git a/examples/scala-js/examples/helloworld/startup.js b/examples/scala-js/examples/helloworld/startup.js deleted file mode 100644 index f45e4cb..0000000 --- a/examples/scala-js/examples/helloworld/startup.js +++ /dev/null @@ -1,8 +0,0 @@ -/* Scala.js example code - * Public domain - * Author: Sébastien Doeraene - */ - -$(function() { - ScalaJS.modules.helloworld_HelloWorld().main(); -}); |