Skip to content

Commit 803a788

Browse files
authored
Fix docs examples (#426)
* openweathermap didn't work (needs an API key), so we use another free API * websockets didn't work when using https, it has to be wss (secure socket) * 2 cosmetic changes
2 parents ec4682b + f82eda3 commit 803a788

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

example/src/main/scala/example/Example.scala

+4-6
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ object XMLHttpRequest{
123123
@JSExport
124124
def main(pre: html.Pre) = {
125125
val xhr = new dom.XMLHttpRequest()
126-
xhr.open("GET",
127-
"http://api.openweathermap.org/" +
128-
"data/2.5/weather?q=Singapore"
126+
xhr.open("GET",
127+
"https://www.boredapi.com/api/activity"
129128
)
130129
xhr.onload = { (e: dom.Event) =>
131130
if (xhr.status == 200) {
@@ -142,7 +141,7 @@ object Websocket {
142141
@JSExport
143142
def main(in: html.Input,
144143
pre: html.Pre) = {
145-
val echo = "ws://echo.websocket.org"
144+
val echo = "wss://echo.websocket.org"
146145
val socket = new dom.WebSocket(echo)
147146
socket.onmessage = {
148147
(e: dom.MessageEvent) =>
@@ -167,8 +166,7 @@ object AjaxExtension {
167166
.Implicits
168167
.global
169168
val url =
170-
"http://api.openweathermap.org/" +
171-
"data/2.5/weather?q=Singapore"
169+
"https://www.boredapi.com/api/activity"
172170
Ajax.get(url).foreach { case xhr =>
173171
pre.textContent = xhr.responseText
174172
}

readme/Index.scalatex

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
@pair("Alert", Nil)
4949

5050
@p
51-
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{<div>} element.
51+
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{<div>} element.
5252

5353
@sect{Usage}
5454
@p
@@ -90,7 +90,7 @@
9090
@sect{Node.onmousemove}
9191
@pair(
9292
"EventHandler",
93-
Seq(pre("pre")),
93+
Seq(pre("Hover this box!")),
9494
autorun=true
9595
)
9696

0 commit comments

Comments
 (0)