Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 23 2021 09:24
    @sjrd banned @yensaoxuan_twitter
  • Apr 18 2021 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 2021 07:47
    @sjrd banned @quangs
  • Jan 23 2021 06:34
    @sjrd banned @Rebeka58_gitlab
  • Jun 08 2020 20:43
    @sjrd banned @sw7240614
  • Sep 29 2019 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 2019 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 2019 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 2019 15:31
    @sjrd banned @lerbatax
  • Jan 31 2019 23:04
    sjrd commented #3555
  • Jan 31 2019 22:56
    sjrd review_requested #3555
  • Jan 31 2019 22:56
    sjrd opened #3555
  • Jan 31 2019 21:06

    sjrd on 0.6.x

    Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)

  • Jan 31 2019 21:06
    sjrd closed #3554
  • Jan 31 2019 20:54
    erikvanoosten commented #2665
  • Jan 31 2019 16:33
    sjrd commented #3538
  • Jan 31 2019 15:54

    sjrd on master

    Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3552
  • Jan 31 2019 15:54

    sjrd on master

    Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3553
David Portabella
@dportabella
We are hiring a Scala/ScalaJs software developer, at the EPFL Swiss university.
Let me know if you are interested, or if you know someone else.
https://lnkd.in/ec_XvPS
The job ad does not say it explicitly, but the platform is written 100% in Scala/ScalaJs.
Dario Abdulrehman
@dabd
@OlegYch if wewant to reuse the library are there any other options than having a server rendering the components?
Dario Abdulrehman
@dabd
@aappddeevv another option would be to compile Nunjucks templates to Twirl or ScalaTags but it would be a challenging task to write the compiler
OlegYch
@OlegYch
if that's a js library then you can just as well run it on client
aappddeevv
@aappddeevv
@dabd would be a bunch of work :-) if performance is that critical and you have to use nunjucks, probably a "nunjucks rendering microservice" along side the jvm service would be cleanest. I just scanned the latest graal and it looks like it would work but its probably harder to setup.
Dario Abdulrehman
@dabd
@aappddeevv wouldn't that have a bit of overhead? Why not as @OlegYch suggests having the client run the Nunjucks library? I'm not sure how can you achieve that to be honest but it would be a matter of having the Play controllers (ScalaJVM) communicating with the client in ScalaJs. Is there an example of such an application I could take a look at?
aappddeevv
@aappddeevv
You can have the client (js or scalajs) run templating for some standard UI rendering vs email server-side rendering that I mentioned earlier. Depending on the volume of templating though, rendering on the client may not make sense. I'm not sure I uderstand what you are trying to do though and the constraints you face. If the templating is for the UI exclusively, then rendering on the client is fine and I've done that as well using the exact same rendering library as I did for the server side emails. Based on your initial description, it sounded like you wanted rendering server side so the client is not impacted.
Dario Abdulrehman
@dabd
@aappddeevv We have a bunch of Play frontend microservices which are doing server-side rendering and they are all using Twirl. Howeve,r soon we will have to use this js library built on Nunjucks which provides standardised UI components for the organisation. I think moving to client-side rendering would have some security implications. Sticking with server-side rendering seems to be the most likely acceptable solution.
aappddeevv
@aappddeevv
That's what I thought. I think that my three "server-side" options are valid unless you rewrite the templating engine. You can skip rewriting the entire server in scala.js as that's probably not feasible. scala.js does not help you per se as you need to run a js-based templating library and scala.js requires a js engine to run on. graal jvm/node is probably too much work to get working and may have ops implications. So if you have to run those js-based templates server side, a small, templating microservice based on nodejs is conceptually easy and callable by your primary play server. It's not clear the overhead from calling a second server is significanlly less than the "slow" rendering though.
Dario Abdulrehman
@dabd
I actually rewrote the templating library in Twirl and used scalacheck to ensure parity of the rendered HTML with the output of the Nunjucks templates, however it is a pain to maintain.
aappddeevv
@aappddeevv
Hmm..you only have a few choices...good luck.
Dario Abdulrehman
@dabd
Thanks for the ideas @aappddeevv !
i started to use FRP sodium with scalajs-react
        val titleS=STextArea(title)
        val button=SButton()
        button.sClickedSink.snapshot(titleS.cell).listen(println)

        <.div(
          titleS.component(),
          button.getVDOM()
        )
