From 7150f70333e63104cf1a25826d4d6c5491314e3e Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:16:28 -0800 Subject: [PATCH 01/66] editor stats package genesis --- src/packages/editor-stats/index.coffee | 9 +++ .../editor-stats/src/editor-stats-view.coffee | 58 +++++++++++++++++++ .../editor-stats/stylesheets/editor-stats.css | 9 +++ 3 files changed, 76 insertions(+) create mode 100644 src/packages/editor-stats/index.coffee create mode 100644 src/packages/editor-stats/src/editor-stats-view.coffee create mode 100644 src/packages/editor-stats/stylesheets/editor-stats.css diff --git a/src/packages/editor-stats/index.coffee b/src/packages/editor-stats/index.coffee new file mode 100644 index 000000000..60a97582e --- /dev/null +++ b/src/packages/editor-stats/index.coffee @@ -0,0 +1,9 @@ +DeferredAtomPackage = require 'deferred-atom-package' + +module.exports = +class EditorStats extends DeferredAtomPackage + loadEvents: ['editor-stats:toggle'] + + instanceClass: 'editor-stats/src/editor-stats-view' + + onLoadEvent: (event, instance) -> instance.toggle() diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee new file mode 100644 index 000000000..480a34017 --- /dev/null +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -0,0 +1,58 @@ +{$$$} = require 'space-pen' +ScrollView = require 'scroll-view' +$ = require 'jquery' +_ = require 'underscore' + +module.exports = +class EditorStatsView extends ScrollView + time = (date) -> + date.setTime(date.getTime() + 6e4) + hour = date.getHours() + minute = date.getMinutes() + "#{hour}:#{minute}" + + @activate: (rootView, state) -> + @instance = new EditorStatsView(rootView, state?.eventLog) + + @content: (rootView) -> + @div class: 'editor-stats', tabindex: -1 + + @serialize: -> + @instance.serialize() + + eventlog: [], + + initialize: (@rootView, @eventLog = {}) -> + super + + date = new Date() + future = new Date(date.getTime() + 36e5) + @eventlog[time(date)] = 0 + + while date <= future + @eventlog[time(date)] = 0 + + @rootView.on 'keyup', @track + @rootView.on 'mousedown', @track + + track: => + date = new Date + @eventlog[time(date)] += 1 + console.log @eventlog + + toggle: -> + if @hasParent() + @detach() + else + @attach() + + attach: -> + @rootView.append @ + @focus() + + detach: -> + super() + @rootView.focus() + + serialize: -> + eventLog: @eventLog \ No newline at end of file diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css new file mode 100644 index 000000000..827da6667 --- /dev/null +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -0,0 +1,9 @@ +.editor-stats { + position: absolute; + height: 200px; + width: 100%; + bottom: 0; + left: 0; + z-index: 99; + background: #1d1f21; +} \ No newline at end of file From fd7358cb9ad42d71413256f016fc1d57a4b2a1d4 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:21:01 -0800 Subject: [PATCH 02/66] maintain the event log length at 60 items --- src/packages/editor-stats/src/editor-stats-view.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 480a34017..72873c6ea 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -37,7 +37,11 @@ class EditorStatsView extends ScrollView track: => date = new Date - @eventlog[time(date)] += 1 + times = time date + @eventlog[times] ||= 0 + @eventlog[times] += 1 + + @eventlog.shift() if @eventlog.length > 60 console.log @eventlog toggle: -> From e3831dddbae28ca0c75e269771ebed63dd6af1c6 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:00 -0800 Subject: [PATCH 03/66] cancel command --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 72873c6ea..861d8cb0b 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -25,6 +25,8 @@ class EditorStatsView extends ScrollView initialize: (@rootView, @eventLog = {}) -> super + @command 'core:cancel', @detach + date = new Date() future = new Date(date.getTime() + 36e5) @eventlog[time(date)] = 0 From 740d929cdd6a3526ce8dd1a093648c1b6b02b128 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:19 -0800 Subject: [PATCH 04/66] expose d3 to the view --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 861d8cb0b..555dbfd3f 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -11,6 +11,8 @@ class EditorStatsView extends ScrollView minute = date.getMinutes() "#{hour}:#{minute}" + d3 = require 'd3.v3' + @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) From b065a67605075374d8bd1664c57b85231ff8a024 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:38 -0800 Subject: [PATCH 05/66] fat arrow detach --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 555dbfd3f..16c12bc6f 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -58,7 +58,7 @@ class EditorStatsView extends ScrollView @rootView.append @ @focus() - detach: -> + detach: => super() @rootView.focus() From f6c9dc1b1c100194553ed594db0501d0c65c2a8c Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:38:57 -0800 Subject: [PATCH 06/66] append svg element --- .../editor-stats/src/editor-stats-view.coffee | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 16c12bc6f..a35de475e 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -39,6 +39,17 @@ class EditorStatsView extends ScrollView @rootView.on 'keyup', @track @rootView.on 'mousedown', @track + append: -> + w = @.width() + h = @.height() + [pt, pl, pb, pr] = [0,0,0,0] + + d3.select(@.get(0)).append('svg') + .attr('width', w) + .attr('height', h) + .append('g') + .attr('transform', "translate(#{pl},#{pt})") + track: => date = new Date times = time date @@ -57,6 +68,7 @@ class EditorStatsView extends ScrollView attach: -> @rootView.append @ @focus() + @append() detach: => super() From 7b586d85f8cb75599cde3887f2f765792399f345 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:39:06 -0800 Subject: [PATCH 07/66] update drawing on every event --- src/packages/editor-stats/src/editor-stats-view.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index a35de475e..279392ec1 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -50,6 +50,12 @@ class EditorStatsView extends ScrollView .append('g') .attr('transform', "translate(#{pl},#{pt})") + draw: -> + w = @.width() + h = @.height() + [pt, pl, pb, pr] = [0,0,0,0] + + track: => date = new Date times = time date @@ -57,7 +63,7 @@ class EditorStatsView extends ScrollView @eventlog[times] += 1 @eventlog.shift() if @eventlog.length > 60 - console.log @eventlog + @draw() toggle: -> if @hasParent() From 3cb4519230097ecd6393981506e57cea6a60ce1c Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:56:44 -0800 Subject: [PATCH 08/66] store x and y scales --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ src/packages/editor-stats/stylesheets/editor-stats.css | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 279392ec1..ab2f7abaf 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -12,6 +12,8 @@ class EditorStatsView extends ScrollView "#{hour}:#{minute}" d3 = require 'd3.v3' + x = d3.scale.ordinal().domain d3.range(60) + y = d3.scale.linear() @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 827da6667..9e01e5b7a 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -1,6 +1,6 @@ .editor-stats { position: absolute; - height: 200px; + height: 50px; width: 100%; bottom: 0; left: 0; From 4b0a7a135d3aab2e83f6b5af5d9899c515e780ea Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 13:56:53 -0800 Subject: [PATCH 09/66] append the bars --- .../editor-stats/src/editor-stats-view.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index ab2f7abaf..283b0c0bc 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -57,6 +57,23 @@ class EditorStatsView extends ScrollView h = @.height() [pt, pl, pb, pr] = [0,0,0,0] + data = d3.entries @eventlog + max = d3.max data, (d) -> d.value + + x.rangeRoundBands [0, w - pl - pr], 0.1 + y.domain([0, max]).range [h, 0] + + vis = d3.select('svg g') + + bars = vis.selectAll('g.bar') + .data(data) + .enter().append('g') + .attr('transform', (d, i) -> "translate(#{x(i)}, 0)") + + bars.append('rect') + .attr('width', x.rangeBand()) + .attr('height', (d, i) -> y(d.value)) + track: => date = new Date From e9ba5f8f8567ca31ad147e4c0c491be688c1bc08 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 14:57:47 -0800 Subject: [PATCH 10/66] update working smoothly --- .../editor-stats/src/editor-stats-view.coffee | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 283b0c0bc..cb8f59909 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -38,19 +38,8 @@ class EditorStatsView extends ScrollView while date <= future @eventlog[time(date)] = 0 - @rootView.on 'keyup', @track - @rootView.on 'mousedown', @track - - append: -> - w = @.width() - h = @.height() - [pt, pl, pb, pr] = [0,0,0,0] - - d3.select(@.get(0)).append('svg') - .attr('width', w) - .attr('height', h) - .append('g') - .attr('transform', "translate(#{pl},#{pt})") + @rootView.on 'keydown', @track + @rootView.on 'mouseup', @track draw: -> w = @.width() @@ -63,17 +52,32 @@ class EditorStatsView extends ScrollView x.rangeRoundBands [0, w - pl - pr], 0.1 y.domain([0, max]).range [h, 0] - vis = d3.select('svg g') + vis = d3.select(@.get(0)).append('svg') + .attr('width', w) + .attr('height', h) + .append('g') + .attr('transform', "translate(#{pl},#{pt})") - bars = vis.selectAll('g.bar') + bars = vis.selectAll('rect.bar') .data(data) - .enter().append('g') - .attr('transform', (d, i) -> "translate(#{x(i)}, 0)") - - bars.append('rect') + .enter().append('rect') + .attr('x', (d, i) => x i) + .attr('y', (d) -> y d.value) + .attr('height', (d) -> h - y(d.value)) .attr('width', x.rangeBand()) - .attr('height', (d, i) -> y(d.value)) + update = => + newdata = d3.entries @eventlog + max = d3.max newdata, (d) -> d.value + + x.rangeRoundBands [0, w - pl - pr], 0.1 + y.domain([0, max]).range [h, 0] + + bars.data(newdata).transition() + .attr('height', (d, i) -> h - y(d.value)) + .attr('y', (d, i) -> y(d.value)) + + setInterval update, 5000 track: => date = new Date @@ -81,8 +85,7 @@ class EditorStatsView extends ScrollView @eventlog[times] ||= 0 @eventlog[times] += 1 - @eventlog.shift() if @eventlog.length > 60 - @draw() + @eventlog.shift() if @eventlog.length > 59 toggle: -> if @hasParent() @@ -93,7 +96,7 @@ class EditorStatsView extends ScrollView attach: -> @rootView.append @ @focus() - @append() + @draw() detach: => super() From 168f08611c63ee036313367a2d5bdf1d3b0419df Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 15:44:09 -0800 Subject: [PATCH 11/66] color dem bars --- src/packages/editor-stats/stylesheets/editor-stats.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 9e01e5b7a..d298ab9d9 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -6,4 +6,9 @@ left: 0; z-index: 99; background: #1d1f21; + border-top: 1px solid rgba(255, 255, 255, 0.1); +} + +.editor-stats rect.bar { + fill: rgba(255, 255, 255, 0.1); } \ No newline at end of file From 57c9412d99d4cf16b66b9444d6cc67cbb6b71971 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 15:44:16 -0800 Subject: [PATCH 12/66] fix scales --- .../editor-stats/src/editor-stats-view.coffee | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index cb8f59909..66e47dcf5 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,6 +5,8 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView + hours = 2 + time = (date) -> date.setTime(date.getTime() + 6e4) hour = date.getHours() @@ -12,7 +14,7 @@ class EditorStatsView extends ScrollView "#{hour}:#{minute}" d3 = require 'd3.v3' - x = d3.scale.ordinal().domain d3.range(60) + x = d3.scale.ordinal().domain d3.range(hours * 60) y = d3.scale.linear() @activate: (rootView, state) -> @@ -32,25 +34,25 @@ class EditorStatsView extends ScrollView @command 'core:cancel', @detach date = new Date() - future = new Date(date.getTime() + 36e5) + future = new Date(date.getTime() + (36e5 * hours)) @eventlog[time(date)] = 0 - while date <= future + while date < future @eventlog[time(date)] = 0 + console.log @eventlog @rootView.on 'keydown', @track @rootView.on 'mouseup', @track draw: -> w = @.width() h = @.height() - [pt, pl, pb, pr] = [0,0,0,0] + [pt, pl, pb, pr] = [5,0,0,0] data = d3.entries @eventlog - max = d3.max data, (d) -> d.value x.rangeRoundBands [0, w - pl - pr], 0.1 - y.domain([0, max]).range [h, 0] + y.range [h, 0] vis = d3.select(@.get(0)).append('svg') .attr('width', w) @@ -61,17 +63,16 @@ class EditorStatsView extends ScrollView bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') - .attr('x', (d, i) => x i) + .attr('x', (d, i) -> console.log x(0); x(i)) .attr('y', (d) -> y d.value) - .attr('height', (d) -> h - y(d.value)) .attr('width', x.rangeBand()) + .attr('class', 'bar') update = => newdata = d3.entries @eventlog max = d3.max newdata, (d) -> d.value - x.rangeRoundBands [0, w - pl - pr], 0.1 - y.domain([0, max]).range [h, 0] + y.domain [0, max] bars.data(newdata).transition() .attr('height', (d, i) -> h - y(d.value)) @@ -84,8 +85,7 @@ class EditorStatsView extends ScrollView times = time date @eventlog[times] ||= 0 @eventlog[times] += 1 - - @eventlog.shift() if @eventlog.length > 59 + @eventlog.shift() if @eventlog.length > (hours * 60) toggle: -> if @hasParent() From aa5660ba81c451e27145462f1854c180b30e5783 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 29 Jan 2013 15:46:19 -0800 Subject: [PATCH 13/66] syntax yo --- src/packages/editor-stats/src/editor-stats-view.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 66e47dcf5..996968724 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,7 +5,7 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView - hours = 2 + hours = 6 time = (date) -> date.setTime(date.getTime() + 6e4) @@ -63,7 +63,7 @@ class EditorStatsView extends ScrollView bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') - .attr('x', (d, i) -> console.log x(0); x(i)) + .attr('x', (d, i) -> x i) .attr('y', (d) -> y d.value) .attr('width', x.rangeBand()) .attr('class', 'bar') @@ -76,7 +76,7 @@ class EditorStatsView extends ScrollView bars.data(newdata).transition() .attr('height', (d, i) -> h - y(d.value)) - .attr('y', (d, i) -> y(d.value)) + .attr('y', (d, i) -> y d.value) setInterval update, 5000 From 29b3a1d5828415a28a4d747dea345a409065ca91 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:00:16 -0800 Subject: [PATCH 14/66] add keymap for editor stats --- src/packages/editor-stats/keymaps/editor-stats.cson | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/packages/editor-stats/keymaps/editor-stats.cson diff --git a/src/packages/editor-stats/keymaps/editor-stats.cson b/src/packages/editor-stats/keymaps/editor-stats.cson new file mode 100644 index 000000000..1364f2098 --- /dev/null +++ b/src/packages/editor-stats/keymaps/editor-stats.cson @@ -0,0 +1,5 @@ +'body, .editor-stats': + 'meta-alt-s': 'editor-stats:toggle' + +'.editor-stats': + 'meta-alt-s': 'editor-stats:toggle' From 0c878c5e7da508ce14f4298dec2ba913deaad041 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:00:40 -0800 Subject: [PATCH 15/66] put editor stats in the document flow so it doesn't overlap the status bar --- .../editor-stats/src/editor-stats-view.coffee | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 996968724..037c449b2 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,7 +5,7 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView - hours = 6 + hours = 2 time = (date) -> date.setTime(date.getTime() + 6e4) @@ -17,6 +17,9 @@ class EditorStatsView extends ScrollView x = d3.scale.ordinal().domain d3.range(hours * 60) y = d3.scale.linear() + xaxis = d3.svg.axis().scale(x) + .orient('top') + @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) @@ -32,6 +35,7 @@ class EditorStatsView extends ScrollView super @command 'core:cancel', @detach + @statusBar = @rootView.find '.status-bar' date = new Date() future = new Date(date.getTime() + (36e5 * hours)) @@ -40,19 +44,19 @@ class EditorStatsView extends ScrollView while date < future @eventlog[time(date)] = 0 - console.log @eventlog @rootView.on 'keydown', @track @rootView.on 'mouseup', @track draw: -> - w = @.width() + w = @statusBar.width() h = @.height() - [pt, pl, pb, pr] = [5,0,0,0] + [pt, pl, pb, pr] = [15,0,0,0] data = d3.entries @eventlog - x.rangeRoundBands [0, w - pl - pr], 0.1 + x.rangeRoundBands [0, w - pl - pr], 0.2 y.range [h, 0] + xaxis.tickSize(-h - pt - pb, 50) vis = d3.select(@.get(0)).append('svg') .attr('width', w) @@ -60,6 +64,10 @@ class EditorStatsView extends ScrollView .append('g') .attr('transform', "translate(#{pl},#{pt})") + vis.append('g') + .attr('class', 'x axis') + .call(xaxis) + bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') @@ -94,7 +102,7 @@ class EditorStatsView extends ScrollView @attach() attach: -> - @rootView.append @ + @.insertBefore @statusBar @focus() @draw() From ebc7daf1dcc0d46ccf7dca3d398a1471ce5a7dd0 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:00:48 -0800 Subject: [PATCH 16/66] more styles --- .../editor-stats/stylesheets/editor-stats.css | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index d298ab9d9..0644808bf 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -1,14 +1,27 @@ .editor-stats { - position: absolute; height: 50px; width: 100%; - bottom: 0; - left: 0; - z-index: 99; background: #1d1f21; border-top: 1px solid rgba(255, 255, 255, 0.1); } .editor-stats rect.bar { - fill: rgba(255, 255, 255, 0.1); + fill: rgba(255, 255, 255, 0.2); + shape-rendering: crispedges; +} + +.editor-stats text { + font-size: 10px; + fill: rgba(255, 255, 255, 0.2); +} + +.editor-stats line { + stroke: #ccc; + stroke-opacity: 0.05; + stroke-width: 1px; + shape-rendering: crispedges; +} + +.editor-stats path.domain { + fill: none; } \ No newline at end of file From 6080ba66e152ef4c7b910b03bf85aad55971c4e2 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:33:39 -0800 Subject: [PATCH 17/66] tweak x axis display --- .../editor-stats/src/editor-stats-view.coffee | 16 ++++++++++++---- .../editor-stats/stylesheets/editor-stats.css | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 037c449b2..61e671ec8 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -5,7 +5,7 @@ _ = require 'underscore' module.exports = class EditorStatsView extends ScrollView - hours = 2 + hours = 4 time = (date) -> date.setTime(date.getTime() + 6e4) @@ -13,6 +13,7 @@ class EditorStatsView extends ScrollView minute = date.getMinutes() "#{hour}:#{minute}" + startDate = new Date d3 = require 'd3.v3' x = d3.scale.ordinal().domain d3.range(hours * 60) y = d3.scale.linear() @@ -37,7 +38,7 @@ class EditorStatsView extends ScrollView @command 'core:cancel', @detach @statusBar = @rootView.find '.status-bar' - date = new Date() + date = new Date(startDate) future = new Date(date.getTime() + (36e5 * hours)) @eventlog[time(date)] = 0 @@ -48,7 +49,7 @@ class EditorStatsView extends ScrollView @rootView.on 'mouseup', @track draw: -> - w = @statusBar.width() + w = @statusBar.outerWidth() h = @.height() [pt, pl, pb, pr] = [15,0,0,0] @@ -56,7 +57,7 @@ class EditorStatsView extends ScrollView x.rangeRoundBands [0, w - pl - pr], 0.2 y.range [h, 0] - xaxis.tickSize(-h - pt - pb, 50) + xaxis.tickSize(-h + pt + pb, 50) vis = d3.select(@.get(0)).append('svg') .attr('width', w) @@ -67,6 +68,13 @@ class EditorStatsView extends ScrollView vis.append('g') .attr('class', 'x axis') .call(xaxis) + .selectAll('g') + .style('display', (d, i) -> + if i % 15 == 0 || i % 5 == 0 + 'block' + else + 'none' + ).classed('minor', (d, i) -> i % 5 == 0 && i % 15 != 0) bars = vis.selectAll('rect.bar') .data(data) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 0644808bf..3e9ccdf97 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -13,6 +13,11 @@ .editor-stats text { font-size: 10px; fill: rgba(255, 255, 255, 0.2); + font-family: Courier; +} + +.editor-stats .minor text { + display: none; } .editor-stats line { From 2abe3e47ded248b0fc6993876f8379b0e4bda48d Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 09:41:49 -0800 Subject: [PATCH 18/66] show actual time on scale --- src/packages/editor-stats/src/editor-stats-view.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 61e671ec8..ae008decd 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -20,6 +20,9 @@ class EditorStatsView extends ScrollView xaxis = d3.svg.axis().scale(x) .orient('top') + .tickFormat (d) -> + d = new Date(startDate.getTime() + (d * 6e4)) + "#{d.getHours()}:#{d.getMinutes()}" @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) From bc61c3ca984956316625996bdc94268673390921 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 10:14:04 -0800 Subject: [PATCH 19/66] remove when detached --- src/packages/editor-stats/src/editor-stats-view.coffee | 1 + src/packages/editor-stats/stylesheets/editor-stats.css | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index ae008decd..e558dfa68 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -119,6 +119,7 @@ class EditorStatsView extends ScrollView detach: => super() + @.remove() @rootView.focus() serialize: -> diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 3e9ccdf97..1368dcdb1 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -10,6 +10,10 @@ shape-rendering: crispedges; } +.editor-stats rect.bar.max { + fill: rgba(0, 163, 255, 1); +} + .editor-stats text { font-size: 10px; fill: rgba(255, 255, 255, 0.2); From 1afb2fbeb571e813fe65082176fe11ca6d82e6e3 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 10:14:12 -0800 Subject: [PATCH 20/66] highlight the max minute --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index e558dfa68..13fbb1ad7 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -97,6 +97,8 @@ class EditorStatsView extends ScrollView .attr('height', (d, i) -> h - y(d.value)) .attr('y', (d, i) -> y d.value) + bars.classed('max', (d, i) -> d.value == max) + setInterval update, 5000 track: => From 164b50d795542f67a6b528ed8f059c3b0bddc6a7 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 10:14:26 -0800 Subject: [PATCH 21/66] zero pad minutes --- src/packages/editor-stats/src/editor-stats-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 13fbb1ad7..8dc2ae947 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -22,7 +22,9 @@ class EditorStatsView extends ScrollView .orient('top') .tickFormat (d) -> d = new Date(startDate.getTime() + (d * 6e4)) - "#{d.getHours()}:#{d.getMinutes()}" + mins = d.getMinutes() + mins = "0#{mins}" if mins < 9 + "#{d.getHours()}:#{mins}" @activate: (rootView, state) -> @instance = new EditorStatsView(rootView, state?.eventLog) From 2d87a60019af9f086d4063acd82f512f4707003a Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 12:15:15 -0800 Subject: [PATCH 22/66] camelCase --- .../editor-stats/src/editor-stats-view.coffee | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 8dc2ae947..a5cd4053d 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -35,7 +35,7 @@ class EditorStatsView extends ScrollView @serialize: -> @instance.serialize() - eventlog: [], + eventLog: [], initialize: (@rootView, @eventLog = {}) -> super @@ -45,10 +45,10 @@ class EditorStatsView extends ScrollView date = new Date(startDate) future = new Date(date.getTime() + (36e5 * hours)) - @eventlog[time(date)] = 0 + @eventLog[time(date)] = 0 while date < future - @eventlog[time(date)] = 0 + @eventLog[time(date)] = 0 @rootView.on 'keydown', @track @rootView.on 'mouseup', @track @@ -58,7 +58,7 @@ class EditorStatsView extends ScrollView h = @.height() [pt, pl, pb, pr] = [15,0,0,0] - data = d3.entries @eventlog + data = d3.entries @eventLog x.rangeRoundBands [0, w - pl - pr], 0.2 y.range [h, 0] @@ -90,7 +90,7 @@ class EditorStatsView extends ScrollView .attr('class', 'bar') update = => - newdata = d3.entries @eventlog + newdata = d3.entries @eventLog max = d3.max newdata, (d) -> d.value y.domain [0, max] @@ -106,9 +106,9 @@ class EditorStatsView extends ScrollView track: => date = new Date times = time date - @eventlog[times] ||= 0 - @eventlog[times] += 1 - @eventlog.shift() if @eventlog.length > (hours * 60) + @eventLog[times] ||= 0 + @eventLog[times] += 1 + @eventLog.shift() if @eventLog.length > (hours * 60) toggle: -> if @hasParent() From c5b9c38311a9765f702142bf02e898d8456c4959 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Wed, 30 Jan 2013 12:15:25 -0800 Subject: [PATCH 23/66] specs for editor stats --- .../spec/editor-stats-spec.coffee | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/packages/editor-stats/spec/editor-stats-spec.coffee diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee new file mode 100644 index 000000000..deba8fe9e --- /dev/null +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -0,0 +1,46 @@ +$ = require 'jquery' +RootView = require 'root-view' +EditorStats = require 'editor-stats/src/editor-stats-view' + +fdescribe "EditorStats", -> + [rootView, editorStats, editor, date, time] = [] + + simulateKeyUp = (key) -> + e = $.Event "keydown", keyCode: key.charCodeAt(0) + rootView.trigger(e) + + simulateClick = -> + e = $.Event "mouseup" + rootView.trigger(e) + + beforeEach -> + rootView = new RootView(require.resolve('fixtures/sample.js')) + + date = new Date() + mins = date.getMinutes() + hours = date.getHours() + + mins = if mins == 60 then '01' else mins + 1 + time = "#{hours}:#{mins}" + + atom.loadPackage('editor-stats').getInstance() + editor = rootView.getActiveEditor() + editorStats = EditorStats.instance + + afterEach -> + rootView.deactivate() + + describe "when a keyup event is triggered", -> + it "records the number of times a keyup is triggered", -> + simulateKeyUp('a') + expect(editorStats.eventLog[time]).toBe 1 + simulateKeyUp('b') + expect(editorStats.eventLog[time]).toBe 2 + + describe "when a mouseup event is triggered", -> + it "records the number of times a mouseup is triggered", -> + simulateClick() + expect(editorStats.eventLog[time]).toBe 1 + simulateClick() + expect(editorStats.eventLog[time]).toBe 2 + From 793bb44bb2864c3e75492ca21075d0342e49c3d5 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Thu, 31 Jan 2013 12:51:36 -0800 Subject: [PATCH 24/66] copy over the .atom template directory instead of individual files --- Rakefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 2a14471ac..ad33f5a86 100644 --- a/Rakefile +++ b/Rakefile @@ -90,13 +90,7 @@ task "create-dot-atom" do end `rm -rf "#{DOT_ATOM_PATH}"` - `mkdir "#{DOT_ATOM_PATH}"` - - `cp "#{dot_atom_template_path}/user.coffee" "#{DOT_ATOM_PATH}"` - `cp "#{dot_atom_template_path}/user.css" "#{DOT_ATOM_PATH}"` - `cp -r "#{dot_atom_template_path}/packages" "#{DOT_ATOM_PATH}"` - `cp -r "#{ATOM_SRC_PATH}/themes" "#{DOT_ATOM_PATH}"` - `cp "#{ATOM_SRC_PATH}/vendor/themes/IR_Black.tmTheme" "#{DOT_ATOM_PATH}/themes"` + `cp -r #{dot_atom_template_path} #{DOT_ATOM_PATH}` end desc "Clone default bundles into vendor/bundles directory" From 4cd220012197dcacc7a41f9c2c5d78f8151b88f9 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Thu, 31 Jan 2013 12:52:02 -0800 Subject: [PATCH 25/66] create a default config.json file with sane defaults --- .atom/config.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .atom/config.json diff --git a/.atom/config.json b/.atom/config.json new file mode 100644 index 000000000..3f2c5de32 --- /dev/null +++ b/.atom/config.json @@ -0,0 +1,11 @@ +{ + "editor": { + + }, + "core": { + "themes": [ + "Atom - Dark", + "IR_Black" + ] + } +} \ No newline at end of file From a57ac08238b5b567c37c63d34b095ef56c1b6b0f Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Thu, 31 Jan 2013 12:58:38 -0800 Subject: [PATCH 26/66] make the default font size 12px --- .atom/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.atom/config.json b/.atom/config.json index 3f2c5de32..89e425883 100644 --- a/.atom/config.json +++ b/.atom/config.json @@ -1,6 +1,6 @@ { "editor": { - + "fontSize": 12 }, "core": { "themes": [ From 6be772d617a2c03fc613cf31a5d0083fee5f178a Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Thu, 31 Jan 2013 12:58:52 -0800 Subject: [PATCH 27/66] add themes directory to .atom template --- .atom/themes/Readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .atom/themes/Readme.md diff --git a/.atom/themes/Readme.md b/.atom/themes/Readme.md new file mode 100644 index 000000000..e69de29bb From 08cac2bbe0b484a12408a79f996a90d1926f7923 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 13:36:52 -0800 Subject: [PATCH 28/66] :lipstick: --- src/packages/editor-stats/spec/editor-stats-spec.coffee | 1 - src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- src/packages/editor-stats/stylesheets/editor-stats.css | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee index deba8fe9e..bb63c91cc 100644 --- a/src/packages/editor-stats/spec/editor-stats-spec.coffee +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -43,4 +43,3 @@ fdescribe "EditorStats", -> expect(editorStats.eventLog[time]).toBe 1 simulateClick() expect(editorStats.eventLog[time]).toBe 2 - diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index a5cd4053d..394a654d3 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -127,4 +127,4 @@ class EditorStatsView extends ScrollView @rootView.focus() serialize: -> - eventLog: @eventLog \ No newline at end of file + eventLog: @eventLog diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 1368dcdb1..25a3cc08b 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -33,4 +33,4 @@ .editor-stats path.domain { fill: none; -} \ No newline at end of file +} From 2b61883d9b830e10a579e569e9771d1cc257e9ab Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 13:37:30 -0800 Subject: [PATCH 29/66] un-f editor stats spec --- src/packages/editor-stats/spec/editor-stats-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee index bb63c91cc..b330f0073 100644 --- a/src/packages/editor-stats/spec/editor-stats-spec.coffee +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -2,7 +2,7 @@ $ = require 'jquery' RootView = require 'root-view' EditorStats = require 'editor-stats/src/editor-stats-view' -fdescribe "EditorStats", -> +describe "EditorStats", -> [rootView, editorStats, editor, date, time] = [] simulateKeyUp = (key) -> From 9f3f0fe397c7dc86732e9dd6f6f1f82977f1d1d2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 13:45:41 -0800 Subject: [PATCH 30/66] Don't focus stats when attaching Leave the editor with focus since the stats aren't interactive --- src/packages/editor-stats/src/editor-stats-view.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 394a654d3..afe49372d 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -118,7 +118,6 @@ class EditorStatsView extends ScrollView attach: -> @.insertBefore @statusBar - @focus() @draw() detach: => From 30e8eee9cecef5d836ca66ef0b1b941f4b7b8bd8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 13:49:14 -0800 Subject: [PATCH 31/66] Move d3 require to top --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index afe49372d..5df176834 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -2,6 +2,7 @@ ScrollView = require 'scroll-view' $ = require 'jquery' _ = require 'underscore' +d3 = require 'd3.v3' module.exports = class EditorStatsView extends ScrollView @@ -14,7 +15,6 @@ class EditorStatsView extends ScrollView "#{hour}:#{minute}" startDate = new Date - d3 = require 'd3.v3' x = d3.scale.ordinal().domain d3.range(hours * 60) y = d3.scale.linear() From 517d4cfe3ae205892e3fcd07cefa413dc0ee0eb5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 13:50:47 -0800 Subject: [PATCH 32/66] Remove unused requires --- src/packages/editor-stats/spec/editor-stats-spec.coffee | 2 +- src/packages/editor-stats/src/editor-stats-view.coffee | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee index b330f0073..bb63c91cc 100644 --- a/src/packages/editor-stats/spec/editor-stats-spec.coffee +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -2,7 +2,7 @@ $ = require 'jquery' RootView = require 'root-view' EditorStats = require 'editor-stats/src/editor-stats-view' -describe "EditorStats", -> +fdescribe "EditorStats", -> [rootView, editorStats, editor, date, time] = [] simulateKeyUp = (key) -> diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 5df176834..4e738c7f3 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -1,7 +1,4 @@ -{$$$} = require 'space-pen' ScrollView = require 'scroll-view' -$ = require 'jquery' -_ = require 'underscore' d3 = require 'd3.v3' module.exports = From 20249b4d38a3211f0c3cf2d320db37129b292e96 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 14:06:16 -0800 Subject: [PATCH 33/66] un-f editor stats spec again --- src/packages/editor-stats/spec/editor-stats-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee index bb63c91cc..b330f0073 100644 --- a/src/packages/editor-stats/spec/editor-stats-spec.coffee +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -2,7 +2,7 @@ $ = require 'jquery' RootView = require 'root-view' EditorStats = require 'editor-stats/src/editor-stats-view' -fdescribe "EditorStats", -> +describe "EditorStats", -> [rootView, editorStats, editor, date, time] = [] simulateKeyUp = (key) -> From 4433f443d4f674561ce96e946d4be3a317b79d76 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 14:06:46 -0800 Subject: [PATCH 34/66] Simplify stats keymap --- src/packages/editor-stats/keymaps/editor-stats.cson | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/packages/editor-stats/keymaps/editor-stats.cson b/src/packages/editor-stats/keymaps/editor-stats.cson index 1364f2098..819b7c04f 100644 --- a/src/packages/editor-stats/keymaps/editor-stats.cson +++ b/src/packages/editor-stats/keymaps/editor-stats.cson @@ -1,5 +1,2 @@ -'body, .editor-stats': - 'meta-alt-s': 'editor-stats:toggle' - -'.editor-stats': +'body': 'meta-alt-s': 'editor-stats:toggle' From 7f86bf1351a40981c5a9577062f7634704968841 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 14:19:20 -0800 Subject: [PATCH 35/66] Remove unneeded remove call --- src/packages/editor-stats/src/editor-stats-view.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 4e738c7f3..8e13c20f0 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -118,8 +118,7 @@ class EditorStatsView extends ScrollView @draw() detach: => - super() - @.remove() + super @rootView.focus() serialize: -> From de09adc45f4c13f4f5249ed4c2a2e6b43acd2395 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 31 Jan 2013 14:24:02 -0800 Subject: [PATCH 36/66] :lipstick: --- src/packages/editor-stats/src/editor-stats-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 8e13c20f0..ac052875b 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -32,7 +32,7 @@ class EditorStatsView extends ScrollView @serialize: -> @instance.serialize() - eventLog: [], + eventLog: [] initialize: (@rootView, @eventLog = {}) -> super @@ -117,7 +117,7 @@ class EditorStatsView extends ScrollView @.insertBefore @statusBar @draw() - detach: => + detach: -> super @rootView.focus() From 4482bdd96415984a53f39779d4c1f482fbf9197b Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 07:55:51 -0800 Subject: [PATCH 37/66] don't need that dot --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index a5cd4053d..ced873693 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -123,7 +123,7 @@ class EditorStatsView extends ScrollView detach: => super() - @.remove() + @remove() @rootView.focus() serialize: -> From 4d8a6e5b6039c0312c66ee1aef782a759506195b Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 07:59:35 -0800 Subject: [PATCH 38/66] remove serialization for now since I'm not reloading the data --- src/packages/editor-stats/src/editor-stats-view.coffee | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index ced873693..e56165b89 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -124,7 +124,4 @@ class EditorStatsView extends ScrollView detach: => super() @remove() - @rootView.focus() - - serialize: -> - eventLog: @eventLog \ No newline at end of file + @rootView.focus() \ No newline at end of file From 52c1ca7a2dd8a24056f17d21acfcacd1831d2c6f Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 08:24:43 -0800 Subject: [PATCH 39/66] fix editor stats so they look as if they are embedded in the status bar --- .../editor-stats/src/editor-stats-view.coffee | 22 ++++++++++--------- .../editor-stats/stylesheets/editor-stats.css | 9 +++++++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index e56165b89..ca4c9e498 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -30,7 +30,8 @@ class EditorStatsView extends ScrollView @instance = new EditorStatsView(rootView, state?.eventLog) @content: (rootView) -> - @div class: 'editor-stats', tabindex: -1 + @div class: 'editor-stats-wrapper', tabindex: -1, => + @div class: 'editor-stats', outlet: 'editorStats' @serialize: -> @instance.serialize() @@ -42,6 +43,7 @@ class EditorStatsView extends ScrollView @command 'core:cancel', @detach @statusBar = @rootView.find '.status-bar' + @css 'background', @statusBar.css('background') date = new Date(startDate) future = new Date(date.getTime() + (36e5 * hours)) @@ -54,17 +56,17 @@ class EditorStatsView extends ScrollView @rootView.on 'mouseup', @track draw: -> - w = @statusBar.outerWidth() + w = @statusBar.width() h = @.height() - [pt, pl, pb, pr] = [15,0,0,0] + [pt, pl, pb, pr] = [15,10,0,10] data = d3.entries @eventLog - x.rangeRoundBands [0, w - pl - pr], 0.2 + x.rangeBands [0, w - pl - pr], 0.2 y.range [h, 0] xaxis.tickSize(-h + pt + pb, 50) - vis = d3.select(@.get(0)).append('svg') + vis = d3.select(@editorStats.get(0)).append('svg') .attr('width', w) .attr('height', h) .append('g') @@ -75,7 +77,7 @@ class EditorStatsView extends ScrollView .call(xaxis) .selectAll('g') .style('display', (d, i) -> - if i % 15 == 0 || i % 5 == 0 + if i % 15 == 0 || i % 5 == 0 || i == data.length - 1 'block' else 'none' @@ -85,7 +87,7 @@ class EditorStatsView extends ScrollView .data(data) .enter().append('rect') .attr('x', (d, i) -> x i) - .attr('y', (d) -> y d.value) + .attr('y', (d) -> y(d.value)) .attr('width', x.rangeBand()) .attr('class', 'bar') @@ -96,8 +98,8 @@ class EditorStatsView extends ScrollView y.domain [0, max] bars.data(newdata).transition() - .attr('height', (d, i) -> h - y(d.value)) - .attr('y', (d, i) -> y d.value) + .attr('height', (d, i) -> h - y(d.value) - 17) + .attr('y', (d, i) -> y(d.value)) bars.classed('max', (d, i) -> d.value == max) @@ -117,7 +119,7 @@ class EditorStatsView extends ScrollView @attach() attach: -> - @.insertBefore @statusBar + @insertAfter @statusBar @focus() @draw() diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 1368dcdb1..57fdd5bf8 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -1,8 +1,15 @@ +.editor-stats-wrapper { + padding: 5px; + box-sizing: border-box; +} + .editor-stats { height: 50px; width: 100%; background: #1d1f21; - border-top: 1px solid rgba(255, 255, 255, 0.1); + border: 1px solid rgba(0, 0, 0, 0.3); + border-bottom: 1px solid rgba(255, 255, 255, 0.1); + border-right: 1px solid rgba(255, 255, 255, 0.1); } .editor-stats rect.bar { From d1b916f5a25aa51052d853df16aee30e7c9ef9b9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 08:32:24 -0800 Subject: [PATCH 40/66] Don't grab focus when attaching stats --- src/packages/editor-stats/src/editor-stats-view.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 7f6b955d4..6738874eb 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -117,7 +117,6 @@ class EditorStatsView extends ScrollView attach: -> @insertAfter @statusBar - @focus() @draw() detach: => From d597de6a7967957a066939ffbb5d132f0e490a07 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 08:34:11 -0800 Subject: [PATCH 41/66] Kill remaining serialization code --- src/packages/editor-stats/src/editor-stats-view.coffee | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 6738874eb..79358a662 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -24,18 +24,15 @@ class EditorStatsView extends ScrollView "#{d.getHours()}:#{mins}" @activate: (rootView, state) -> - @instance = new EditorStatsView(rootView, state?.eventLog) + @instance = new EditorStatsView(rootView) @content: (rootView) -> @div class: 'editor-stats-wrapper', tabindex: -1, => @div class: 'editor-stats', outlet: 'editorStats' - @serialize: -> - @instance.serialize() - eventLog: [] - initialize: (@rootView, @eventLog = {}) -> + initialize: (@rootView) -> super @command 'core:cancel', @detach From 3f7c7c1b9209b6e626efd8b70b88a930508e2ff3 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 08:42:54 -0800 Subject: [PATCH 42/66] soo many conflicts --- src/packages/editor-stats/src/editor-stats-view.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 79358a662..66d1818cc 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -37,6 +37,7 @@ class EditorStatsView extends ScrollView @command 'core:cancel', @detach @statusBar = @rootView.find '.status-bar' + @panes = @rootView.find('#panes') @css 'background', @statusBar.css('background') date = new Date(startDate) @@ -92,7 +93,7 @@ class EditorStatsView extends ScrollView y.domain [0, max] bars.data(newdata).transition() - .attr('height', (d, i) -> h - y(d.value) - 17) + .attr('height', (d, i) -> h - y(d.value)) .attr('y', (d, i) -> y(d.value)) bars.classed('max', (d, i) -> d.value == max) @@ -113,7 +114,7 @@ class EditorStatsView extends ScrollView @attach() attach: -> - @insertAfter @statusBar + @panes.append(@) @draw() detach: => From 3916f44d28a2b22909874e220db66c36ad4b05ae Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 08:46:35 -0800 Subject: [PATCH 43/66] append to the vertical element so its context appears global --- src/packages/editor-stats/src/editor-stats-view.coffee | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 66d1818cc..16f0e0c40 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -36,8 +36,7 @@ class EditorStatsView extends ScrollView super @command 'core:cancel', @detach - @statusBar = @rootView.find '.status-bar' - @panes = @rootView.find('#panes') + @statusBar = @rootView.find('.status-bar') @css 'background', @statusBar.css('background') date = new Date(startDate) @@ -51,9 +50,9 @@ class EditorStatsView extends ScrollView @rootView.on 'mouseup', @track draw: -> - w = @statusBar.width() + w = @rootView.vertical.width() h = @.height() - [pt, pl, pb, pr] = [15,10,0,10] + [pt, pl, pb, pr] = [15,10,0,25] data = d3.entries @eventLog @@ -114,7 +113,7 @@ class EditorStatsView extends ScrollView @attach() attach: -> - @panes.append(@) + @rootView.vertical.append(@) @draw() detach: => From 4f6f95ef4297f1181123890951d520aa5edc67e7 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 08:55:44 -0800 Subject: [PATCH 44/66] tweak dimensions --- src/packages/editor-stats/src/editor-stats-view.coffee | 8 ++++---- src/packages/editor-stats/stylesheets/editor-stats.css | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 16f0e0c40..4132792c6 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -3,7 +3,7 @@ d3 = require 'd3.v3' module.exports = class EditorStatsView extends ScrollView - hours = 4 + hours = 6 time = (date) -> date.setTime(date.getTime() + 6e4) @@ -52,12 +52,12 @@ class EditorStatsView extends ScrollView draw: -> w = @rootView.vertical.width() h = @.height() - [pt, pl, pb, pr] = [15,10,0,25] + [pt, pl, pb, pr] = [15, 10, 3, 25] data = d3.entries @eventLog x.rangeBands [0, w - pl - pr], 0.2 - y.range [h, 0] + y.range [h - pt - pb, 0] xaxis.tickSize(-h + pt + pb, 50) vis = d3.select(@editorStats.get(0)).append('svg') @@ -92,7 +92,7 @@ class EditorStatsView extends ScrollView y.domain [0, max] bars.data(newdata).transition() - .attr('height', (d, i) -> h - y(d.value)) + .attr('height', (d, i) -> h - y(d.value) - pt - pb) .attr('y', (d, i) -> y(d.value)) bars.classed('max', (d, i) -> d.value == max) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 2f1da6516..781959197 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -1,6 +1,7 @@ .editor-stats-wrapper { padding: 5px; box-sizing: border-box; + border-top: 1px solid rgba(255, 255, 255, 0.05); } .editor-stats { From 3c654c67e280612bf1ef803fb154ac62f51fd414 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 08:59:17 -0800 Subject: [PATCH 45/66] use background-color just in case --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- src/packages/editor-stats/stylesheets/editor-stats.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 4132792c6..f3d56f4ba 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -37,7 +37,7 @@ class EditorStatsView extends ScrollView @command 'core:cancel', @detach @statusBar = @rootView.find('.status-bar') - @css 'background', @statusBar.css('background') + @css 'background', @statusBar.css('background-color') date = new Date(startDate) future = new Date(date.getTime() + (36e5 * hours)) diff --git a/src/packages/editor-stats/stylesheets/editor-stats.css b/src/packages/editor-stats/stylesheets/editor-stats.css index 781959197..a7d5e3ff2 100644 --- a/src/packages/editor-stats/stylesheets/editor-stats.css +++ b/src/packages/editor-stats/stylesheets/editor-stats.css @@ -2,6 +2,7 @@ padding: 5px; box-sizing: border-box; border-top: 1px solid rgba(255, 255, 255, 0.05); + z-index: 9999; } .editor-stats { From 336c1299c59223d201268f47001efcec0745cb84 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 09:04:20 -0800 Subject: [PATCH 46/66] Start tracking stats before graph is opened This allows the graph to open with data available since the editor was launched. --- src/packages/editor-stats/index.coffee | 11 ++- .../spec/editor-stats-spec.coffee | 6 +- .../editor-stats/src/editor-stats-view.coffee | 77 ++++++------------- src/packages/editor-stats/src/stats.coffee | 29 +++++++ .../tree-view/spec/tree-view-spec.coffee | 2 +- 5 files changed, 67 insertions(+), 58 deletions(-) create mode 100644 src/packages/editor-stats/src/stats.coffee diff --git a/src/packages/editor-stats/index.coffee b/src/packages/editor-stats/index.coffee index 60a97582e..70b0871b1 100644 --- a/src/packages/editor-stats/index.coffee +++ b/src/packages/editor-stats/index.coffee @@ -1,4 +1,5 @@ DeferredAtomPackage = require 'deferred-atom-package' +Stats = require './src/stats' module.exports = class EditorStats extends DeferredAtomPackage @@ -6,4 +7,12 @@ class EditorStats extends DeferredAtomPackage instanceClass: 'editor-stats/src/editor-stats-view' - onLoadEvent: (event, instance) -> instance.toggle() + stats: new Stats + + activate: (rootView) -> + super + + rootView.on 'keydown', => @stats.track() + rootView.on 'mouseup', => @stats.track() + + onLoadEvent: (event, instance) -> instance.toggle(@stats) diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee index b330f0073..3a5626b7b 100644 --- a/src/packages/editor-stats/spec/editor-stats-spec.coffee +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -23,9 +23,11 @@ describe "EditorStats", -> mins = if mins == 60 then '01' else mins + 1 time = "#{hours}:#{mins}" - atom.loadPackage('editor-stats').getInstance() + editorStatsPackage = atom.loadPackage('editor-stats') + editorStatsPackage.getInstance() + editorStats = editorStatsPackage.stats + editorStats.clear() editor = rootView.getActiveEditor() - editorStats = EditorStats.instance afterEach -> rootView.deactivate() diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index f3d56f4ba..aaa975596 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -3,26 +3,6 @@ d3 = require 'd3.v3' module.exports = class EditorStatsView extends ScrollView - hours = 6 - - time = (date) -> - date.setTime(date.getTime() + 6e4) - hour = date.getHours() - minute = date.getMinutes() - "#{hour}:#{minute}" - - startDate = new Date - x = d3.scale.ordinal().domain d3.range(hours * 60) - y = d3.scale.linear() - - xaxis = d3.svg.axis().scale(x) - .orient('top') - .tickFormat (d) -> - d = new Date(startDate.getTime() + (d * 6e4)) - mins = d.getMinutes() - mins = "0#{mins}" if mins < 9 - "#{d.getHours()}:#{mins}" - @activate: (rootView, state) -> @instance = new EditorStatsView(rootView) @@ -30,8 +10,6 @@ class EditorStatsView extends ScrollView @div class: 'editor-stats-wrapper', tabindex: -1, => @div class: 'editor-stats', outlet: 'editorStats' - eventLog: [] - initialize: (@rootView) -> super @@ -39,26 +17,24 @@ class EditorStatsView extends ScrollView @statusBar = @rootView.find('.status-bar') @css 'background', @statusBar.css('background-color') - date = new Date(startDate) - future = new Date(date.getTime() + (36e5 * hours)) - @eventLog[time(date)] = 0 - - while date < future - @eventLog[time(date)] = 0 - - @rootView.on 'keydown', @track - @rootView.on 'mouseup', @track - draw: -> + @x ?= d3.scale.ordinal().domain d3.range(@stats.hours * 60) + @y ?= d3.scale.linear() w = @rootView.vertical.width() - h = @.height() + h = @height() [pt, pl, pb, pr] = [15, 10, 3, 25] - data = d3.entries @eventLog + data = d3.entries @stats.eventLog - x.rangeBands [0, w - pl - pr], 0.2 - y.range [h - pt - pb, 0] - xaxis.tickSize(-h + pt + pb, 50) + @x.rangeBands [0, w - pl - pr], 0.2 + @y.range [h - pt - pb, 0] + + @xaxis ?= d3.svg.axis().scale(@x).orient('top').tickFormat (d) => + d = new Date(@stats.startDate.getTime() + (d * 6e4)) + mins = d.getMinutes() + mins = "0#{mins}" if mins < 9 + "#{d.getHours()}:#{mins}" + @xaxis.tickSize(-h + pt + pb, 50) vis = d3.select(@editorStats.get(0)).append('svg') .attr('width', w) @@ -68,7 +44,7 @@ class EditorStatsView extends ScrollView vis.append('g') .attr('class', 'x axis') - .call(xaxis) + .call(@xaxis) .selectAll('g') .style('display', (d, i) -> if i % 15 == 0 || i % 5 == 0 || i == data.length - 1 @@ -80,33 +56,26 @@ class EditorStatsView extends ScrollView bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') - .attr('x', (d, i) -> x i) - .attr('y', (d) -> y(d.value)) - .attr('width', x.rangeBand()) + .attr('x', (d, i) => @x i) + .attr('y', (d) => @y(d.value)) + .attr('width', @x.rangeBand()) .attr('class', 'bar') update = => - newdata = d3.entries @eventLog + newdata = d3.entries @stats.eventLog max = d3.max newdata, (d) -> d.value - y.domain [0, max] + @y.domain [0, max] bars.data(newdata).transition() - .attr('height', (d, i) -> h - y(d.value) - pt - pb) - .attr('y', (d, i) -> y(d.value)) + .attr('height', (d, i) => h - @y(d.value) - pt - pb) + .attr('y', (d, i) => @y(d.value)) bars.classed('max', (d, i) -> d.value == max) setInterval update, 5000 - track: => - date = new Date - times = time date - @eventLog[times] ||= 0 - @eventLog[times] += 1 - @eventLog.shift() if @eventLog.length > (hours * 60) - - toggle: -> + toggle: (@stats) -> if @hasParent() @detach() else @@ -116,6 +85,6 @@ class EditorStatsView extends ScrollView @rootView.vertical.append(@) @draw() - detach: => + detach: -> super() @rootView.focus() diff --git a/src/packages/editor-stats/src/stats.coffee b/src/packages/editor-stats/src/stats.coffee new file mode 100644 index 000000000..5e9c6700d --- /dev/null +++ b/src/packages/editor-stats/src/stats.coffee @@ -0,0 +1,29 @@ +module.exports = +class Stats + startDate: new Date + hours: 6 + eventLog: [] + + constructor: -> + date = new Date(@startDate) + future = new Date(date.getTime() + (36e5 * @hours)) + @eventLog[@time(date)] = 0 + + while date < future + @eventLog[@time(date)] = 0 + + clear: -> + @eventLog = [] + + track: -> + date = new Date + times = @time date + @eventLog[times] ?= 0 + @eventLog[times] += 1 + @eventLog.shift() if @eventLog.length > (@hours * 60) + + time: (date) -> + date.setTime(date.getTime() + 6e4) + hour = date.getHours() + minute = date.getMinutes() + "#{hour}:#{minute}" diff --git a/src/packages/tree-view/spec/tree-view-spec.coffee b/src/packages/tree-view/spec/tree-view-spec.coffee index f0a83fe63..ab6d16d1a 100644 --- a/src/packages/tree-view/spec/tree-view-spec.coffee +++ b/src/packages/tree-view/spec/tree-view-spec.coffee @@ -761,7 +761,7 @@ describe "TreeView", -> expect(addDialog.miniEditor.getText().length).toBe 0 - fdescribe "tree-view:move", -> + describe "tree-view:move", -> describe "when a file is selected", -> moveDialog = null From 8c1fe35166d69b60a7a92291a1d387702c5455c0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 09:12:49 -0800 Subject: [PATCH 47/66] Zero pad 9 --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index aaa975596..165be44a7 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -32,7 +32,7 @@ class EditorStatsView extends ScrollView @xaxis ?= d3.svg.axis().scale(@x).orient('top').tickFormat (d) => d = new Date(@stats.startDate.getTime() + (d * 6e4)) mins = d.getMinutes() - mins = "0#{mins}" if mins < 9 + mins = "0#{mins}" if mins <= 9 "#{d.getHours()}:#{mins}" @xaxis.tickSize(-h + pt + pb, 50) From 18f62498a176a949b1e2cdd4ac3f200f53d4d0f9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 09:22:36 -0800 Subject: [PATCH 48/66] Don't rely on status bar for background color --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 165be44a7..df4fc063c 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -14,8 +14,6 @@ class EditorStatsView extends ScrollView super @command 'core:cancel', @detach - @statusBar = @rootView.find('.status-bar') - @css 'background', @statusBar.css('background-color') draw: -> @x ?= d3.scale.ordinal().domain d3.range(@stats.hours * 60) From a3ec402ca9dc8bdb23c9f75891086deab7affcc3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 09:22:50 -0800 Subject: [PATCH 49/66] Only detach with toggle keybinding --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index df4fc063c..f66bdb0f6 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -13,8 +13,6 @@ class EditorStatsView extends ScrollView initialize: (@rootView) -> super - @command 'core:cancel', @detach - draw: -> @x ?= d3.scale.ordinal().domain d3.range(@stats.hours * 60) @y ?= d3.scale.linear() From 1cb81037a81e7a91d03fdb7d9d6cf657e8ce6be4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 09:27:32 -0800 Subject: [PATCH 50/66] :lipstick: --- src/packages/editor-stats/index.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/packages/editor-stats/index.coffee b/src/packages/editor-stats/index.coffee index 70b0871b1..e743c0f18 100644 --- a/src/packages/editor-stats/index.coffee +++ b/src/packages/editor-stats/index.coffee @@ -4,9 +4,7 @@ Stats = require './src/stats' module.exports = class EditorStats extends DeferredAtomPackage loadEvents: ['editor-stats:toggle'] - instanceClass: 'editor-stats/src/editor-stats-view' - stats: new Stats activate: (rootView) -> From 47acd5912a6fc66b3c74538230b31de9294e95e9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 09:29:02 -0800 Subject: [PATCH 51/66] Remove unused variables --- src/packages/editor-stats/spec/editor-stats-spec.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/packages/editor-stats/spec/editor-stats-spec.coffee b/src/packages/editor-stats/spec/editor-stats-spec.coffee index 3a5626b7b..ca274a252 100644 --- a/src/packages/editor-stats/spec/editor-stats-spec.coffee +++ b/src/packages/editor-stats/spec/editor-stats-spec.coffee @@ -3,7 +3,7 @@ RootView = require 'root-view' EditorStats = require 'editor-stats/src/editor-stats-view' describe "EditorStats", -> - [rootView, editorStats, editor, date, time] = [] + [rootView, editorStats, time] = [] simulateKeyUp = (key) -> e = $.Event "keydown", keyCode: key.charCodeAt(0) @@ -27,7 +27,6 @@ describe "EditorStats", -> editorStatsPackage.getInstance() editorStats = editorStatsPackage.stats editorStats.clear() - editor = rootView.getActiveEditor() afterEach -> rootView.deactivate() From 1bf587b626bbb6b412c3debdc889416bf339598f Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 10:02:26 -0800 Subject: [PATCH 52/66] chain them methods --- .../editor-stats/src/editor-stats-view.coffee | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index f66bdb0f6..971a67f00 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -25,12 +25,13 @@ class EditorStatsView extends ScrollView @x.rangeBands [0, w - pl - pr], 0.2 @y.range [h - pt - pb, 0] - @xaxis ?= d3.svg.axis().scale(@x).orient('top').tickFormat (d) => - d = new Date(@stats.startDate.getTime() + (d * 6e4)) - mins = d.getMinutes() - mins = "0#{mins}" if mins <= 9 - "#{d.getHours()}:#{mins}" - @xaxis.tickSize(-h + pt + pb, 50) + @xaxis ?= d3.svg.axis().scale(@x).orient('top') + .tickSize(-h + pt + pb, 50) + .tickFormat (d) => + d = new Date(@stats.startDate.getTime() + (d * 6e4)) + mins = d.getMinutes() + mins = "0#{mins}" if mins <= 9 + "#{d.getHours()}:#{mins}" vis = d3.select(@editorStats.get(0)).append('svg') .attr('width', w) From 93183c8146388a02bac48ed7bbe8553d6f218db2 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 10:05:25 -0800 Subject: [PATCH 53/66] :lipstick: --- src/packages/editor-stats/src/editor-stats-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 971a67f00..9830eaa99 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -43,12 +43,12 @@ class EditorStatsView extends ScrollView .attr('class', 'x axis') .call(@xaxis) .selectAll('g') - .style('display', (d, i) -> + .classed('minor', (d, i) -> i % 5 == 0 && i % 15 != 0) + .style 'display', (d, i) -> if i % 15 == 0 || i % 5 == 0 || i == data.length - 1 'block' else 'none' - ).classed('minor', (d, i) -> i % 5 == 0 && i % 15 != 0) bars = vis.selectAll('rect.bar') .data(data) From 8e1314107cb2cbf05388daab64f79bc70a5b9f18 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 10:10:06 -0800 Subject: [PATCH 54/66] we no longer need the minor tick size --- src/packages/editor-stats/src/editor-stats-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 9830eaa99..a709b3fb9 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -26,7 +26,7 @@ class EditorStatsView extends ScrollView @y.range [h - pt - pb, 0] @xaxis ?= d3.svg.axis().scale(@x).orient('top') - .tickSize(-h + pt + pb, 50) + .tickSize(-h + pt + pb) .tickFormat (d) => d = new Date(@stats.startDate.getTime() + (d * 6e4)) mins = d.getMinutes() From b48a76a17bc5ec70691487b2392b9dc09edd9db5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 10:24:24 -0800 Subject: [PATCH 55/66] Clear interval when detaching Otherwise an interval is leaker per each attach event. --- src/packages/editor-stats/src/editor-stats-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index a709b3fb9..266b37456 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -14,6 +14,7 @@ class EditorStatsView extends ScrollView super draw: -> + @editorStats.empty() @x ?= d3.scale.ordinal().domain d3.range(@stats.hours * 60) @y ?= d3.scale.linear() w = @rootView.vertical.width() @@ -70,7 +71,7 @@ class EditorStatsView extends ScrollView bars.classed('max', (d, i) -> d.value == max) - setInterval update, 5000 + @updateInterval = setInterval update, 5000 toggle: (@stats) -> if @hasParent() @@ -84,4 +85,5 @@ class EditorStatsView extends ScrollView detach: -> super() + clearInterval(@updateInterval) @rootView.focus() From cfed6859d52df13620b7bcfd4a0ead9b3120e180 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 10:28:42 -0800 Subject: [PATCH 56/66] Redraw graph on window resize events --- src/packages/editor-stats/src/editor-stats-view.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 266b37456..e72a6ede1 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -1,5 +1,7 @@ ScrollView = require 'scroll-view' d3 = require 'd3.v3' +_ = require 'underscore' +$ = require 'jquery' module.exports = class EditorStatsView extends ScrollView @@ -13,6 +15,8 @@ class EditorStatsView extends ScrollView initialize: (@rootView) -> super + @subscribe $(window), 'resize', _.debounce((=> @draw()), 300) + draw: -> @editorStats.empty() @x ?= d3.scale.ordinal().domain d3.range(@stats.hours * 60) From 7b472ed88897074e03e7106f6a64a2c289672e26 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 10:33:51 -0800 Subject: [PATCH 57/66] Immediately update after resize completes --- .../editor-stats/src/editor-stats-view.coffee | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index e72a6ede1..afa94c8e4 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -12,10 +12,18 @@ class EditorStatsView extends ScrollView @div class: 'editor-stats-wrapper', tabindex: -1, => @div class: 'editor-stats', outlet: 'editorStats' + pt: 15 + pl: 10 + pb: 3 + pr: 25 + initialize: (@rootView) -> super - @subscribe $(window), 'resize', _.debounce((=> @draw()), 300) + resizer = => + @draw() + @update() + @subscribe $(window), 'resize', _.debounce(resizer, 300) draw: -> @editorStats.empty() @@ -23,15 +31,13 @@ class EditorStatsView extends ScrollView @y ?= d3.scale.linear() w = @rootView.vertical.width() h = @height() - [pt, pl, pb, pr] = [15, 10, 3, 25] - data = d3.entries @stats.eventLog - @x.rangeBands [0, w - pl - pr], 0.2 - @y.range [h - pt - pb, 0] + @x.rangeBands [0, w - @pl - @pr], 0.2 + @y.range [h - @pt - @pb, 0] @xaxis ?= d3.svg.axis().scale(@x).orient('top') - .tickSize(-h + pt + pb) + .tickSize(-h + @pt + @pb) .tickFormat (d) => d = new Date(@stats.startDate.getTime() + (d * 6e4)) mins = d.getMinutes() @@ -42,7 +48,7 @@ class EditorStatsView extends ScrollView .attr('width', w) .attr('height', h) .append('g') - .attr('transform', "translate(#{pl},#{pt})") + .attr('transform', "translate(#{@pl},#{@pt})") vis.append('g') .attr('class', 'x axis') @@ -55,7 +61,7 @@ class EditorStatsView extends ScrollView else 'none' - bars = vis.selectAll('rect.bar') + @bars = vis.selectAll('rect.bar') .data(data) .enter().append('rect') .attr('x', (d, i) => @x i) @@ -63,19 +69,17 @@ class EditorStatsView extends ScrollView .attr('width', @x.rangeBand()) .attr('class', 'bar') - update = => - newdata = d3.entries @stats.eventLog - max = d3.max newdata, (d) -> d.value + @updateInterval = setInterval((=> @update()), 5000) - @y.domain [0, max] - - bars.data(newdata).transition() - .attr('height', (d, i) => h - @y(d.value) - pt - pb) - .attr('y', (d, i) => @y(d.value)) - - bars.classed('max', (d, i) -> d.value == max) - - @updateInterval = setInterval update, 5000 + update: -> + newdata = d3.entries @stats.eventLog + max = d3.max newdata, (d) -> d.value + @y.domain [0, max] + h = @height() + @bars.data(newdata).transition() + .attr('height', (d, i) => h - @y(d.value) - @pt - @pb) + .attr('y', (d, i) => @y(d.value)) + @bars.classed('max', (d, i) -> d.value == max) toggle: (@stats) -> if @hasParent() From b1b9a6914602e26c07dda1bcf9eba80ee7ee2ddf Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 10:34:31 -0800 Subject: [PATCH 58/66] :camel: case --- src/packages/editor-stats/src/editor-stats-view.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index afa94c8e4..121e969fc 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -72,11 +72,11 @@ class EditorStatsView extends ScrollView @updateInterval = setInterval((=> @update()), 5000) update: -> - newdata = d3.entries @stats.eventLog - max = d3.max newdata, (d) -> d.value + newData = d3.entries @stats.eventLog + max = d3.max newData, (d) -> d.value @y.domain [0, max] h = @height() - @bars.data(newdata).transition() + @bars.data(newData).transition() .attr('height', (d, i) => h - @y(d.value) - @pt - @pb) .attr('y', (d, i) => @y(d.value)) @bars.classed('max', (d, i) -> d.value == max) From 262cbcf168ac017bd63c9421fd01f3b3b9e5aae5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 10:36:53 -0800 Subject: [PATCH 59/66] Set initial render to be 100ms after attach --- src/packages/editor-stats/src/editor-stats-view.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 121e969fc..b4983c08a 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -69,6 +69,7 @@ class EditorStatsView extends ScrollView .attr('width', @x.rangeBand()) .attr('class', 'bar') + setTimeout((=> @update()), 100) @updateInterval = setInterval((=> @update()), 5000) update: -> From d7b09f0ba9baf5ddb7e30bddcf478c16039e5574 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 10:39:48 -0800 Subject: [PATCH 60/66] fix initial height so bars don't fly in from the top --- src/packages/editor-stats/src/editor-stats-view.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index b4983c08a..047c20f5b 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -65,6 +65,7 @@ class EditorStatsView extends ScrollView .data(data) .enter().append('rect') .attr('x', (d, i) => @x i) + .attr('height', (d, i) => h - @y(d.value) - @pt - @pb) .attr('y', (d) => @y(d.value)) .attr('width', @x.rangeBand()) .attr('class', 'bar') From 341764e406c90ba541b89b9c100b069167023c39 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 1 Feb 2013 10:45:35 -0800 Subject: [PATCH 61/66] we need to set this for the initial bar, otherwise there's a small jump at the beginning --- src/packages/editor-stats/src/editor-stats-view.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/packages/editor-stats/src/editor-stats-view.coffee b/src/packages/editor-stats/src/editor-stats-view.coffee index 047c20f5b..bd93cc1c3 100644 --- a/src/packages/editor-stats/src/editor-stats-view.coffee +++ b/src/packages/editor-stats/src/editor-stats-view.coffee @@ -32,9 +32,10 @@ class EditorStatsView extends ScrollView w = @rootView.vertical.width() h = @height() data = d3.entries @stats.eventLog + max = d3.max data, (d) -> d.value @x.rangeBands [0, w - @pl - @pr], 0.2 - @y.range [h - @pt - @pb, 0] + @y.domain([0, max]).range [h - @pt - @pb, 0] @xaxis ?= d3.svg.axis().scale(@x).orient('top') .tickSize(-h + @pt + @pb) From 31aa1a947128635dcd084ffba7b021d95a3b91d4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 11:11:52 -0800 Subject: [PATCH 62/66] Add a little documentation --- .atom/packages/Readme.md | 1 + .atom/themes/Readme.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.atom/packages/Readme.md b/.atom/packages/Readme.md index e69de29bb..540b6949c 100644 --- a/.atom/packages/Readme.md +++ b/.atom/packages/Readme.md @@ -0,0 +1 @@ +All packages in this directory will be automatically loaded diff --git a/.atom/themes/Readme.md b/.atom/themes/Readme.md index e69de29bb..dbedd5e13 100644 --- a/.atom/themes/Readme.md +++ b/.atom/themes/Readme.md @@ -0,0 +1 @@ +All themes in this directory will be automatically loaded From 0484ecde7d106bcb3e4bc71f80fee196360cacd9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 11:12:58 -0800 Subject: [PATCH 63/66] Screaming README --- .atom/packages/{Readme.md => README.md} | 0 .atom/themes/{Readme.md => README.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .atom/packages/{Readme.md => README.md} (100%) rename .atom/themes/{Readme.md => README.md} (100%) diff --git a/.atom/packages/Readme.md b/.atom/packages/README.md similarity index 100% rename from .atom/packages/Readme.md rename to .atom/packages/README.md diff --git a/.atom/themes/Readme.md b/.atom/themes/README.md similarity index 100% rename from .atom/themes/Readme.md rename to .atom/themes/README.md From a51ccdee0660cd03854323cce8bfca04aeb31b1b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 11:13:22 -0800 Subject: [PATCH 64/66] Use valid css comment --- .atom/user.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.atom/user.css b/.atom/user.css index f53057581..d63ad257e 100644 --- a/.atom/user.css +++ b/.atom/user.css @@ -1,8 +1,8 @@ -// User styles +/* User styles */ .tree-view { } .editor { -} \ No newline at end of file +} From 919ecb5a5659f20f8535ec10187a5f5759975abe Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 11:15:30 -0800 Subject: [PATCH 65/66] Add trailing newline --- .atom/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.atom/config.json b/.atom/config.json index 89e425883..61420466f 100644 --- a/.atom/config.json +++ b/.atom/config.json @@ -8,4 +8,4 @@ "IR_Black" ] } -} \ No newline at end of file +} From 5285ee2b762b353eb44c49019cbfe8b373731783 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Feb 2013 11:17:12 -0800 Subject: [PATCH 66/66] 16 is the new 12 --- .atom/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.atom/config.json b/.atom/config.json index 61420466f..f6b59770b 100644 --- a/.atom/config.json +++ b/.atom/config.json @@ -1,6 +1,6 @@ { "editor": { - "fontSize": 12 + "fontSize": 16 }, "core": { "themes": [