Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vzex committed Feb 16, 2016
1 parent 5b92531 commit dbb2bab
Show file tree
Hide file tree
Showing 23 changed files with 1,078 additions and 17 deletions.
32 changes: 16 additions & 16 deletions server/httpserver.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package server
import "net/http"
import "net"
import "html/template"
import "log"
import "strconv"

func InitAdminPort(port int) error {
mux := http.NewServeMux()
f := func(w http.ResponseWriter, r *http.Request) {
}
mux.HandleFunc("/admin", f)
addr := "0.0.0.0:" + strconv.Itoa(port)
server := &http.Server{Addr: addr, Handler: mux}
listener, err := net.Listen("tcp", addr)
if err != nil {
return err
}
log.Println("begin serve admin port:", addr)
go server.Serve(listener)
return nil
func InitAdminPort(addr, websock string) error {
http.Handle("/css/", http.FileServer(http.Dir("website")))
http.Handle("/fonts/", http.FileServer(http.Dir("website")))
http.Handle("/js/", http.FileServer(http.Dir("website")))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
t, er := template.ParseFiles("website/index.html")
if er == nil {
t.Execute(w, websock)
} else {
log.Println("err:", er.Error())
}
})
log.Println("begin serve http:", addr)
er := http.ListenAndServe(addr, nil)
return er
}


8 changes: 7 additions & 1 deletion server/init.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package server

import "flag"
import "log"

var service = flag.String("service", "", "for remote client connect")
var webservice = flag.String("web", ":8080", "http server port")
var websocket = flag.String("websocket", ":8081", "http web-socket port")
var websocket = flag.String("websocket", "10.240.160.17:8081", "http web-socket port")
func Init() {
flag.Parse()
er:=InitAdminPort(*webservice, *websocket)
if er !=nil {
log.Println("web server fail", er.Error())
return
}
Listen(*service)
}
17 changes: 17 additions & 0 deletions website/css/sui.min.css

Large diffs are not rendered by default.

Binary file added website/fonts/icon-moon.eot
Binary file not shown.
145 changes: 145 additions & 0 deletions website/fonts/icon-moon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/fonts/icon-moon.ttf
Binary file not shown.
Binary file added website/fonts/icon-moon.woff
Binary file not shown.
Binary file added website/fonts/icon-pc.eot
Binary file not shown.
68 changes: 68 additions & 0 deletions website/fonts/icon-pc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/fonts/icon-pc.ttf
Binary file not shown.
Binary file added website/fonts/icon-pc.woff
Binary file not shown.
Binary file added website/fonts/icon-tb.eot
Binary file not shown.
570 changes: 570 additions & 0 deletions website/fonts/icon-tb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/fonts/icon-tb.ttf
Binary file not shown.
Binary file added website/fonts/icon-tb.woff
Binary file not shown.
Binary file added website/fonts/icon-touch.eot
Binary file not shown.
162 changes: 162 additions & 0 deletions website/fonts/icon-touch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/fonts/icon-touch.ttf
Binary file not shown.
Binary file added website/fonts/icon-touch.woff
Binary file not shown.
82 changes: 82 additions & 0 deletions website/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<title>gds</title>
<link href="css/sui.min.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/sui.min.js"></script>
</head>
<body>
<div class="sui-layout">
<div class="sidebar">
<ul class="sui-nav nav-tabs nav-large tab-vertical">
<li><a>语文</a></li>
<li class="active"><a href="#index" data-toggle="tab">数学</a></li>
<li><a href="#profile" data-toggle="tab">英语</a></li>
</ul>
</div>
<div class="content">
<div class="tab-content tab-wraped">
<div id="index" class="tab-pane active">
<p>qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
</div>
<div id="profile" class="tab-pane">
<p>Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park</p>
</div>
<div id="about" class="tab-pane">
<p>Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p>
</div>
<div id="help" class="tab-pane">
<p>help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!help!!!</p>
</div>
</div>
</div>
</div>
<script>
function Decode(content) {
var vars = content.split(":");
var head, msg;
if (vars.length > 0) {
head = vars[0];
}
if (vars.length > 1) {
msg = "";
for(var i=1;i<vars.length;i++) {
if(i==1) {
msg=vars[i];
}
else {
msg=msg+":"+vars[i];
}
}
}
return [head, msg];
}

function OnRecv(data) {
var arr= Decode(data)
var head = arr[0];
var msg= arr[1];
switch(head){
case "needinit":
}
}
if (window["WebSocket"]) {
conn = new WebSocket("ws://{{.}}/ws");
conn.onclose = function() {
}
conn.onerror = function(ev) {
$.alert("connect error");
}
conn.onmessage = function(evt) {
OnRecv(evt.data);
}
} else {
$.alert("<div><b>Your browser does not support WebSockets.</b></div>");
}
</script>
</body>
</html>
6 changes: 6 additions & 0 deletions website/js/jquery-1.10.2.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions website/js/sui-extends.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions website/js/sui.min.js

Large diffs are not rendered by default.

0 comments on commit dbb2bab

Please sign in to comment.