diff --git a/.gitignore b/.gitignore index 7ccdfe56..9758f20a 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,6 @@ node_modules/ # jsDoc out/ + +# TypeScript +typings/ diff --git a/nengo_gui/components/htmlview.py b/nengo_gui/components/htmlview.py index 6c4b3af2..1d4a0726 100644 --- a/nengo_gui/components/htmlview.py +++ b/nengo_gui/components/htmlview.py @@ -39,7 +39,7 @@ def update_client(self, client): def javascript(self): info = dict(uid=id(self), label=self.label) json = self.javascript_config(info) - return 'new HTMLView(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new HTMLView.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def code_python_args(self, uids): return [uids[self.obj]] diff --git a/nengo_gui/components/pointer.py b/nengo_gui/components/pointer.py index bfe64cc3..01020889 100644 --- a/nengo_gui/components/pointer.py +++ b/nengo_gui/components/pointer.py @@ -87,7 +87,7 @@ def update_client(self, client): def javascript(self): info = dict(uid=id(self), label=self.label) json = self.javascript_config(info) - return 'new Pointer(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new Pointer.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def code_python_args(self, uids): return [uids[self.obj], 'target=%r' % self.target] diff --git a/nengo_gui/components/raster.py b/nengo_gui/components/raster.py index 8d42e9b6..30d3a47d 100644 --- a/nengo_gui/components/raster.py +++ b/nengo_gui/components/raster.py @@ -61,7 +61,7 @@ def javascript(self): info = dict(uid=id(self), label=self.label, max_neurons=self.max_neurons) json = self.javascript_config(info) - return 'new Raster(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new Raster.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def code_python_args(self, uids): return [uids[self.obj.ensemble]] diff --git a/nengo_gui/components/slider.py b/nengo_gui/components/slider.py index 02e4ac20..13a3a7c8 100644 --- a/nengo_gui/components/slider.py +++ b/nengo_gui/components/slider.py @@ -114,7 +114,7 @@ def javascript(self): label=self.label, start_value=[float(x) for x in self.start_value]) json = self.javascript_config(info) - return 'new Slider(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new Slider.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def update_client(self, client): while len(self.to_client) > 0: diff --git a/nengo_gui/components/spa_similarity.py b/nengo_gui/components/spa_similarity.py index a490d636..f498fa28 100644 --- a/nengo_gui/components/spa_similarity.py +++ b/nengo_gui/components/spa_similarity.py @@ -81,7 +81,7 @@ def javascript(self): info = dict(uid=id(self), label=self.label, n_lines=len(self.labels), synapse=0, pointer_labels=self.labels) json = self.javascript_config(info) - return 'new SpaSimilarity(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new SpaSimilarity.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def message(self, msg): """Message receive function for show_pairs toggling and reset""" diff --git a/nengo_gui/components/spike_grid.py b/nengo_gui/components/spike_grid.py index 142a5ee3..14dfe294 100644 --- a/nengo_gui/components/spike_grid.py +++ b/nengo_gui/components/spike_grid.py @@ -68,7 +68,7 @@ def javascript(self): info = dict(uid=id(self), label=self.label, pixels_x=self.pixels_x, pixels_y=self.pixels_y) json = self.javascript_config(info) - return 'new Image(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new Image.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def code_python_args(self, uids): args = [uids[self.obj]] diff --git a/nengo_gui/components/value.py b/nengo_gui/components/value.py index 364ed95d..e50c72d0 100644 --- a/nengo_gui/components/value.py +++ b/nengo_gui/components/value.py @@ -83,7 +83,7 @@ def javascript(self): info = dict(uid=id(self), label=self.label, n_lines=self.n_lines) json = self.javascript_config(info) - return 'new Value(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new Value.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def code_python_args(self, uids): # generate the list of strings for the .cfg file to save this Component diff --git a/nengo_gui/components/voltage.py b/nengo_gui/components/voltage.py index cf38ecd3..07185478 100644 --- a/nengo_gui/components/voltage.py +++ b/nengo_gui/components/voltage.py @@ -56,7 +56,7 @@ def javascript(self): info = dict(uid=id(self), label=self.label, n_lines=self.n_neurons, synapse=0) json = self.javascript_config(info) - return 'new Value(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new Value.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def code_python_args(self, uids): return [uids[self.obj.ensemble]] diff --git a/nengo_gui/components/xyvalue.py b/nengo_gui/components/xyvalue.py index 89c33a4a..0cd0d2e2 100644 --- a/nengo_gui/components/xyvalue.py +++ b/nengo_gui/components/xyvalue.py @@ -46,7 +46,7 @@ def update_client(self, client): def javascript(self): info = dict(uid=id(self), n_lines=self.n_lines, label=self.label) json = self.javascript_config(info) - return 'new XYValue(nengo.main, nengo.viewport, nengo.sim, %s);' % json + return 'new XYValue.default(nengo.main, nengo.viewport, nengo.sim, %s);' % json def code_python_args(self, uids): return [uids[self.obj]] diff --git a/nengo_gui/static/components/2d_axes.js b/nengo_gui/static/components/2d_axes.ts similarity index 90% rename from nengo_gui/static/components/2d_axes.js rename to nengo_gui/static/components/2d_axes.ts index 9f33c0f9..25fe1990 100644 --- a/nengo_gui/static/components/2d_axes.js +++ b/nengo_gui/static/components/2d_axes.ts @@ -10,9 +10,11 @@ * @param {float} args.max_value - maximum value on y-axis */ -var d3 = require('d3'); +import * as d3 from "d3"; -var Axes2D = function(parent, args) { +export default class Axes2D { + +constructor(parent, args) { var self = this; this.max_y_width = 100; @@ -51,8 +53,8 @@ var Axes2D = function(parent, args) { .call(this.axis_y); }; -Axes2D.prototype.set_axes_geometry = function(width, height) { - scale = parseFloat($('#main').css('font-size')); +set_axes_geometry(width, height) { + var scale = parseFloat($('#main').css('font-size')); this.width = width; this.height = height; this.ax_left = this.max_y_width; @@ -67,7 +69,7 @@ Axes2D.prototype.set_axes_geometry = function(width, height) { /** * Adjust the graph layout due to changed size */ -Axes2D.prototype.on_resize = function(width, height) { +on_resize(width, height) { if (width < this.minWidth) { width = this.minWidth; } @@ -93,7 +95,7 @@ Axes2D.prototype.on_resize = function(width, height) { this.axis_y_g.call(this.axis_y); }; -Axes2D.prototype.fit_ticks = function(parent) { +fit_ticks(parent) { var self = this; setTimeout(function() { var ticks = $(parent.div).find('.tick'); @@ -110,4 +112,4 @@ Axes2D.prototype.fit_ticks = function(parent) { }, 1); }; -module.exports = Axes2D; +} diff --git a/nengo_gui/static/components/component.js b/nengo_gui/static/components/component.ts similarity index 87% rename from nengo_gui/static/components/component.js rename to nengo_gui/static/components/component.ts index 4bea95eb..41126b1e 100644 --- a/nengo_gui/static/components/component.js +++ b/nengo_gui/static/components/component.ts @@ -18,19 +18,22 @@ * */ -var interact = require('interact.js'); -var menu = require('../menu'); -var utils = require('../utils'); +import * as interact from "interact.js"; -var all_components = []; +import * as menu from "../menu"; +import * as utils from "../utils"; -var save_all_components = function() { +export var all_components = []; + +export function save_all_components() { for (var index in all_components) { all_components[index].save_layout(); } }; -var Component = function(parent, viewport, args) { +export class Component { + +constructor(parent, viewport, args) { var self = this; this.viewport = viewport; @@ -179,14 +182,14 @@ var Component = function(parent, viewport, args) { /** * Method to be called when Component is resized. */ -Component.prototype.on_resize = function(width, height) {}; +on_resize(width, height) {}; /** * Method to be called when Component received a WebSocket message. */ -Component.prototype.on_message = function(event) {}; +on_message(event) {}; -Component.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; if (this.label_visible) { @@ -204,7 +207,7 @@ Component.prototype.generate_menu = function() { return items; }; -Component.prototype.remove = function(undo_flag, notify_server) { +remove(undo_flag, notify_server) { undo_flag = typeof undo_flag !== 'undefined' ? undo_flag : false; notify_server = typeof notify_server !== 'undefined' ? notify_server : true; @@ -227,7 +230,7 @@ Component.prototype.remove = function(undo_flag, notify_server) { * how fast update() is called in the case that we are changing the data faster * than whatever processing is needed in update(). */ -Component.prototype.schedule_update = function(event) { +schedule_update(event) { if (this.pending_update == false) { this.pending_update = true; var self = this; @@ -242,24 +245,23 @@ Component.prototype.schedule_update = function(event) { /** * Do any visual updating that is needed due to changes in the underlying data. */ -Component.prototype.update = function(event) { -}; +update(event) {}; -Component.prototype.hide_label = function(event) { +hide_label(event) { if (this.label_visible) { this.label.style.display = 'none'; this.label_visible = false; } }; -Component.prototype.show_label = function(event) { +show_label(event) { if (!this.label_visible) { this.label.style.display = 'inline'; this.label_visible = true; } }; -Component.prototype.layout_info = function() { +layout_info() { var info = {}; info.x = this.x; info.y = this.y; @@ -269,12 +271,12 @@ Component.prototype.layout_info = function() { return info; }; -Component.prototype.save_layout = function() { +save_layout() { var info = this.layout_info(); this.ws.send('config:' + JSON.stringify(info)); }; -Component.prototype.update_layout = function(config) { +update_layout(config) { this.w = config.width; this.h = config.height; this.x = config.x; @@ -291,14 +293,14 @@ Component.prototype.update_layout = function(config) { } }; -Component.prototype.redraw_size = function() { +redraw_size() { this.width = this.viewport.w * this.w * this.viewport.scale * 2; this.height = this.viewport.h * this.h * this.viewport.scale * 2; this.div.style.width = this.width; this.div.style.height = this.height; }; -Component.prototype.redraw_pos = function() { +redraw_pos() { var x = (this.x + this.viewport.x - this.w) * this.viewport.w * this.viewport.scale; var y = (this.y + this.viewport.y - this.h) * @@ -306,13 +308,12 @@ Component.prototype.redraw_pos = function() { utils.set_transform(this.div, x, y); }; -Component.prototype.get_screen_width = function() { +get_screen_width() { return this.viewport.w * this.w * this.viewport.scale * 2; }; -Component.prototype.get_screen_height = function() { + +get_screen_height() { return this.viewport.h * this.h * this.viewport.scale * 2; }; -module.exports.Component = Component; -module.exports.all_components = all_components; -module.exports.save_all_components = save_all_components; +} diff --git a/nengo_gui/static/components/htmlview.js b/nengo_gui/static/components/htmlview.ts similarity index 78% rename from nengo_gui/static/components/htmlview.js rename to nengo_gui/static/components/htmlview.ts index 7906106b..68e8acc5 100644 --- a/nengo_gui/static/components/htmlview.js +++ b/nengo_gui/static/components/htmlview.ts @@ -8,12 +8,14 @@ * @param {dict} args - A set of constructor arguments (see Component) */ -var Component = require('./component').Component; -var DataStore = require('../datastore').DataStore; -var utils = require('../utils'); +import { Component } from "./component"; +import { DataStore } from "../datastore"; +import * as utils from "../utils"; -var HTMLView = function(parent, viewport, sim, args) { - Component.call(this, parent, viewport, args); +export default class HTMLView extends Component { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, args); var self = this; this.sim = sim; @@ -36,13 +38,10 @@ var HTMLView = function(parent, viewport, sim, args) { this.on_resize(this.get_screen_width(), this.get_screen_height()); }; -HTMLView.prototype = Object.create(Component.prototype); -HTMLView.prototype.constructor = HTMLView; - /** * Receive new line data from the server */ -HTMLView.prototype.on_message = function(event) { +on_message(event) { var data = event.data.split(" ", 1); var time = parseFloat(data[0]); @@ -55,7 +54,7 @@ HTMLView.prototype.on_message = function(event) { /** * Redraw the lines and axis due to changed data */ -HTMLView.prototype.update = function() { +update() { // Let the data store clear out old values this.data_store.update(); @@ -72,7 +71,7 @@ HTMLView.prototype.update = function() { /** * Adjust the graph layout due to changed size */ -HTMLView.prototype.on_resize = function(width, height) { +on_resize(width, height) { if (width < this.minWidth) { width = this.minWidth; } @@ -87,4 +86,4 @@ HTMLView.prototype.on_resize = function(width, height) { this.update(); }; -module.exports = HTMLView; +} diff --git a/nengo_gui/static/components/image.js b/nengo_gui/static/components/image.ts similarity index 87% rename from nengo_gui/static/components/image.js rename to nengo_gui/static/components/image.ts index c2d9487f..f7c024b5 100644 --- a/nengo_gui/static/components/image.js +++ b/nengo_gui/static/components/image.ts @@ -10,14 +10,16 @@ * @param {float} args.maxy - maximum value on y-axis */ -var d3 = require('d3'); -var Component = require('./component').Component; -var DataStore = require('../datastore').DataStore; +import * as d3 from "d3"; +import { Component } from "./component"; +import { DataStore } from "../datastore"; -var Image = function(parent, viewport, sim, args) { - var self = this; +export default class Image extends Component { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, args); - Component.call(self, parent, viewport, args); + var self = this; self.sim = sim; self.display_time = args.display_time; self.pixels_x = args.pixels_x; @@ -59,13 +61,10 @@ var Image = function(parent, viewport, sim, args) { }; -Image.prototype = Object.create(Component.prototype); -Image.prototype.constructor = Image; - /** * Receive new line data from the server */ -Image.prototype.on_message = function(event) { +on_message(event) { var data = new Uint8Array(event.data); var msg_size = this.n_pixels + 4; @@ -81,7 +80,7 @@ Image.prototype.on_message = function(event) { /** * Redraw the lines and axis due to changed data */ -Image.prototype.update = function() { +update() { var self = this; // Let the data store clear out old values @@ -105,7 +104,7 @@ Image.prototype.update = function() { /** * Adjust the graph layout due to changed size */ -Image.prototype.on_resize = function(width, height) { +on_resize(width, height) { var self = this; if (width < self.minWidth) { width = self.minWidth; @@ -128,4 +127,4 @@ Image.prototype.on_resize = function(width, height) { self.div.style.height = height; }; -module.exports = Image; +} diff --git a/nengo_gui/static/components/netgraph.js b/nengo_gui/static/components/netgraph.ts similarity index 93% rename from nengo_gui/static/components/netgraph.js rename to nengo_gui/static/components/netgraph.ts index 80e31f18..a267f42d 100644 --- a/nengo_gui/static/components/netgraph.js +++ b/nengo_gui/static/components/netgraph.ts @@ -10,16 +10,19 @@ * server and is run on page load. */ -var interact = require('interact.js'); -require('./netgraph.css'); -var comp = require('./component'); -var menu = require('../menu'); -var NetGraphConnection = require('./netgraph_conn'); -var NetGraphItem = require('./netgraph_item'); -var utils = require('../utils'); -var Viewport = require('../viewport'); - -var NetGraph = function(parent, config, args) { +import * as interact from "interact.js"; + +import "./netgraph.css"; +import * as comp from "./component"; +import * as menu from "../menu"; +import NetGraphConnection from "./netgraph_conn"; +import NetGraphItem from "./netgraph_item"; +import * as utils from "../utils"; +import Viewport from "../viewport"; + +export default class NetGraph { + +constructor(parent, config, args) { var self = this; this.config = config; this.viewport = new Viewport(this); @@ -335,7 +338,7 @@ var NetGraph = function(parent, config, args) { this.update_fonts(); }; -NetGraph.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; items.push(['Auto-layout', function() { @@ -347,8 +350,8 @@ NetGraph.prototype.generate_menu = function() { /** * Event handler for received WebSocket messages */ -NetGraph.prototype.on_message = function(event) { - data = JSON.parse(event.data); +on_message(event) { + var data = JSON.parse(event.data); if (data.type === 'net') { this.create_object(data); } else if (data.type === 'ens') { @@ -425,14 +428,14 @@ NetGraph.prototype.on_message = function(event) { /** * Report an event back to the server */ -NetGraph.prototype.notify = function(info) { +notify(info) { this.ws.send(JSON.stringify(info)); }; /** * Pan the screen (and redraw accordingly) */ -NetGraph.prototype.set_offset = function(x, y) { +set_offset(x, y) { this.offsetX = x; this.offsetY = y; this.redraw(); @@ -442,7 +445,7 @@ NetGraph.prototype.set_offset = function(x, y) { this.viewport.redraw_all(); }; -NetGraph.prototype.update_fonts = function() { +update_fonts() { if (this.zoom_fonts) { $('#main').css('font-size', 3 * this.scale * this.font_size/100 + 'em'); } else { @@ -453,7 +456,7 @@ NetGraph.prototype.update_fonts = function() { /** * Redraw all elements */ -NetGraph.prototype.redraw = function() { +redraw() { for (var key in this.svg_objects) { this.svg_objects[key].redraw(); } @@ -465,7 +468,7 @@ NetGraph.prototype.redraw = function() { /** * Helper function for correctly creating SVG elements. */ -NetGraph.prototype.createSVGElement = function(tag) { +createSVGElement(tag) { return document.createElementNS("http://www.w3.org/2000/svg", tag); }; @@ -475,7 +478,7 @@ NetGraph.prototype.createSVGElement = function(tag) { * If an existing NetGraphConnection is looking for this item, it will be * notified */ -NetGraph.prototype.create_object = function(info) { +create_object(info) { var item_mini = new NetGraphItem(this, info, true); this.minimap_objects[info.uid] = item_mini; @@ -491,7 +494,7 @@ NetGraph.prototype.create_object = function(info) { /** * Create a new NetGraphConnection. */ -NetGraph.prototype.create_connection = function(info) { +create_connection(info) { var conn_mini = new NetGraphConnection(this, info, true); this.minimap_conns[info.uid] = conn_mini; @@ -502,7 +505,7 @@ NetGraph.prototype.create_connection = function(info) { /** * Handler for resizing the full SVG. */ -NetGraph.prototype.on_resize = function(event) { +on_resize(event) { var width = $(this.svg).width(); var height = $(this.svg).height(); @@ -529,21 +532,21 @@ NetGraph.prototype.on_resize = function(event) { /** * Return the pixel width of the SVG times the current scale factor. */ -NetGraph.prototype.get_scaled_width = function() { +get_scaled_width() { return this.width * this.scale; }; /** * Return the pixel height of the SVG times the current scale factor. */ -NetGraph.prototype.get_scaled_height = function() { +get_scaled_height() { return this.height * this.scale; }; /** * Expand or collapse a network. */ -NetGraph.prototype.toggle_network = function(uid) { +toggle_network(uid) { var item = this.svg_objects[uid]; if (item.expanded) { item.collapse(true); @@ -559,7 +562,7 @@ NetGraph.prototype.toggle_network = function(uid) { * collapsed network. When it does appear, NetGraph.detect_collapsed will * handle notifying the NetGraphConnection. */ -NetGraph.prototype.register_conn = function(conn, target) { +register_conn(conn, target) { if (this.collapsed_conns[target] === undefined) { this.collapsed_conns[target] = [conn]; } else { @@ -579,7 +582,7 @@ NetGraph.prototype.register_conn = function(conn, target) { * an item is created, this function is used to see if any * NetGraphConnections are waiting for it, and notifies them. */ -NetGraph.prototype.detect_collapsed_conns = function(uid) { +detect_collapsed_conns(uid) { var conns = this.collapsed_conns[uid]; if (conns !== undefined) { delete this.collapsed_conns[uid]; @@ -599,7 +602,7 @@ NetGraph.prototype.detect_collapsed_conns = function(uid) { /** * Create a minimap. */ -NetGraph.prototype.create_minimap = function() { +create_minimap() { var self = this; this.minimap_div = document.createElement('div'); @@ -632,7 +635,7 @@ NetGraph.prototype.create_minimap = function() { this.toggleMiniMap(); }; -NetGraph.prototype.toggleMiniMap = function() { +toggleMiniMap() { if (this.mm_display == true) { $('.minimap')[0].style.visibility = 'hidden'; this.g_conns_mini.style.opacity = 0; @@ -648,12 +651,12 @@ NetGraph.prototype.toggleMiniMap = function() { /** * Calculate the minimap position offsets and scaling. */ -NetGraph.prototype.scaleMiniMap = function() { +scaleMiniMap() { if (!this.mm_display) { return; } - keys = Object.keys(this.svg_objects); + var keys = Object.keys(this.svg_objects); if (keys.length === 0) { return; } @@ -664,7 +667,7 @@ NetGraph.prototype.scaleMiniMap = function() { // networks. var first_item = true; for (var key in this.svg_objects) { - item = this.svg_objects[key]; + var item = this.svg_objects[key]; // Ignore anything inside a subnetwork if (item.depth > 1) { continue; @@ -716,7 +719,7 @@ NetGraph.prototype.scaleMiniMap = function() { * Calculate which part of the map is being displayed on the * main viewport and scale the viewbox to reflect that. */ -NetGraph.prototype.scaleMiniMapViewBox = function() { +scaleMiniMapViewBox() { if (!this.mm_display) { return; } @@ -741,4 +744,4 @@ NetGraph.prototype.scaleMiniMapViewBox = function() { this.view.setAttribute('height', h / this.scale); }; -module.exports = NetGraph; +} diff --git a/nengo_gui/static/components/netgraph_conn.js b/nengo_gui/static/components/netgraph_conn.ts similarity index 93% rename from nengo_gui/static/components/netgraph_conn.js rename to nengo_gui/static/components/netgraph_conn.ts index f82a12fa..37e9c156 100644 --- a/nengo_gui/static/components/netgraph_conn.js +++ b/nengo_gui/static/components/netgraph_conn.ts @@ -10,7 +10,9 @@ * @param {string[]} info.post - uid to connect to and its parents */ -var NetGraphConnection = function(ng, info, minimap, mini_conn) { +export default class NetGraphConnection { + +constructor(ng, info, minimap, mini_conn) { this.ng = ng; this.uid = info.uid; @@ -65,9 +67,9 @@ var NetGraphConnection = function(ng, info, minimap, mini_conn) { this.redraw(); this.g_conns.appendChild(this.g); -}; +} -NetGraphConnection.prototype.set_recurrent = function(recurrent) { +set_recurrent(recurrent) { if (this.recurrent === recurrent) { return; } @@ -76,7 +78,7 @@ NetGraphConnection.prototype.set_recurrent = function(recurrent) { this.create_line(); }; -NetGraphConnection.prototype.create_line = function() { +create_line() { if (this.recurrent) { this.recurrent_ellipse = this.ng.createSVGElement('path'); this.recurrent_ellipse.setAttribute( @@ -109,7 +111,7 @@ NetGraphConnection.prototype.create_line = function() { } }; -NetGraphConnection.prototype.remove_line = function() { +remove_line() { if (this.recurrent) { this.g.removeChild(this.recurrent_ellipse); this.g.removeChild(this.marker); @@ -126,7 +128,7 @@ NetGraphConnection.prototype.remove_line = function() { /** * Set the item connecting from. */ -NetGraphConnection.prototype.set_pre = function(pre) { +set_pre(pre) { if (this.pre !== null) { // If we're currently connected, disconnect var index = this.pre.conn_out.indexOf(this); @@ -145,7 +147,7 @@ NetGraphConnection.prototype.set_pre = function(pre) { /** * Set the item connecting to. */ -NetGraphConnection.prototype.set_post = function(post) { +set_post(post) { if (this.post !== null) { // If we're currently connected, disconnect var index = this.post.conn_in.indexOf(this); @@ -164,7 +166,7 @@ NetGraphConnection.prototype.set_post = function(post) { /** * Determine the best available item to connect from. */ -NetGraphConnection.prototype.find_pre = function() { +find_pre() { for (var i in this.pres) { var pre = this.objects[this.pres[i]]; if (pre !== undefined) { @@ -180,7 +182,7 @@ NetGraphConnection.prototype.find_pre = function() { /** * Determine the best available item to connect to. */ -NetGraphConnection.prototype.find_post = function() { +find_post() { for (var i in this.posts) { var post = this.objects[this.posts[i]]; if (post !== undefined) { @@ -193,7 +195,7 @@ NetGraphConnection.prototype.find_post = function() { return null; }; -NetGraphConnection.prototype.set_pres = function(pres) { +set_pres(pres) { this.pres = pres; this.set_pre(this.find_pre()); @@ -202,7 +204,7 @@ NetGraphConnection.prototype.set_pres = function(pres) { } }; -NetGraphConnection.prototype.set_posts = function(posts) { +set_posts(posts) { this.posts = posts; this.set_post(this.find_post()); @@ -214,7 +216,7 @@ NetGraphConnection.prototype.set_posts = function(posts) { /** * Remove this connection. */ -NetGraphConnection.prototype.remove = function() { +remove() { if (!this.minimap && this.parent !== null) { var index = this.parent.child_connections.indexOf(this); if (index === -1) { @@ -252,7 +254,7 @@ NetGraphConnection.prototype.remove = function() { /** * Redraw the connection. */ -NetGraphConnection.prototype.redraw = function() { +redraw() { if (this.pre === null || this.post === null) { if (this.line !== undefined) { this.line.setAttribute('visibility', 'hidden'); @@ -320,8 +322,8 @@ NetGraphConnection.prototype.redraw = function() { var w2 = this.post.get_screen_width(); var h2 = this.post.get_screen_height(); - a1 = Math.atan2(h1, w1); - a2 = Math.atan2(h2, w2); + var a1 = Math.atan2(h1, w1); + var a2 = Math.atan2(h2, w2); var pre_length = this.intersect_length(angle, a1, w1, h1); var post_to_pre_angle = angle - Math.PI; @@ -366,7 +368,7 @@ NetGraphConnection.prototype.redraw = function() { * @param {number} alpha - the angle between zero and the top right corner * of the object **/ -NetGraphConnection.prototype.intersect_length = function( +intersect_length( theta, alpha, width, height) { var quad = 0; var beta = 2 * (Math.PI/2 - alpha); // Angle between top corners @@ -394,4 +396,4 @@ NetGraphConnection.prototype.intersect_length = function( return [x, y]; }; -module.exports = NetGraphConnection; +} diff --git a/nengo_gui/static/components/netgraph_item.js b/nengo_gui/static/components/netgraph_item.ts similarity index 93% rename from nengo_gui/static/components/netgraph_item.js rename to nengo_gui/static/components/netgraph_item.ts index efd89e80..7ad44e00 100644 --- a/nengo_gui/static/components/netgraph_item.js +++ b/nengo_gui/static/components/netgraph_item.ts @@ -11,10 +11,12 @@ * @param {string|null} info.parent - a NetGraphItem with .type=='net' */ -var interact = require('interact.js'); -var menu = require('../menu'); +import * as interact from "interact.js"; +import * as menu from "../menu"; -var NetGraphItem = function(ng, info, minimap, mini_item) { +export default class NetGraphItem { + +constructor(ng, info, minimap, mini_item) { var self = this; this.ng = ng; @@ -152,7 +154,7 @@ var NetGraphItem = function(ng, info, minimap, mini_item) { this.shape = this.ensemble_svg(); } else { console.log("Unknown NetGraphItem type"); - console.log(item); + console.log(info.type); } this.compute_fill(); @@ -360,11 +362,11 @@ var NetGraphItem = function(ng, info, minimap, mini_item) { }; }; -NetGraphItem.prototype.set_label = function(label) { +set_label(label) { this.label.innerHTML = label; }; -NetGraphItem.prototype.move_to_front = function() { +move_to_front() { this.g.parentNode.appendChild(this.g); for (var item in this.children) { @@ -372,7 +374,7 @@ NetGraphItem.prototype.move_to_front = function() { } }; -NetGraphItem.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; if (this.type === 'net') { @@ -448,7 +450,7 @@ NetGraphItem.prototype.generate_menu = function() { return items; }; -NetGraphItem.prototype.create_graph = function(type, args) { +create_graph(type, args) { var info = {}; info.act = 'create_graph'; info.type = type; @@ -476,7 +478,7 @@ NetGraphItem.prototype.create_graph = function(type, args) { this.ng.notify(info); }; -NetGraphItem.prototype.create_modal = function() { +create_modal() { var info = {}; info.act = 'create_modal'; info.uid = this.uid; @@ -489,14 +491,14 @@ NetGraphItem.prototype.create_modal = function() { this.ng.notify(info); }; -NetGraphItem.prototype.request_feedforward_layout = function() { +request_feedforward_layout() { this.ng.notify({act: "feedforward_layout", uid: this.uid}); }; /** * Expand a collapsed network. */ -NetGraphItem.prototype.expand = function(rts, auto) { +expand(rts, auto) { // Default to true if no parameter is specified rts = typeof rts !== 'undefined' ? rts : true; auto = typeof auto !== 'undefined' ? auto : false; @@ -528,7 +530,7 @@ NetGraphItem.prototype.expand = function(rts, auto) { } }; -NetGraphItem.prototype.set_label_below = function(flag) { +set_label_below(flag) { if (flag && !this.label_below) { var screen_h = this.get_screen_height(); this.label.setAttribute( @@ -541,7 +543,7 @@ NetGraphItem.prototype.set_label_below = function(flag) { /** * Collapse an expanded network. */ -NetGraphItem.prototype.collapse = function(report_to_server, auto) { +collapse(report_to_server, auto) { auto = typeof auto !== 'undefined' ? auto : false; this.g.classList.remove('expanded'); @@ -581,7 +583,7 @@ NetGraphItem.prototype.collapse = function(report_to_server, auto) { /** * Determine the fill color based on the depth. */ -NetGraphItem.prototype.compute_fill = function() { +compute_fill() { var depth = this.ng.transparent_nets ? 1 : this.depth; if (!this.passthrough) { @@ -596,7 +598,7 @@ NetGraphItem.prototype.compute_fill = function() { /** * Remove the item from the graph. */ -NetGraphItem.prototype.remove = function() { +remove() { if (this.expanded) { // Collapse the item, but don't tell the server since that would // update the server's config @@ -636,11 +638,11 @@ NetGraphItem.prototype.remove = function() { } }; -NetGraphItem.prototype.constrain_aspect = function() { +constrain_aspect() { this.size = this.get_displayed_size(); }; -NetGraphItem.prototype.get_displayed_size = function() { +get_displayed_size() { if (this.aspect !== null) { var h_scale = this.ng.get_scaled_width(); var v_scale = this.ng.get_scaled_height(); @@ -659,7 +661,7 @@ NetGraphItem.prototype.get_displayed_size = function() { } }; -NetGraphItem.prototype.constrain_position = function() { +constrain_position() { this.constrain_aspect(); if (this.parent !== null) { @@ -674,7 +676,7 @@ NetGraphItem.prototype.constrain_position = function() { } }; -NetGraphItem.prototype.redraw_position = function() { +redraw_position() { var screen = this.get_screen_location(); // Update my position @@ -682,7 +684,7 @@ NetGraphItem.prototype.redraw_position = function() { screen[1] + ')'); }; -NetGraphItem.prototype.redraw_children = function() { +redraw_children() { // Update any children's positions for (var i in this.children) { var item = this.children[i]; @@ -690,7 +692,7 @@ NetGraphItem.prototype.redraw_children = function() { } }; -NetGraphItem.prototype.redraw_child_connections = function() { +redraw_child_connections() { // Update any children's positions for (var i in this.child_connections) { var item = this.child_connections[i]; @@ -698,7 +700,7 @@ NetGraphItem.prototype.redraw_child_connections = function() { } }; -NetGraphItem.prototype.redraw_connections = function() { +redraw_connections() { // Update any connections into and out of this for (var i in this.conn_in) { var item = this.conn_in[i]; @@ -713,7 +715,7 @@ NetGraphItem.prototype.redraw_connections = function() { /** * Return the width of the item, taking into account parent widths. */ -NetGraphItem.prototype.get_nested_width = function() { +get_nested_width() { var w = this.width; var parent = this.parent; while (parent !== null) { @@ -726,7 +728,7 @@ NetGraphItem.prototype.get_nested_width = function() { /** * Return the height of the item, taking into account parent heights. */ -NetGraphItem.prototype.get_nested_height = function() { +get_nested_height() { var h = this.height; var parent = this.parent; while (parent !== null) { @@ -736,7 +738,7 @@ NetGraphItem.prototype.get_nested_height = function() { return h; }; -NetGraphItem.prototype.redraw_size = function() { +redraw_size() { var screen_w = this.get_screen_width(); var screen_h = this.get_screen_height(); @@ -785,7 +787,7 @@ NetGraphItem.prototype.redraw_size = function() { }; }; -NetGraphItem.prototype.get_screen_width = function() { +get_screen_width() { if (this.minimap && !this.ng.mm_display) { return 1; } @@ -809,7 +811,7 @@ NetGraphItem.prototype.get_screen_width = function() { return screen_w * 2; }; -NetGraphItem.prototype.get_screen_height = function() { +get_screen_height() { if (this.minimap && !this.ng.mm_display) { return 1; } @@ -836,7 +838,7 @@ NetGraphItem.prototype.get_screen_height = function() { /** * Force a redraw of the item. */ -NetGraphItem.prototype.redraw = function() { +redraw() { this.redraw_position(); this.redraw_size(); this.redraw_children(); @@ -851,7 +853,7 @@ NetGraphItem.prototype.redraw = function() { /** * Determine the pixel location of the centre of the item. */ -NetGraphItem.prototype.get_screen_location = function() { +get_screen_location() { // FIXME: this should probably use this.ng.get_scaled_width // and this.ng.get_scaled_height if (this.minimap && !this.ng.mm_display) { @@ -906,7 +908,7 @@ NetGraphItem.prototype.get_screen_location = function() { /** * Function for drawing ensemble svg. */ -NetGraphItem.prototype.ensemble_svg = function() { +ensemble_svg() { var shape = this.ng.createSVGElement('g'); shape.setAttribute('class', 'ensemble'); @@ -944,18 +946,18 @@ NetGraphItem.prototype.ensemble_svg = function() { /** * Helper function for setting attributes. */ -NetGraphItem.prototype.setAttributes = function(el, attrs) { +setAttributes(el, attrs) { for (var key in attrs) { el.setAttribute(key, attrs[key]); } }; -NetGraphItem.prototype.getMinMaxXY = function() { - min_x = this.x - this.width; - max_x = this.x + this.width; - min_y = this.y - this.height; - max_y = this.y + this.height; +getMinMaxXY() { + var min_x = this.x - this.width; + var max_x = this.x + this.width; + var min_y = this.y - this.height; + var max_y = this.y + this.height; return [min_x, max_x, min_y, max_y]; }; -module.exports = NetGraphItem; +} diff --git a/nengo_gui/static/components/pointer.js b/nengo_gui/static/components/pointer.ts similarity index 88% rename from nengo_gui/static/components/pointer.js rename to nengo_gui/static/components/pointer.ts index bd9be21d..c3d91984 100644 --- a/nengo_gui/static/components/pointer.js +++ b/nengo_gui/static/components/pointer.ts @@ -11,13 +11,15 @@ * netgraph.js {.on_message} function. */ -require('./pointer.css'); -var Component = require('./component').Component; -var DataStore = require('../datastore').DataStore; -var utils = require('../utils'); +import "./pointer.css"; +import { Component } from "./component"; +import { DataStore } from "../datastore"; +import * as utils from "../utils"; -var Pointer = function(parent, viewport, sim, args) { - Component.call(this, parent, viewport, args); +export default class Pointer extends Component { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, args); var self = this; this.sim = sim; @@ -72,10 +74,7 @@ var Pointer = function(parent, viewport, sim, args) { }); }; -Pointer.prototype = Object.create(Component.prototype); -Pointer.prototype.constructor = Pointer; - -Pointer.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; items.push(['Set value...', function() { @@ -96,14 +95,14 @@ Pointer.prototype.generate_menu = function() { return $.merge(items, Component.prototype.generate_menu.call(this)); }; -Pointer.prototype.set_show_pairs = function(value) { +set_show_pairs(value) { if (this.show_pairs !== value) { this.show_pairs = value; this.save_layout(); } }; -Pointer.prototype.set_value = function() { +set_value() { var self = this; self.sim.modal.title('Enter a Semantic Pointer value...'); self.sim.modal.single_input_body('Pointer', 'New value'); @@ -147,8 +146,8 @@ Pointer.prototype.set_value = function() { /** * Receive new line data from the server. */ -Pointer.prototype.on_message = function(event) { - data = event.data.split(" "); +on_message(event) { + var data = event.data.split(" "); if (data[0].substring(0, 11) == "bad_pointer") { this.pointer_status = false; @@ -168,7 +167,7 @@ Pointer.prototype.on_message = function(event) { /** * Redraw the lines and axis due to changed data. */ -Pointer.prototype.update = function() { +update() { // Let the data store clear out old values this.data_store.update(); @@ -218,7 +217,7 @@ Pointer.prototype.update = function() { /** * Adjust the graph layout due to changed size. */ -Pointer.prototype.on_resize = function(width, height) { +on_resize(width, height) { if (width < this.minWidth) { width = this.minWidth; } @@ -236,20 +235,20 @@ Pointer.prototype.on_resize = function(width, height) { this.update(); }; -Pointer.prototype.layout_info = function() { +layout_info() { var info = Component.prototype.layout_info.call(this); info.show_pairs = this.show_pairs; return info; }; -Pointer.prototype.update_layout = function(config) { +update_layout(config) { this.show_pairs = config.show_pairs; Component.prototype.update_layout.call(this, config); }; -Pointer.prototype.reset = function(event) { +reset(event) { this.data_store.reset(); this.schedule_update(); }; -module.exports = Pointer; +} diff --git a/nengo_gui/static/components/raster.js b/nengo_gui/static/components/raster.ts similarity index 86% rename from nengo_gui/static/components/raster.js rename to nengo_gui/static/components/raster.ts index 8a451c40..74cfbcaa 100644 --- a/nengo_gui/static/components/raster.js +++ b/nengo_gui/static/components/raster.ts @@ -12,15 +12,18 @@ * netgraph.js {.on_message} function. */ -require('./raster.css'); -var d3 = require('d3'); -var Component = require('./component').Component; -var DataStore = require('../datastore').DataStore; -var TimeAxes = require('./time_axes'); -var utils = require('../utils'); - -var Raster = function(parent, viewport, sim, args) { - Component.call(this, parent, viewport, args); +import * as d3 from "d3"; + +import "./raster.css"; +import { Component } from "./component"; +import { DataStore } from "../datastore"; +import TimeAxes from "./time_axes"; +import * as utils from "../utils"; + +export default class Raster extends Component { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, args); var self = this; this.n_neurons = args.n_neurons || 1; this.sim = sim; @@ -44,7 +47,7 @@ var Raster = function(parent, viewport, sim, args) { // Create the lines on the plots var line = d3.svg.line() .x(function(d, i) { - return self.axes2d.scale_x(times[i]); + return self.axes2d.scale_x(this.data_store.times[i]); }) .y(function(d) { return self.axes2d.scale_y(d); @@ -64,20 +67,17 @@ var Raster = function(parent, viewport, sim, args) { this.axes2d.fit_ticks(this); }; -Raster.prototype = Object.create(Component.prototype); -Raster.prototype.constructor = Raster; - /** * Receive new line data from the server. */ -Raster.prototype.on_message = function(event) { +on_message(event) { var time = new Float32Array(event.data, 0, 1); var data = new Int16Array(event.data, 4); this.data_store.push([time[0], data]); this.schedule_update(); }; -Raster.prototype.set_n_neurons = function(n_neurons) { +set_n_neurons(n_neurons) { this.n_neurons = n_neurons; this.axes2d.scale_y.domain([0, n_neurons]); this.axes2d.axis_y.tickValues([0, n_neurons]); @@ -87,7 +87,7 @@ Raster.prototype.set_n_neurons = function(n_neurons) { /** * Redraw the lines and axis due to changed data. */ -Raster.prototype.update = function() { +update() { // Let the data store clear out old values this.data_store.update(); @@ -118,7 +118,7 @@ Raster.prototype.update = function() { /** * Adjust the graph layout due to changed size. */ -Raster.prototype.on_resize = function(width, height) { +on_resize(width, height) { if (width < this.minWidth) { width = this.minWidth; } @@ -138,12 +138,12 @@ Raster.prototype.on_resize = function(width, height) { this.div.style.height = height; }; -Raster.prototype.reset = function(event) { +reset(event) { this.data_store.reset(); this.schedule_update(); }; -Raster.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; items.push(['Set # neurons...', function() {self.set_neuron_count();}]); @@ -151,7 +151,7 @@ Raster.prototype.generate_menu = function() { return $.merge(items, Component.prototype.generate_menu.call(this)); }; -Raster.prototype.set_neuron_count = function() { +set_neuron_count() { var count = this.n_neurons; var self = this; self.sim.modal.title('Set number of neurons...'); @@ -196,4 +196,4 @@ Raster.prototype.set_neuron_count = function() { }); }; -module.exports = Raster; +} diff --git a/nengo_gui/static/components/slider.js b/nengo_gui/static/components/slider.ts similarity index 89% rename from nengo_gui/static/components/slider.js rename to nengo_gui/static/components/slider.ts index a40b31cb..830569c4 100644 --- a/nengo_gui/static/components/slider.js +++ b/nengo_gui/static/components/slider.ts @@ -12,14 +12,16 @@ * netgraph.js {.on_message} function. */ -require('./slider.css'); -var Component = require('./component').Component; -var DataStore = require('../datastore').DataStore; -var menu = require('../menu'); -var SliderControl = require('./slidercontrol'); - -var Slider = function(parent, viewport, sim, args) { - Component.call(this, parent, viewport, args); +import "./slider.css"; +import { Component } from "./component"; +import { DataStore } from "../datastore"; +import * as menu from "../menu"; +import SliderControl from "./slidercontrol"; + +export default class Slider extends Component { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, args); var self = this; this.sim = sim; @@ -88,19 +90,16 @@ var Slider = function(parent, viewport, sim, args) { this.on_resize(this.get_screen_width(), this.get_screen_height()); }; -Slider.prototype = Object.create(Component.prototype); -Slider.prototype.constructor = Slider; - -Slider.prototype.set_axes_geometry = function(width, height) { +set_axes_geometry(width, height) { this.width = width; this.height = height; - scale = parseFloat($('#main').css('font-size')); + var scale = parseFloat($('#main').css('font-size')); this.border_size = 1; this.ax_top = 1.75 * scale; this.slider_height = this.height - this.ax_top; }; -Slider.prototype.send_value = function(slider_index, value) { +send_value(slider_index, value) { console.assert(typeof slider_index == 'number'); console.assert(typeof value == 'number'); @@ -112,7 +111,7 @@ Slider.prototype.send_value = function(slider_index, value) { this.sim.time_slider.jump_to_end(); }; -Slider.prototype.on_sim_reset = function(event) { +on_sim_reset(event) { // Release slider position and reset it for (var i = 0; i < this.sliders.length; i++) { this.notify('' + i + ',reset'); @@ -124,7 +123,7 @@ Slider.prototype.on_sim_reset = function(event) { /** * Receive new line data from the server. */ -Slider.prototype.on_message = function(event) { +on_message(event) { var data = new Float32Array(event.data); if (this.data_store === null) { this.data_store = new DataStore(this.sliders.length, this.sim, 0); @@ -145,7 +144,7 @@ Slider.prototype.on_message = function(event) { /** * Update visual display based when component is resized. */ -Slider.prototype.on_resize = function(width, height) { +on_resize(width, height) { console.assert(typeof width == 'number'); console.assert(typeof height == 'number'); @@ -171,7 +170,7 @@ Slider.prototype.on_resize = function(width, height) { this.div.style.height = this.height; }; -Slider.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; items.push(['Set range...', function() { @@ -192,7 +191,7 @@ Slider.prototype.generate_menu = function() { /** * Report an event back to the server. */ -Slider.prototype.notify = function(info) { +notify(info) { this.notify_msgs.push(info); // Only send one message at a time @@ -211,8 +210,8 @@ Slider.prototype.notify = function(info) { * * Also schedule the next message to be sent, if any. */ -Slider.prototype.send_notify_msg = function() { - msg = this.notify_msgs[0]; +send_notify_msg() { + var msg = this.notify_msgs[0]; this.ws.send(msg); if (this.notify_msgs.length > 1) { var self = this; @@ -223,7 +222,7 @@ Slider.prototype.send_notify_msg = function() { this.notify_msgs.splice(0, 1); }; -Slider.prototype.update = function() { +update() { // Let the data store clear out old values if (this.data_store !== null) { this.data_store.update(); @@ -238,7 +237,7 @@ Slider.prototype.update = function() { } }; -Slider.prototype.user_value = function() { +user_value() { var self = this; // First build the prompt string @@ -294,7 +293,7 @@ Slider.prototype.user_value = function() { self.sim.modal.show(); }; -Slider.prototype.user_reset_value = function() { +user_reset_value() { for (var i = 0; i < this.sliders.length; i++) { this.notify('' + i + ',reset'); @@ -303,7 +302,7 @@ Slider.prototype.user_reset_value = function() { } }; -Slider.prototype.set_range = function() { +set_range() { var range = this.sliders[0].scale.domain(); var self = this; self.sim.modal.title('Set slider range...'); @@ -348,7 +347,7 @@ Slider.prototype.set_range = function() { self.sim.modal.show(); }; -Slider.prototype.layout_info = function() { +layout_info() { var info = Component.prototype.layout_info.call(this); info.width = info.width; info.min_value = this.sliders[0].scale.domain()[1]; @@ -356,7 +355,7 @@ Slider.prototype.layout_info = function() { return info; }; -Slider.prototype.update_layout = function(config) { +update_layout(config) { // FIXME: this has to be backwards to work. Something fishy must be going on for (var i in this.sliders) { this.sliders[i].set_range(config.min_value, config.max_value); @@ -364,4 +363,4 @@ Slider.prototype.update_layout = function(config) { Component.prototype.update_layout.call(this, config); }; -module.exports = Slider; +} diff --git a/nengo_gui/static/components/slidercontrol.js b/nengo_gui/static/components/slidercontrol.ts similarity index 85% rename from nengo_gui/static/components/slidercontrol.js rename to nengo_gui/static/components/slidercontrol.ts index ccf07d52..0eaa79d7 100644 --- a/nengo_gui/static/components/slidercontrol.js +++ b/nengo_gui/static/components/slidercontrol.ts @@ -10,11 +10,14 @@ * handle that is needed. */ -var d3 = require('d3'); -var interact = require('interact.js'); -var utils = require('../utils'); +import * as d3 from "d3"; +import * as interact from "interact.js"; -var SliderControl = function(min, max) { +import * as utils from "../utils"; + +export default class SliderControl { + +constructor(min, max) { var self = this; this.min = min; @@ -90,18 +93,18 @@ var SliderControl = function(min, max) { this.listeners = {}; }; -SliderControl.prototype.on = function(type, fn) { +on(type, fn) { this.listeners[type] = fn; return this; }; -SliderControl.prototype.dispatch = function(type, ev) { +dispatch(type, ev) { if (type in this.listeners) { this.listeners[type].call(this, ev); } }; -SliderControl.prototype.set_range = function(min, max) { +set_range(min, max) { this.min = min; this.max = max; this.scale.domain([max, min]); @@ -109,7 +112,7 @@ SliderControl.prototype.set_range = function(min, max) { this.on_resize(); }; -SliderControl.prototype.display_value = function(value) { +display_value(value) { if (value < this.min) { value = this.min; } @@ -123,13 +126,13 @@ SliderControl.prototype.display_value = function(value) { this.update_value_text(value); }; -SliderControl.prototype.set_value = function(value) { +set_value(value) { var old_value = this.value; this.display_value(value); this.dispatch('change', {'target': this, 'value': this.value}); }; -SliderControl.prototype.activate_type_mode = function() { +activate_type_mode() { if (this.type_mode) { return; } @@ -160,7 +163,7 @@ SliderControl.prototype.activate_type_mode = function() { }); }; -SliderControl.prototype.deactivate_type_mode = function(event) { +deactivate_type_mode(event) { if (!this.type_mode) { return; } @@ -174,7 +177,7 @@ SliderControl.prototype.deactivate_type_mode = function(event) { this.handle.innerHTML = this.format_value(this.value); }; -SliderControl.prototype.handle_keypress = function(event) { +handle_keypress(event) { if (!this.type_mode) { return; } @@ -194,25 +197,25 @@ SliderControl.prototype.handle_keypress = function(event) { } }; -SliderControl.prototype.update_handle_pos = function(value) { +update_handle_pos(value) { this.handle.style.top = this.scale(value) + this.border_width; }; -SliderControl.prototype.get_handle_pos = function() { +get_handle_pos() { return parseFloat(this.handle.style.top) - this.border_width; }; -SliderControl.prototype.update_value_text = function(value) { +update_value_text(value) { this.handle.innerHTML = this.format_value(value); }; -SliderControl.prototype.format_value = function(value) { +format_value(value) { return value.toFixed(2); }; -SliderControl.prototype.on_resize = function() { +on_resize() { this.scale.range([0, this.guideline.clientHeight]); this.update_handle_pos(this.value); }; -module.exports = SliderControl; +} diff --git a/nengo_gui/static/components/spa_similarity.js b/nengo_gui/static/components/spa_similarity.ts similarity index 86% rename from nengo_gui/static/components/spa_similarity.js rename to nengo_gui/static/components/spa_similarity.ts index 363172b9..d9c3443b 100644 --- a/nengo_gui/static/components/spa_similarity.js +++ b/nengo_gui/static/components/spa_similarity.ts @@ -8,15 +8,18 @@ * @param {int} args.n_lines - number of decoded values */ -require('./spa_similarity.css'); -var d3 = require('d3'); -var Component = require('./component').Component; -var GrowableDataStore = require('../datastore').GrowableDataStore; -var utils = require('../utils'); -var Value = require('./value'); +import * as d3 from "d3"; -var SpaSimilarity = function(parent, viewport, sim, args) { - Value.call(this, parent, viewport, sim, args); +import "./spa_similarity.css"; +import { Component } from "./component"; +import { GrowableDataStore } from "../datastore"; +import * as utils from "../utils"; +import Value from "./value"; + +export default class SpaSimilarity extends Value { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, sim, args); this.synapse = args.synapse; this.data_store = @@ -43,10 +46,7 @@ var SpaSimilarity = function(parent, viewport, sim, args) { this.legend, args.pointer_labels, this.color_func, this.uid); }; -SpaSimilarity.prototype = Object.create(Value.prototype); -SpaSimilarity.prototype.constructor = SpaSimilarity; - -SpaSimilarity.prototype.reset_legend_and_data = function(new_labels) { +reset_legend_and_data(new_labels) { // Clear the database and create a new one since dimensions have changed this.data_store = new GrowableDataStore(new_labels.length, this.sim, this.synapse); @@ -68,7 +68,7 @@ SpaSimilarity.prototype.reset_legend_and_data = function(new_labels) { this.update(); }; -SpaSimilarity.prototype.data_msg = function(push_data) { +data_msg(push_data) { var data_dims = push_data.length - 1; // TODO: Move this check inside datastore? @@ -81,7 +81,7 @@ SpaSimilarity.prototype.data_msg = function(push_data) { this.schedule_update(); }; -SpaSimilarity.prototype.update_legend = function(new_labels) { +update_legend(new_labels) { var self = this; this.legend_labels = this.legend_labels.concat(new_labels); @@ -146,7 +146,7 @@ SpaSimilarity.prototype.update_legend = function(new_labels) { * - show_pairs has been toggledn * This calls the method associated to handling the type of message. */ -SpaSimilarity.prototype.on_message = function(event) { +on_message(event) { var data = JSON.parse(event.data); var func_name = data.shift(); this[func_name](data); @@ -155,7 +155,7 @@ SpaSimilarity.prototype.on_message = function(event) { /** * Redraw the lines and axis due to changed data. */ -SpaSimilarity.prototype.update = function() { +update() { // Let the data store clear out old values this.data_store.update(); @@ -202,7 +202,7 @@ SpaSimilarity.prototype.update = function() { } }; -SpaSimilarity.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; items.push(['Set range...', function() { @@ -223,7 +223,7 @@ SpaSimilarity.prototype.generate_menu = function() { return $.merge(items, Component.prototype.generate_menu.call(this)); }; -SpaSimilarity.prototype.set_show_pairs = function(value) { +set_show_pairs(value) { if (this.show_pairs !== value) { this.show_pairs = value; this.save_layout(); @@ -231,7 +231,7 @@ SpaSimilarity.prototype.set_show_pairs = function(value) { } }; -SpaSimilarity.prototype.layout_info = function() { +layout_info() { var info = Component.prototype.layout_info.call(this); info.show_pairs = this.show_pairs; info.min_value = this.axes2d.scale_y.domain()[0]; @@ -239,13 +239,13 @@ SpaSimilarity.prototype.layout_info = function() { return info; }; -SpaSimilarity.prototype.update_layout = function(config) { +update_layout(config) { this.update_range(config.min_value, config.max_value); this.show_pairs = config.show_pairs; Component.prototype.update_layout.call(this, config); }; -SpaSimilarity.prototype.reset = function() { +reset() { // Ask for a legend update this.ws.send("reset_legend"); }; @@ -253,4 +253,4 @@ SpaSimilarity.prototype.reset = function() { // TODO: should I remove the ability to set range? // Or limit it to something intuitive -module.exports = SpaSimilarity; +} diff --git a/nengo_gui/static/components/time_axes.js b/nengo_gui/static/components/time_axes.ts similarity index 80% rename from nengo_gui/static/components/time_axes.js rename to nengo_gui/static/components/time_axes.ts index 5f5ca50c..354e8aa9 100644 --- a/nengo_gui/static/components/time_axes.js +++ b/nengo_gui/static/components/time_axes.ts @@ -9,10 +9,12 @@ * @param {dict} args - A set of constructor arguments (see Axes2D) */ -var Axes2D = require('./2d_axes'); +import Axes2D from "./2d_axes"; -var TimeAxes = function(parent, args) { - Axes2D.call(this, parent, args); +export default class TimeAxes extends Axes2D { + +constructor(parent, args) { + super(parent, args); var self = this; this.display_time = args.display_time; @@ -31,20 +33,17 @@ var TimeAxes = function(parent, args) { } }; -TimeAxes.prototype = Object.create(Axes2D.prototype); -TimeAxes.prototype.constructor = TimeAxes; - -TimeAxes.prototype.set_time_range = function(start, end) { +set_time_range(start, end) { this.scale_x.domain([start, end]); this.axis_time_start.textContent = start.toFixed(3); this.axis_time_end.textContent = end.toFixed(3); this.axis_x_g.call(this.axis_x); }; -TimeAxes.prototype.on_resize = function(width, height) { +on_resize(width, height) { Axes2D.prototype.on_resize.call(this, width, height); - scale = parseFloat($('#main').css('font-size')); + var scale = parseFloat($('#main').css('font-size')); var suppression_width = 6 * scale; var text_offset = 1.2 * scale; @@ -60,4 +59,4 @@ TimeAxes.prototype.on_resize = function(width, height) { this.axis_time_end.setAttribute('x', this.ax_right - text_offset); }; -module.exports = TimeAxes; +} diff --git a/nengo_gui/static/components/value.js b/nengo_gui/static/components/value.ts similarity index 92% rename from nengo_gui/static/components/value.js rename to nengo_gui/static/components/value.ts index e7c9586e..7bed6a90 100644 --- a/nengo_gui/static/components/value.js +++ b/nengo_gui/static/components/value.ts @@ -14,15 +14,18 @@ * @param {float} args.max_value - maximum value on y-axis */ -var d3 = require('d3'); -require('./value.css'); -var Component = require('./component').Component; -var DataStore = require('../datastore').DataStore; -var TimeAxes = require('./time_axes'); -var utils = require('../utils'); - -var Value = function(parent, viewport, sim, args) { - Component.call(this, parent, viewport, args); +import * as d3 from "d3"; + +import "./value.css"; +import { Component } from "./component"; +import { DataStore } from "../datastore"; +import TimeAxes from "./time_axes"; +import * as utils from "../utils"; + +export default class Value extends Component { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, args); var self = this; this.n_lines = args.n_lines || 1; this.sim = sim; @@ -149,10 +152,7 @@ var Value = function(parent, viewport, sim, args) { } }; -Value.prototype = Object.create(Component.prototype); -Value.prototype.constructor = Value; - -Value.prototype.update_crosshair = function(mouse) { +update_crosshair(mouse) { var self = this; var x = mouse[0]; var y = mouse[1]; @@ -197,7 +197,7 @@ Value.prototype.update_crosshair = function(mouse) { /** * Receive new line data from the server. */ -Value.prototype.on_message = function(event) { +on_message(event) { var data = new Float32Array(event.data); data = Array.prototype.slice.call(data); var size = this.n_lines + 1; @@ -216,7 +216,7 @@ Value.prototype.on_message = function(event) { /** * Redraw the lines and axis due to changed data. */ -Value.prototype.update = function() { +update() { // Let the data store clear out old values this.data_store.update(); @@ -242,7 +242,7 @@ Value.prototype.update = function() { /** * Adjust the graph layout due to changed size. */ -Value.prototype.on_resize = function(width, height) { +on_resize(width, height) { if (width < this.minWidth) { width = this.minWidth; } @@ -262,7 +262,7 @@ Value.prototype.on_resize = function(width, height) { this.div.style.height = height; }; -Value.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; items.push(['Set range...', function() { @@ -291,7 +291,7 @@ Value.prototype.generate_menu = function() { return $.merge(items, Component.prototype.generate_menu.call(this)); }; -Value.prototype.set_show_legend = function(value) { +set_show_legend(value) { if (this.show_legend !== value) { this.show_legend = value; this.save_layout(); @@ -309,7 +309,7 @@ Value.prototype.set_show_legend = function(value) { } }; -Value.prototype.set_legend_labels = function() { +set_legend_labels() { var self = this; self.sim.modal.title('Enter comma seperated legend label values'); @@ -324,7 +324,7 @@ Value.prototype.set_legend_labels = function() { // Excissive entries get ignored. // TODO: Allow escaping of commas if ((label_csv !== null) && (label_csv !== '')) { - labels = label_csv.split(','); + var labels = label_csv.split(','); for (var i = 0; i < self.n_lines; i++) { if (labels[i] !== "" && labels[i] !== undefined) { @@ -346,7 +346,7 @@ Value.prototype.set_legend_labels = function() { self.sim.modal.show(); }; -Value.prototype.layout_info = function() { +layout_info() { var info = Component.prototype.layout_info.call(this); info.show_legend = this.show_legend; info.legend_labels = this.legend_labels; @@ -355,12 +355,12 @@ Value.prototype.layout_info = function() { return info; }; -Value.prototype.update_layout = function(config) { +update_layout(config) { this.update_range(config.min_value, config.max_value); Component.prototype.update_layout.call(this, config); }; -Value.prototype.set_range = function() { +set_range() { var range = this.axes2d.scale_y.domain(); var self = this; self.sim.modal.title('Set graph range...'); @@ -408,17 +408,17 @@ Value.prototype.set_range = function() { }); }; -Value.prototype.update_range = function(min, max) { +update_range(min, max) { this.axes2d.scale_y.domain([min, max]); this.axes2d.axis_y_g.call(this.axes2d.axis_y); }; -Value.prototype.reset = function(event) { +reset(event) { this.data_store.reset(); this.schedule_update(); }; -Value.prototype.set_synapse_dialog = function() { +set_synapse_dialog() { var self = this; self.sim.modal.title('Set synaptic filter...'); self.sim.modal.single_input_body(this.synapse, @@ -458,4 +458,4 @@ Value.prototype.set_synapse_dialog = function() { self.sim.modal.show(); }; -module.exports = Value; +} diff --git a/nengo_gui/static/components/xy_axes.js b/nengo_gui/static/components/xy_axes.ts similarity index 81% rename from nengo_gui/static/components/xy_axes.js rename to nengo_gui/static/components/xy_axes.ts index 315167fa..f301557e 100644 --- a/nengo_gui/static/components/xy_axes.js +++ b/nengo_gui/static/components/xy_axes.ts @@ -10,10 +10,12 @@ * @param {float} args.max_value - maximum value on y-axis */ -var Axes2D = require('./2d_axes'); +import Axes2D from "./2d_axes"; -XYAxes = function(parent, args) { - Axes2D.call(this, parent, args); +export default class XYAxes extends Axes2D { + +constructor(parent, args) { + super(parent, args); this.scale_x.domain([args.min_value, args.max_value]); this.axis_x.tickValues([args.min_value, args.max_value]); @@ -23,13 +25,10 @@ XYAxes = function(parent, args) { this.max_val = args.max_value; }; -XYAxes.prototype = Object.create(Axes2D.prototype); -XYAxes.prototype.constructor = XYAxes; - /** * Adjust the graph layout due to changed size. */ -XYAxes.prototype.on_resize = function(width, height) { +on_resize(width, height) { Axes2D.prototype.on_resize.call(this, width, height); var x_offset = this.ax_bottom - this.min_val / @@ -43,4 +42,4 @@ XYAxes.prototype.on_resize = function(width, height) { this.axis_y_g.call(this.axis_y); }; -module.exports = XYAxes; +} diff --git a/nengo_gui/static/components/xyvalue.js b/nengo_gui/static/components/xyvalue.ts similarity index 89% rename from nengo_gui/static/components/xyvalue.js rename to nengo_gui/static/components/xyvalue.ts index 9ea74d88..82dd290c 100644 --- a/nengo_gui/static/components/xyvalue.js +++ b/nengo_gui/static/components/xyvalue.ts @@ -15,15 +15,18 @@ * netgraph.js {.on_message} function. */ -require('./xyvalue.css'); -var d3 = require('d3'); -var Component = require('./component').Component; -var DataStore = require('../datastore').DataStore; -var utils = require('../utils'); -var XYAxes = require('./xy_axes'); - -var XYValue = function(parent, viewport, sim, args) { - Component.call(this, parent, viewport, args); +import * as d3 from "d3"; + +import "./xyvalue.css"; +import { Component } from "./component"; +import { DataStore } from "../datastore"; +import * as utils from "../utils"; +import XYAxes from "./xy_axes"; + +export default class XYValue extends Component { + +constructor(parent, viewport, sim, args) { + super(parent, viewport, args); var self = this; this.n_lines = args.n_lines || 1; @@ -76,13 +79,10 @@ var XYValue = function(parent, viewport, sim, args) { this.on_resize(this.get_screen_width(), this.get_screen_height()); }; -XYValue.prototype = Object.create(Component.prototype); -XYValue.prototype.constructor = XYValue; - /** * Receive new line data from the server. */ -XYValue.prototype.on_message = function(event) { +on_message(event) { var data = new Float32Array(event.data); this.data_store.push(data); this.schedule_update(); @@ -91,7 +91,7 @@ XYValue.prototype.on_message = function(event) { /** * Redraw the lines and axis due to changed data. */ -XYValue.prototype.update = function() { +update() { var self = this; // Let the data store clear out old values @@ -145,7 +145,7 @@ XYValue.prototype.update = function() { /** * Adjust the graph layout due to changed size */ -XYValue.prototype.on_resize = function(width, height) { +on_resize(width, height) { this.axes2d.on_resize(width, height); this.update(); @@ -158,11 +158,11 @@ XYValue.prototype.on_resize = function(width, height) { this.recent_circle.attr("r", this.get_circle_radius()); }; -XYValue.prototype.get_circle_radius = function() { +get_circle_radius() { return Math.min(this.width, this.height) / 30; }; -XYValue.prototype.generate_menu = function() { +generate_menu() { var self = this; var items = []; items.push(['Set range...', function() { @@ -176,7 +176,7 @@ XYValue.prototype.generate_menu = function() { return $.merge(items, Component.prototype.generate_menu.call(this)); }; -XYValue.prototype.layout_info = function() { +layout_info() { var info = Component.prototype.layout_info.call(this); info.min_value = this.axes2d.scale_y.domain()[0]; info.max_value = this.axes2d.scale_y.domain()[1]; @@ -185,13 +185,13 @@ XYValue.prototype.layout_info = function() { return info; }; -XYValue.prototype.update_layout = function(config) { +update_layout(config) { this.update_indices(config.index_x, config.index_y); this.update_range(config.min_value, config.max_value); Component.prototype.update_layout.call(this, config); }; -XYValue.prototype.set_range = function() { +set_range() { var range = this.axes2d.scale_y.domain(); var self = this; self.sim.modal.title('Set graph range...'); @@ -238,7 +238,7 @@ XYValue.prototype.set_range = function() { self.sim.modal.show(); }; -XYValue.prototype.update_range = function(min, max) { +update_range(min, max) { this.axes2d.min_val = min; this.axes2d.max_val = max; this.axes2d.scale_x.domain([min, max]); @@ -250,7 +250,7 @@ XYValue.prototype.update_range = function(min, max) { this.on_resize(this.get_screen_width(), this.get_screen_height()); }; -XYValue.prototype.set_indices = function() { +set_indices() { var self = this; self.sim.modal.title('Set X and Y indices...'); self.sim.modal.single_input_body( @@ -294,15 +294,15 @@ XYValue.prototype.set_indices = function() { self.sim.modal.show(); }; -XYValue.prototype.update_indices = function(index_x, index_y) { +update_indices(index_x, index_y) { this.index_x = index_x; this.index_y = index_y; this.update(); }; -XYValue.prototype.reset = function(event) { +reset(event) { this.data_store.reset(); this.schedule_update(); }; -module.exports = XYValue; +} diff --git a/nengo_gui/static/config.js b/nengo_gui/static/config.ts similarity index 89% rename from nengo_gui/static/config.js rename to nengo_gui/static/config.ts index b91d191c..6b13c948 100644 --- a/nengo_gui/static/config.js +++ b/nengo_gui/static/config.ts @@ -1,7 +1,9 @@ -var Config = function() { +export default class Config { + +constructor() { var self = this; - define_option = function(key, default_val) { + var define_option = function(key, default_val) { var type = typeof(default_val); Object.defineProperty(self, key, { get: function() { @@ -36,7 +38,7 @@ var Config = function() { define_option("console_height", 100); }; -Config.prototype.restore_defaults = function() { +restore_defaults() { for (var option in this) { if (this.hasOwnProperty(option)) { localStorage.removeItem("ng." + option); @@ -44,4 +46,4 @@ Config.prototype.restore_defaults = function() { } }; -module.exports = Config; +} diff --git a/nengo_gui/static/data_to_csv.js b/nengo_gui/static/data_to_csv.ts similarity index 91% rename from nengo_gui/static/data_to_csv.js rename to nengo_gui/static/data_to_csv.ts index bd12a5d7..8524d8a6 100644 --- a/nengo_gui/static/data_to_csv.js +++ b/nengo_gui/static/data_to_csv.ts @@ -7,10 +7,10 @@ * @param {Component[]} data_set - A list of the graph items in the simulation */ -var Value = require('./components/value'); -var XYValue = require('./components/xyvalue'); +import Value from "./components/value"; +import XYValue from "./components/xyvalue"; -var data_to_csv = function(data_set) { +export default function data_to_csv(data_set) { var values = []; var dim_values = []; @@ -53,7 +53,7 @@ var data_to_csv = function(data_set) { // Puts the data at each time step into a row in the csv for (var x = 0; x < times.length; x++) { - temp_arr = [times[x]]; + var temp_arr = [times[x]]; for (var y = 0; y < values.length; y++) { for (var z = 0; z < values[y].length; z++) { temp_arr.push(values[y][z][x]); @@ -69,5 +69,3 @@ var data_to_csv = function(data_set) { csv_string = csv.join("\n"); return csv_string; }; - -module.exports = data_to_csv; diff --git a/nengo_gui/static/datastore.js b/nengo_gui/static/datastore.ts similarity index 90% rename from nengo_gui/static/datastore.js rename to nengo_gui/static/datastore.ts index 530f2ae0..bc561ef0 100644 --- a/nengo_gui/static/datastore.js +++ b/nengo_gui/static/datastore.ts @@ -8,7 +8,9 @@ * @param {float} synapse - the filter to apply to the data */ -var DataStore = function(dims, sim, synapse) { +export class DataStore { + +constructor(dims, sim, synapse) { this.synapse = synapse; // TODO: get from SimControl this.sim = sim; this.times = []; @@ -23,7 +25,7 @@ var DataStore = function(dims, sim, synapse) { * * @param {array} row - dims+1 data points, with time as the first one */ -DataStore.prototype.push = function(row) { +push(row) { // If you get data out of order, wipe out the later data if (row[0] < this.times[this.times.length - 1]) { var index = 0; @@ -64,7 +66,7 @@ DataStore.prototype.push = function(row) { * This will clear current data so there is * nothing to display on a reset event. */ -DataStore.prototype.reset = function() { +reset() { var index = 0; this.times.splice(index, this.times.length); for (var i = 0; i < this.data.length; i++) { @@ -79,7 +81,7 @@ DataStore.prototype.reset = function() { * after every push()). Removes old data outside the storage limit set by * the SimControl. */ -DataStore.prototype.update = function() { +update() { // Figure out how many extra values we have (values whose time stamp is // outside the range to keep) var extra = 0; @@ -102,7 +104,7 @@ DataStore.prototype.update = function() { /** * Return just the data that is to be shown. */ -DataStore.prototype.get_shown_data = function() { +get_shown_data() { // Determine time range var t1 = this.sim.time_slider.first_shown_time; var t2 = t1 + this.sim.time_slider.shown_time; @@ -126,12 +128,12 @@ DataStore.prototype.get_shown_data = function() { return shown; }; -DataStore.prototype.is_at_end = function() { +is_at_end() { var ts = this.sim.time_slider; return (ts.last_time < ts.first_shown_time + ts.shown_time + 1e-9); }; -DataStore.prototype.get_last_data = function() { +get_last_data() { // Determine time range var t1 = this.sim.time_slider.first_shown_time; var t2 = t1 + this.sim.time_slider.shown_time; @@ -150,6 +152,8 @@ DataStore.prototype.get_last_data = function() { return shown; }; +} + /** * Storage of a set of data points and associated times with an increasable * number of dimensions. @@ -159,8 +163,10 @@ DataStore.prototype.get_last_data = function() { * @param {SimControl} sim - the simulation controller * @param {float} synapse - the filter to apply to the data */ -var GrowableDataStore = function(dims, sim, synapse) { - DataStore.call(this, dims, sim, synapse); +export class GrowableDataStore extends DataStore { + +constructor (dims, sim, synapse) { + super(dims, sim, synapse); this._dims = dims; @@ -183,10 +189,7 @@ var GrowableDataStore = function(dims, sim, synapse) { }); }; -GrowableDataStore.prototype = Object.create(DataStore.prototype); -GrowableDataStore.prototype.constructor = GrowableDataStore; - -GrowableDataStore.prototype.get_offset = function() { +get_offset() { var offset = []; offset.push(0); @@ -206,7 +209,7 @@ GrowableDataStore.prototype.get_offset = function() { * * @param {array} row - dims+1 data points, with time as the first one */ -GrowableDataStore.prototype.push = function(row) { +push(row) { // Get the offsets var offset = this.get_offset(); @@ -248,7 +251,7 @@ GrowableDataStore.prototype.push = function(row) { /** * Reset dimensions before resetting the datastore. */ -GrowableDataStore.prototype.reset = function() { +reset() { console.log("resetting growable"); this._dims = 1; DataStore.call(this, this._dims, this.sim, this.synapse); @@ -261,7 +264,7 @@ GrowableDataStore.prototype.reset = function() { * after every push()). Removes old data outside the storage limit set by * the SimControl. */ -GrowableDataStore.prototype.update = function() { +update() { // Figure out how many extra values we have (values whose time stamp is // outside the range to keep) var offset = this.get_offset(); @@ -286,7 +289,7 @@ GrowableDataStore.prototype.update = function() { /** * Return just the data that is to be shown. */ -GrowableDataStore.prototype.get_shown_data = function() { +get_shown_data() { var offset = this.get_offset(); // Determine time range var t1 = this.sim.time_slider.first_shown_time; @@ -337,7 +340,7 @@ GrowableDataStore.prototype.get_shown_data = function() { return shown; }; -GrowableDataStore.prototype.get_last_data = function() { +get_last_data() { var offset = this.get_offset(); // Determine time range var t1 = this.sim.time_slider.first_shown_time; @@ -359,5 +362,4 @@ GrowableDataStore.prototype.get_last_data = function() { return shown; }; -module.exports.DataStore = DataStore; -module.exports.GrowableDataStore = GrowableDataStore; +} diff --git a/nengo_gui/static/dist/nengo.js b/nengo_gui/static/dist/nengo.js index d8cceacf..c7c6f11b 100644 --- a/nengo_gui/static/dist/nengo.js +++ b/nengo_gui/static/dist/nengo.js @@ -1,4 +1,4 @@ -var Nengo=function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="/static/dist/",e(0)}([function(t,e,i){t.exports=i(42)},function(t,e,i){var n,o;/*! +var Nengo=function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="/static/dist/",e(0)}([function(t,e,i){t.exports=i(108)},function(t,e,i){var n,o;/*! * jQuery JavaScript Library v2.1.3 * http://jquery.com/ * @@ -11,7 +11,7 @@ var Nengo=function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={expo * * Date: 2014-12-18T15:11Z */ -!function(e,i){"object"==typeof t&&"object"==typeof t.exports?t.exports=e.document?i(e,!0):function(t){if(!t.document)throw new Error("jQuery requires a window with a document");return i(t)}:i(e)}("undefined"!=typeof window?window:this,function(i,r){function s(t){var e=t.length,i=nt.type(t);return"function"!==i&&!nt.isWindow(t)&&(!(1!==t.nodeType||!e)||("array"===i||0===e||"number"==typeof e&&e>0&&e-1 in t))}function a(t,e,i){if(nt.isFunction(e))return nt.grep(t,function(t,n){return!!e.call(t,n,t)!==i});if(e.nodeType)return nt.grep(t,function(t){return t===e!==i});if("string"==typeof e){if(ut.test(e))return nt.filter(e,t,i);e=nt.filter(e,t)}return nt.grep(t,function(t){return Q.call(e,t)>=0!==i})}function l(t,e){for(;(t=t[e])&&1!==t.nodeType;);return t}function h(t){var e=bt[t]={};return nt.each(t.match(vt)||[],function(t,i){e[i]=!0}),e}function c(){et.removeEventListener("DOMContentLoaded",c,!1),i.removeEventListener("load",c,!1),nt.ready()}function u(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=nt.expando+u.uid++}function d(t,e,i){var n;if(void 0===i&&1===t.nodeType)if(n="data-"+e.replace(Ct,"-$1").toLowerCase(),i=t.getAttribute(n),"string"==typeof i){try{i="true"===i||"false"!==i&&("null"===i?null:+i+""===i?+i:_t.test(i)?nt.parseJSON(i):i)}catch(o){}At.set(t,e,i)}else i=void 0;return i}function p(){return!0}function f(){return!1}function g(){try{return et.activeElement}catch(t){}}function m(t,e){return nt.nodeName(t,"table")&&nt.nodeName(11!==e.nodeType?e:e.firstChild,"tr")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}function v(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function b(t){var e=Pt.exec(t.type);return e?t.type=e[1]:t.removeAttribute("type"),t}function y(t,e){for(var i=0,n=t.length;i")).appendTo(e.documentElement),e=Ut[0].contentDocument,e.write(),e.close(),i=_(t,e),Ut.detach()),jt[t]=i),i}function E(t,e,i){var n,o,r,s,a=t.style;return i=i||Kt(t),i&&(s=i.getPropertyValue(e)||i[e]),i&&(""!==s||nt.contains(t.ownerDocument,t)||(s=nt.style(t,e)),qt.test(s)&&Vt.test(e)&&(n=a.width,o=a.minWidth,r=a.maxWidth,a.minWidth=a.maxWidth=a.width=s,s=i.width,a.width=n,a.minWidth=o,a.maxWidth=r)),void 0!==s?s+"":s}function k(t,e){return{get:function(){return t()?void delete this.get:(this.get=e).apply(this,arguments)}}}function F(t,e){if(e in t)return e;for(var i=e[0].toUpperCase()+e.slice(1),n=e,o=Zt.length;o--;)if(e=Zt[o]+i,e in t)return e;return n}function D(t,e,i){var n=Gt.exec(e);return n?Math.max(0,n[1]-(i||0))+(n[2]||"px"):e}function S(t,e,i,n,o){for(var r=i===(n?"border":"content")?4:"width"===e?1:0,s=0;r<4;r+=2)"margin"===i&&(s+=nt.css(t,i+kt[r],!0,o)),n?("content"===i&&(s-=nt.css(t,"padding"+kt[r],!0,o)),"margin"!==i&&(s-=nt.css(t,"border"+kt[r]+"Width",!0,o))):(s+=nt.css(t,"padding"+kt[r],!0,o),"padding"!==i&&(s+=nt.css(t,"border"+kt[r]+"Width",!0,o)));return s}function M(t,e,i){var n=!0,o="width"===e?t.offsetWidth:t.offsetHeight,r=Kt(t),s="border-box"===nt.css(t,"boxSizing",!1,r);if(o<=0||null==o){if(o=E(t,e,r),(o<0||null==o)&&(o=t.style[e]),qt.test(o))return o;n=s&&(tt.boxSizingReliable()||o===t.style[e]),o=parseFloat(o)||0}return o+S(t,e,i||(s?"border":"content"),n,r)+"px"}function T(t,e){for(var i,n,o,r=[],s=0,a=t.length;s=0&&i=0},isPlainObject:function(t){return"object"===nt.type(t)&&!t.nodeType&&!nt.isWindow(t)&&!(t.constructor&&!Z.call(t.constructor.prototype,"isPrototypeOf"))},isEmptyObject:function(t){var e;for(e in t)return!1;return!0},type:function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?X[J.call(t)]||"object":typeof t},globalEval:function(t){var e,i=eval;t=nt.trim(t),t&&(1===t.indexOf("use strict")?(e=et.createElement("script"),e.text=t,et.head.appendChild(e).parentNode.removeChild(e)):i(t))},camelCase:function(t){return t.replace(rt,"ms-").replace(st,at)},nodeName:function(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()},each:function(t,e,i){var n,o=0,r=t.length,a=s(t);if(i){if(a)for(;o0&&e-1 in t))}function a(t,e,i){if(nt.isFunction(e))return nt.grep(t,function(t,n){return!!e.call(t,n,t)!==i});if(e.nodeType)return nt.grep(t,function(t){return t===e!==i});if("string"==typeof e){if(ut.test(e))return nt.filter(e,t,i);e=nt.filter(e,t)}return nt.grep(t,function(t){return Q.call(e,t)>=0!==i})}function l(t,e){for(;(t=t[e])&&1!==t.nodeType;);return t}function h(t){var e=bt[t]={};return nt.each(t.match(vt)||[],function(t,i){e[i]=!0}),e}function c(){et.removeEventListener("DOMContentLoaded",c,!1),i.removeEventListener("load",c,!1),nt.ready()}function u(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=nt.expando+u.uid++}function d(t,e,i){var n;if(void 0===i&&1===t.nodeType)if(n="data-"+e.replace(Ct,"-$1").toLowerCase(),i=t.getAttribute(n),"string"==typeof i){try{i="true"===i||"false"!==i&&("null"===i?null:+i+""===i?+i:At.test(i)?nt.parseJSON(i):i)}catch(o){}_t.set(t,e,i)}else i=void 0;return i}function p(){return!0}function f(){return!1}function g(){try{return et.activeElement}catch(t){}}function m(t,e){return nt.nodeName(t,"table")&&nt.nodeName(11!==e.nodeType?e:e.firstChild,"tr")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}function v(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function b(t){var e=Pt.exec(t.type);return e?t.type=e[1]:t.removeAttribute("type"),t}function y(t,e){for(var i=0,n=t.length;i")).appendTo(e.documentElement),e=Ut[0].contentDocument,e.write(),e.close(),i=A(t,e),Ut.detach()),jt[t]=i),i}function E(t,e,i){var n,o,r,s,a=t.style;return i=i||Kt(t),i&&(s=i.getPropertyValue(e)||i[e]),i&&(""!==s||nt.contains(t.ownerDocument,t)||(s=nt.style(t,e)),qt.test(s)&&Vt.test(e)&&(n=a.width,o=a.minWidth,r=a.maxWidth,a.minWidth=a.maxWidth=a.width=s,s=i.width,a.width=n,a.minWidth=o,a.maxWidth=r)),void 0!==s?s+"":s}function k(t,e){return{get:function(){return t()?void delete this.get:(this.get=e).apply(this,arguments)}}}function F(t,e){if(e in t)return e;for(var i=e[0].toUpperCase()+e.slice(1),n=e,o=Zt.length;o--;)if(e=Zt[o]+i,e in t)return e;return n}function D(t,e,i){var n=Gt.exec(e);return n?Math.max(0,n[1]-(i||0))+(n[2]||"px"):e}function S(t,e,i,n,o){for(var r=i===(n?"border":"content")?4:"width"===e?1:0,s=0;r<4;r+=2)"margin"===i&&(s+=nt.css(t,i+kt[r],!0,o)),n?("content"===i&&(s-=nt.css(t,"padding"+kt[r],!0,o)),"margin"!==i&&(s-=nt.css(t,"border"+kt[r]+"Width",!0,o))):(s+=nt.css(t,"padding"+kt[r],!0,o),"padding"!==i&&(s+=nt.css(t,"border"+kt[r]+"Width",!0,o)));return s}function M(t,e,i){var n=!0,o="width"===e?t.offsetWidth:t.offsetHeight,r=Kt(t),s="border-box"===nt.css(t,"boxSizing",!1,r);if(o<=0||null==o){if(o=E(t,e,r),(o<0||null==o)&&(o=t.style[e]),qt.test(o))return o;n=s&&(tt.boxSizingReliable()||o===t.style[e]),o=parseFloat(o)||0}return o+S(t,e,i||(s?"border":"content"),n,r)+"px"}function T(t,e){for(var i,n,o,r=[],s=0,a=t.length;s=0&&i=0},isPlainObject:function(t){return"object"===nt.type(t)&&!t.nodeType&&!nt.isWindow(t)&&!(t.constructor&&!Z.call(t.constructor.prototype,"isPrototypeOf"))},isEmptyObject:function(t){var e;for(e in t)return!1;return!0},type:function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?X[J.call(t)]||"object":typeof t},globalEval:function(t){var e,i=eval;t=nt.trim(t),t&&(1===t.indexOf("use strict")?(e=et.createElement("script"),e.text=t,et.head.appendChild(e).parentNode.removeChild(e)):i(t))},camelCase:function(t){return t.replace(rt,"ms-").replace(st,at)},nodeName:function(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()},each:function(t,e,i){var n,o=0,r=t.length,a=s(t);if(i){if(a)for(;oA.cacheLength&&delete t[e.shift()],t[i+" "]=n}var e=[];return t}function n(t){return t[O]=!0,t}function o(t){var e=B.createElement("div");try{return!!t(e)}catch(i){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function r(t,e){for(var i=t.split("|"),n=t.length;n--;)A.attrHandle[i[n]]=e}function s(t,e){var i=e&&t,n=i&&1===t.nodeType&&1===e.nodeType&&(~e.sourceIndex||K)-(~t.sourceIndex||K);if(n)return n;if(i)for(;i=i.nextSibling;)if(i===e)return-1;return t?1:-1}function a(t){return function(e){var i=e.nodeName.toLowerCase();return"input"===i&&e.type===t}}function l(t){return function(e){var i=e.nodeName.toLowerCase();return("input"===i||"button"===i)&&e.type===t}}function h(t){return n(function(e){return e=+e,n(function(i,n){for(var o,r=t([],i.length,e),s=r.length;s--;)i[o=r[s]]&&(i[o]=!(n[o]=i[o]))})})}function c(t){return t&&"undefined"!=typeof t.getElementsByTagName&&t}function u(){}function d(t){for(var e=0,i=t.length,n="";e1?function(e,i,n){for(var o=t.length;o--;)if(!t[o](e,i,n))return!1;return!0}:t[0]}function g(t,i,n){for(var o=0,r=i.length;o-1&&(n[h]=!(s[h]=u))}}else y=m(y===s?y.splice(f,y.length):y),r?r(null,s,y,l):J.apply(s,y)})}function b(t){for(var e,i,n,o=t.length,r=A.relative[t[0].type],s=r||A.relative[" "],a=r?1:0,l=p(function(t){return t===e},s,!0),h=p(function(t){return tt(e,t)>-1},s,!0),c=[function(t,i,n){var o=!r&&(n||i!==D)||((e=i).nodeType?l(t,i,n):h(t,i,n));return e=null,o}];a1&&f(c),a>1&&d(t.slice(0,a-1).concat({value:" "===t[a-2].type?"*":""})).replace(lt,"$1"),i,a0,r=t.length>0,s=function(n,s,a,l,h){var c,u,d,p=0,f="0",g=n&&[],v=[],b=D,y=n||r&&A.find.TAG("*",h),w=W+=null==b?1:Math.random()||.1,x=y.length;for(h&&(D=s!==B&&s);f!==x&&null!=(c=y[f]);f++){if(r&&c){for(u=0;d=t[u++];)if(d(c,s,a)){l.push(c);break}h&&(W=w)}o&&((c=!d&&c)&&p--,n&&g.push(c))}if(p+=f,o&&f!==p){for(u=0;d=i[u++];)d(g,v,s,a);if(n){if(p>0)for(;f--;)g[f]||v[f]||(v[f]=Q.call(l));v=m(v)}J.apply(l,v),h&&!n&&v.length>0&&p+i.length>1&&e.uniqueSort(l)}return h&&(W=w,D=b),g};return o?n(s):s}var w,x,A,_,C,E,k,F,D,S,M,T,B,L,$,R,I,z,N,O="sizzle"+1*new Date,P=t.document,W=0,H=0,U=i(),j=i(),V=i(),q=function(t,e){return t===e&&(M=!0),0},K=1<<31,Y={}.hasOwnProperty,G=[],Q=G.pop,X=G.push,J=G.push,Z=G.slice,tt=function(t,e){for(var i=0,n=t.length;i+~]|"+it+")"+it+"*"),ut=new RegExp("="+it+"*([^\\]'\"]*?)"+it+"*\\]","g"),dt=new RegExp(st),pt=new RegExp("^"+ot+"$"),ft={ID:new RegExp("^#("+nt+")"),CLASS:new RegExp("^\\.("+nt+")"),TAG:new RegExp("^("+nt.replace("w","w*")+")"),ATTR:new RegExp("^"+rt),PSEUDO:new RegExp("^"+st),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+it+"*(even|odd|(([+-]|)(\\d*)n|)"+it+"*(?:([+-]|)"+it+"*(\\d+)|))"+it+"*\\)|)","i"),bool:new RegExp("^(?:"+et+")$","i"),needsContext:new RegExp("^"+it+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+it+"*((?:-\\d)?\\d*)"+it+"*\\)|)(?=[^-]|$)","i")},gt=/^(?:input|select|textarea|button)$/i,mt=/^h\d$/i,vt=/^[^{]+\{\s*\[native \w/,bt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,yt=/[+~]/,wt=/'|\\/g,xt=new RegExp("\\\\([\\da-f]{1,6}"+it+"?|("+it+")|.)","ig"),At=function(t,e,i){var n="0x"+e-65536;return n!==n||i?e:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},_t=function(){T()};try{J.apply(G=Z.call(P.childNodes),P.childNodes),G[P.childNodes.length].nodeType}catch(Ct){J={apply:G.length?function(t,e){X.apply(t,Z.call(e))}:function(t,e){for(var i=t.length,n=0;t[i++]=e[n++];);t.length=i-1}}}x=e.support={},C=e.isXML=function(t){var e=t&&(t.ownerDocument||t).documentElement;return!!e&&"HTML"!==e.nodeName},T=e.setDocument=function(t){var e,i,n=t?t.ownerDocument||t:P;return n!==B&&9===n.nodeType&&n.documentElement?(B=n,L=n.documentElement,i=n.defaultView,i&&i!==i.top&&(i.addEventListener?i.addEventListener("unload",_t,!1):i.attachEvent&&i.attachEvent("onunload",_t)),$=!C(n),x.attributes=o(function(t){return t.className="i",!t.getAttribute("className")}),x.getElementsByTagName=o(function(t){return t.appendChild(n.createComment("")),!t.getElementsByTagName("*").length}),x.getElementsByClassName=vt.test(n.getElementsByClassName),x.getById=o(function(t){return L.appendChild(t).id=O,!n.getElementsByName||!n.getElementsByName(O).length}),x.getById?(A.find.ID=function(t,e){if("undefined"!=typeof e.getElementById&&$){var i=e.getElementById(t);return i&&i.parentNode?[i]:[]}},A.filter.ID=function(t){var e=t.replace(xt,At);return function(t){return t.getAttribute("id")===e}}):(delete A.find.ID,A.filter.ID=function(t){var e=t.replace(xt,At);return function(t){var i="undefined"!=typeof t.getAttributeNode&&t.getAttributeNode("id");return i&&i.value===e}}),A.find.TAG=x.getElementsByTagName?function(t,e){return"undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t):x.qsa?e.querySelectorAll(t):void 0}:function(t,e){var i,n=[],o=0,r=e.getElementsByTagName(t);if("*"===t){for(;i=r[o++];)1===i.nodeType&&n.push(i);return n}return r},A.find.CLASS=x.getElementsByClassName&&function(t,e){if($)return e.getElementsByClassName(t)},I=[],R=[],(x.qsa=vt.test(n.querySelectorAll))&&(o(function(t){L.appendChild(t).innerHTML="",t.querySelectorAll("[msallowcapture^='']").length&&R.push("[*^$]="+it+"*(?:''|\"\")"),t.querySelectorAll("[selected]").length||R.push("\\["+it+"*(?:value|"+et+")"),t.querySelectorAll("[id~="+O+"-]").length||R.push("~="),t.querySelectorAll(":checked").length||R.push(":checked"),t.querySelectorAll("a#"+O+"+*").length||R.push(".#.+[+~]")}),o(function(t){var e=n.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&R.push("name"+it+"*[*^$|!~]?="),t.querySelectorAll(":enabled").length||R.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),R.push(",.*:")})),(x.matchesSelector=vt.test(z=L.matches||L.webkitMatchesSelector||L.mozMatchesSelector||L.oMatchesSelector||L.msMatchesSelector))&&o(function(t){x.disconnectedMatch=z.call(t,"div"),z.call(t,"[s!='']:x"),I.push("!=",st)}),R=R.length&&new RegExp(R.join("|")),I=I.length&&new RegExp(I.join("|")),e=vt.test(L.compareDocumentPosition),N=e||vt.test(L.contains)?function(t,e){var i=9===t.nodeType?t.documentElement:t,n=e&&e.parentNode;return t===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):t.compareDocumentPosition&&16&t.compareDocumentPosition(n)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},q=e?function(t,e){if(t===e)return M=!0,0;var i=!t.compareDocumentPosition-!e.compareDocumentPosition;return i?i:(i=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1,1&i||!x.sortDetached&&e.compareDocumentPosition(t)===i?t===n||t.ownerDocument===P&&N(P,t)?-1:e===n||e.ownerDocument===P&&N(P,e)?1:S?tt(S,t)-tt(S,e):0:4&i?-1:1)}:function(t,e){if(t===e)return M=!0,0;var i,o=0,r=t.parentNode,a=e.parentNode,l=[t],h=[e];if(!r||!a)return t===n?-1:e===n?1:r?-1:a?1:S?tt(S,t)-tt(S,e):0;if(r===a)return s(t,e);for(i=t;i=i.parentNode;)l.unshift(i);for(i=e;i=i.parentNode;)h.unshift(i);for(;l[o]===h[o];)o++;return o?s(l[o],h[o]):l[o]===P?-1:h[o]===P?1:0},n):B},e.matches=function(t,i){return e(t,null,null,i)},e.matchesSelector=function(t,i){if((t.ownerDocument||t)!==B&&T(t),i=i.replace(ut,"='$1']"),x.matchesSelector&&$&&(!I||!I.test(i))&&(!R||!R.test(i)))try{var n=z.call(t,i);if(n||x.disconnectedMatch||t.document&&11!==t.document.nodeType)return n}catch(o){}return e(i,B,null,[t]).length>0},e.contains=function(t,e){return(t.ownerDocument||t)!==B&&T(t),N(t,e)},e.attr=function(t,e){(t.ownerDocument||t)!==B&&T(t);var i=A.attrHandle[e.toLowerCase()],n=i&&Y.call(A.attrHandle,e.toLowerCase())?i(t,e,!$):void 0;return void 0!==n?n:x.attributes||!$?t.getAttribute(e):(n=t.getAttributeNode(e))&&n.specified?n.value:null},e.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},e.uniqueSort=function(t){var e,i=[],n=0,o=0;if(M=!x.detectDuplicates,S=!x.sortStable&&t.slice(0),t.sort(q),M){for(;e=t[o++];)e===t[o]&&(n=i.push(o));for(;n--;)t.splice(i[n],1)}return S=null,t},_=e.getText=function(t){var e,i="",n=0,o=t.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)i+=_(t)}else if(3===o||4===o)return t.nodeValue}else for(;e=t[n++];)i+=_(e);return i},A=e.selectors={cacheLength:50,createPseudo:n,match:ft,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(xt,At),t[3]=(t[3]||t[4]||t[5]||"").replace(xt,At),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||e.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&e.error(t[0]),t},PSEUDO:function(t){var e,i=!t[6]&&t[2];return ft.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":i&&dt.test(i)&&(e=E(i,!0))&&(e=i.indexOf(")",i.length-e)-i.length)&&(t[0]=t[0].slice(0,e),t[2]=i.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(xt,At).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=U[t+" "];return e||(e=new RegExp("(^|"+it+")"+t+"("+it+"|$)"))&&U(t,function(t){return e.test("string"==typeof t.className&&t.className||"undefined"!=typeof t.getAttribute&&t.getAttribute("class")||"")})},ATTR:function(t,i,n){return function(o){var r=e.attr(o,t);return null==r?"!="===i:!i||(r+="","="===i?r===n:"!="===i?r!==n:"^="===i?n&&0===r.indexOf(n):"*="===i?n&&r.indexOf(n)>-1:"$="===i?n&&r.slice(-n.length)===n:"~="===i?(" "+r.replace(at," ")+" ").indexOf(n)>-1:"|="===i&&(r===n||r.slice(0,n.length+1)===n+"-"))}},CHILD:function(t,e,i,n,o){var r="nth"!==t.slice(0,3),s="last"!==t.slice(-4),a="of-type"===e;return 1===n&&0===o?function(t){return!!t.parentNode}:function(e,i,l){var h,c,u,d,p,f,g=r!==s?"nextSibling":"previousSibling",m=e.parentNode,v=a&&e.nodeName.toLowerCase(),b=!l&&!a;if(m){if(r){for(;g;){for(u=e;u=u[g];)if(a?u.nodeName.toLowerCase()===v:1===u.nodeType)return!1;f=g="only"===t&&!f&&"nextSibling"}return!0}if(f=[s?m.firstChild:m.lastChild],s&&b){for(c=m[O]||(m[O]={}),h=c[t]||[],p=h[0]===W&&h[1],d=h[0]===W&&h[2],u=p&&m.childNodes[p];u=++p&&u&&u[g]||(d=p=0)||f.pop();)if(1===u.nodeType&&++d&&u===e){c[t]=[W,p,d];break}}else if(b&&(h=(e[O]||(e[O]={}))[t])&&h[0]===W)d=h[1];else for(;(u=++p&&u&&u[g]||(d=p=0)||f.pop())&&((a?u.nodeName.toLowerCase()!==v:1!==u.nodeType)||!++d||(b&&((u[O]||(u[O]={}))[t]=[W,d]),u!==e)););return d-=o,d===n||d%n===0&&d/n>=0}}},PSEUDO:function(t,i){var o,r=A.pseudos[t]||A.setFilters[t.toLowerCase()]||e.error("unsupported pseudo: "+t);return r[O]?r(i):r.length>1?(o=[t,t,"",i],A.setFilters.hasOwnProperty(t.toLowerCase())?n(function(t,e){for(var n,o=r(t,i),s=o.length;s--;)n=tt(t,o[s]),t[n]=!(e[n]=o[s])}):function(t){return r(t,0,o)}):r}},pseudos:{not:n(function(t){var e=[],i=[],o=k(t.replace(lt,"$1"));return o[O]?n(function(t,e,i,n){for(var r,s=o(t,null,n,[]),a=t.length;a--;)(r=s[a])&&(t[a]=!(e[a]=r))}):function(t,n,r){return e[0]=t,o(e,null,r,i),e[0]=null,!i.pop()}}),has:n(function(t){return function(i){return e(t,i).length>0}}),contains:n(function(t){return t=t.replace(xt,At),function(e){return(e.textContent||e.innerText||_(e)).indexOf(t)>-1}}),lang:n(function(t){return pt.test(t||"")||e.error("unsupported lang: "+t),t=t.replace(xt,At).toLowerCase(),function(e){var i;do if(i=$?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return i=i.toLowerCase(),i===t||0===i.indexOf(t+"-");while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var i=t.location&&t.location.hash;return i&&i.slice(1)===e.id},root:function(t){return t===L},focus:function(t){return t===B.activeElement&&(!B.hasFocus||B.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:function(t){return t.disabled===!1},disabled:function(t){return t.disabled===!0},checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,t.selected===!0},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!A.pseudos.empty(t)},header:function(t){return mt.test(t.nodeName)},input:function(t){return gt.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:h(function(){return[0]}),last:h(function(t,e){return[e-1]}),eq:h(function(t,e,i){return[i<0?i+e:i]}),even:h(function(t,e){for(var i=0;i=0;)t.push(n);return t}),gt:h(function(t,e,i){for(var n=i<0?i+e:i;++n2&&"ID"===(s=r[0]).type&&x.getById&&9===e.nodeType&&$&&A.relative[r[1].type]){if(e=(A.find.ID(s.matches[0].replace(xt,At),e)||[])[0],!e)return i;h&&(e=e.parentNode),t=t.slice(r.shift().value.length)}for(o=ft.needsContext.test(t)?0:r.length;o--&&(s=r[o],!A.relative[a=s.type]);)if((l=A.find[a])&&(n=l(s.matches[0].replace(xt,At),yt.test(r[0].type)&&c(e.parentNode)||e))){if(r.splice(o,1),t=n.length&&d(r),!t)return J.apply(i,n),i;break}}return(h||k(t,u))(n,e,!$,i,yt.test(t)&&c(e.parentNode)||e),i},x.sortStable=O.split("").sort(q).join("")===O,x.detectDuplicates=!!M,T(),x.sortDetached=o(function(t){return 1&t.compareDocumentPosition(B.createElement("div"))}),o(function(t){return t.innerHTML="","#"===t.firstChild.getAttribute("href")})||r("type|href|height|width",function(t,e,i){if(!i)return t.getAttribute(e,"type"===e.toLowerCase()?1:2)}),x.attributes&&o(function(t){return t.innerHTML="",t.firstChild.setAttribute("value",""),""===t.firstChild.getAttribute("value")})||r("value",function(t,e,i){if(!i&&"input"===t.nodeName.toLowerCase())return t.defaultValue}),o(function(t){return null==t.getAttribute("disabled")})||r(et,function(t,e,i){var n;if(!i)return t[e]===!0?e.toLowerCase():(n=t.getAttributeNode(e))&&n.specified?n.value:null}),e}(i);nt.find=lt,nt.expr=lt.selectors,nt.expr[":"]=nt.expr.pseudos,nt.unique=lt.uniqueSort,nt.text=lt.getText,nt.isXMLDoc=lt.isXML,nt.contains=lt.contains;var ht=nt.expr.match.needsContext,ct=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,ut=/^.[^:#\[\.,]*$/;nt.filter=function(t,e,i){var n=e[0];return i&&(t=":not("+t+")"),1===e.length&&1===n.nodeType?nt.find.matchesSelector(n,t)?[n]:[]:nt.find.matches(t,nt.grep(e,function(t){return 1===t.nodeType}))},nt.fn.extend({find:function(t){var e,i=this.length,n=[],o=this;if("string"!=typeof t)return this.pushStack(nt(t).filter(function(){for(e=0;e1?nt.unique(n):n),n.selector=this.selector?this.selector+" "+t:t,n},filter:function(t){return this.pushStack(a(this,t||[],!1))},not:function(t){return this.pushStack(a(this,t||[],!0))},is:function(t){return!!a(this,"string"==typeof t&&ht.test(t)?nt(t):t||[],!1).length}});var dt,pt=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,ft=nt.fn.init=function(t,e){var i,n;if(!t)return this;if("string"==typeof t){if(i="<"===t[0]&&">"===t[t.length-1]&&t.length>=3?[null,t,null]:pt.exec(t),!i||!i[1]&&e)return!e||e.jquery?(e||dt).find(t):this.constructor(e).find(t);if(i[1]){if(e=e instanceof nt?e[0]:e,nt.merge(this,nt.parseHTML(i[1],e&&e.nodeType?e.ownerDocument||e:et,!0)),ct.test(i[1])&&nt.isPlainObject(e))for(i in e)nt.isFunction(this[i])?this[i](e[i]):this.attr(i,e[i]);return this}return n=et.getElementById(i[2]),n&&n.parentNode&&(this.length=1,this[0]=n),this.context=et,this.selector=t,this}return t.nodeType?(this.context=this[0]=t,this.length=1,this):nt.isFunction(t)?"undefined"!=typeof dt.ready?dt.ready(t):t(nt):(void 0!==t.selector&&(this.selector=t.selector,this.context=t.context),nt.makeArray(t,this))};ft.prototype=nt.fn,dt=nt(et);var gt=/^(?:parents|prev(?:Until|All))/,mt={children:!0,contents:!0,next:!0,prev:!0};nt.extend({dir:function(t,e,i){for(var n=[],o=void 0!==i;(t=t[e])&&9!==t.nodeType;)if(1===t.nodeType){if(o&&nt(t).is(i))break;n.push(t)}return n},sibling:function(t,e){for(var i=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&i.push(t);return i}}),nt.fn.extend({has:function(t){var e=nt(t,this),i=e.length;return this.filter(function(){for(var t=0;t-1:1===i.nodeType&&nt.find.matchesSelector(i,t))){r.push(i);break}return this.pushStack(r.length>1?nt.unique(r):r)},index:function(t){return t?"string"==typeof t?Q.call(nt(t),this[0]):Q.call(this,t.jquery?t[0]:t):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(nt.unique(nt.merge(this.get(),nt(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),nt.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return nt.dir(t,"parentNode")},parentsUntil:function(t,e,i){return nt.dir(t,"parentNode",i)},next:function(t){return l(t,"nextSibling")},prev:function(t){return l(t,"previousSibling")},nextAll:function(t){return nt.dir(t,"nextSibling")},prevAll:function(t){return nt.dir(t,"previousSibling")},nextUntil:function(t,e,i){return nt.dir(t,"nextSibling",i)},prevUntil:function(t,e,i){return nt.dir(t,"previousSibling",i)},siblings:function(t){return nt.sibling((t.parentNode||{}).firstChild,t)},children:function(t){return nt.sibling(t.firstChild)},contents:function(t){return t.contentDocument||nt.merge([],t.childNodes)}},function(t,e){nt.fn[t]=function(i,n){var o=nt.map(this,e,i);return"Until"!==t.slice(-5)&&(n=i),n&&"string"==typeof n&&(o=nt.filter(n,o)),this.length>1&&(mt[t]||nt.unique(o),gt.test(t)&&o.reverse()),this.pushStack(o)}});var vt=/\S+/g,bt={};nt.Callbacks=function(t){t="string"==typeof t?bt[t]||h(t):nt.extend({},t);var e,i,n,o,r,s,a=[],l=!t.once&&[],c=function(h){for(e=t.memory&&h,i=!0,s=o||0,o=0,r=a.length,n=!0;a&&s-1;)a.splice(i,1),n&&(i<=r&&r--,i<=s&&s--)}),this},has:function(t){return t?nt.inArray(t,a)>-1:!(!a||!a.length)},empty:function(){return a=[],r=0,this},disable:function(){return a=l=e=void 0,this},disabled:function(){return!a},lock:function(){return l=void 0,e||u.disable(),this},locked:function(){return!l},fireWith:function(t,e){return!a||i&&!l||(e=e||[],e=[t,e.slice?e.slice():e],n?l.push(e):c(e)),this},fire:function(){return u.fireWith(this,arguments),this},fired:function(){return!!i}};return u},nt.extend({Deferred:function(t){var e=[["resolve","done",nt.Callbacks("once memory"),"resolved"],["reject","fail",nt.Callbacks("once memory"),"rejected"],["notify","progress",nt.Callbacks("memory")]],i="pending",n={state:function(){return i},always:function(){return o.done(arguments).fail(arguments),this},then:function(){var t=arguments;return nt.Deferred(function(i){nt.each(e,function(e,r){var s=nt.isFunction(t[e])&&t[e];o[r[1]](function(){var t=s&&s.apply(this,arguments);t&&nt.isFunction(t.promise)?t.promise().done(i.resolve).fail(i.reject).progress(i.notify):i[r[0]+"With"](this===n?i.promise():this,s?[t]:arguments)})}),t=null}).promise()},promise:function(t){return null!=t?nt.extend(t,n):n}},o={};return n.pipe=n.then,nt.each(e,function(t,r){var s=r[2],a=r[3];n[r[1]]=s.add,a&&s.add(function(){i=a},e[1^t][2].disable,e[2][2].lock),o[r[0]]=function(){return o[r[0]+"With"](this===o?n:this,arguments),this},o[r[0]+"With"]=s.fireWith}),n.promise(o),t&&t.call(o,o),o},when:function(t){var e,i,n,o=0,r=K.call(arguments),s=r.length,a=1!==s||t&&nt.isFunction(t.promise)?s:0,l=1===a?t:nt.Deferred(),h=function(t,i,n){return function(o){i[t]=this,n[t]=arguments.length>1?K.call(arguments):o,n===e?l.notifyWith(i,n):--a||l.resolveWith(i,n)}};if(s>1)for(e=new Array(s),i=new Array(s),n=new Array(s);o0||(yt.resolveWith(et,[nt]),nt.fn.triggerHandler&&(nt(et).triggerHandler("ready"),nt(et).off("ready"))))}}),nt.ready.promise=function(t){return yt||(yt=nt.Deferred(),"complete"===et.readyState?setTimeout(nt.ready):(et.addEventListener("DOMContentLoaded",c,!1),i.addEventListener("load",c,!1))),yt.promise(t)},nt.ready.promise();var wt=nt.access=function(t,e,i,n,o,r,s){var a=0,l=t.length,h=null==i;if("object"===nt.type(i)){o=!0;for(a in i)nt.access(t,e,a,i[a],!0,r,s)}else if(void 0!==n&&(o=!0,nt.isFunction(n)||(s=!0),h&&(s?(e.call(t,n),e=null):(h=e,e=function(t,e,i){return h.call(nt(t),i)})),e))for(;a1,null,!0)},removeData:function(t){return this.each(function(){At.remove(this,t)})}}),nt.extend({queue:function(t,e,i){var n;if(t)return e=(e||"fx")+"queue",n=xt.get(t,e),i&&(!n||nt.isArray(i)?n=xt.access(t,e,nt.makeArray(i)):n.push(i)),n||[]},dequeue:function(t,e){e=e||"fx";var i=nt.queue(t,e),n=i.length,o=i.shift(),r=nt._queueHooks(t,e),s=function(){nt.dequeue(t,e)};"inprogress"===o&&(o=i.shift(),n--),o&&("fx"===e&&i.unshift("inprogress"),delete r.stop,o.call(t,s,r)),!n&&r&&r.empty.fire()},_queueHooks:function(t,e){var i=e+"queueHooks";return xt.get(t,i)||xt.access(t,i,{empty:nt.Callbacks("once memory").add(function(){xt.remove(t,[e+"queue",i])})})}}),nt.fn.extend({queue:function(t,e){var i=2;return"string"!=typeof t&&(e=t,t="fx",i--),arguments.lengthx",tt.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var St="undefined";tt.focusinBubbles="onfocusin"in i;var Mt=/^key/,Tt=/^(?:mouse|pointer|contextmenu)|click/,Bt=/^(?:focusinfocus|focusoutblur)$/,Lt=/^([^.]*)(?:\.(.+)|)$/;nt.event={global:{},add:function(t,e,i,n,o){var r,s,a,l,h,c,u,d,p,f,g,m=xt.get(t);if(m)for(i.handler&&(r=i,i=r.handler,o=r.selector),i.guid||(i.guid=nt.guid++),(l=m.events)||(l=m.events={}),(s=m.handle)||(s=m.handle=function(e){return typeof nt!==St&&nt.event.triggered!==e.type?nt.event.dispatch.apply(t,arguments):void 0}),e=(e||"").match(vt)||[""],h=e.length;h--;)a=Lt.exec(e[h])||[],p=g=a[1],f=(a[2]||"").split(".").sort(),p&&(u=nt.event.special[p]||{},p=(o?u.delegateType:u.bindType)||p,u=nt.event.special[p]||{},c=nt.extend({type:p,origType:g,data:n,handler:i,guid:i.guid,selector:o,needsContext:o&&nt.expr.match.needsContext.test(o),namespace:f.join(".")},r),(d=l[p])||(d=l[p]=[],d.delegateCount=0,u.setup&&u.setup.call(t,n,f,s)!==!1||t.addEventListener&&t.addEventListener(p,s,!1)),u.add&&(u.add.call(t,c),c.handler.guid||(c.handler.guid=i.guid)),o?d.splice(d.delegateCount++,0,c):d.push(c),nt.event.global[p]=!0)},remove:function(t,e,i,n,o){var r,s,a,l,h,c,u,d,p,f,g,m=xt.hasData(t)&&xt.get(t);if(m&&(l=m.events)){for(e=(e||"").match(vt)||[""],h=e.length;h--;)if(a=Lt.exec(e[h])||[],p=g=a[1],f=(a[2]||"").split(".").sort(),p){for(u=nt.event.special[p]||{},p=(n?u.delegateType:u.bindType)||p,d=l[p]||[],a=a[2]&&new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=r=d.length;r--;)c=d[r],!o&&g!==c.origType||i&&i.guid!==c.guid||a&&!a.test(c.namespace)||n&&n!==c.selector&&("**"!==n||!c.selector)||(d.splice(r,1),c.selector&&d.delegateCount--,u.remove&&u.remove.call(t,c));s&&!d.length&&(u.teardown&&u.teardown.call(t,f,m.handle)!==!1||nt.removeEvent(t,p,m.handle),delete l[p])}else for(p in l)nt.event.remove(t,p+e[h],i,n,!0);nt.isEmptyObject(l)&&(delete m.handle,xt.remove(t,"events"))}},trigger:function(t,e,n,o){var r,s,a,l,h,c,u,d=[n||et],p=Z.call(t,"type")?t.type:t,f=Z.call(t,"namespace")?t.namespace.split("."):[];if(s=a=n=n||et,3!==n.nodeType&&8!==n.nodeType&&!Bt.test(p+nt.event.triggered)&&(p.indexOf(".")>=0&&(f=p.split("."),p=f.shift(),f.sort()),h=p.indexOf(":")<0&&"on"+p,t=t[nt.expando]?t:new nt.Event(p,"object"==typeof t&&t),t.isTrigger=o?2:3, -t.namespace=f.join("."),t.namespace_re=t.namespace?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=n),e=null==e?[t]:nt.makeArray(e,[t]),u=nt.event.special[p]||{},o||!u.trigger||u.trigger.apply(n,e)!==!1)){if(!o&&!u.noBubble&&!nt.isWindow(n)){for(l=u.delegateType||p,Bt.test(l+p)||(s=s.parentNode);s;s=s.parentNode)d.push(s),a=s;a===(n.ownerDocument||et)&&d.push(a.defaultView||a.parentWindow||i)}for(r=0;(s=d[r++])&&!t.isPropagationStopped();)t.type=r>1?l:u.bindType||p,c=(xt.get(s,"events")||{})[t.type]&&xt.get(s,"handle"),c&&c.apply(s,e),c=h&&s[h],c&&c.apply&&nt.acceptData(s)&&(t.result=c.apply(s,e),t.result===!1&&t.preventDefault());return t.type=p,o||t.isDefaultPrevented()||u._default&&u._default.apply(d.pop(),e)!==!1||!nt.acceptData(n)||h&&nt.isFunction(n[p])&&!nt.isWindow(n)&&(a=n[h],a&&(n[h]=null),nt.event.triggered=p,n[p](),nt.event.triggered=void 0,a&&(n[h]=a)),t.result}},dispatch:function(t){t=nt.event.fix(t);var e,i,n,o,r,s=[],a=K.call(arguments),l=(xt.get(this,"events")||{})[t.type]||[],h=nt.event.special[t.type]||{};if(a[0]=t,t.delegateTarget=this,!h.preDispatch||h.preDispatch.call(this,t)!==!1){for(s=nt.event.handlers.call(this,t,l),e=0;(o=s[e++])&&!t.isPropagationStopped();)for(t.currentTarget=o.elem,i=0;(r=o.handlers[i++])&&!t.isImmediatePropagationStopped();)t.namespace_re&&!t.namespace_re.test(r.namespace)||(t.handleObj=r,t.data=r.data,n=((nt.event.special[r.origType]||{}).handle||r.handler).apply(o.elem,a),void 0!==n&&(t.result=n)===!1&&(t.preventDefault(),t.stopPropagation()));return h.postDispatch&&h.postDispatch.call(this,t),t.result}},handlers:function(t,e){var i,n,o,r,s=[],a=e.delegateCount,l=t.target;if(a&&l.nodeType&&(!t.button||"click"!==t.type))for(;l!==this;l=l.parentNode||this)if(l.disabled!==!0||"click"!==t.type){for(n=[],i=0;i=0:nt.find(o,this,null,[l]).length),n[o]&&n.push(r);n.length&&s.push({elem:l,handlers:n})}return a]*)\/>/gi,Rt=/<([\w:]+)/,It=/<|&#?\w+;/,zt=/<(?:script|style|link)/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,Ot=/^$|\/(?:java|ecma)script/i,Pt=/^true\/(.*)/,Wt=/^\s*\s*$/g,Ht={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};Ht.optgroup=Ht.option,Ht.tbody=Ht.tfoot=Ht.colgroup=Ht.caption=Ht.thead,Ht.th=Ht.td,nt.extend({clone:function(t,e,i){var n,o,r,s,a=t.cloneNode(!0),l=nt.contains(t.ownerDocument,t);if(!(tt.noCloneChecked||1!==t.nodeType&&11!==t.nodeType||nt.isXMLDoc(t)))for(s=x(a),r=x(t),n=0,o=r.length;n0&&y(s,!l&&x(t,"script")),a},buildFragment:function(t,e,i,n){for(var o,r,s,a,l,h,c=e.createDocumentFragment(),u=[],d=0,p=t.length;d")+a[2],h=a[0];h--;)r=r.lastChild;nt.merge(u,r.childNodes),r=c.firstChild,r.textContent=""}else u.push(e.createTextNode(o));for(c.textContent="",d=0;o=u[d++];)if((!n||nt.inArray(o,n)===-1)&&(l=nt.contains(o.ownerDocument,o),r=x(c.appendChild(o),"script"),l&&y(r),i))for(h=0;o=r[h++];)Ot.test(o.type||"")&&i.push(o);return c},cleanData:function(t){for(var e,i,n,o,r=nt.event.special,s=0;void 0!==(i=t[s]);s++){if(nt.acceptData(i)&&(o=i[xt.expando],o&&(e=xt.cache[o]))){if(e.events)for(n in e.events)r[n]?nt.event.remove(i,n):nt.removeEvent(i,n,e.handle);xt.cache[o]&&delete xt.cache[o]}delete At.cache[i[At.expando]]}}}),nt.fn.extend({text:function(t){return wt(this,function(t){return void 0===t?nt.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=t)})},null,t,arguments.length)},append:function(){return this.domManip(arguments,function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=m(this,t);e.appendChild(t)}})},prepend:function(){return this.domManip(arguments,function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=m(this,t);e.insertBefore(t,e.firstChild)}})},before:function(){return this.domManip(arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this)})},after:function(){return this.domManip(arguments,function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)})},remove:function(t,e){for(var i,n=t?nt.filter(t,this):this,o=0;null!=(i=n[o]);o++)e||1!==i.nodeType||nt.cleanData(x(i)),i.parentNode&&(e&&nt.contains(i.ownerDocument,i)&&y(x(i,"script")),i.parentNode.removeChild(i));return this},empty:function(){for(var t,e=0;null!=(t=this[e]);e++)1===t.nodeType&&(nt.cleanData(x(t,!1)),t.textContent="");return this},clone:function(t,e){return t=null!=t&&t,e=null==e?t:e,this.map(function(){return nt.clone(this,t,e)})},html:function(t){return wt(this,function(t){var e=this[0]||{},i=0,n=this.length;if(void 0===t&&1===e.nodeType)return e.innerHTML;if("string"==typeof t&&!zt.test(t)&&!Ht[(Rt.exec(t)||["",""])[1].toLowerCase()]){t=t.replace($t,"<$1>");try{for(;i1&&"string"==typeof d&&!tt.checkClone&&Nt.test(d))return this.each(function(i){var n=c.eq(i);p&&(t[0]=d.call(this,i,n.html())),n.domManip(t,e)});if(h&&(i=nt.buildFragment(t,this[0].ownerDocument,!1,this),n=i.firstChild,1===i.childNodes.length&&(i=n),n)){for(o=nt.map(x(i,"script"),v),r=o.length;l1)},show:function(){return T(this,!0)},hide:function(){return T(this)},toggle:function(t){return"boolean"==typeof t?t?this.show():this.hide():this.each(function(){Ft(this)?nt(this).show():nt(this).hide()})}}),nt.Tween=B,B.prototype={constructor:B,init:function(t,e,i,n,o,r){this.elem=t,this.prop=i,this.easing=o||"swing",this.options=e,this.start=this.now=this.cur(),this.end=n,this.unit=r||(nt.cssNumber[i]?"":"px")},cur:function(){var t=B.propHooks[this.prop];return t&&t.get?t.get(this):B.propHooks._default.get(this)},run:function(t){var e,i=B.propHooks[this.prop];return this.options.duration?this.pos=e=nt.easing[this.easing](t,this.options.duration*t,0,1,this.options.duration):this.pos=e=t,this.now=(this.end-this.start)*e+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),i&&i.set?i.set(this):B.propHooks._default.set(this),this}},B.prototype.init.prototype=B.prototype,B.propHooks={_default:{get:function(t){var e;return null==t.elem[t.prop]||t.elem.style&&null!=t.elem.style[t.prop]?(e=nt.css(t.elem,t.prop,""),e&&"auto"!==e?e:0):t.elem[t.prop]},set:function(t){nt.fx.step[t.prop]?nt.fx.step[t.prop](t):t.elem.style&&(null!=t.elem.style[nt.cssProps[t.prop]]||nt.cssHooks[t.prop])?nt.style(t.elem,t.prop,t.now+t.unit):t.elem[t.prop]=t.now}}},B.propHooks.scrollTop=B.propHooks.scrollLeft={set:function(t){t.elem.nodeType&&t.elem.parentNode&&(t.elem[t.prop]=t.now)}},nt.easing={linear:function(t){return t},swing:function(t){return.5-Math.cos(t*Math.PI)/2}},nt.fx=B.prototype.init,nt.fx.step={};var te,ee,ie=/^(?:toggle|show|hide)$/,ne=new RegExp("^(?:([+-])=|)("+Et+")([a-z%]*)$","i"),oe=/queueHooks$/,re=[I],se={"*":[function(t,e){var i=this.createTween(t,e),n=i.cur(),o=ne.exec(e),r=o&&o[3]||(nt.cssNumber[t]?"":"px"),s=(nt.cssNumber[t]||"px"!==r&&+n)&&ne.exec(nt.css(i.elem,t)),a=1,l=20;if(s&&s[3]!==r){r=r||s[3],o=o||[],s=+n||1;do a=a||".5",s/=a,nt.style(i.elem,t,s+r);while(a!==(a=i.cur()/n)&&1!==a&&--l)}return o&&(s=i.start=+s||+n||0,i.unit=r,i.end=o[1]?s+(o[1]+1)*o[2]:+o[2]),i}]};nt.Animation=nt.extend(N,{tweener:function(t,e){nt.isFunction(t)?(e=t,t=["*"]):t=t.split(" ");for(var i,n=0,o=t.length;n1)},removeAttr:function(t){return this.each(function(){nt.removeAttr(this,t)})}}),nt.extend({attr:function(t,e,i){var n,o,r=t.nodeType;if(t&&3!==r&&8!==r&&2!==r)return typeof t.getAttribute===St?nt.prop(t,e,i):(1===r&&nt.isXMLDoc(t)||(e=e.toLowerCase(),n=nt.attrHooks[e]||(nt.expr.match.bool.test(e)?le:ae)),void 0===i?n&&"get"in n&&null!==(o=n.get(t,e))?o:(o=nt.find.attr(t,e),null==o?void 0:o):null!==i?n&&"set"in n&&void 0!==(o=n.set(t,i,e))?o:(t.setAttribute(e,i+""),i):void nt.removeAttr(t,e))},removeAttr:function(t,e){var i,n,o=0,r=e&&e.match(vt);if(r&&1===t.nodeType)for(;i=r[o++];)n=nt.propFix[i]||i,nt.expr.match.bool.test(i)&&(t[n]=!1),t.removeAttribute(i)},attrHooks:{type:{set:function(t,e){if(!tt.radioValue&&"radio"===e&&nt.nodeName(t,"input")){var i=t.value;return t.setAttribute("type",e),i&&(t.value=i),e}}}}}),le={set:function(t,e,i){return e===!1?nt.removeAttr(t,i):t.setAttribute(i,i),i}},nt.each(nt.expr.match.bool.source.match(/\w+/g),function(t,e){var i=he[e]||nt.find.attr;he[e]=function(t,e,n){var o,r;return n||(r=he[e],he[e]=o,o=null!=i(t,e,n)?e.toLowerCase():null,he[e]=r),o}});var ce=/^(?:input|select|textarea|button)$/i;nt.fn.extend({prop:function(t,e){return wt(this,nt.prop,t,e,arguments.length>1)},removeProp:function(t){return this.each(function(){delete this[nt.propFix[t]||t]})}}),nt.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(t,e,i){var n,o,r,s=t.nodeType;if(t&&3!==s&&8!==s&&2!==s)return r=1!==s||!nt.isXMLDoc(t),r&&(e=nt.propFix[e]||e,o=nt.propHooks[e]),void 0!==i?o&&"set"in o&&void 0!==(n=o.set(t,i,e))?n:t[e]=i:o&&"get"in o&&null!==(n=o.get(t,e))?n:t[e]},propHooks:{tabIndex:{get:function(t){return t.hasAttribute("tabindex")||ce.test(t.nodeName)||t.href?t.tabIndex:-1}}}}),tt.optSelected||(nt.propHooks.selected={get:function(t){var e=t.parentNode;return e&&e.parentNode&&e.parentNode.selectedIndex,null}}),nt.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){nt.propFix[this.toLowerCase()]=this});var ue=/[\t\r\n\f]/g;nt.fn.extend({addClass:function(t){var e,i,n,o,r,s,a="string"==typeof t&&t,l=0,h=this.length;if(nt.isFunction(t))return this.each(function(e){nt(this).addClass(t.call(this,e,this.className))});if(a)for(e=(t||"").match(vt)||[];l=0;)n=n.replace(" "+o+" "," ");s=t?nt.trim(n):"",i.className!==s&&(i.className=s)}return this},toggleClass:function(t,e){var i=typeof t;return"boolean"==typeof e&&"string"===i?e?this.addClass(t):this.removeClass(t):nt.isFunction(t)?this.each(function(i){nt(this).toggleClass(t.call(this,i,this.className,e),e)}):this.each(function(){if("string"===i)for(var e,n=0,o=nt(this),r=t.match(vt)||[];e=r[n++];)o.hasClass(e)?o.removeClass(e):o.addClass(e);else i!==St&&"boolean"!==i||(this.className&&xt.set(this,"__className__",this.className),this.className=this.className||t===!1?"":xt.get(this,"__className__")||"")})},hasClass:function(t){for(var e=" "+t+" ",i=0,n=this.length;i=0)return!0;return!1}});var de=/\r/g;nt.fn.extend({val:function(t){var e,i,n,o=this[0];{if(arguments.length)return n=nt.isFunction(t),this.each(function(i){var o;1===this.nodeType&&(o=n?t.call(this,i,nt(this).val()):t,null==o?o="":"number"==typeof o?o+="":nt.isArray(o)&&(o=nt.map(o,function(t){return null==t?"":t+""})),e=nt.valHooks[this.type]||nt.valHooks[this.nodeName.toLowerCase()],e&&"set"in e&&void 0!==e.set(this,o,"value")||(this.value=o))});if(o)return e=nt.valHooks[o.type]||nt.valHooks[o.nodeName.toLowerCase()],e&&"get"in e&&void 0!==(i=e.get(o,"value"))?i:(i=o.value,"string"==typeof i?i.replace(de,""):null==i?"":i)}}}),nt.extend({valHooks:{option:{get:function(t){var e=nt.find.attr(t,"value");return null!=e?e:nt.trim(nt.text(t))}},select:{get:function(t){for(var e,i,n=t.options,o=t.selectedIndex,r="select-one"===t.type||o<0,s=r?null:[],a=r?o+1:n.length,l=o<0?a:r?o:0;l=0)&&(i=!0);return i||(t.selectedIndex=-1),r}}}}),nt.each(["radio","checkbox"],function(){nt.valHooks[this]={set:function(t,e){if(nt.isArray(e))return t.checked=nt.inArray(nt(t).val(),e)>=0}},tt.checkOn||(nt.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})}),nt.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(t,e){nt.fn[e]=function(t,i){return arguments.length>0?this.on(e,null,t,i):this.trigger(e)}}),nt.fn.extend({hover:function(t,e){return this.mouseenter(t).mouseleave(e||t)},bind:function(t,e,i){return this.on(t,null,e,i)},unbind:function(t,e){return this.off(t,null,e)},delegate:function(t,e,i,n){return this.on(e,t,i,n)},undelegate:function(t,e,i){return 1===arguments.length?this.off(t,"**"):this.off(e,t||"**",i)}});var pe=nt.now(),fe=/\?/;nt.parseJSON=function(t){return JSON.parse(t+"")},nt.parseXML=function(t){var e,i;if(!t||"string"!=typeof t)return null;try{i=new DOMParser,e=i.parseFromString(t,"text/xml")}catch(n){e=void 0}return e&&!e.getElementsByTagName("parsererror").length||nt.error("Invalid XML: "+t),e};var ge=/#.*$/,me=/([?&])_=[^&]*/,ve=/^(.*?):[ \t]*([^\r\n]*)$/gm,be=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,ye=/^(?:GET|HEAD)$/,we=/^\/\//,xe=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Ae={},_e={},Ce="*/".concat("*"),Ee=i.location.href,ke=xe.exec(Ee.toLowerCase())||[];nt.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ee,type:"GET",isLocal:be.test(ke[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ce,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":nt.parseJSON,"text xml":nt.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(t,e){return e?W(W(t,nt.ajaxSettings),e):W(nt.ajaxSettings,t)},ajaxPrefilter:O(Ae),ajaxTransport:O(_e),ajax:function(t,e){function i(t,e,i,s){var l,c,v,b,w,A=e;2!==y&&(y=2,a&&clearTimeout(a),n=void 0,r=s||"",x.readyState=t>0?4:0,l=t>=200&&t<300||304===t,i&&(b=H(u,x,i)),b=U(u,b,x,l),l?(u.ifModified&&(w=x.getResponseHeader("Last-Modified"),w&&(nt.lastModified[o]=w),w=x.getResponseHeader("etag"),w&&(nt.etag[o]=w)),204===t||"HEAD"===u.type?A="nocontent":304===t?A="notmodified":(A=b.state,c=b.data,v=b.error,l=!v)):(v=A,!t&&A||(A="error",t<0&&(t=0))),x.status=t,x.statusText=(e||A)+"",l?f.resolveWith(d,[c,A,x]):f.rejectWith(d,[x,A,v]),x.statusCode(m),m=void 0,h&&p.trigger(l?"ajaxSuccess":"ajaxError",[x,u,l?c:v]),g.fireWith(d,[x,A]),h&&(p.trigger("ajaxComplete",[x,u]),--nt.active||nt.event.trigger("ajaxStop")))}"object"==typeof t&&(e=t,t=void 0),e=e||{};var n,o,r,s,a,l,h,c,u=nt.ajaxSetup({},e),d=u.context||u,p=u.context&&(d.nodeType||d.jquery)?nt(d):nt.event,f=nt.Deferred(),g=nt.Callbacks("once memory"),m=u.statusCode||{},v={},b={},y=0,w="canceled",x={readyState:0,getResponseHeader:function(t){var e;if(2===y){if(!s)for(s={};e=ve.exec(r);)s[e[1].toLowerCase()]=e[2];e=s[t.toLowerCase()]}return null==e?null:e},getAllResponseHeaders:function(){return 2===y?r:null},setRequestHeader:function(t,e){var i=t.toLowerCase();return y||(t=b[i]=b[i]||t,v[t]=e),this},overrideMimeType:function(t){return y||(u.mimeType=t),this},statusCode:function(t){var e;if(t)if(y<2)for(e in t)m[e]=[m[e],t[e]];else x.always(t[x.status]);return this},abort:function(t){var e=t||w;return n&&n.abort(e),i(0,e),this}};if(f.promise(x).complete=g.add,x.success=x.done,x.error=x.fail,u.url=((t||u.url||Ee)+"").replace(ge,"").replace(we,ke[1]+"//"),u.type=e.method||e.type||u.method||u.type,u.dataTypes=nt.trim(u.dataType||"*").toLowerCase().match(vt)||[""],null==u.crossDomain&&(l=xe.exec(u.url.toLowerCase()),u.crossDomain=!(!l||l[1]===ke[1]&&l[2]===ke[2]&&(l[3]||("http:"===l[1]?"80":"443"))===(ke[3]||("http:"===ke[1]?"80":"443")))),u.data&&u.processData&&"string"!=typeof u.data&&(u.data=nt.param(u.data,u.traditional)),P(Ae,u,e,x),2===y)return x;h=nt.event&&u.global,h&&0===nt.active++&&nt.event.trigger("ajaxStart"),u.type=u.type.toUpperCase(),u.hasContent=!ye.test(u.type),o=u.url,u.hasContent||(u.data&&(o=u.url+=(fe.test(o)?"&":"?")+u.data,delete u.data),u.cache===!1&&(u.url=me.test(o)?o.replace(me,"$1_="+pe++):o+(fe.test(o)?"&":"?")+"_="+pe++)),u.ifModified&&(nt.lastModified[o]&&x.setRequestHeader("If-Modified-Since",nt.lastModified[o]),nt.etag[o]&&x.setRequestHeader("If-None-Match",nt.etag[o])),(u.data&&u.hasContent&&u.contentType!==!1||e.contentType)&&x.setRequestHeader("Content-Type",u.contentType),x.setRequestHeader("Accept",u.dataTypes[0]&&u.accepts[u.dataTypes[0]]?u.accepts[u.dataTypes[0]]+("*"!==u.dataTypes[0]?", "+Ce+"; q=0.01":""):u.accepts["*"]);for(c in u.headers)x.setRequestHeader(c,u.headers[c]);if(u.beforeSend&&(u.beforeSend.call(d,x,u)===!1||2===y))return x.abort();w="abort";for(c in{success:1,error:1,complete:1})x[c](u[c]);if(n=P(_e,u,e,x)){x.readyState=1,h&&p.trigger("ajaxSend",[x,u]),u.async&&u.timeout>0&&(a=setTimeout(function(){x.abort("timeout")},u.timeout));try{y=1,n.send(v,i)}catch(A){if(!(y<2))throw A;i(-1,A)}}else i(-1,"No Transport");return x},getJSON:function(t,e,i){return nt.get(t,e,i,"json")},getScript:function(t,e){return nt.get(t,void 0,e,"script")}}),nt.each(["get","post"],function(t,e){nt[e]=function(t,i,n,o){return nt.isFunction(i)&&(o=o||n,n=i,i=void 0),nt.ajax({url:t,type:e,dataType:o,data:i,success:n})}}),nt._evalUrl=function(t){return nt.ajax({url:t,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},nt.fn.extend({wrapAll:function(t){var e;return nt.isFunction(t)?this.each(function(e){nt(this).wrapAll(t.call(this,e))}):(this[0]&&(e=nt(t,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&e.insertBefore(this[0]),e.map(function(){for(var t=this;t.firstElementChild;)t=t.firstElementChild;return t}).append(this)),this)},wrapInner:function(t){return nt.isFunction(t)?this.each(function(e){nt(this).wrapInner(t.call(this,e))}):this.each(function(){var e=nt(this),i=e.contents();i.length?i.wrapAll(t):e.append(t)})},wrap:function(t){var e=nt.isFunction(t);return this.each(function(i){nt(this).wrapAll(e?t.call(this,i):t)})},unwrap:function(){return this.parent().each(function(){ -nt.nodeName(this,"body")||nt(this).replaceWith(this.childNodes)}).end()}}),nt.expr.filters.hidden=function(t){return t.offsetWidth<=0&&t.offsetHeight<=0},nt.expr.filters.visible=function(t){return!nt.expr.filters.hidden(t)};var Fe=/%20/g,De=/\[\]$/,Se=/\r?\n/g,Me=/^(?:submit|button|image|reset|file)$/i,Te=/^(?:input|select|textarea|keygen)/i;nt.param=function(t,e){var i,n=[],o=function(t,e){e=nt.isFunction(e)?e():null==e?"":e,n[n.length]=encodeURIComponent(t)+"="+encodeURIComponent(e)};if(void 0===e&&(e=nt.ajaxSettings&&nt.ajaxSettings.traditional),nt.isArray(t)||t.jquery&&!nt.isPlainObject(t))nt.each(t,function(){o(this.name,this.value)});else for(i in t)j(i,t[i],e,o);return n.join("&").replace(Fe,"+")},nt.fn.extend({serialize:function(){return nt.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var t=nt.prop(this,"elements");return t?nt.makeArray(t):this}).filter(function(){var t=this.type;return this.name&&!nt(this).is(":disabled")&&Te.test(this.nodeName)&&!Me.test(t)&&(this.checked||!Dt.test(t))}).map(function(t,e){var i=nt(this).val();return null==i?null:nt.isArray(i)?nt.map(i,function(t){return{name:e.name,value:t.replace(Se,"\r\n")}}):{name:e.name,value:i.replace(Se,"\r\n")}}).get()}}),nt.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(t){}};var Be=0,Le={},$e={0:200,1223:204},Re=nt.ajaxSettings.xhr();i.attachEvent&&i.attachEvent("onunload",function(){for(var t in Le)Le[t]()}),tt.cors=!!Re&&"withCredentials"in Re,tt.ajax=Re=!!Re,nt.ajaxTransport(function(t){var e;if(tt.cors||Re&&!t.crossDomain)return{send:function(i,n){var o,r=t.xhr(),s=++Be;if(r.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(o in t.xhrFields)r[o]=t.xhrFields[o];t.mimeType&&r.overrideMimeType&&r.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(o in i)r.setRequestHeader(o,i[o]);e=function(t){return function(){e&&(delete Le[s],e=r.onload=r.onerror=null,"abort"===t?r.abort():"error"===t?n(r.status,r.statusText):n($e[r.status]||r.status,r.statusText,"string"==typeof r.responseText?{text:r.responseText}:void 0,r.getAllResponseHeaders()))}},r.onload=e(),r.onerror=e("error"),e=Le[s]=e("abort");try{r.send(t.hasContent&&t.data||null)}catch(a){if(e)throw a}},abort:function(){e&&e()}}}),nt.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(t){return nt.globalEval(t),t}}}),nt.ajaxPrefilter("script",function(t){void 0===t.cache&&(t.cache=!1),t.crossDomain&&(t.type="GET")}),nt.ajaxTransport("script",function(t){if(t.crossDomain){var e,i;return{send:function(n,o){e=nt(" diff --git a/package.json b/package.json index 9edd57f0..9e60d723 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,12 @@ "jscs": "^3.0.7", "jsdoc": "^3.4.0", "style-loader": "^0.13.1", + "ts-loader": "^0.8.2", + "tslint": "^3.14.0", + "typescript": "^1.8.10", + "typings": "^1.3.2", "url-loader": "^0.5.7", - "webpack": "^1.13.1" + "webpack": "^1.13.1", + "webpack-fail-plugin": "^1.0.5" } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..503dfb67 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es5", + "sourceMap": true + }, + "files": [ + "./typings/index.d.ts", + "./nengo_gui/static/webpack.d.ts" + ] +} diff --git a/typings.json b/typings.json new file mode 100644 index 00000000..c97279dd --- /dev/null +++ b/typings.json @@ -0,0 +1,10 @@ +{ + "name": "nengo", + "dependencies": { + "d3": "registry:npm/d3#3.0.0+20160723033700" + }, + "globalDependencies": { + "jquery": "registry:dt/jquery#1.10.0+20160704162008", + "interact": "registry:dt/interact#1.0.25+20160613160313" + } +} diff --git a/webpack.config.js b/webpack.config.js index 61d04404..8a745539 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,7 +5,7 @@ module.exports = { context: __dirname, // Paths are relative to nengo_gui // Putting the entry point in a list is a workaround for this error: // Error: a dependency to an entry point is not allowed - entry: ['./nengo_gui/static/nengo.js'], + entry: ['./nengo_gui/static/nengo.ts'], output: { path: './nengo_gui/static/dist', filename: 'nengo.js', @@ -14,7 +14,7 @@ module.exports = { publicPath: '/static/dist/' // Fixes issue finding emitted files }, resolve: { - extensions: ['', '.js'] + extensions: ['', '.js', '.ts'] }, module: { loaders: [ @@ -28,14 +28,26 @@ module.exports = { { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader?name=./[hash].[ext]' - } + }, + { test: /\.tsx?$/, loader: 'ts-loader' } ] }, plugins: [ + require('webpack-fail-plugin'), new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', "window.jQuery": 'jquery', }) - ] + ], + ts: { + ignoreDiagnostics: [ + "2322", + "2339", + "2342", + "2345", + "2346", + "2403" + ] + } }