import static scala.collection.JavaConversions.asJavaCollection;
@@ -61,4 +61,4 @@ It also uses JavaConversions to convert between Scala collections
and Java collections.
-
\ No newline at end of file
+
diff --git a/_scala_items/2-type-inference.md b/_scala_items/2-type-inference.md
index 7e2edee38..25f759f53 100644
--- a/_scala_items/2-type-inference.md
+++ b/_scala_items/2-type-inference.md
@@ -1,11 +1,11 @@
---
shortTitle: "Type Inference"
shortDescription: "So the type system doesn’t feel so static. Don’t work for the type system. Let the type system work for you!"
-scastieUrl:
+scastieUrl:
---
-
+
Type inference
scala> class Person(val name: String, val age: Int) {
| override def toString = s"$name ($age)"
@@ -46,4 +46,4 @@ class and two functions. You can observe that the compiler infers the result
types of the functions automatically, as well as all the intermediate values.
-
\ No newline at end of file
+
diff --git a/_scala_items/3-concurrency-distribution.md b/_scala_items/3-concurrency-distribution.md
index 7a3989c2e..d03a8a269 100644
--- a/_scala_items/3-concurrency-distribution.md
+++ b/_scala_items/3-concurrency-distribution.md
@@ -1,11 +1,11 @@
---
shortTitle: "Concurrency & Distribution"
shortDescription: "Use data-parallel operations on collections, use actors for concurrency and distribution, or futures for asynchronous programming."
-scastieUrl:
+scastieUrl:
---
-
+
Concurrent/Distributed
val x = Future { someExpensiveComputation() }
val y = Future { someOtherExpensiveComputation() }
diff --git a/_scala_items/4-traits.md b/_scala_items/4-traits.md
index ed4d16061..fb49e2724 100644
--- a/_scala_items/4-traits.md
+++ b/_scala_items/4-traits.md
@@ -1,7 +1,7 @@
---
shortTitle: "Traits"
shortDescription: "Combine the flexibility of Java-style interfaces with the power of classes. Think principled multiple-inheritance."
-scastieUrl:
+scastieUrl:
---
{% comment %}
Borrowed from
@@ -9,7 +9,7 @@ https://gleichmann.wordpress.com/2009/10/21/scala-in-practice-composing-traits-l
{% endcomment %}
-
+
Traits
abstract class Spacecraft {
def engage(): Unit
@@ -46,4 +46,4 @@ engage the ship (provided a means to speed up) and a PulseEngine th
specifies how to speed up.
-
\ No newline at end of file
+
diff --git a/_scala_items/5-pattern-matching.md b/_scala_items/5-pattern-matching.md
index 8e8b2f517..3b0cb7ccd 100644
--- a/_scala_items/5-pattern-matching.md
+++ b/_scala_items/5-pattern-matching.md
@@ -20,7 +20,7 @@ deconstructs the arguments of a Node.
-
+
Pattern matching
// Define a set of case classes for representing binary trees.
sealed abstract class Tree
diff --git a/_scala_items/6-higher-order-functions.md b/_scala_items/6-higher-order-functions.md
index 67997617c..77f6f5459 100644
--- a/_scala_items/6-higher-order-functions.md
+++ b/_scala_items/6-higher-order-functions.md
@@ -1,7 +1,7 @@
---
shortTitle: "Higher-order functions"
shortDescription: "Functions are first-class objects. Compose them with guaranteed type safety. Use them anywhere, pass them to anything."
-scastieUrl:
+scastieUrl:
---
@@ -10,7 +10,7 @@ scastieUrl:
with a concise syntax.
-
+
Scala
val people: Array[Person]
@@ -20,7 +20,7 @@ val (minors, adults) = people partition (_.age < 18)
-
+
Java
List<Person> people;
diff --git a/_scala_items/7-education.md b/_scala_items/7-education.md
index 58d4218e6..310e84dcc 100644
--- a/_scala_items/7-education.md
+++ b/_scala_items/7-education.md
@@ -28,12 +28,12 @@ shortDescription: "Scala is ideal for teaching programming to beginners as well
-
+
HelloWorld.scala
@main def run() = println("Hello, World!")
-
+
Modules.scala
// A module that can access the data stored in a database
class DatabaseAccess(connection: Connection):
@@ -51,7 +51,7 @@ class HttpServer(databaseAccess: DatabaseAccess):
-
+
Modeling.scala
/** A Player can either be a Bot, or a Human.
* In case it is a Human, it has a name.
@@ -61,7 +61,7 @@ enum Player:
case Human(name: String)
-
+
Algorithms.scala
// Average number of contacts a person has according to age
def contactsByAge(people: Seq[Person]): Map[Int, Double] =
diff --git a/index.md b/index.md
index 7622e47b2..956a33f1e 100644
--- a/index.md
+++ b/index.md
@@ -1,6 +1,8 @@
---
layout: frontpage
+darkmodeCode: true
+
# Header texts
headerTitle: "The Scala Programming Language"
headerSubtitle: "Scala combines object-oriented and functional programming in one concise, high-level language. Scala's static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries."
diff --git a/resources/css/highlightjs-dark.css b/resources/css/highlightjs-dark.css
new file mode 100644
index 000000000..9db5b23d7
--- /dev/null
+++ b/resources/css/highlightjs-dark.css
@@ -0,0 +1,148 @@
+/*!
+ Theme: GitHub Dark Dimmed
+ Description: Dark dimmed theme as seen on github.com
+ Author: github.com
+ Maintainer: @Hirse
+ Updated: 2021-05-15
+
+ Colors taken from GitHub's CSS
+
+ BSD 3-Clause License
+
+ Copyright (c) 2006, Ivan Sagalaev.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms,
+ with or without modification,
+ are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING,
+ BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT,
+ INCIDENTAL,
+ SPECIAL,
+ EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT,
+ STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+.hljs {
+ color: #adbac7;
+ background: #22272e;
+}
+
+.hljs-doctag,
+.hljs-keyword,
+.hljs-meta .hljs-keyword,
+.hljs-template-tag,
+.hljs-template-variable,
+.hljs-variable.language_ {
+ /* prettylights-syntax-keyword */
+ color: #f47067;
+}
+
+.hljs-title,
+.hljs-type,
+.hljs-title.class_,
+.hljs-title.class_.inherited__,
+.hljs-title.function_ {
+ /* prettylights-syntax-entity */
+ color: #dcbdfb;
+}
+
+.hljs-attr,
+.hljs-attribute,
+.hljs-literal,
+.hljs-meta,
+.hljs-number,
+.hljs-operator,
+.hljs-variable,
+.hljs-selector-attr,
+.hljs-selector-class,
+.hljs-selector-id {
+ /* prettylights-syntax-constant */
+ color: #6cb6ff;
+}
+
+.hljs-regexp,
+.hljs-string,
+.hljs-meta .hljs-string {
+ /* prettylights-syntax-string */
+ color: #96d0ff;
+}
+
+.hljs-built_in,
+.hljs-symbol {
+ /* prettylights-syntax-variable */
+ color: #f69d50;
+}
+
+.hljs-comment,
+.hljs-code,
+.hljs-formula {
+ /* prettylights-syntax-comment */
+ color: #768390;
+}
+
+.hljs-name,
+.hljs-quote,
+.hljs-selector-tag,
+.hljs-selector-pseudo {
+ /* prettylights-syntax-entity-tag */
+ color: #8ddb8c;
+}
+
+.hljs-subst {
+ /* prettylights-syntax-storage-modifier-import */
+ color: #adbac7;
+}
+
+.hljs-section {
+ /* prettylights-syntax-markup-heading */
+ color: #316dca;
+ font-weight: bold;
+}
+
+.hljs-bullet {
+ /* prettylights-syntax-markup-list */
+ color: #eac55f;
+}
+
+.hljs-emphasis {
+ /* prettylights-syntax-markup-italic */
+ color: #adbac7;
+ font-style: italic;
+}
+
+.hljs-strong {
+ /* prettylights-syntax-markup-bold */
+ color: #adbac7;
+ font-weight: bold;
+}
+
+.hljs-addition {
+ /* prettylights-syntax-markup-inserted */
+ color: #b4f1b4;
+ background-color: #1b4721;
+}
+
+.hljs-deletion {
+ /* prettylights-syntax-markup-deleted */
+ color: #ffd8d3;
+ background-color: #78191b;
+}
+
+.hljs-char.escape_,
+.hljs-link,
+.hljs-params,
+.hljs-property,
+.hljs-punctuation,
+.hljs-tag {
+ /* purposely ignored */
+}
diff --git a/resources/js/functions.js b/resources/js/functions.js
index 36bcfd735..5ad0b4ed4 100644
--- a/resources/js/functions.js
+++ b/resources/js/functions.js
@@ -323,6 +323,40 @@ $(document).ready(function () {
}
});
+$(document).ready(function () {
+ // set up automatic switching of code carousel
+ $(".code-carousel").each(function () {
+ var carousel = this;
+ var inputs = [];
+ $(carousel).children("input.code-carousel_control").each(function () {
+ inputs.push(this);
+ });
+
+ // if there is more than one section, set up automatic switching
+ if (inputs.length > 1) {
+
+ var cancelled = false;
+
+ var index = inputs.findIndex(input => input.checked);
+
+ // switch every 8 seconds while the page is visible and not cancelled
+ const intervalHandle = setInterval(() => {
+ if (!document.hidden && !cancelled) {
+ const nextIndex = (index + 1) % inputs.length;
+ inputs[nextIndex].checked = true;
+ index = nextIndex;
+ }
+ }, 8000);
+
+ carousel.addEventListener("click", function cancelTicker() {
+ carousel.removeEventListener("click", cancelTicker);
+ cancelled = true;
+ clearInterval(intervalHandle);
+ });
+ }
+ });
+});
+
var image = { width: 1680, height: 1100 };
var target = { x: 1028, y: 290 };