Browse Source

изменил тип дарт-проекта с приложения на библиотеку

kpmy 10 years ago
parent
commit
d126b412a2
8 changed files with 62 additions and 108 deletions
  1. 11 0
      example/si3m.dart
  2. 11 0
      lib/si3m.dart
  3. 11 0
      lib/src/si3m_base.dart
  4. 8 5
      pubspec.yaml
  5. 21 0
      test/all_test.dart
  6. 0 17
      web/index.html
  7. 0 79
      web/main.dart
  8. 0 7
      web/styles/main.css

+ 11 - 0
example/si3m.dart

@@ -0,0 +1,11 @@
+// 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.
+
+library si3m.example;
+
+import 'package:si3m/si3m.dart';
+
+main() {
+  var awesome = new Awesome();
+  print('awesome: ${awesome.isAwesome}');
+}

+ 11 - 0
lib/si3m.dart

@@ -0,0 +1,11 @@
+// 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.
+
+/// The si3m library.
+///
+/// This is an awesome library. More dartdocs go here.
+library si3m;
+
+// TODO: Export any libraries intended for clients of this package.
+
+export 'src/si3m_base.dart';

+ 11 - 0
lib/src/si3m_base.dart

@@ -0,0 +1,11 @@
+// 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.
+
+// TODO: Put public facing types in this file.
+
+library si3m.base;
+
+/// Checks if you are awesome. Spoiler: you are.
+class Awesome {
+  bool get isAwesome => true;
+}

+ 8 - 5
pubspec.yaml

@@ -1,7 +1,10 @@
 name: sim3
+description: >
+  A library useful for applications or for sharing on pub.dartlang.org.
 version: 0.0.1
-description: console for tri sim
-environment:
-  sdk: '>=1.0.0 <2.0.0'
-dependencies:
-  browser: any
+#author: <your name> <email@example.com>
+#homepage: https://www.example.com
+#dependencies:
+#  lib_name: any
+dev_dependencies:
+  unittest: any

+ 21 - 0
test/all_test.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.
+
+library si3m.test;
+
+import 'package:unittest/unittest.dart';
+import 'package:si3m/si3m.dart';
+
+main() {
+  group('A group of tests', () {
+    Awesome awesome;
+
+    setUp(() {
+      awesome = new Awesome();
+    });
+
+    test('First Test', () {
+      expect(awesome.isAwesome, isTrue);
+    });
+  });
+}

+ 0 - 17
web/index.html

@@ -1,17 +0,0 @@
-<!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>
-  <div id="data">
-  </div>
-<script type="application/dart" src="main.dart"></script>
-<script data-pub-inline src="packages/browser/dart.js"></script>
-</body>
-</html>

+ 0 - 79
web/main.dart

@@ -1,79 +0,0 @@
-// 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;
-
-class Item implements Comparable{
-  int timestamp;
-  String name;
-  String type;
-  bool meta;
-  bool signal;
-
-  @override
-  int compareTo(Item that){
-    DateTime a = new DateTime.fromMillisecondsSinceEpoch(this.timestamp);
-    DateTime b = new DateTime.fromMillisecondsSinceEpoch(that.timestamp);
-    if(a.isBefore(b))
-      return -1;
-    else if(a.isAfter(b))
-      return 1;
-    else return 0;
-  }
-
-  Item(this.timestamp, this.name, this.type, this.meta, this.signal);
-}
-
-List<Item> cache = new List();
-
-update() async{
-  (Q("#data") as DivElement).children.clear();
-  Map<String, List<Item>> map = new Map();
-  cache.forEach((i){
-    if(!map.containsKey(i.name)){
-      map[i.name] = new List<Item>();
-    }
-    map[i.name].add(i);
-  });
-  var keys = map.keys.toList();
-  keys.sort();
-  keys.forEach((s){
-    var id = "p"+s.hashCode.toString();
-    (Q("#data") as DivElement).appendHtml("<div>$s:</div><div id='p$id' style='white-space: nowrap;'></div>");
-    String dump = "";
-    map[s].forEach((i){
-      var sig = i.signal == null ? "0" : i.signal ? "+" : "-";
-      if(i.meta)
-        dump = "$sig$dump";
-      else
-        dump = "_$dump";
-    });
-    (Q("#p$id") as DivElement).appendHtml(dump);
-  });
-  return 0;
-}
-
-main() async{
-  var get;
-  get = (){
-    HttpRequest.getString("http://localhost:3000/tri.json")
-    ..then((s){
-      var data = JSON.decode(s);
-      List il = (data as List);
-      il.forEach((i){
-        bool sig = i["Signal"]["N"] ? null : i["Signal"]["T"];
-        cache.add(new Item(i["Timestamp"], i["Name"], i["Type"], i["Meta"], sig));
-      });
-      cache.sort();
-      update();
-    })
-    ..catchError((e){});
-    new Future.delayed(new Duration(milliseconds: 300), get);
-  };
-  //get();
-  new Worker("go/sim3.js");
-}

+ 0 - 7
web/styles/main.css

@@ -1,7 +0,0 @@
-html, body {
-    width: 100%;
-    height: 100%;
-    margin: 0;
-    padding: 0;
-    font-family: monospace;
-}