From 042ee504bd8dfa8fe22563b2f1720b79742f241b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sakib=20Had=C5=BEiavdi=C4=87?= Date: Thu, 8 Oct 2020 01:01:04 +0200 Subject: [PATCH 1/3] Fix docs examples --- example/src/main/scala/example/Example.scala | 11 ++++------- readme/Index.scalatex | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/example/src/main/scala/example/Example.scala b/example/src/main/scala/example/Example.scala index 16a751fdb..b522daf81 100644 --- a/example/src/main/scala/example/Example.scala +++ b/example/src/main/scala/example/Example.scala @@ -124,13 +124,11 @@ object XMLHttpRequest{ def main(pre: html.Pre) = { val xhr = new dom.XMLHttpRequest() xhr.open("GET", - "http://api.openweathermap.org/" + - "data/2.5/weather?q=Singapore" + "https://www.boredapi.com/api/activity?type=recreational" ) xhr.onload = { (e: dom.Event) => if (xhr.status == 200) { - pre.textContent = - xhr.responseText + pre.textContent = xhr.responseText } } xhr.send() @@ -142,7 +140,7 @@ object Websocket { @JSExport def main(in: html.Input, pre: html.Pre) = { - val echo = "ws://echo.websocket.org" + val echo = "wss://echo.websocket.org" val socket = new dom.WebSocket(echo) socket.onmessage = { (e: dom.MessageEvent) => @@ -167,8 +165,7 @@ object AjaxExtension { .Implicits .global val url = - "http://api.openweathermap.org/" + - "data/2.5/weather?q=Singapore" + "https://www.boredapi.com/api/activity?type=recreational" Ajax.get(url).foreach { case xhr => pre.textContent = xhr.responseText } diff --git a/readme/Index.scalatex b/readme/Index.scalatex index 3649d861e..14d5b9246 100644 --- a/readme/Index.scalatex +++ b/readme/Index.scalatex @@ -48,7 +48,7 @@ @pair("Alert", Nil) @p - Will cause a javascript alert box saying `HAI` to appear. Other javascript classes and objects can be similarly accessed e.g. @hl.scala{new dom.XMLHttpRequest()} to perform a new Ajax request, @hl.scala{dom.document} to access the global @hl.scala{document} object, or @hl.scala{html.Div} to to refer to the type of a @hl.scala{
} element. + Will cause a javascript alert box saying `Hi from Scala-js-dom` to appear. Other javascript classes and objects can be similarly accessed e.g. @hl.scala{new dom.XMLHttpRequest()} to perform a new Ajax request, @hl.scala{dom.document} to access the global @hl.scala{document} object, or @hl.scala{html.Div} to to refer to the type of a @hl.scala{
} element. @sect{Usage} @p @@ -90,7 +90,7 @@ @sect{Node.onmousemove} @pair( "EventHandler", - Seq(pre("pre")), + Seq(pre("Hover this box!")), autorun=true ) From 72cf1b2b99b24e050c077d259d41e8db90a1eb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sakib=20Had=C5=BEiavdi=C4=87?= Date: Thu, 8 Oct 2020 01:05:03 +0200 Subject: [PATCH 2/3] Simplify examples url --- example/src/main/scala/example/Example.scala | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/example/src/main/scala/example/Example.scala b/example/src/main/scala/example/Example.scala index b522daf81..ae7604c68 100644 --- a/example/src/main/scala/example/Example.scala +++ b/example/src/main/scala/example/Example.scala @@ -123,9 +123,7 @@ object XMLHttpRequest{ @JSExport def main(pre: html.Pre) = { val xhr = new dom.XMLHttpRequest() - xhr.open("GET", - "https://www.boredapi.com/api/activity?type=recreational" - ) + xhr.open("GET", "https://www.boredapi.com/api/activity") xhr.onload = { (e: dom.Event) => if (xhr.status == 200) { pre.textContent = xhr.responseText @@ -164,8 +162,7 @@ object AjaxExtension { .ExecutionContext .Implicits .global - val url = - "https://www.boredapi.com/api/activity?type=recreational" + val url = "https://www.boredapi.com/api/activity" Ajax.get(url).foreach { case xhr => pre.textContent = xhr.responseText } From f82eda38fdfd318b222dc97911c800da2e71dffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sakib=20Had=C5=BEiavdi=C4=87?= Date: Thu, 8 Oct 2020 10:51:48 +0200 Subject: [PATCH 3/3] Fix code formatting --- example/src/main/scala/example/Example.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/example/src/main/scala/example/Example.scala b/example/src/main/scala/example/Example.scala index ae7604c68..4e3d76300 100644 --- a/example/src/main/scala/example/Example.scala +++ b/example/src/main/scala/example/Example.scala @@ -123,10 +123,13 @@ object XMLHttpRequest{ @JSExport def main(pre: html.Pre) = { val xhr = new dom.XMLHttpRequest() - xhr.open("GET", "https://www.boredapi.com/api/activity") + xhr.open("GET", + "https://www.boredapi.com/api/activity" + ) xhr.onload = { (e: dom.Event) => if (xhr.status == 200) { - pre.textContent = xhr.responseText + pre.textContent = + xhr.responseText } } xhr.send() @@ -162,7 +165,8 @@ object AjaxExtension { .ExecutionContext .Implicits .global - val url = "https://www.boredapi.com/api/activity" + val url = + "https://www.boredapi.com/api/activity" Ajax.get(url).foreach { case xhr => pre.textContent = xhr.responseText }