Initial commit

This commit is contained in:
Erik Thuning 2020-10-21 16:42:07 +02:00
commit 6586f8f100
7 changed files with 92 additions and 0 deletions

12
.gitignore vendored Normal file

@ -0,0 +1,12 @@
# Emacs backup files
*~
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test

5
backend/go.mod Normal file

@ -0,0 +1,5 @@
module drawserver
go 1.15
require github.com/gorilla/websocket v1.4.2 // indirect

2
backend/go.sum Normal file

@ -0,0 +1,2 @@
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=

36
backend/server.go Normal file

@ -0,0 +1,36 @@
package main
import (
"fmt"
"log"
"net/http"
//"encoding/json"
//"github.com/gorilla/websocket"
)
func init() {
log.SetPrefix("server: ")
log.SetFlags(0)
}
func main() {
http.HandleFunc("/save", saveHandler)
http.HandleFunc("/read", readHandler)
log.Fatal(http.ListenAndServe("localhost:8080", nil))
}
func openHandler(w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Println(err)
return
}
}
func saveHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "save!")
}
func readHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "read!")
}

10
frontend/index.html Normal file

@ -0,0 +1,10 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/JavaScript" src="script.js" ></script>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Drawing together!</title>
</head>
<body>
</body>
</html>

21
frontend/script.js Normal file

@ -0,0 +1,21 @@
document.addEventListener('DOMContentLoaded', function whiteboardInit() {
console.log("script init")
var body = document.querySelector('body')
body.addEventListener('click', function doClick(event) {
console.log("clicked: (" + event.clientX + ", " + event.clientY + ")")
var e = createElement('div')
e.style.position = 'absolute'
e.style.left = event.clientX
e.style.top = event.clientY
body.appendChild(e)
})
})
function createElement(tagname, event) {
var e = document.createElement(tagname)
e.style.border = "1px solid black"
e.style.width = "100px"
e.style.height = "100px"
return e
}

6
frontend/style.css Normal file

@ -0,0 +1,6 @@
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
}