this code prints the content of a text area to the console when the button is pressed
titleS does not know nothing about SButton
or the other way around
and of SButton :
here runs the code... right now ... for a while ... until i change it
Brian Kent
@bdkent
is there a library to generate Typescript definitions from ScalaJS types?
Glen Marchesani
@fizzy33
@bdkent I was wondering the same thing myself
Antoine Doeraene
@sherpal
I'd also be very happy to have such a thing. I started to implement it using scalameta, then I realised that I actually need SemanticDB but didn't have/take the time to learn it deep enough. I could try to start again if there is demand... There was also this talk at the last scala days that could be of interest to you. I don't know where that project stands now though.
David Portabella
@dportabella

MouseEvent.target returns an EventTarget instead of a HTMLElement when clicked inside an iframe.

    val iframe = document.createElement("iframe")
    document.body.appendChild(iframe)
    val iframeWindow = iframe.asInstanceOf[HTMLIFrameElement].contentWindow
    iframeWindow.document.body.innerHTML = "<h1>iframe</h1>"

    val clicked: js.Function1[MouseEvent, Unit] = (e: MouseEvent) => {
      e.target match {
        case e: HTMLElement => console.log("clicked an HTMLElement", e)
        case e: EventTarget => console.log("clicked an EventTarget", e)
      }
    }
    iframeWindow.document.addEventListener("click", clicked)

When I click inside the iframe on the <h1>iframe</h1>, I get an EventTarget instead of an HTMLElement. Why and how to solve it?

https://stackoverflow.com/questions/58702991/mouseevent-target-returns-an-eventtarget-instead-of-a-htmlelement-when-clicked-i

jhegedus42
@jhegedus42
hmm
i dont even know what this pattern match doing
case e: HTMLElement
why not case HTMLElement ?
you are pattern matching on the type ?
also
things
are a bit shadowy
why e
why not e1 ?
jhegedus42
@jhegedus42
what is they type of HTMLElement ?
is it a type or a value ?
anyway
is there any nice example on how to upload a file to a webserver ?
an image
for example ?
       <.div(
          titleS.component(),
          button.getVDOM(),
          "For debug:",
          <.br,
          <.pre(HelperPrint.prettyPrint(e2)),
          <.button("upload",^.`type`:="file",^.onClick-->Callback(println("upload clicked")))
        )
i am the one who is writing the web server too
so... i can create any sort of event handler
Øyvind Raddum Berg
@oyvindberg
@dportabella I think that code should have worked. Try to say e.target.asInstanceOf[js.Dynamic].nodeName to see what you actually get
David Portabella
@dportabella

I've modified the example with your comments:

package tutorial.webapp

import org.scalajs.dom._
import org.scalajs.dom.raw._
import scala.scalajs.js

object TutorialApp {
  def main(args: Array[String]): Unit = {
    window.document.body.innerHTML = "<p><b>main window</b></p>"

    val iframe = document.createElement("iframe")
    document.body.appendChild(iframe)
    val iframeWindow = iframe.asInstanceOf[HTMLIFrameElement].contentWindow
    iframeWindow.document.body.innerHTML = "<p><b>iframe</b></p>"


    window.document.addEventListener("click", clicked)        
    // this works as expected:
    // clicking on the 'main window' text, produces this console log:
    // - clicked an HTMLElement B
    // - parent is an HTMLParagraphElement P


    iframeWindow.document.addEventListener("click", clicked)  // this doesn't
    // this does not work as expected:
    // clicking on the 'iframe' text, produces this console log:
    // - clicked an EventTarget B
    // - parent is an HTMLElement P
  }

  def clicked(mouseEvent: MouseEvent) {
    mouseEvent.target match {
      case e: HTMLElement => console.log("clicked an HTMLElement", e.asInstanceOf[HTMLElement].tagName)
      case e: EventTarget => console.log("clicked an EventTarget", e.asInstanceOf[HTMLElement].tagName)
    }

    val parent = mouseEvent.target.asInstanceOf[HTMLParagraphElement].parentElement
    parent match {
      case e: HTMLParagraphElement => console.log("parent is an HTMLParagraphElement", e.asInstanceOf[HTMLElement].tagName)
      case e: HTMLElement => console.log("parent is an HTMLElement", e.asInstanceOf[HTMLElement].tagName)
    }
  }
}

When I click inside the iframe on the <h1>iframe</h1>, I get an EventTarget instead of an HTMLElement. Casting it to HTMLElement works, but e.parentElement is an HTMLElement instead of HTMLParagraphElement.

Maybe the ScalaJs script adds some functionality to the window to cast the html nodes into ScalaJs classes, and this functionality is not loaded inside the iframe.
Any idea?

Øyvind Raddum Berg
@oyvindberg
Maybe DOM elements in iframes are different from what is loaded in the main document, I don't know. I would just cast instead of pattern patch