-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
444 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.v6ak.scalajs.time | ||
|
||
case class Seconds(totalSeconds: Int) extends AnyVal { | ||
def hours: Int = totalSeconds / 3600 | ||
|
||
def minutes: Int = (totalSeconds / 60) % 60 | ||
|
||
def seconds: Int = totalSeconds % 60 | ||
|
||
override def toString: String = f"$hours:$minutes:$seconds" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.v6ak.zbdb | ||
|
||
final case class Checkpoint(pos: Int, place: String, cumLen: BigDecimal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.v6ak.zbdb | ||
|
||
import org.scalajs.dom | ||
import org.scalajs.dom._ | ||
import scalatags.JsDom.all._ | ||
|
||
|
||
final class ClassSwitches(initialSwitchesState: Map[String, String]) { | ||
private val switchesState = collection.mutable.Map(initialSwitchesState.toSeq: _*) | ||
|
||
def values = switchesState.values | ||
|
||
private def update(switchName: String, newClass: String, allValues: Set[String]) = { | ||
val oldClasses = allValues - newClass | ||
val classList = dom.document.body.classList | ||
classList.add(newClass) | ||
oldClasses.foreach(classList.remove) | ||
switchesState(switchName) = newClass | ||
} | ||
|
||
def classSelect(switchName: String)(items: (String, String)*) = select( | ||
onchange := { e: Event => | ||
val el = e.currentTarget.asInstanceOf[HTMLSelectElement] | ||
update(switchName, el.value, items.map(_._1).toSet) | ||
} | ||
)( | ||
for ((cls, name) <- items) yield | ||
option(value := cls, if (cls == switchesState(switchName)) selected := true else "")(name) | ||
) | ||
|
||
def checkbox(switchName: String, description: Frag)(onClass: String, offClass: String) = label( | ||
input( | ||
`type` := "checkbox", | ||
if (onClass == switchesState(switchName)) checked := true else "", | ||
onchange := { e: Event => | ||
val el = e.currentTarget.asInstanceOf[HTMLInputElement] | ||
update(switchName, if (el.checked) onClass else offClass, Set(onClass, offClass)) | ||
} | ||
), | ||
" ", | ||
description, | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.v6ak.zbdb | ||
|
||
final case class Overtakes(overtook: Seq[Participant], overtakenBy: Seq[Participant]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.v6ak.zbdb | ||
|
||
import com.example.moment.Moment | ||
import com.example.RichMoment._ | ||
|
||
final case class Pause(startTime: Moment, endTime: Moment) { | ||
def overtook(other: Pause): Boolean = this.startTime >= other.startTime && this.endTime < other.endTime | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.