本文整理汇总了Scala中scala.scalajs.js.annotation.JSExport类的典型用法代码示例。如果您正苦于以下问题:Scala JSExport类的具体用法?Scala JSExport怎么用?Scala JSExport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JSExport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: TorrentStreamFrontend
//设置package包名称以及导入依赖的类
package com.karasiq.torrentstream.frontend
import com.karasiq.bootstrap.BootstrapImplicits._
import com.karasiq.bootstrap.grid.GridSystem
import com.karasiq.bootstrap.icons.FontAwesome
import com.karasiq.bootstrap.navbar.{NavigationBar, NavigationTab}
import com.karasiq.torrentstream.frontend.components.TorrentManagementPanel
import org.scalajs.dom
import org.scalajs.jquery.jQuery
import rx._
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
object TorrentStreamFrontend extends JSApp {
private implicit val context = implicitly[Ctx.Owner]
@JSExport
override def main(): Unit = {
jQuery(() ? {
val navigationBar = NavigationBar(
NavigationTab("Torrents", "torrents", "file".fontAwesome(FontAwesome.fixedWidth), new TorrentManagementPanel)
)
val body = dom.document.body
body.appendChild(navigationBar.navbar("TorrentStream").render)
body.appendChild {
GridSystem.container(id := "main-container")(
GridSystem.mkRow(navigationBar.content)
).render
}
})
}
}
示例2: getARGB
//设置package包名称以及导入依赖的类
package ai.dragonfly.img
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
import scala.scalajs.js.typedarray.Uint8ClampedArray
trait ImageBasics {
@JSExport def getARGB(x:Int, y:Int): Int
@JSExport def setARGB(x:Int, y:Int, argb: Int): Unit
@JSExport def width: Int
@JSExport def height: Int
@JSExport def pixels(f: (Int, Int) => Any): ImageBasics = {
for (y <- 0 until height) {
for (x <- 0 until width) {
f(x, y)
}
}
this
}
@JSExport def pixels (f: js.Function2[Int, Int, Any]): ImageBasics = {
for (y <- 0 until height) {
for (x <- 0 until width) {
f(x, y)
}
}
this
}
@JSExport def linearIndexOf(x: Int, y: Int): Int
@JSExport def getSubImage(xOffset: Int, yOffset: Int, w: Int, h: Int): ImageBasics
@JSExport def getIntArray(startX: Int, startY: Int, w: Int, h: Int): Array[Int]
@JSExport def setIntArray(startX: Int, startY: Int, w: Int, h: Int, rgba: Array[Int], offset: Int, stride: Int): ImageBasics
@JSExport def getUint8ClampedArray(startX: Int, startY: Int, w: Int, h: Int): Uint8ClampedArray
@JSExport def setUint8ClampedArray(startX: Int, startY: Int, w: Int, h: Int, uint8Array: Uint8ClampedArray): ImageBasics
}
示例3: VariantBrowser
//设置package包名称以及导入依赖的类
package variantBrowser
import org.scalajs.dom
import variantBrowser.components.VariantBrowserClient
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
import japgolly.scalajs.react.extra.router.StaticDsl.Route
import japgolly.scalajs.react.{Callback, ReactDOM}
import japgolly.scalajs.react.extra.router._
@JSExport
object VariantBrowser extends js.JSApp{
val baseUrl = BaseUrl("http://bioinfo01-ingemm.salud.madrid.org:9000")
// Define the locations (pages) used in this application
sealed trait Loc
case class Home() extends Loc
val routerConfig = RouterConfigDsl[Loc].buildConfig { dsl =>
import dsl._
( emptyRule
| dynamicRouteCT( ("/").caseClass[Home] ) ~> dynRenderR( (page,ctl) => VariantBrowserClient(ctl, page))
).notFound(redirectToPath(root)(Redirect.Replace))
}
@JSExport
def main() : Unit = {
dom.console.info(s"Initializing scalajs VariantBrowser lab")
val router = Router( baseUrl, routerConfig.logToConsole)
ReactDOM.render( router(), dom.document.getElementById("wrapper"))
}
}
示例4: H2RMain
//设置package包名称以及导入依赖的类
package com.mdelcid
import com.mdelcid.models.H2RNode
import scala.scalajs.js.annotation.JSExport
import scala.scalajs.js
import org.scalajs.{dom, jquery}
import org.scalajs.dom.window.console
@JSExport
object H2RMain {
val $ = jquery.jQuery
@JSExport
def main(): Unit = {
$("#html-textarea").click((e: dom.Event) => {
$("#html-textarea").select()
})
$("#convert-button").click((e: dom.Event) => {
val htmlStr = $("#html-textarea").`val`().toString
try {
val htmlArray = $.parseHTML(htmlStr).asInstanceOf[js.Array[dom.Node]]
js.Dynamic.global.vvv = htmlArray
val rootNode = new js.Object {
val nodeName = "#root"
val childNodes = htmlArray
val textContent = ""
}.asInstanceOf[dom.Node]
console.log(rootNode)
val scalaJSReactCode = H2RNode(rootNode, 0).childrenStr
$("#html-textarea").`val`(scalaJSReactCode)
$("#html-textarea").select()
} catch {
case e: Throwable =>
e.printStackTrace()
dom.window.alert("There was an error parsing the HTML. Please check your input is valid.")
}
})
}
}
示例5: Client
//设置package包名称以及导入依赖的类
package simple
import org.scalajs.dom
import org.scalajs.dom.ext.Ajax
import org.scalajs.dom.html
import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
object Client extends JSApp {
@JSExport
def main(): Unit = {
val canvas = dom.document.createElement("canvas").asInstanceOf[dom.html.Canvas]
dom.document.body.appendChild(canvas)
canvas.height = 600
Twenty48.Draw.init(canvas)
}
}
示例6: Context
//设置package包名称以及导入依赖的类
package org.codeape.sc.frontend
import io.udash._
import io.udash.wrappers.jquery._
import org.codeape.sc.shared.MainServerREST
import org.scalajs.dom
import org.scalajs.dom.{Element, document}
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
import scala.util.Try
object Context {
implicit val executionContext = scalajs.concurrent.JSExecutionContext.Implicits.queue
private val routingRegistry = new RoutingRegistryDef
private val viewPresenterRegistry = new StatesToViewPresenterDef
implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry, RootState)
import io.udash.rest._
val port = Try(dom.window.location.port.toInt).getOrElse(80)
val host = dom.window.location.hostname
val restServer = DefaultServerREST[MainServerREST](host, port, "/api/")
}
object Init extends JSApp with StrictLogging {
import Context._
@JSExport
override def main(): Unit = {
logger.info("StampClock started")
jQ(document).ready((_: Element) => {
val appRoot = jQ("#application").get(0)
if (appRoot.isEmpty) {
logger.error("Application root element not found! Check your index.html file!")
} else {
applicationInstance.run(appRoot.get)
}
})
}
}
示例7: WallApp
//设置package包名称以及导入依赖的类
package com.kindone.infinitewall
import com.kindone.infinitewall.elements._
import com.kindone.infinitewall.events._
import com.kindone.infinitewall.facades.ShowdownConverter
import com.kindone.infinitewall.persistence.api.Persistence
import com.kindone.infinitewall.persistence.localstorage.{ LocalPersistence, LocalStorage }
import com.kindone.infinitewall.data.{ Sheet => SheetModel, _ }
import com.kindone.infinitewall.persistence.httpstorage.HttpPersistence
import com.kindone.infinitewall.persistence.wsstorage.WebSocketPersistence
import org.scalajs.jquery._
import scala.scalajs.js
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
class WallApp(val useLocalStorage: Boolean = true, val useWS: Boolean = false) {
val persistence: Persistence = {
if (useLocalStorage)
new LocalPersistence()
else if (useWS)
new WebSocketPersistence("localhost:9000")
else
new HttpPersistence("")
}
@JSExport
def setup(wallId: Int): Unit = {
val stage = jQuery("#stage")
val wallView = new WallView(wallId, persistence)
stage.append(wallView.element)
wallView.setup()
}
}
示例8: IndexApp
//设置package包名称以及导入依赖的类
package com.kindone.infinitewall
import com.kindone.infinitewall.persistence.api.Persistence
import com.kindone.infinitewall.persistence.localstorage.{ LocalPersistence, WallManager, LocalStorage }
import com.kindone.infinitewall.persistence.httpstorage.HttpPersistence
import com.kindone.infinitewall.persistence.wsstorage.WebSocketPersistence
import upickle.default._
import scala.scalajs.js.JSON
import scala.scalajs.js.annotation.JSExport
import scala.scalajs.js
import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
@JSExport
class IndexApp(val useLocalStorage: Boolean = true, val useWS: Boolean = false) {
val persistence: Persistence = {
if (useLocalStorage)
new LocalPersistence()
else if (useWS)
new WebSocketPersistence("")
else
new HttpPersistence("")
}
@JSExport
def walls(onComplete: js.Function1[js.Array[js.Dictionary[Any]], Unit]): Unit = {
import js.JSConverters._
val wallManager = persistence.wallManager
val wallsFuture = wallManager.getWalls().map { walls =>
walls.map { wall =>
JSON.parse(write(wall)).asInstanceOf[js.Dictionary[Any]]
}.toJSArray
}
wallsFuture.foreach { walls =>
onComplete.apply(walls)
}
}
@JSExport
def createWall(title: String, onComplete: js.Function1[js.Dictionary[Any], Unit]): Unit = {
val wallManager = persistence.wallManager
val wallFuture = wallManager.create(title)
wallFuture.foreach { wall =>
val result = JSON.parse(write(wall)).asInstanceOf[js.Dictionary[Any]]
onComplete.apply(result)
}
}
@JSExport
def deleteWall(id: Int, onComplete: js.Function1[Boolean, Unit]): Unit = {
val wallManager = persistence.wallManager
wallManager.delete(id).map { status =>
onComplete.apply(status)
}
}
}
示例9: Main
//设置package包名称以及导入依赖的类
package org.remus32.BetterServer.js
import org.querki.jquery.JQueryEventObject
import scala.scalajs.js.annotation.JSExport
@JSExport
object Main {
def initAbout() = {
$(".about-btn").click(() => {
Api.loadAbout($(".main"))
})
}
@JSExport
def error() = {
}
@JSExport
def launch() = {
initAbout()
val tree = new Tree($("body"))
}
}
示例10: Init
//设置package包名称以及导入依赖的类
package com.oni.udash
import acyclic.file
import io.udash._
import io.udash.wrappers.jquery._
import org.scalajs.dom.{ Element, document }
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
import scalacss.Defaults._
import scalacss.ScalatagsCss._
import scalatags.JsDom._
import com.oni.udash.styles._
import com.oni.udash.styles.OniStyles2
import com.oni.udash.styles.GlobalStyles
import com.oni.udash.styles.DemoStyles
import com.oni.udash.styles.partials.FooterStyles
import com.oni.udash.styles.partials.HeaderStyles
import org.scalajs.dom.raw.HTMLStyleElement
object Init extends JSApp with StrictLogging {
import Context._
@JSExport
override def main(): Unit = {
jQ(document).ready((_: Element) => {
val appRoot = jQ("#application").get(0)
if (appRoot.isEmpty) {
logger.error("Application root element not found! Check your index.html file!")
} else {
applicationInstance.run(appRoot.get)
jQ(GlobalStyles.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
jQ(DemoStyles.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
jQ(OniStyles.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
jQ(OniStyles2.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
jQ(CsStyles.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
jQ(CsStyles2.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
jQ(FooterStyles.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
jQ(HeaderStyles.render[TypedTag[HTMLStyleElement]].render).insertBefore(appRoot.get)
}
})
}
}
示例11: App
//设置package包名称以及导入依赖的类
package com.github.kelebra.akka.js.snake
import akka.actor.{ActorSystem, Props}
import org.scalajs.dom.{html, _}
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
import scala.util.Random
object App extends js.JSApp {
@JSExport
override def main(): Unit = {
val system = ActorSystem("system")
val `moves per second` = 27
val canvas = document.getElementById("canvas").asInstanceOf[html.Canvas]
canvas.width = 1000
canvas.height = 500
val radius = 5
val `random block generator`: () => Block = () => Block(
radius + Random.nextInt(canvas.width - radius - 1) + 1,
radius + Random.nextInt(canvas.height - radius - 1) + 1,
radius
)
val pane = system.actorOf(Props(classOf[CanvasDrawing], canvas))
val snake = system.actorOf(Props(classOf[Snake], pane))
val keyboard = system.actorOf(Props(classOf[Keyboard], snake))
val game = system.actorOf(Props(classOf[Game], snake, pane, `random block generator`, `moves per second`))
game ! Start(?, Block(canvas.width / 2, canvas.height / 2, 5))
document.onkeydown = (event: KeyboardEvent) => keyboard ! event.keyCode
}
}
示例12: Client
//设置package包名称以及导入依赖的类
package foobar
import org.scalajs.dom.ext.Ajax
import org.scalajs.dom.html
import upickle.default._
import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
import scala.scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
object Client extends {
val inputName = input(name := "name", `type` := "text", size := 30)
val inputEmail = input(name := "email", `type` := "text", size := 30)
val inputMessage = input(name := "message", `type` := "text", size := 255)
@JSExport
def main(container: html.Div) = {
val nameBox = inputName.render
val emailBox = inputEmail.render
val messageBox = inputMessage.render
def update() =
Ajax.post("/ajax/list", write(FormData(nameBox.value, emailBox.value, messageBox.value))).foreach{ xhr =>
println(s"received ${xhr.responseText}")
}
container.appendChild(
form(
div(label(`for` := "name", "Your name:"), nameBox),
div(label(`for` := "email", "Your email:"), emailBox),
div(label(`for` := "message", "Your message:"), messageBox),
input(`type` := "submit", value := "Send Email", onclick := update())
).render
)
}
}
示例13: uuid
//设置package包名称以及导入依赖的类
package de.mukis.js
import scala.annotation.meta.field
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport.Namespace
import scala.scalajs.js.annotation.{JSExport, JSImport}
import scala.scalajs.js.|
@JSImport("node-uuid/uuid", Namespace)
@js.native
object uuid extends UUID
@js.native
trait UUID extends js.Object {
def v1(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v1(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def v4(options: js.UndefOr[UUIDOptions] = js.undefined): String = js.native
def v4(
options: UUIDOptions,
buffer: js.Array[Double],
offset: js.UndefOr[Double]
): js.Array[Double] = js.native
def parse(
id: String,
buffer: js.UndefOr[js.Array[Double]] = js.undefined,
offset: js.UndefOr[Double] = js.undefined
): js.Array[Double] = js.native
def unparse(
buffer: js.Array[Double],
offset: js.UndefOr[Double] = js.undefined
): String = js.native
}
case class UUIDOptions(
@(JSExport @field) node: js.UndefOr[js.Array[js.Any]] = js.undefined,
@(JSExport @field) clockseq: js.UndefOr[Double] = js.undefined,
@(JSExport @field) msecs: js.UndefOr[Double | js.Date] = js.undefined,
@(JSExport @field) nsecs: js.UndefOr[Double] = js.undefined
)
示例14: Context
//设置package包名称以及导入依赖的类
package io.udash.demos.jquery
import io.udash._
import io.udash.wrappers.jquery._
import org.scalajs.dom
import org.scalajs.dom.{Element, document}
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
object Context {
implicit val executionContext = scalajs.concurrent.JSExecutionContext.Implicits.queue
private val routingRegistry = new RoutingRegistryDef
private val viewPresenterRegistry = new StatesToViewPresenterDef
implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry, RootState)
}
object Init {
import Context._
@JSExport
def main(args: Array[String]): Unit = {
jQ((_: Element) => {
val appRoot = jQ("#application").get(0)
if (appRoot.isEmpty) {
dom.console.error("Application root element not found! Check you index.html file!")
} else {
applicationInstance.run(appRoot.get)
}
})
}
}
示例15: WebDemoUIEntry
//设置package包名称以及导入依赖的类
package webdemo
import suzaku.platform.web.{WebWorkerTransport, WorkerClientTransport}
import org.scalajs.dom
import org.scalajs.dom.raw.Worker
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}
import scala.scalajs.js.typedarray.{ArrayBuffer, TypedArrayBuffer}
@JSExportTopLevel("WebDemoUIEntry")
object WebDemoUIEntry {
var transport: WebWorkerTransport = _
@JSExport
def entry(workerScript: String): Unit = {
// create the worker to run our application in
val worker = new Worker(workerScript)
// create the transport
transport = new WorkerClientTransport(worker)
// listen to messages from worker
worker.onmessage = onMessage _
new WebDemoUI(transport)
}
private def debugPrint(data: Array[Byte]): Unit = {
data.grouped(16).foreach { d =>
val hex = d.map(c => "%02X " format (c & 0xFF)).mkString
val str = d
.collect {
case ascii if ascii >= 0x20 && ascii < 0x80 => ascii
case _ => '.'.toByte
}
.map(_.toChar)
.mkString
println(hex.padTo(16 * 3, ' ') + str)
}
}
def onMessage(msg: dom.MessageEvent) = {
msg.data match {
case buffer: ArrayBuffer =>
transport.receive(buffer)
case _ => // ignore other messages
}
}
}