Browse Source

попытка добавить веб-отладчик

kpmy 10 năm trước cách đây
mục cha
commit
f0f93fa909
6 tập tin đã thay đổi với 72 bổ sung7 xóa
  1. 8 0
      .gitignore
  2. 7 0
      pubspec.yaml
  3. 12 7
      sim.go
  4. 15 0
      web/index.html
  5. 21 0
      web/main.dart
  6. 9 0
      web/styles/main.css

+ 8 - 0
.gitignore

@@ -22,3 +22,11 @@ _testmain.go
 *.exe
 *.exe
 *.test
 *.test
 *.prof
 *.prof
+
+.buildlog
+.DS_Store
+.idea
+.pub/
+build/
+packages
+pubspec.lock 

+ 7 - 0
pubspec.yaml

@@ -0,0 +1,7 @@
+name: sim3
+version: 0.0.1
+description: console for tri sim
+environment:
+  sdk: '>=1.0.0 <2.0.0'
+dependencies:
+  browser: any

+ 12 - 7
sim.go

@@ -2,24 +2,29 @@ package main
 
 
 import (
 import (
 	"github.com/ivpusic/neo"
 	"github.com/ivpusic/neo"
+	"github.com/ivpusic/neo-cors"
 	"runtime"
 	"runtime"
 	"sim3/ncl"
 	"sim3/ncl"
 	"sim3/ncl/std"
 	"sim3/ncl/std"
-	"time"
+	"sync"
 )
 )
 
 
 func main() {
 func main() {
+	runtime.GOMAXPROCS(runtime.NumCPU() * 4)
+
 	nw := func() {
 	nw := func() {
 		app := neo.App()
 		app := neo.App()
-
-		app.Get("/", func(ctx *neo.Ctx) {
-			ctx.Res.Text("I am Neo Programmer", 200)
+		app.Use(cors.Init())
+		app.Get("/tri.json", func(ctx *neo.Ctx) {
+			ctx.Res.Text("[]", 200)
 		})
 		})
-
 		app.Start()
 		app.Start()
 	}
 	}
 	go nw()
 	go nw()
-	runtime.GOMAXPROCS(runtime.NumCPU() * 4)
+
+	wg := &sync.WaitGroup{}
+	wg.Add(1)
+
 	board := std.Board()
 	board := std.Board()
 	not := std.NewNot()
 	not := std.NewNot()
 	board.Point("+").Solder(std.NewProbe("+").Pin(ncl.I))
 	board.Point("+").Solder(std.NewProbe("+").Pin(ncl.I))
@@ -28,5 +33,5 @@ func main() {
 	buf := std.NewBuffer()
 	buf := std.NewBuffer()
 	board.Point("not+").Solder(buf.Pin(ncl.I))
 	board.Point("not+").Solder(buf.Pin(ncl.I))
 	board.Point("not+buf").Solder(buf.Pin(ncl.O), std.NewProbe("not+buf").Pin(ncl.I))
 	board.Point("not+buf").Solder(buf.Pin(ncl.O), std.NewProbe("not+buf").Pin(ncl.I))
-	time.Sleep(time.Duration(time.Second * 2))
+	wg.Wait()
 }
 }

+ 15 - 0
web/index.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="scaffolded-by" content="https://github.com/google/stagehand">
+    <title>sim3w</title>
+    <link rel="stylesheet" href="styles/main.css">
+</head>
+<body>
+<script type="application/dart" src="main.dart"></script>
+<script data-pub-inline src="packages/browser/dart.js"></script>
+</body>
+</html>

+ 21 - 0
web/main.dart

@@ -0,0 +1,21 @@
+// Copyright (c) 2015, <your name>. All rights reserved. Use of this source code
+// is governed by a BSD-style license that can be found in the LICENSE file.
+
+import 'dart:html';
+import 'dart:async';
+import 'dart:convert';
+
+var Q = querySelector;
+
+void main() {
+  var get;
+  get = (){
+    HttpRequest.getString("http://localhost:3000/tri.json")
+    ..then((s){
+      var data = JSON.decode(s);
+    })
+    ..catchError((e){});
+    new Future.delayed(new Duration(milliseconds: 100), get);
+  };
+  get();
+}

+ 9 - 0
web/styles/main.css

@@ -0,0 +1,9 @@
+@import url(https://fonts.googleapis.com/css?family=Roboto);
+
+html, body {
+    width: 100%;
+    height: 100%;
+    margin: 0;
+    padding: 0;
+    font-family: 'Roboto', sans-serif;
+}