Skip to content

Commit

Permalink
Merge pull request #1 from gkossakowski/master
Browse files Browse the repository at this point in the history
Various updates to Scala+GWT homepage.
  • Loading branch information
gkossakowski committed Aug 31, 2011
2 parents 7ee500e + 29104ca commit dd5a1ab
Show file tree
Hide file tree
Showing 946 changed files with 1,425,480 additions and 974,714 deletions.
5 changes: 3 additions & 2 deletions css/screen.css
Expand Up @@ -5,11 +5,12 @@
/*****************************************************************************/

/* Global Reset */

/* grek: I turned this off because it was breaking the whole page layout */
/*
* {
margin: 0;
padding: 0;
}
}*/

html, body {
height: 100%;
Expand Down
10 changes: 6 additions & 4 deletions index.md
Expand Up @@ -14,8 +14,10 @@ via the GWT toolchain.
Status
------

One milestone past "Hello World." Someone help me define what that
is ...
We can compile most of Scala code. Check [Samples](samples) for
live demos.

First milestone release coming soon.

Contributors
------------
Expand All @@ -30,9 +32,9 @@ Google Group
------------
[scalagwt@googlegroups.com](http://groups.google.com/group/scalagwt)

Code Review
Code
-----------
[Gerrit Code Review](http://review.source.gogoego.com)
[GitHub](http://github.com/scalagwt)

Twitter
-------
Expand Down
22 changes: 22 additions & 0 deletions samples/GwtDlx.html
@@ -0,0 +1,22 @@
<!doctype html>

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="gwtdlx.css">
<script type="text/javascript" language="javascript"
src="gwtdlx/gwtdlx.nocache.js"></script>
<title>gwtdlx</title>
</head>
<body>

<div id="contents">
<p class="chunky">Put your sudoku puzzle here.</p>

<div id="board"></div>

<div id="button"></div>
<br clear="all"/>
</div>
</body>
</html>
119 changes: 119 additions & 0 deletions samples/Mnemonics.html
@@ -0,0 +1,119 @@
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Phone mnemonics</title>
<style>
input#phonenumber {
font-size: 22px;
height: 30px;
}
div.input {
padding-top: 20px;
padding-bottom: 30px;
}
div.output {
font-family: "museo-slab-1","museo-slab-2",Georgia,"Times New Roman",serif;
color: #BF3604;
font-size: 28px;
line-height: 34px;
}
div.hidden {
visibility: hidden;
}
</style>
<script type="text/javascript" language="javascript" src="mnemonics/mnemonics.nocache.js"></script>
</head>

<body>
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
<div class="container" id="main">
<div class="page-header">
<h1>Phone mnemonics
<small>Scala collections in a browser</small>
</h1>
</div>
<div class="modal hidden" style="position: fixed; top: 100px; left: 380px; margin: 0 auto; z-index: 1" id="implicitcat">
<div class="modal-header">
<h3>Oh, don't do that, or implicit-cat will get you</h3>
<a href="javascript:(document.getElementById('implicitcat').className += ' hidden');void(0);" class="close">×</a>
</div>
<div class="modal-body">
<img src="mnemonics/implicit-cat.png">
</div>
<div class="modal-footer">
</div>
</div>
<div class="row">
<div class="span9 columns">
<section id="overview">
<img src="mnemonics/phone-small.jpg">
<p class="small"><small>Image taken from http://www.flickr.com/photos/gadgetgirl70/225913840/ (CC license)</small></p>
</section>
</div>
<div class="span7 columns">
<h2 >This is the phone mnemonics problem tested in <a
href="http://page.mi.fu-berlin.de/prechelt/Biblio/jccpprt_computer2000.pdf">a
well-known empirical comparison of seven programming languages</a>.
The Scala version is as short as the scripting-language solutions.
Through the use of GWT, the Scala code can run directly within the web
browser and not need any server-side support.</h3>
</div>
</div>
<section id="run">
<h3>Enter phone number</h3>
</section>
</div>
<div class="container" id="srccode">
<div class="page-header">
<h2>Source code
<small>Original code compiles straight to JS</small>
</h2>
</div>
<p>We decided to exclude code handling page updates. GWT libraries didn't get Scala's
<a href="http://www.artima.com/weblogs/viewpost.jsp?thread=179766">pimp-love</a> yet so it's not pretty.</p>
<!-- We probably would like to have some dynamic inclusion mechanism (e.g. at build time) but I'll leave it for others to improve -->
<pre class="prettyprint lang-scala linenums">
package com.google.gwt.sample.mnemonics.client

/** Taken from presentation by Martin Odersky at OSCON 2011 */
class Coder(words: List[String]) {

private val mnemonics = Map(
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL",
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ")

/** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */
private val charCode: Map[Char, Char] =
for ((digit, str) <- mnemonics; ltr <- str) yield (ltr -> digit)

/** Maps a word to the digit string it can represent, e.g. "Java" -> "5282" */
def wordCode(word: String) = word.toUpperCase map charCode

/** A map from digit strings to the words that represent them,
* e.g. "5282" -> Set("Java", "Kata", "Lava", ...) */
private val wordsForNum: Map[String, List[String]] = (words groupBy wordCode) withDefaultValue List()

/** Return all ways to encode a number as a list of words */
def encode(number: String): Set[List[String]] =
if (number.isEmpty)
Set(List())
else {
for {
splitPoint <- 1 to number.length
word <- wordsForNum(number take splitPoint)
rest <- encode(number drop splitPoint)
} yield word :: rest
}.toSet

/** Maps a number to a list of all word phrases that can represent it */
def translate(number: String): Set[String] = encode(number) map (_ mkString " ")
}</pre>
</div>
</body>
</html>
74 changes: 74 additions & 0 deletions samples/gwtdlx.css
@@ -0,0 +1,74 @@
body {
color:#fff;
background:#666;
font-family: arial,sans-serif;
}

p.chunky {
font-family: arial,sans-serif;
font-size: 200%;
font-weight; bold;
color: #fff;
padding-bottom: 0.5em;
margin: 0;
}

div#contents {
width: 30em;
margin-left: auto;
margin-right: auto;
}

div#button {
padding-top: 1em;
}

button {
border: 4px solid #666;
margin: 4px;
font-family: arial,sans-serif;
font-size: 2em;
font-weight; bold;
color: #666;
margin: 0;
}

table.board {
font-family: monospace;
font-size: 150%;
}

td {
width: 30px;
height: 30px;
}

td.spacer {
width: 10px;
}

th.spacer {
height: 10px;
}

td input {
font-size: 1.5em;
border: 0;
}

.cell {
background-color: white;
color:#666;
text-align: center;
width: 1em;
}

.fail {
font-size: 6em;
}

#ajax {
position: absolute;
float: left;
top: 0px;
}

0 comments on commit dd5a1ab

Please sign in to comment.