flammarion 0.0.14 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/flammarion.svg)](https://badge.fury.io/rb/flammarion)
4
4
 
5
5
  * [Source](https://github.com/zach-capalbo/flammarion)
6
- * [Documentation](http://zach-capalbo.github.io/flammarion/doc/)
6
+ * [Documentation](http://zach-capalbo.github.io/flammarion/doc/Flammarion)
7
7
 
8
8
  ## Overview
9
9
 
@@ -12,7 +12,7 @@ normally display to the command line in a slightly easier-to-access way.
12
12
 
13
13
  It is not intended to be a full fledged application development toolkit. It is
14
14
  intended instead for small scripts where you just want to show some information
15
- without going through too much trouble.
15
+ or buttons without going through too much trouble.
16
16
 
17
17
  ## Installation
18
18
 
@@ -28,7 +28,7 @@ gem install flammarion
28
28
 
29
29
  or add it to your Gemfile.
30
30
 
31
- ## Documentation
31
+ ## Tutorial
32
32
 
33
33
  The easiest way to use Flammarion, is similar to how you might use STDOUT:
34
34
 
@@ -76,9 +76,8 @@ f.button("Click Here!!!") {f.puts "You clicked the button!"}
76
76
  f.input("Placeholder > ") {|msg| f.puts "You wrote: #{msg['text'].light_magenta}"}
77
77
  ```
78
78
 
79
- The (_almost_) full [api documetaion](http://zach-capalbo.github.io/flammarion/doc/)
80
- is available at <http://zach-capalbo.github.io/flammarion/doc/>. See especially
81
- the [Writeable Module](http://zach-capalbo.github.io/flammarion/doc/Flammarion/Writeable.html)
79
+ The [api documetaion](http://zach-capalbo.github.io/flammarion/doc/Flammarion)
80
+ is available at <http://zach-capalbo.github.io/flammarion/doc/Flammarion>.
82
81
 
83
82
  ## Screenshots / Samples
84
83
 
@@ -96,7 +95,7 @@ icons = %w[thumbs-up meh-o bicycle gears star-o star] + [nil] * 5
96
95
  name = Faker::Name.name
97
96
  f.pane("contacts").button(name, right_icon:icons.sample, left_icon:icons.sample) do
98
97
  recipient = name
99
- f.subpane("numer").replace(name)
98
+ f.subpane("number").replace(name)
100
99
  end
101
100
  end
102
101
  ```
@@ -23,8 +23,14 @@ require_relative 'flammarion/revelator.rb'
23
23
  require_relative 'flammarion/about.rb'
24
24
  require_relative 'flammarion/engraving.rb'
25
25
 
26
- # This is the main namespace for Flammarion.
26
+ # This is the main namespace for Flammarion. You really need an {Engraving} to
27
+ # do anything useful. If you just want to test that everything is setup
28
+ # correctly, you can use {Flammarion.about}. You can find samples and
29
+ # screenshots at https://github.com/zach-capalbo/flammarion and some examples
30
+ # at https://github.com/zach-capalbo/flammarion/tree/master/examples
27
31
  # @see Engraving
28
32
  # @see Writeable
33
+ # @see https://github.com/zach-capalbo/flammarion
34
+ # @see https://github.com/zach-capalbo/flammarion/tree/master/examples
29
35
  module Flammarion
30
36
  end
@@ -1,10 +1,10 @@
1
1
  module Flammarion
2
2
 
3
3
  # The engraving class represents a window. It contains everything you need to
4
- # display on the screen and interacts with a user. An +Engraving+ contains
4
+ # display on the screen and interacts with a user. An {Engraving} contains
5
5
  # one or more panes, which are containers for writeable areas. Most of the
6
- # power of the panes comes from the +Writeable+ module, which is also included
7
- # in +Engraving+ (operating on the default pane) for convenience.
6
+ # power of the panes comes from the {Writeable} module, which is also included
7
+ # in {Engraving} (operating on the default pane) for convenience.
8
8
  # @see Writeable
9
9
  # @note Right now, there is no persistence of Engravings. Once it is closed,
10
10
  # everything is erased, and you'll need to set it up all over again.
@@ -12,8 +12,8 @@ module Flammarion
12
12
  # blank window, and then display that thing.
13
13
  class Engraving
14
14
  include Revelator
15
- attr_reader :chrome
16
- attr_accessor :callbacks, :sockets, :on_disconnect, :on_connect, :actions
15
+ attr_accessor :on_disconnect, :on_connect, :actions
16
+ attr_accessor :callbacks, :sockets # @api private
17
17
  include Writeable
18
18
 
19
19
  # Creates a new Engraving (i.e., a new display window)
@@ -56,7 +56,7 @@ module Flammarion
56
56
  sleep 1 until @sockets.empty?
57
57
  end
58
58
 
59
- # Is thie Engraving displayed on the screen.
59
+ # Is this Engraving displayed on the screen.
60
60
  def window_open?
61
61
  not @sockets.empty?
62
62
  end
@@ -1,10 +1,13 @@
1
1
  require_relative 'writeable.rb'
2
2
 
3
3
  module Flammarion
4
+ # A reference to some writeable area within the {Engraving}
4
5
  # @see Writeable
6
+ # @see Engraving
5
7
  class Pane
6
- attr_reader :pane_name
7
8
  include Writeable
9
+
10
+ # @api private
8
11
  def initialize(engraving, name, options = {})
9
12
  @engraving = engraving
10
13
  @pane_name = name
@@ -7,6 +7,7 @@ module Flammarion
7
7
  file_path = File.absolute_path(File.join(File.dirname(__FILE__), ".."))
8
8
  file_path = `cygpath -w '#{file_path}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
9
9
  resource = %[file\://#{file_path}/html/build/index.html]
10
+ resource = "http://localhost:4567/" if ENV["FLAMMARION_DEVELOPMENT"] == "true"
10
11
  chrome_path = CHROME_PATH
11
12
  chrome_path = `cygpath -u '#{CHROME_PATH}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
12
13
  Process.detach(spawn(chrome_path, %[--app=#{resource}?path=#{@window_id}&port=#{server.port}&title="#{options[:title] || "Flammarion%20Engraving"}"]))
@@ -1,3 +1,3 @@
1
1
  module Flammarion
2
- VERSION = "0.0.14"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,32 +1,47 @@
1
1
  module Flammarion
2
2
  module Writeable
3
+ # @api private
3
4
  attr_reader :engraving
5
+
6
+ # A way to retrieve the current value of a user interacterive component.
7
+ # @see Writeable#input
8
+ # @see Writeable#checkbox
9
+ # @see Writeable#dropdown
4
10
  class DeferredValue < Delegator
11
+ # @api private
5
12
  def initialize
6
13
  super @value
7
14
  end
15
+
16
+ # @api private
8
17
  def __setobj__(value)
9
18
  @value = value
10
19
  end
11
20
 
21
+ # @return [Object] the current value of the remote component
12
22
  def value
13
23
  @value
14
24
  end
15
25
 
26
+ # @api private
16
27
  def __getobj__
17
28
  @value
18
29
  end
19
30
 
31
+ # @return [String] a string representing the remote component's value
20
32
  def inspect
21
33
  "#R#{@value.inspect}"
22
34
  end
23
35
 
36
+ # @return [Boolean] true if the component is checked and false if it is
37
+ # not. Undefined if the component is not a checkbox.
24
38
  def checked?
25
39
  return @value
26
40
  end
27
41
  end
28
42
 
29
- class Spectrum
43
+ # A representation of a plot in a writeable area. See {Writeable#plot}
44
+ class Plot
30
45
  attr_reader :engraving
31
46
  def initialize(id, target, engraving)
32
47
  @id = id
@@ -105,20 +120,36 @@ module Flammarion
105
120
 
106
121
  # Creates a new plot to display single axis data
107
122
  # @param [Array<Number>] values A list of numbers to plot
108
- # @todo finish documenting options
109
- # @return [Spectrum] A Spectrum object for manipulation after creation.
123
+ # @macro add_options
124
+ # @option options [Integer] :number_of_ticks The number of tick marks to
125
+ # display across the bottom
126
+ # @option options [Integer] :tick_precision The number of digits after the
127
+ # decimal point to display next to the tick marks
128
+ # @option options [Float] :xstart (0.0) The starting value for the x-axis
129
+ # @option options [Float, String] :ystart ('min') The starting value for the
130
+ # y-axis. Can be 'min' to start at the minimum value.
131
+ # @option options [Boolean] :draw_zero (true) draw a line through y = 0
132
+ # @option options [Boolean] :draw_mark (false) place a + at each point on
133
+ # the line.
134
+ # @option options [Boolean] :draw_line (true) draw a line through all the
135
+ # points.
136
+ # @option options [Boolean] :fill (false) fill in the area between the curve
137
+ # and zero
138
+ # @note You can press 'a' while hovering the plot to reset the zoom.
139
+ # @return [Plot] A Plot object for manipulation after creation.
110
140
  def plot(values, options = {})
111
141
  id = @engraving.make_id
112
142
  send_json({action:'plot', data:values, id:id}.merge(options))
113
- return Spectrum.new(id, @pane_name, @engraving)
143
+ return Plot.new(id, @pane_name, @engraving)
114
144
  end
115
145
 
146
+ # Adds a pretty-printed, colorful display of data or code
116
147
  # @overload highlight(data, options)
117
148
  # Adds a pretty-printed, highlighted display of data
118
149
  # @param text [Hash, Array] A dataset to be displayed
119
150
  # @macro escape_options
120
151
  # @overload highlight(text, options)
121
- # Adds syntax-highlighted text or code to the writeable area
152
+ # Adds syntax-highlighted code to the writeable area
122
153
  # @param text [String] Code to be highlighed
123
154
  # @macro escape_options
124
155
  def highlight(text, options = {})
@@ -177,7 +208,7 @@ module Flammarion
177
208
  # which can be used to get the value at any time.
178
209
  # @param label [String] The displayed placeholder text for the input. This
179
210
  # does not set the actual value of the input field or the returned
180
- # +DeferredValue+. Use the +:value+ option for that.
211
+ # {DeferredValue}. Use the +:value+ option for that.
181
212
  # @option options [Boolean] :multiline (false) Creates a large text box if
182
213
  # true; otherwise creates a single line input box.
183
214
  # @option options [Boolean] :autoclear (false) Automatically clears the
@@ -186,7 +217,7 @@ module Flammarion
186
217
  # @option options [Boolean] :history (false) Keeps track of entered values,
187
218
  # letting the user choose betwen them with the up and down keys.
188
219
  # @option options [String] :value Sets the starting value of the field and
189
- # the returned +DeferredValue+.
220
+ # the returned {DeferredValue}.
190
221
  # @option options [Boolean] :once (false) If true, then the input box will
191
222
  # be converted into a normal line of text once the user has changed it.
192
223
  # The callback will still be called, but the user will no longer be able
@@ -216,7 +247,7 @@ module Flammarion
216
247
  # @param items [Array<#to_s>] The possible choices
217
248
  # @overload dropdown(items, options = {})
218
249
  # @return [DeferredValue] An object representing the currently selected
219
- # item, which can be converted to text using +#to_s+
250
+ # item, which can be retrieved using {DeferredValue#value}
220
251
  # @overload dropdown(item, options = {})
221
252
  # @yield [message_hash] Invokes the block every time the user selects a
222
253
  # different option. Current item text can be obtained from the +"text"+
@@ -228,7 +259,9 @@ module Flammarion
228
259
  @engraving.callbacks[id] = block
229
260
  else
230
261
  d = DeferredValue.new
231
- @engraving.callbacks[id] = Proc.new {|v| d.__setobj__ v["text"]}
262
+ d.__setobj__(items[0]) if items.is_a? Array
263
+ d.__setobj__(items[items.keys.first]) if items.is_a? Hash
264
+ @engraving.callbacks[id] = Proc.new {|v| d.__setobj__ v["value"]}
232
265
  return d
233
266
  end
234
267
  end
@@ -261,7 +294,7 @@ module Flammarion
261
294
  send_json({action:'break'}.merge(options))
262
295
  end
263
296
 
264
- # Adds raw html
297
+ # Renders raw html into the writeable area
265
298
  def html(data)
266
299
  send_json({action:'replace', text:data, raw:true})
267
300
  end
@@ -285,13 +318,21 @@ module Flammarion
285
318
  send_json({action: 'style', attribute: attribute, value: value})
286
319
  end
287
320
 
288
- # Will render the given Slim template into the pane
289
- # @param file [String] Path to the template file to render
321
+ # Will render the given Slim template into the Writeable area. This is
322
+ # useful for creating complex or custom application layouts components
323
+ # beyond what's built into Flammarion.
324
+ # @note If you just want to include html (or outut from another template
325
+ # engine, you can just use {#html})
326
+ # @param file [String] Path to the Slim file to render
327
+ # @see http://slim-lang.com/
290
328
  def template(file)
291
329
  data = Slim::Template.new(file).render
292
330
  send_json({action:'replace', text:data, raw:true})
293
331
  end
294
332
 
333
+ # Reloads a template every time the file changes. This is mostly just useful
334
+ # when developing a template file.
335
+ # @see #template
295
336
  def live_reload_template(file)
296
337
  FileWatcher.new(file).watch {|file| template(file) }
297
338
  end
@@ -342,7 +383,7 @@ module Flammarion
342
383
  # share the same scope, so you want to be careful with your naming.
343
384
  # @return [Pane] The newly created or already existing pane.
344
385
  # @macro pane_difference
345
- # @see pane
386
+ # @see #pane
346
387
  def subpane(name, options = {})
347
388
  send_json({action:'subpane', name:name}.merge(options))
348
389
  return Pane.new(@engraving, name)
@@ -354,18 +395,33 @@ module Flammarion
354
395
  # share the same scope, so you want to be careful with your naming.
355
396
  # @return [Pane] The newly created or already existing pane.
356
397
  # @macro pane_difference
357
- # @see pane
358
- # @see orientation=
398
+ # @see #pane
399
+ # @see #orientation=
359
400
  def pane(name, options = {})
360
401
  send_json({action:'addpane', name:name}.merge(options))
361
402
  return Pane.new(@engraving, name)
362
403
  end
363
404
 
405
+ # Changes the orientation of the panes within this Writeable area. If
406
+ # +orientation+ is +:vertical+ (the default), the panes will be stacked on
407
+ # top of each other, each occupying 1/nth of the height (where n is the
408
+ # number of panes) and 100% of the width. If +orientation+ is +:horizontal+,
409
+ # the panes will be placed next to each other, with each pane occupying 1/n of
410
+ # the width (where n is the number of panes) and 100% of the heigh.
411
+ # @note This applies only to panes, not to subpanes.
412
+ # @see #pane
413
+ # @param orientation [Symbol] can be +:horizontal+ or +:vertical+
414
+ # @raise ArgumentError if the orientation is not one of the allowed values
364
415
  def orientation=(orientation)
365
416
  raise ArgumentError.new("Orientation must be :horizontal or :vertical") unless [:horizontal, :vertical].include?(orientation)
366
417
  send_json({action:'reorient', orientation:orientation})
367
418
  end
368
419
 
420
+ # Pops up a little floating writeable pane for buttons and stuff.
421
+ # @overload button_box()
422
+ # @return [Pane] The {Writeable} associated with the button box
423
+ # @overload button_box(name)
424
+ # @deprecated
369
425
  def button_box(name = "buttonbox")
370
426
  send_json({action:'buttonbox', name:name})
371
427
  return Pane.new(@engraving, name)
@@ -383,14 +439,25 @@ module Flammarion
383
439
  @engraving.send_json({action:'status', text: str}.merge(options))
384
440
  end
385
441
 
442
+ # Displays a table of data
443
+ # @param rows [Array<Array<#to_s>>] an array of rows, where each row is an
444
+ # array of objects which will be converted to a string and diplayed in the
445
+ # table.
446
+ # @macro escape_options
447
+ # @option options [Array<#to_s>] :headers An array of column headers to put
448
+ # at the top of the table.
449
+ # @option options [Boolean] :interactive (true) Allows the user to mouse
450
+ # over the table and have it styled. Set to false if you experience
451
+ # performance issues with large datasets.
386
452
  def table(rows, options = {})
387
453
  send_json({action:'table', rows: rows}.merge(options))
388
454
  end
389
455
 
390
456
  # Prompts the user for a sting. Blocks until a string has been entered.
391
457
  # @param prompt [String] A prompt to tell the user what to input.
392
- # @param options (See #input)
458
+ # @param options Same as {#input}
393
459
  # @return [String] The text that the user has entered.
460
+ # @see #input
394
461
  def gets(prompt = "", options = {})
395
462
  str = nil
396
463
  input(prompt, {once:true, focus:true}.merge(options)) {|msg| str = msg["text"]}
@@ -432,6 +499,7 @@ module Flammarion
432
499
  send_json({action:'map'}.merge(options))
433
500
  end
434
501
 
502
+ # Searches for and highlights the string in the engraving.
435
503
  def search(string)
436
504
  send_json({action:'search', text: string})
437
505
  end
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type" /><meta charset="utf-8" /><meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" /><meta content="width=device-width, initial-scale=1.0" name="viewport" /><title>Flammarion</title><link href="stylesheets/all.css" rel="stylesheet" type="text/css" /><script src="javascripts/all.js" type="text/javascript"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="hidden" id="toolbar"><a class="tool-button" href="#">Open</a><a class="tool-button" href="#">Save</a></div><div id="panes"><pre class="pane" id="console-default" style="height:100%"></pre></div><div class="hidden" id="dialog"><div id="content"><pre id="message">Hi World</pre><a class="full-button" href="#" id="ok">Ok</a></div></div><div id="status"><div class="left"></div><div class="center"></div><div class="right"></div></div><div class="hidden" id="searchbar"><i class="fa fa-search"></i><input /></div></body></html>
1
+ <!DOCTYPE html><html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type" /><meta charset="utf-8" /><meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" /><meta content="width=device-width, initial-scale=1.0" name="viewport" /><title>Flammarion</title><link href="stylesheets/all.css" rel="stylesheet" type="text/css" /><script src="javascripts/all.js" type="text/javascript"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="hidden" id="toolbar"><a class="tool-button" href="#">Open</a><a class="tool-button" href="#">Save</a></div><div id="panes"><pre class="pane" id="console-default" style="height:100%"></pre></div><div class="hidden" id="dialog"><div id="content"><pre id="message">Hi World</pre><a class="full-button" href="#" id="ok">Ok</a></div></div><div id="status"><div class="left"></div><div class="center"></div><div class="right"></div></div><div class="hidden" id="searchbar"><i class="fa fa-search"></i><input /></div><div class="hidden" id="plot-style"><div class="tickmarks"></div><div class="markers"></div><div class="zero"></div></div></body></html>
@@ -7177,20 +7177,37 @@ if (typeof module !== 'undefined') {
7177
7177
  return target.append(element);
7178
7178
  },
7179
7179
  dropdown: function(data) {
7180
- var element, item, j, len, ref, target;
7180
+ var element, item, j, k, len, option, ref, ref1, target, v;
7181
7181
  target = this.__parent.check_target(data);
7182
7182
  element = $("<select class='inline-dropdown' name='" + data.id + "'></select>");
7183
- ref = data.options;
7184
- for (j = 0, len = ref.length; j < len; j++) {
7185
- item = ref[j];
7186
- element.append($("<option>" + item + "</option>"));
7183
+ console.log(data.options);
7184
+ if (data.options instanceof Array) {
7185
+ ref = data.options;
7186
+ for (j = 0, len = ref.length; j < len; j++) {
7187
+ item = ref[j];
7188
+ element.append($("<option>" + item + "</option>"));
7189
+ }
7190
+ } else {
7191
+ ref1 = data.options;
7192
+ for (k in ref1) {
7193
+ v = ref1[k];
7194
+ option = $("<option>" + k + "</option>");
7195
+ option.val(JSON.stringify(v));
7196
+ element.append(option);
7197
+ }
7187
7198
  }
7188
7199
  element.change((function(_this) {
7189
7200
  return function(e) {
7201
+ var val;
7202
+ val = element.find('option:selected').text();
7203
+ if (element.find('option:selected')[0].value) {
7204
+ val = $.parseJSON(element.find('option:selected')[0].value);
7205
+ }
7190
7206
  return _this.__parent.send({
7191
7207
  id: data.id,
7192
7208
  action: 'callback',
7193
7209
  source: 'dropdown',
7210
+ value: val,
7194
7211
  text: element.find('option:selected').text()
7195
7212
  });
7196
7213
  };
@@ -7281,9 +7298,9 @@ if (typeof module !== 'undefined') {
7281
7298
  }
7282
7299
  });
7283
7300
 
7284
- Plot = (function() {
7285
- Plot.prototype.default_options = {
7286
- color: $(document.body).css("color"),
7301
+ $(document).ready(function() {
7302
+ return Plot.prototype.default_options = {
7303
+ color: $('#plot-style').css("color"),
7287
7304
  replace: true,
7288
7305
  size: 1.0,
7289
7306
  orientation: 'vertical',
@@ -7291,16 +7308,22 @@ if (typeof module !== 'undefined') {
7291
7308
  yscale: 1.0,
7292
7309
  tick_height: 15,
7293
7310
  number_of_ticks: 10,
7294
- tick_color: "rgba(255,255,255,0.5)",
7311
+ tick_color: $("#plot-style > .tickmarks").css("color"),
7295
7312
  tick_precision: 2,
7296
7313
  id: "spec0",
7297
7314
  draw_zero: true,
7298
7315
  fill_color: null,
7299
7316
  draw_line: true,
7300
7317
  draw_marker: false,
7301
- marker_color: '#88F'
7318
+ marker_color: $("#plot-style > .markers").css("color"),
7319
+ ystart: 'min',
7320
+ fill: false,
7321
+ fill_color: $('#plot-style').css("background-color"),
7322
+ zero_color: $('#plot-style > .zero').css("color")
7302
7323
  };
7324
+ });
7303
7325
 
7326
+ Plot = (function() {
7304
7327
  Plot.prototype.parse_property = function(prop) {
7305
7328
  return parseInt(prop.slice(0, -1));
7306
7329
  };
@@ -7329,7 +7352,7 @@ if (typeof module !== 'undefined') {
7329
7352
  mouse_x_value = relative_x_pos * this.xscaled_end_value + (1.0 - relative_x_pos) * this.xscaled_start_value;
7330
7353
  mouse_x_value = mouse_x_value * this.xvalue_scale;
7331
7354
  mouse_y_value = relative_y_pos * this.yscaled_end_value + (1.0 - relative_y_pos) * this.yscaled_start_value;
7332
- this.mouse_element.text((mouse_x_value.toFixed(2)) + ". " + (mouse_y_value.toFixed(2)));
7355
+ this.mouse_element.text((mouse_x_value.toFixed(2)) + ", " + (mouse_y_value.toFixed(2)));
7333
7356
  if (this.mouse_is_down) {
7334
7357
  return this.move_zoom(event);
7335
7358
  }
@@ -7367,7 +7390,6 @@ if (typeof module !== 'undefined') {
7367
7390
  relative_yend_pos = 1.0 - (zoom_yend_pixel / this.plot_height);
7368
7391
  zoom_ystart_value = relative_ystart_pos * this.yscaled_end_value + (1.0 - relative_ystart_pos) * this.yscaled_start_value;
7369
7392
  zoom_yend_value = relative_yend_pos * this.yscaled_end_value + (1.0 - relative_yend_pos) * this.yscaled_start_value;
7370
- console.log(zoom_ystart_value, zoom_yend_value);
7371
7393
  return this.zoom_to(zoom_xstart_value, zoom_xend_value, zoom_ystart_value, zoom_yend_value);
7372
7394
  };
7373
7395
 
@@ -7474,11 +7496,14 @@ if (typeof module !== 'undefined') {
7474
7496
  this.ctx.moveTo(this.x_value_to_pixel(0), this.y_value_to_pixel(data[0]));
7475
7497
  this.ctx.closePath();
7476
7498
  this.ctx.fillStyle = this.options.fill_color;
7477
- if (this.options.fill_color) {
7499
+ if (this.options.fill_color && this.options.fill) {
7478
7500
  this.ctx.fill();
7479
7501
  }
7480
7502
  this.ctx.stroke();
7481
- return this.draw_ticks();
7503
+ this.draw_ticks();
7504
+ if (this.options.draw_zero) {
7505
+ return this.draw_zero();
7506
+ }
7482
7507
  };
7483
7508
 
7484
7509
  Plot.prototype.draw_ticks = function() {
@@ -7510,6 +7535,14 @@ if (typeof module !== 'undefined') {
7510
7535
  return this.ctx.stroke();
7511
7536
  };
7512
7537
 
7538
+ Plot.prototype.draw_zero = function() {
7539
+ this.ctx.strokeStyle = this.options.zero_color;
7540
+ this.ctx.beginPath();
7541
+ this.ctx.moveTo(0, this.y_value_to_pixel(0));
7542
+ this.ctx.lineTo(this.canvas_width, this.y_value_to_pixel(0));
7543
+ return this.ctx.stroke();
7544
+ };
7545
+
7513
7546
  Plot.prototype.update = function(data) {
7514
7547
  this.data = data.data;
7515
7548
  $.extend(this.options, data);
@@ -357,20 +357,37 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
357
357
  return target.append(element);
358
358
  },
359
359
  dropdown: function(data) {
360
- var element, item, j, len, ref, target;
360
+ var element, item, j, k, len, option, ref, ref1, target, v;
361
361
  target = this.__parent.check_target(data);
362
362
  element = $("<select class='inline-dropdown' name='" + data.id + "'></select>");
363
- ref = data.options;
364
- for (j = 0, len = ref.length; j < len; j++) {
365
- item = ref[j];
366
- element.append($("<option>" + item + "</option>"));
363
+ console.log(data.options);
364
+ if (data.options instanceof Array) {
365
+ ref = data.options;
366
+ for (j = 0, len = ref.length; j < len; j++) {
367
+ item = ref[j];
368
+ element.append($("<option>" + item + "</option>"));
369
+ }
370
+ } else {
371
+ ref1 = data.options;
372
+ for (k in ref1) {
373
+ v = ref1[k];
374
+ option = $("<option>" + k + "</option>");
375
+ option.val(JSON.stringify(v));
376
+ element.append(option);
377
+ }
367
378
  }
368
379
  element.change((function(_this) {
369
380
  return function(e) {
381
+ var val;
382
+ val = element.find('option:selected').text();
383
+ if (element.find('option:selected')[0].value) {
384
+ val = $.parseJSON(element.find('option:selected')[0].value);
385
+ }
370
386
  return _this.__parent.send({
371
387
  id: data.id,
372
388
  action: 'callback',
373
389
  source: 'dropdown',
390
+ value: val,
374
391
  text: element.find('option:selected').text()
375
392
  });
376
393
  };
@@ -23,9 +23,9 @@
23
23
  }
24
24
  });
25
25
 
26
- Plot = (function() {
27
- Plot.prototype.default_options = {
28
- color: $(document.body).css("color"),
26
+ $(document).ready(function() {
27
+ return Plot.prototype.default_options = {
28
+ color: $('#plot-style').css("color"),
29
29
  replace: true,
30
30
  size: 1.0,
31
31
  orientation: 'vertical',
@@ -33,16 +33,22 @@
33
33
  yscale: 1.0,
34
34
  tick_height: 15,
35
35
  number_of_ticks: 10,
36
- tick_color: "rgba(255,255,255,0.5)",
36
+ tick_color: $("#plot-style > .tickmarks").css("color"),
37
37
  tick_precision: 2,
38
38
  id: "spec0",
39
39
  draw_zero: true,
40
40
  fill_color: null,
41
41
  draw_line: true,
42
42
  draw_marker: false,
43
- marker_color: '#88F'
43
+ marker_color: $("#plot-style > .markers").css("color"),
44
+ ystart: 'min',
45
+ fill: false,
46
+ fill_color: $('#plot-style').css("background-color"),
47
+ zero_color: $('#plot-style > .zero').css("color")
44
48
  };
49
+ });
45
50
 
51
+ Plot = (function() {
46
52
  Plot.prototype.parse_property = function(prop) {
47
53
  return parseInt(prop.slice(0, -1));
48
54
  };
@@ -71,7 +77,7 @@
71
77
  mouse_x_value = relative_x_pos * this.xscaled_end_value + (1.0 - relative_x_pos) * this.xscaled_start_value;
72
78
  mouse_x_value = mouse_x_value * this.xvalue_scale;
73
79
  mouse_y_value = relative_y_pos * this.yscaled_end_value + (1.0 - relative_y_pos) * this.yscaled_start_value;
74
- this.mouse_element.text((mouse_x_value.toFixed(2)) + ". " + (mouse_y_value.toFixed(2)));
80
+ this.mouse_element.text((mouse_x_value.toFixed(2)) + ", " + (mouse_y_value.toFixed(2)));
75
81
  if (this.mouse_is_down) {
76
82
  return this.move_zoom(event);
77
83
  }
@@ -109,7 +115,6 @@
109
115
  relative_yend_pos = 1.0 - (zoom_yend_pixel / this.plot_height);
110
116
  zoom_ystart_value = relative_ystart_pos * this.yscaled_end_value + (1.0 - relative_ystart_pos) * this.yscaled_start_value;
111
117
  zoom_yend_value = relative_yend_pos * this.yscaled_end_value + (1.0 - relative_yend_pos) * this.yscaled_start_value;
112
- console.log(zoom_ystart_value, zoom_yend_value);
113
118
  return this.zoom_to(zoom_xstart_value, zoom_xend_value, zoom_ystart_value, zoom_yend_value);
114
119
  };
115
120
 
@@ -216,11 +221,14 @@
216
221
  this.ctx.moveTo(this.x_value_to_pixel(0), this.y_value_to_pixel(data[0]));
217
222
  this.ctx.closePath();
218
223
  this.ctx.fillStyle = this.options.fill_color;
219
- if (this.options.fill_color) {
224
+ if (this.options.fill_color && this.options.fill) {
220
225
  this.ctx.fill();
221
226
  }
222
227
  this.ctx.stroke();
223
- return this.draw_ticks();
228
+ this.draw_ticks();
229
+ if (this.options.draw_zero) {
230
+ return this.draw_zero();
231
+ }
224
232
  };
225
233
 
226
234
  Plot.prototype.draw_ticks = function() {
@@ -252,6 +260,14 @@
252
260
  return this.ctx.stroke();
253
261
  };
254
262
 
263
+ Plot.prototype.draw_zero = function() {
264
+ this.ctx.strokeStyle = this.options.zero_color;
265
+ this.ctx.beginPath();
266
+ this.ctx.moveTo(0, this.y_value_to_pixel(0));
267
+ this.ctx.lineTo(this.canvas_width, this.y_value_to_pixel(0));
268
+ return this.ctx.stroke();
269
+ };
270
+
255
271
  Plot.prototype.update = function(data) {
256
272
  this.data = data.data;
257
273
  $.extend(this.options, data);
@@ -665,6 +665,11 @@ html {
665
665
  height: 100%;
666
666
  width: 100%;
667
667
  overflow: hidden;
668
+ padding: 2px;
669
+ padding-bottom: 0px;
670
+ height: calc(100% - 2px);
671
+ width: calc(100% - 4px);
672
+ box-shadow: inset 0px 0px 2px 2px #bebebe;
668
673
  }
669
674
  a {
670
675
  text-decoration: none;
@@ -708,34 +713,10 @@ p a:hover {
708
713
  width: 100%;
709
714
  box-sizing: border-box;
710
715
  }
711
- html {
712
- padding-top: 2px;
713
- box-shadow: inset 0px 0px 2px 2px #bebebe;
714
- }
715
716
  .horizontal > .pane {
716
717
  height: 100%;
717
718
  float: left;
718
719
  }
719
- .plot {
720
- width: 100%;
721
- height: 100%;
722
- border: 1px solid #333;
723
- margin: -1px;
724
- overflow: none;
725
- }
726
- #plot-mouseover {
727
- position: absolute;
728
- background-color: rgba(0,0,0,0.5);
729
- color: #333;
730
- pointer-events: none;
731
- font-family: Monospace;
732
- }
733
- #plot-zoom-element {
734
- position: absolute;
735
- background-color: rgba(0,3,10,0.75);
736
- pointer-events: none;
737
- border: 1px solid #012;
738
- }
739
720
  hr {
740
721
  width: 95%;
741
722
  background-color: #333;
@@ -3318,6 +3299,41 @@ hr {
3318
3299
  max-width: 45em;
3319
3300
  margin: auto;
3320
3301
  }
3302
+ .plot {
3303
+ width: 100%;
3304
+ height: 100%;
3305
+ border: 1px solid #333;
3306
+ margin: -1px;
3307
+ overflow: none;
3308
+ }
3309
+ #plot-mouseover {
3310
+ position: absolute;
3311
+ background-color: rgba(190,190,190,0.5);
3312
+ color: #333;
3313
+ pointer-events: none;
3314
+ font-family: Monospace;
3315
+ padding: 0.25em;
3316
+ box-shadow: 2px 2px 4px 2px #bebebe;
3317
+ }
3318
+ #plot-zoom-element {
3319
+ position: absolute;
3320
+ background-color: rgba(0,3,10,0.75);
3321
+ pointer-events: none;
3322
+ border: 1px solid #012;
3323
+ }
3324
+ #plot-style {
3325
+ color: #333;
3326
+ background-color: #d6d6d6;
3327
+ }
3328
+ #plot-style .tickmarks {
3329
+ color: #707070;
3330
+ }
3331
+ #plot-style .markers {
3332
+ color: #707070;
3333
+ }
3334
+ #plot-style .zero {
3335
+ color: rgba(190,190,190,0.75);
3336
+ }
3321
3337
  ::-webkit-scrollbar {
3322
3338
  width: 0.666em;
3323
3339
  height: 0.666em;
@@ -19,6 +19,11 @@ html {
19
19
  height: 100%;
20
20
  width: 100%;
21
21
  overflow: hidden;
22
+ padding: 2px;
23
+ padding-bottom: 0px;
24
+ height: calc(100% - 2px);
25
+ width: calc(100% - 4px);
26
+ box-shadow: inset 0px 0px 2px 2px #bebebe;
22
27
  }
23
28
  a {
24
29
  text-decoration: none;
@@ -62,34 +67,10 @@ p a:hover {
62
67
  width: 100%;
63
68
  box-sizing: border-box;
64
69
  }
65
- html {
66
- padding-top: 2px;
67
- box-shadow: inset 0px 0px 2px 2px #bebebe;
68
- }
69
70
  .horizontal > .pane {
70
71
  height: 100%;
71
72
  float: left;
72
73
  }
73
- .plot {
74
- width: 100%;
75
- height: 100%;
76
- border: 1px solid #333;
77
- margin: -1px;
78
- overflow: none;
79
- }
80
- #plot-mouseover {
81
- position: absolute;
82
- background-color: rgba(0,0,0,0.5);
83
- color: #333;
84
- pointer-events: none;
85
- font-family: Monospace;
86
- }
87
- #plot-zoom-element {
88
- position: absolute;
89
- background-color: rgba(0,3,10,0.75);
90
- pointer-events: none;
91
- border: 1px solid #012;
92
- }
93
74
  hr {
94
75
  width: 95%;
95
76
  background-color: #333;
@@ -0,0 +1,35 @@
1
+ .plot {
2
+ width: 100%;
3
+ height: 100%;
4
+ border: 1px solid #333;
5
+ margin: -1px;
6
+ overflow: none;
7
+ }
8
+ #plot-mouseover {
9
+ position: absolute;
10
+ background-color: rgba(190,190,190,0.5);
11
+ color: #333;
12
+ pointer-events: none;
13
+ font-family: Monospace;
14
+ padding: 0.25em;
15
+ box-shadow: 2px 2px 4px 2px #bebebe;
16
+ }
17
+ #plot-zoom-element {
18
+ position: absolute;
19
+ background-color: rgba(0,3,10,0.75);
20
+ pointer-events: none;
21
+ border: 1px solid #012;
22
+ }
23
+ #plot-style {
24
+ color: #333;
25
+ background-color: #d6d6d6;
26
+ }
27
+ #plot-style .tickmarks {
28
+ color: #707070;
29
+ }
30
+ #plot-style .markers {
31
+ color: #707070;
32
+ }
33
+ #plot-style .zero {
34
+ color: rgba(190,190,190,0.75);
35
+ }
@@ -32,3 +32,7 @@ html
32
32
  #searchbar.hidden
33
33
  i.fa.fa-search
34
34
  input
35
+ #plot-style.hidden
36
+ .tickmarks
37
+ .markers
38
+ .zero
@@ -106,12 +106,23 @@ $.extend WSClient.prototype.actions,
106
106
  dropdown: (data) ->
107
107
  target = @__parent.check_target(data)
108
108
  element = $("<select class='inline-dropdown' name='#{data.id}'></select>")
109
- element.append($("<option>#{item}</option>")) for item in data.options
109
+ console.log data.options
110
+ if data.options instanceof Array
111
+ element.append($("<option>#{item}</option>")) for item in data.options
112
+ else
113
+ for k, v of data.options
114
+ option = $("<option>#{k}</option>")
115
+ option.val(JSON.stringify(v))
116
+ element.append(option)
110
117
  element.change (e) =>
118
+ val = element.find('option:selected').text()
119
+ if element.find('option:selected')[0].value
120
+ val = $.parseJSON(element.find('option:selected')[0].value)
111
121
  @__parent.send({
112
122
  id:data.id
113
123
  action:'callback'
114
124
  source:'dropdown'
125
+ value: val
115
126
  text: element.find('option:selected').text()
116
127
  })
117
128
  @__parent.add(element, target, data)
@@ -11,25 +11,30 @@ $.extend WSClient.prototype.actions,
11
11
  else
12
12
  @__plots[data.id] = new Plot(target, @__parent, data)
13
13
 
14
- class Plot
15
- default_options:
16
- color: $(document.body).css("color")
17
- replace: true
18
- size: 1.0
19
- orientation: 'vertical'
20
- xscale: 1.0
21
- yscale: 1.0
22
- tick_height: 15
23
- number_of_ticks: 10
24
- tick_color: "rgba(255,255,255,0.5)"
25
- tick_precision: 2
26
- id: "spec0"
27
- draw_zero: true
28
- fill_color: null
29
- draw_line: true
30
- draw_marker: false
31
- marker_color: '#88F'
14
+ $(document).ready ->
15
+ Plot.prototype.default_options =
16
+ color: $('#plot-style').css("color")
17
+ replace: true
18
+ size: 1.0
19
+ orientation: 'vertical'
20
+ xscale: 1.0
21
+ yscale: 1.0
22
+ tick_height: 15
23
+ number_of_ticks: 10
24
+ tick_color: $("#plot-style > .tickmarks").css("color")
25
+ tick_precision: 2
26
+ id: "spec0"
27
+ draw_zero: true
28
+ fill_color: null
29
+ draw_line: true
30
+ draw_marker: false
31
+ marker_color: $("#plot-style > .markers").css("color")
32
+ ystart: 'min'
33
+ fill: false
34
+ fill_color: $('#plot-style').css("background-color")
35
+ zero_color: $('#plot-style > .zero').css("color")
32
36
 
37
+ class Plot
33
38
  parse_property: (prop) ->
34
39
  parseInt(prop.slice(0, -1))
35
40
 
@@ -54,7 +59,7 @@ class Plot
54
59
  mouse_x_value = relative_x_pos * @xscaled_end_value + (1.0 - relative_x_pos) * @xscaled_start_value
55
60
  mouse_x_value = mouse_x_value * @xvalue_scale
56
61
  mouse_y_value = relative_y_pos * @yscaled_end_value + (1.0 - relative_y_pos) * @yscaled_start_value
57
- @mouse_element.text "#{mouse_x_value.toFixed(2)}. #{mouse_y_value.toFixed(2)}"
62
+ @mouse_element.text "#{mouse_x_value.toFixed(2)}, #{mouse_y_value.toFixed(2)}"
58
63
 
59
64
  @move_zoom(event) if @mouse_is_down
60
65
 
@@ -94,7 +99,7 @@ class Plot
94
99
  zoom_ystart_value = relative_ystart_pos * @yscaled_end_value + (1.0 - relative_ystart_pos) * @yscaled_start_value
95
100
  zoom_yend_value = relative_yend_pos * @yscaled_end_value + (1.0 - relative_yend_pos) * @yscaled_start_value
96
101
 
97
- console.log zoom_ystart_value, zoom_yend_value
102
+ # console.log zoom_ystart_value, zoom_yend_value
98
103
 
99
104
  @zoom_to(zoom_xstart_value, zoom_xend_value, zoom_ystart_value, zoom_yend_value)
100
105
 
@@ -178,9 +183,10 @@ class Plot
178
183
  @ctx.closePath()
179
184
 
180
185
  @ctx.fillStyle = @options.fill_color
181
- @ctx.fill() if @options.fill_color
186
+ @ctx.fill() if @options.fill_color and @options.fill
182
187
  @ctx.stroke()
183
188
  @draw_ticks()
189
+ @draw_zero() if @options.draw_zero
184
190
 
185
191
  draw_ticks: ->
186
192
  @ctx.font = "#{@options.tick_height - 3}px Monospace";
@@ -210,6 +216,13 @@ class Plot
210
216
  @ctx.lineTo(@canvas_width, @plot_height)
211
217
  @ctx.stroke()
212
218
 
219
+ draw_zero: ->
220
+ @ctx.strokeStyle = @options.zero_color
221
+ @ctx.beginPath()
222
+ @ctx.moveTo(0, @y_value_to_pixel(0))
223
+ @ctx.lineTo(@canvas_width, @y_value_to_pixel(0))
224
+ @ctx.stroke()
225
+
213
226
  update: (data) ->
214
227
  @data = data.data
215
228
  $.extend @options, data
@@ -18,6 +18,13 @@ html
18
18
  width 100%
19
19
  overflow hidden
20
20
 
21
+ if $enable-gradients
22
+ padding 2px
23
+ padding-bottom 0px
24
+ height calc(100% - 2px)
25
+ width calc(100% - 4px)
26
+ box-shadow-inset()
27
+
21
28
  a
22
29
  text-decoration none
23
30
  p &
@@ -52,35 +59,10 @@ a
52
59
  width 100%
53
60
  box-sizing: border-box
54
61
 
55
- html
56
- if $enable-gradients
57
- padding-top 2px
58
- box-shadow-inset()
59
-
60
62
  .horizontal > .pane
61
63
  height 100%
62
64
  float left
63
65
 
64
- .plot
65
- width 100%
66
- height 100%
67
- border 1px solid #333
68
- margin -1px
69
- overflow none
70
-
71
- #plot-mouseover
72
- position absolute
73
- background-color rgba(0, 0, 0, 0.5)
74
- color $fg-color
75
- pointer-events none
76
- font-family Monospace
77
-
78
- #plot-zoom-element
79
- position absolute
80
- background-color rgba(0, 3, 10, 0.75)
81
- pointer-events none
82
- border 1px solid #012
83
-
84
66
  hr
85
67
  width 95%
86
68
  background-color $fg-color
@@ -0,0 +1,36 @@
1
+ @import "mixins.styl"
2
+ @import "colors.styl"
3
+
4
+ .plot
5
+ width 100%
6
+ height 100%
7
+ border 1px solid #333
8
+ margin -1px
9
+ overflow none
10
+
11
+ #plot-mouseover
12
+ position absolute
13
+ background-color rgba($active-highlight, 0.5)
14
+ color $fg-color
15
+ pointer-events none
16
+ font-family Monospace
17
+ padding 0.25em
18
+ drop-shadow()
19
+
20
+ #plot-zoom-element
21
+ position absolute
22
+ background-color rgba(0, 3, 10, 0.75)
23
+ pointer-events none
24
+ border 1px solid #012
25
+
26
+ // Note: You have to add a div with each of these to
27
+ // index.html.slim for this to take effect.
28
+ #plot-style
29
+ color $fg-color
30
+ background-color activate($bg-color, 10%)
31
+ & .tickmarks
32
+ color activate($fg-color, 30%)
33
+ & .markers
34
+ color activate($fg-color, 30%)
35
+ & .zero
36
+ color rgba(activate($bg-color, 20%), 0.75)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flammarion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-21 00:00:00.000000000 Z
12
+ date: 2016-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: em-websocket
@@ -183,6 +183,7 @@ files:
183
183
  - lib/html/source/layouts/layout.erb
184
184
  - lib/html/source/stylesheets/scrollbar.styl
185
185
  - lib/html/source/stylesheets/normalize.bak
186
+ - lib/html/source/stylesheets/plot.styl
186
187
  - lib/html/source/stylesheets/leaflet.css
187
188
  - lib/html/source/stylesheets/buttons.styl
188
189
  - lib/html/source/stylesheets/all.css
@@ -242,6 +243,7 @@ files:
242
243
  - lib/html/build/stylesheets/map.css
243
244
  - lib/html/build/stylesheets/buttons.css
244
245
  - lib/html/build/stylesheets/code.css
246
+ - lib/html/build/stylesheets/plot.css
245
247
  - lib/html/build/stylesheets/status.css
246
248
  - lib/html/build/stylesheets/ansi_colors.css
247
249
  - lib/html/build/stylesheets/font-awesome/HELP-US-OUT.txt