10 changed files with 192 additions and 60 deletions
-
48assets/html/main.html
-
0assets/image/waldschrat.jpg
-
0assets/js/jquery-1.7.1.js
-
0assets/js/jquery-1.7.1.min.js
-
60assets/js/serverval.js
-
41assets/style/common.css
-
1src/Makefile.am
-
57src/http/response/me.c
-
43src/http/worker/process.c
-
2src/webgameserver.c
@ -0,0 +1,48 @@ |
|||||
|
<?xml version="1.0" encoding="iso-8859-1"?> |
||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
||||
|
<head> |
||||
|
<title>My own little Web-App</title> |
||||
|
<link rel="stylesheet" type="text/css" href="/assets/style/common"> |
||||
|
<script type="text/javascript" src="/assets/js/jquery"></script> |
||||
|
<script type="text/javascript" src="/assets/js/serverval"></script> |
||||
|
<script> |
||||
|
//<![CDATA[ |
||||
|
$(document).ready(function() { |
||||
|
var sval = new ServerVal("#randval"); |
||||
|
|
||||
|
$("ul#menu li:eq(0)").click(function() { |
||||
|
sval.start(); |
||||
|
}); |
||||
|
|
||||
|
$("#randval").click(function() { |
||||
|
sval.stop(); |
||||
|
}); |
||||
|
}); |
||||
|
//]]> |
||||
|
</script> |
||||
|
</head> |
||||
|
<body> |
||||
|
<ul id="menu"> |
||||
|
<li>random Value</li> |
||||
|
</ul> |
||||
|
<div id="randval" class="hide"> |
||||
|
<span class=\"small"> |
||||
|
Value created at: <br /> |
||||
|
<span></span><br> |
||||
|
Next value in: <span></span><br /> |
||||
|
</span> |
||||
|
Value: <span></span> |
||||
|
</div> |
||||
|
<div id="main"> |
||||
|
<h1>Testpage</h1> |
||||
|
Welcome You!!!<br /> |
||||
|
<img src="/image/me" /> |
||||
|
</div> |
||||
|
<hr /> |
||||
|
<div id="msg"></div> |
||||
|
</body> |
||||
|
</html> |
||||
|
|
||||
|
<!-- vim: set ts=4 sw=4: --> |
||||
|
Before Width: 250 | Height: 250 | Size: 78 KiB After Width: 250 | Height: 250 | Size: 78 KiB |
@ -0,0 +1,60 @@ |
|||||
|
function ServerVal(eId) |
||||
|
{ |
||||
|
this.eId = eId; |
||||
|
this.eCtime = eId + " span:eq(1)"; |
||||
|
this.eVnext = eId + " span:eq(2)"; |
||||
|
this.eValue = eId + " span:eq(3)"; |
||||
|
|
||||
|
this.interval = null; |
||||
|
this.ctime = null; |
||||
|
this.vnext = 0; |
||||
|
this.value = null; |
||||
|
} |
||||
|
|
||||
|
ServerVal.prototype.loadJSON = function(data) |
||||
|
{ |
||||
|
this.ctime = new Date(data.ctime * 1000); |
||||
|
this.vnext = data.vnext; |
||||
|
this.value = data.value; |
||||
|
|
||||
|
this.show(); |
||||
|
} |
||||
|
|
||||
|
ServerVal.prototype.show = function() |
||||
|
{ |
||||
|
$(this.eCtime).empty().append(this.ctime.toString()); |
||||
|
$(this.eVnext).empty().append(this.vnext); |
||||
|
$(this.eValue).empty().append(this.value); |
||||
|
|
||||
|
if ($(this.eId).hasClass("hide")) { |
||||
|
$(this.eId).removeClass("hide"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ServerVal.prototype.start = function() |
||||
|
{ |
||||
|
this.interval = setInterval($.proxy(this.process, this), 1000); |
||||
|
} |
||||
|
|
||||
|
ServerVal.prototype.process = function() |
||||
|
{ |
||||
|
if (0 >= this.vnext) { |
||||
|
$.getJSON("/randval/", $.proxy(this.loadJSON, this)); |
||||
|
} |
||||
|
|
||||
|
else { |
||||
|
this.vnext--; |
||||
|
$(this.eVnext).empty().append(this.vnext); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ServerVal.prototype.stop = function() |
||||
|
{ |
||||
|
$(this.eId).addClass("hide"); |
||||
|
|
||||
|
clearInterval(this.interval); |
||||
|
this.interval = null; |
||||
|
this.vnext = 0; |
||||
|
} |
||||
|
|
||||
|
// vim: set ts=4 sw=4:
|
||||
@ -0,0 +1,41 @@ |
|||||
|
div#randval { |
||||
|
left: 200px; |
||||
|
top: 100px; |
||||
|
padding: 10px; |
||||
|
position: fixed; |
||||
|
background-color: white; |
||||
|
border: 1px solid black; |
||||
|
border-radius: 10px; |
||||
|
} |
||||
|
|
||||
|
div.hide#randval { |
||||
|
top: -500px; |
||||
|
} |
||||
|
|
||||
|
.small { |
||||
|
font-size: small; |
||||
|
} |
||||
|
|
||||
|
ul#menu { |
||||
|
list-style: none inside; |
||||
|
margin: 0px; |
||||
|
padding: 1px 0px 0px; |
||||
|
border-bottom: 1px solid #7b0b2b; |
||||
|
display: inline-block; |
||||
|
width: 100%; |
||||
|
} |
||||
|
|
||||
|
ul#menu li { |
||||
|
padding: 2px; |
||||
|
border-top-left-radius: 10px; |
||||
|
border-top-right-radius: 10px; |
||||
|
border-top: 1px solid #7b0b2b; |
||||
|
border-left: 1px solid #7b0b2b; |
||||
|
border-right: 1px solid #7b0b2b; |
||||
|
text-align: center; |
||||
|
cursor: pointer; |
||||
|
|
||||
|
float: left; |
||||
|
margin-right: 1px; |
||||
|
} |
||||
|
/* vim: set st=4 sw=4: */ |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue