<commit_before>package client.js

import autowire._
import org.scalajs.dom
import shared.map.MapApi
import upickle.Js
import upickle.default._
import scala.util.{Success, Failure}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.scalajs.js.annotation.JSExport
import scalatags.JsDom.all._

@JSExport
object FrontClient extends Client[Js.Value, Reader, Writer] {

  def myContent = div(
    h1(id := "title", "This is a title"),
    p("This is a proof that we can do awesome javascripting from client!! haha finally!")
  ).render

  @JSExport
  def main(): Unit = {

    val textContent = FrontClient[MapApi].test().call().onComplete {
      case Success(s) => dom.document.getElementById("scalaMagicClientCode").textContent = s
      case Failure(s) => println("failure: " + s)
    }
    dom.document.getElementById("scalaMagicClientCode").appendChild(myContent)
  }

  def read[Result: Reader](p: Js.Value) = upickle.default.readJs[Result](p)

  def write[Result: Writer](r: Result) = upickle.default.writeJs(r)

  override def doCall(req: Request): Future[Js.Value] = {
    dom.ext.Ajax.get(
      url = "/api/" + req.path.mkString("/"),
      data = upickle.json.write(Js.Obj(req.args.toSeq: _*))
    ).map(_.responseText)
      .map(upickle.json.read)

  }
}<commit_msg>FIxed body insertion<commit_after>package client.js

import autowire._
import org.scalajs.dom
import shared.map.MapApi
import upickle.Js
import upickle.default._
import scala.util.{Success, Failure}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.scalajs.js.annotation.JSExport
import scalatags.JsDom.all._

@JSExport
object FrontClient extends Client[Js.Value, Reader, Writer] {

  def myContent = div(
    h1(id := "title", "This is a title"),
    p("This is a proof that we can do awesome javascripting from client!! haha finally!")
  ).render

  @JSExport
  def main(): Unit = {

    val textContent = FrontClient[MapApi].test().call().onComplete {
      case Success(s) => dom.document.getElementById("scalaMagicClientCode").textContent = s
      case Failure(s) => println("failure: " + s)
    }
    dom.document.body.appendChild(myContent)
  }

  def read[Result: Reader](p: Js.Value) = upickle.default.readJs[Result](p)

  def write[Result: Writer](r: Result) = upickle.default.writeJs(r)

  override def doCall(req: Request): Future[Js.Value] = {
    dom.ext.Ajax.get(
      url = "/api/" + req.path.mkString("/"),
      data = upickle.json.write(Js.Obj(req.args.toSeq: _*))
    ).map(_.responseText)
      .map(upickle.json.read)

  }
}
{'fraction_non_alphanumeric': 0.13845568657284138, 'fraction_numerical': 0.0007607455306200076, 'mean_word_length': 4.0095238095238095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '247927', 'n_tokens_mistral': 901, 'n_tokens_neox': 868, 'n_words': 188}