forked from scala/scala-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownloadLinks.scala
45 lines (36 loc) · 1.36 KB
/
DownloadLinks.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.scalalang
import org.querki.jquery._
import org.scalajs.dom.{Element, document}
import org.scalalang.utils.{JsUtils, Logger, OS}
/**
* This updates our download links based on the OS of the client
*/
object DownloadLinks {
def apply(): Unit = {
setupBinariesElement()
setupMainDownload()
}
private def setupBinariesElement(): Unit = JsUtils.findElement("#download-binaries").foreach((binariesElmnt: JQuery) => {
val os: OS = OS()
val osLabel: String = os.label
var anchor: Element = document.getElementById("#link-main-unixsys")
if (os == OS.Windows) {
anchor = document.getElementById("#link-main-windows")
}
if (anchor == null) {
anchor = document.getElementById("#link-main-one4all")
}
val link: String = anchor.getAttribute("href")
binariesElmnt.attr("href", link).addClass(osLabel)
$("#users-os").text(osLabel)
})
private def setupMainDownload(): Unit = JsUtils.findElement(".main-download").foreach(_ => {
val osLabel: String = OS().label
val intelliJlink: String = $("#intellij-" + osLabel).text()
val sbtLink: String = $("#sbt-" + osLabel).text()
val stepOneContent: String = $("#stepOne-" + osLabel).html()
$("#download-intellij-link").attr("href", intelliJlink)
$("#download-sbt-link").attr("href", sbtLink)
$("#download-step-one").html(stepOneContent)
})
}