-
-
Save jimbok8/18bcfdd383131f9b309878d068326718 to your computer and use it in GitHub Desktop.
Hello World via Knockout4Java
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
package dew.demo.duke2brwsr; | |
import net.java.html.json.*; | |
@Model(className = "Data", properties = { | |
@Property(name = "image", type = String.class), | |
@Property(name = "buttonText", type =String.class), | |
@Property(name = "on", type = boolean.class) | |
}) | |
class Duke2Brwsr { | |
static { | |
Data model = new Data(); | |
model.setButtonText("Krakow Duke"); | |
model.setImage("http://www.comscigate.com/gifs/duke/Juggler.gif"); | |
model.applyBindings(); | |
} | |
@Function | |
static void switchDuke(Data model) { | |
if(model.getImage().equals("http://www.agilejava.eu/duke2brwser/Juggler.gif")) { | |
model.setImage("http://www.agilejava.eu/duke2brwser/krakowduke.jpg"); | |
model.setButtonText("Normal Duke"); | |
} else { | |
model.setImage("http://www.agilejava.eu/duke2brwser/Juggler.gif"); | |
model.setButtonText("Krakow Duke"); | |
} | |
} | |
@Function | |
static void turnOn(Data model) { | |
model.setOn(true); | |
} | |
@Function | |
static void turnOff(Data model) { | |
model.setOn(false); | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<style type="text/css"> | |
@-webkit-keyframes spin { | |
0% { -webkit-transform: rotate(0deg); } | |
100% { -webkit-transform: rotate(360deg); } | |
} | |
.rotate { | |
-webkit-animation-name: spin; | |
-webkit-animation-duration: 3s; | |
-webkit-animation-iteration-count: infinite; | |
-webkit-animation-direction: alternate; | |
} | |
#scene { | |
position: relative; | |
top: 60px; | |
text-align: center; | |
} | |
#words span { | |
border: 1px solid #ccc; | |
background: rgba(255,255,155,0.8); | |
text-align: center; | |
font-size: 30px; | |
-webkit-box-shadow: inset 0 0 40px rgba(0,0,0,0.4); | |
position: absolute; | |
} | |
#words span:nth-child(1) { left: 45%; top: 0px; } | |
#words span:nth-child(2) { left: 25%; top: 100px; } | |
#words span:nth-child(3) { left: 65%; top: 100px; } | |
#words span:nth-child(4) { left: 10%; top: 200px; } | |
#words span:nth-child(5) { left: 45%; top: 200px; } | |
#words span:nth-child(6) { left: 80%; top: 200px; } | |
</style> | |
</head> | |
<body> | |
<h1>Spinning Duke</h1> | |
<br> | |
<button data-bind="enable: !on(), click: $root.turnOn">Start</button> | |
<button data-bind="enable: on, click: $root.turnOff">Stop</button> | |
<button data-bind="enable: true, click: $root.switchDuke, text: $root.buttonText" ></button> | |
<div id="scene"> | |
<img data-bind="attr: {'src' : $root.image, 'alt': '', 'height':200, 'width': 200}, css: {'rotate' : $root.on }"/> | |
</div> | |
<iframe id="forecast_embed" type="text/html" frameborder="0" height="245" width="100%" src="http://forecast.io/embed/#lat=52.9&lon=-1.5&name=Derby"> </iframe> | |
<script type="text/javascript" src="bck2brwsr.js"></script> | |
<script> | |
var vm = bck2brwsr('${project.build.finalName}.jar'); | |
vm.loadClass('eu.agilejava.duke2brwsr.MainBrwsr'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment