From 3853fdad52e97527187ed450ec9993fda3ba41d7 Mon Sep 17 00:00:00 2001 From: xieguigang Date: Sun, 1 Sep 2019 13:58:12 +0800 Subject: [PATCH] update environment --- .../ManagerInterface/html/js/linq.js | 42 ++++++++++++++----- .../ManagerInterface/interface/app.ts | 24 +++++++++-- .../ManagerInterface/linq.d.ts | 4 ++ viz/ts/TsLinq | 2 +- 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/Distribute_computing/ManagerInterface/html/js/linq.js b/Distribute_computing/ManagerInterface/html/js/linq.js index f3cefae..771c004 100644 --- a/Distribute_computing/ManagerInterface/html/js/linq.js +++ b/Distribute_computing/ManagerInterface/html/js/linq.js @@ -907,6 +907,27 @@ var IEnumerator = /** @class */ (function (_super) { IEnumerator.prototype.OrderByDescending = function (key) { return Enumerable.OrderByDescending(this.sequence, key); }; + /** + * Split a sequence by elements count + */ + IEnumerator.prototype.Split = function (size) { + var seq = []; + var row = []; + for (var _i = 0, _a = this.sequence; _i < _a.length; _i++) { + var element = _a[_i]; + if (row.length < size) { + row.push(element); + } + else { + seq.push(row); + row = []; + } + } + if (row.length > 0) { + seq.push(row); + } + return new IEnumerator(seq); + }; /** * 取出序列之中的前n个元素 */ @@ -924,7 +945,8 @@ var IEnumerator = /** @class */ (function (_super) { */ IEnumerator.prototype.Reverse = function () { var rseq = this.ToArray().reverse(); - return new IEnumerator(rseq); + var seq = new IEnumerator(rseq); + return seq; }; /** * Returns elements from a sequence as long as a specified condition is true. @@ -5935,16 +5957,16 @@ var TypeScript; garbageCollect.handler = getHandler(); function getHandler() { if (typeof window.require === "function") { - var require = window.require; + var require_1 = window.require; try { - require("v8").setFlagsFromString('--expose_gc'); + require_1("v8").setFlagsFromString('--expose_gc'); if (window.global != null) { - var global = window.global; - if (typeof global.gc == "function") { - return global.gc; + var global_1 = window.global; + if (typeof global_1.gc == "function") { + return global_1.gc; } } - var vm = require("vm"); + var vm = require_1("vm"); if (vm != null) { if (typeof vm.runInNewContext == "function") { var k = vm.runInNewContext("gc"); @@ -5979,9 +6001,9 @@ var TypeScript; // } //} if (typeof window.global !== 'undefined') { - var global = window.global; - if (global.gc) { - return global.gc; + var global_2 = window.global; + if (global_2.gc) { + return global_2.gc; } } //if (typeof Duktape == 'object') { diff --git a/Distribute_computing/ManagerInterface/interface/app.ts b/Distribute_computing/ManagerInterface/interface/app.ts index e4967c2..89f2cf9 100644 --- a/Distribute_computing/ManagerInterface/interface/app.ts +++ b/Distribute_computing/ManagerInterface/interface/app.ts @@ -17,12 +17,13 @@ enum nodeStatus { } enum protocols { - return_initialize_data + return_initialize_data, + log_events } interface message { protocol: protocols; - msg: GridNode[] + msg: GridNode[] | string; } module app { @@ -52,16 +53,31 @@ module app { switch (msg.protocol) { case protocols.return_initialize_data: - drawInterface(msg.msg); + drawInterface(msg.msg); break; + case protocols.log_events: + logEvents(msg.msg); default: throw `not implements: ${msg.protocol}`; } } + function logEvents(event: string) { + + } + function drawInterface(data: GridNode[]) { // 5个节点一行? - let matrix = $ts("#grid"); + let matrix: HTMLBodyElement = $ts("#grid"); + let columns: number = 5; + let mat: IEnumerator = $ts(data).Split(columns); + + for (let mrow of mat.ToArray(false)) { + let row = $ts(""); + + // row + matrix.appendChild(row); + } } } diff --git a/Distribute_computing/ManagerInterface/linq.d.ts b/Distribute_computing/ManagerInterface/linq.d.ts index 71804ea..6b66ce9 100644 --- a/Distribute_computing/ManagerInterface/linq.d.ts +++ b/Distribute_computing/ManagerInterface/linq.d.ts @@ -293,6 +293,10 @@ declare class IEnumerator extends LINQIterator { * sorted in descending order according to a key. */ OrderByDescending(key: (e: T) => number): IEnumerator; + /** + * Split a sequence by elements count + */ + Split(size: number): IEnumerator; /** * 取出序列之中的前n个元素 */ diff --git a/viz/ts/TsLinq b/viz/ts/TsLinq index e95d2ae..be6109b 160000 --- a/viz/ts/TsLinq +++ b/viz/ts/TsLinq @@ -1 +1 @@ -Subproject commit e95d2ae72dc58ce7c5e22ab16c0a7cb97f282dea +Subproject commit be6109bf643c799771be8e9caccbe212a70f94af