perkins 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/.vagrant/machines/default/virtualbox/action_provision +1 -0
- data/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/.vagrant/machines/default/virtualbox/id +1 -0
- data/Gemfile +0 -1
- data/README.md +11 -4
- data/Rakefile +3 -2
- data/TODO.md +2 -2
- data/Vagrantfile +53 -0
- data/db/migrate/20150220143050_add_status_fields_to_repos.rb +11 -0
- data/db/schema.rb +3 -1
- data/examples/Gemfile +4 -0
- data/examples/Gemfile.lock +164 -0
- data/examples/Procfile +4 -0
- data/examples/boot.rb +15 -0
- data/examples/config.ru +22 -0
- data/examples/database.yml +2 -2
- data/examples/sidekiq.yml +9 -0
- data/lib/core_ext/string/color.rb +22 -0
- data/lib/perkins/application.rb +27 -3
- data/lib/perkins/assets/images/error.gif +0 -0
- data/lib/perkins/assets/images/working.gif +0 -0
- data/lib/perkins/assets/javascripts/app.js +17 -1
- data/lib/perkins/assets/javascripts/config.js.coffee +14 -0
- data/lib/perkins/assets/javascripts/log_view.js.coffee +1 -2
- data/lib/perkins/assets/javascripts/perkings.js.coffee +129 -20
- data/lib/perkins/assets/javascripts/perkins/helpers.js.coffee +21 -0
- data/lib/perkins/assets/javascripts/perkins/m/models.js.coffee +50 -0
- data/lib/perkins/assets/javascripts/perkins/router.js.coffee +10 -0
- data/lib/perkins/assets/javascripts/perkins/v/dashboard.js.coffee +17 -0
- data/lib/perkins/assets/javascripts/perkins/v/err.js.coffee +12 -0
- data/lib/perkins/assets/javascripts/perkins/v/menu.js.coffee +10 -0
- data/lib/perkins/assets/javascripts/perkins/v/my_repos.js.coffee +41 -0
- data/lib/perkins/assets/javascripts/perkins/v/orgs.js.coffee +39 -0
- data/lib/perkins/assets/javascripts/perkins/v/profile.js.coffee +20 -0
- data/lib/perkins/assets/javascripts/perkins/v/repo.js.coffee +192 -0
- data/lib/perkins/assets/javascripts/perkins/v/sidebar.js.coffee +33 -0
- data/lib/perkins/assets/javascripts/templates/dashboard.hamlc +11 -0
- data/lib/perkins/assets/javascripts/templates/error.hamlc +22 -0
- data/lib/perkins/assets/javascripts/templates/menu.hamlc +18 -0
- data/lib/perkins/assets/javascripts/templates/org.hamlc +77 -0
- data/lib/perkins/assets/javascripts/templates/profile.hamlc +28 -0
- data/lib/perkins/assets/javascripts/templates/repo.hamlc +37 -0
- data/lib/perkins/assets/javascripts/templates/repos/build_row.hamlc +19 -0
- data/lib/perkins/assets/javascripts/templates/repos/builds.hamlc +25 -0
- data/lib/perkins/assets/javascripts/templates/repos/config.hamlc +77 -0
- data/lib/perkins/assets/javascripts/templates/repos/gb_repo.hamlc +31 -0
- data/lib/perkins/assets/javascripts/templates/repos/github.hamlc +7 -0
- data/lib/perkins/assets/javascripts/templates/repos/menu.hamlc +17 -0
- data/lib/perkins/assets/javascripts/templates/repos/report_detail.hamlc +53 -0
- data/lib/perkins/assets/javascripts/templates/sidebar.hamlc +14 -0
- data/lib/perkins/assets/javascripts/templates/sidebar_repo.hamlc +4 -0
- data/lib/perkins/assets/javascripts/vendor/backbone-min.js +2 -0
- data/lib/perkins/assets/javascripts/vendor/backbone.marionette.js +2891 -0
- data/lib/perkins/assets/javascripts/vendor/hamlcoffee.js.coffee.erb +138 -0
- data/lib/perkins/assets/javascripts/vendor/livequery.jquery.js +8 -0
- data/lib/perkins/assets/javascripts/vendor/log.js +1 -1
- data/lib/perkins/assets/javascripts/vendor/md5.js +207 -0
- data/lib/perkins/assets/javascripts/vendor/nprogress.js +476 -0
- data/lib/perkins/assets/javascripts/vendor/underscore.js +6 -0
- data/lib/perkins/assets/stylesheets/app.css +3 -0
- data/lib/perkins/assets/stylesheets/bootstrap-overrides.css.scss +13 -0
- data/lib/perkins/assets/stylesheets/styles.css.scss +30 -3
- data/lib/perkins/assets/stylesheets/vendor/nprogress.css +74 -0
- data/lib/perkins/assets.rb +42 -0
- data/lib/perkins/build/script/ruby.rb +1 -1
- data/lib/perkins/build_report.rb +13 -0
- data/lib/perkins/{worker.rb → build_worker.rb} +9 -5
- data/lib/perkins/cli.rb +4 -2
- data/lib/perkins/commit.rb +8 -1
- data/lib/perkins/git_loader_worker.rb +29 -0
- data/lib/perkins/repo.rb +23 -9
- data/lib/perkins/runner.rb +16 -25
- data/lib/perkins/server.rb +121 -116
- data/lib/perkins/version.rb +1 -1
- data/lib/perkins/views/builds.haml +0 -3
- data/lib/perkins/views/layout.haml +25 -36
- data/lib/perkins/views/menu.haml +1 -1
- data/lib/perkins/views/repos/github.haml +0 -31
- data/lib/perkins/views/repos/repo.haml +1 -1
- data/lib/perkins.rb +4 -2
- data/perkins.gemspec +5 -2
- data/spec/lib/repo_spec.rb +27 -6
- data/spec/lib/runner_spec.rb +1 -0
- data/spec/lib/server_spec.rb +6 -23
- data/spec/spec_helper.rb +14 -3
- metadata +160 -70
- data/examples/config.rb +0 -12
- data/examples/mongo.yml +0 -13
- data/lib/perkins/listener.rb +0 -38
- data/spec/lib/listener_spec.rb +0 -30
@@ -0,0 +1,138 @@
|
|
1
|
+
#https://raw.githubusercontent.com/netzpirat/haml_coffee_assets/master/vendor/assets/javascripts/hamlcoffee.js.coffee.erb
|
2
|
+
# HAML Coffee namespace
|
3
|
+
#
|
4
|
+
class window.HAML
|
5
|
+
|
6
|
+
# HAML Coffee html escape function.
|
7
|
+
#
|
8
|
+
# @param text [String] the text to escape
|
9
|
+
# @return [String] the escaped text
|
10
|
+
#
|
11
|
+
@escape: (text) ->
|
12
|
+
("" + text)
|
13
|
+
.replace(/&/g, "&")
|
14
|
+
.replace(/</g, "<")
|
15
|
+
.replace(/>/g, ">")
|
16
|
+
.replace(/"/g, """)
|
17
|
+
.replace(/'/g, "'")
|
18
|
+
.replace(/\//g, "/")
|
19
|
+
|
20
|
+
# HAML Coffee clean value function. Beside just
|
21
|
+
# cleaning `null` and `undefined` values, it
|
22
|
+
# adds a hidden unicode marker character to
|
23
|
+
# boolean values, so that the render time boolean
|
24
|
+
# logic can distinguish between real booleans and
|
25
|
+
# boolean-like strings.
|
26
|
+
#
|
27
|
+
# @param text [String] the text to be cleaned
|
28
|
+
# @return [String] the cleaned text
|
29
|
+
#
|
30
|
+
@cleanValue: (text) ->
|
31
|
+
switch text
|
32
|
+
when null, undefined then ''
|
33
|
+
when true, false then '\u0093' + text
|
34
|
+
else text
|
35
|
+
|
36
|
+
# Extends an object with the properties from
|
37
|
+
# the source objects.
|
38
|
+
#
|
39
|
+
# @param [Object] obj the object to extended
|
40
|
+
# @param [Object] sources the objects to copy from
|
41
|
+
# @return [Object] the extended object
|
42
|
+
#
|
43
|
+
@extend: (obj, sources...) ->
|
44
|
+
for source in sources
|
45
|
+
obj[key] = val for key, val of source
|
46
|
+
|
47
|
+
obj
|
48
|
+
|
49
|
+
# HAML Coffee global template context.
|
50
|
+
#
|
51
|
+
# @return [Object] the global template context
|
52
|
+
#
|
53
|
+
@globals: -> {}
|
54
|
+
|
55
|
+
# Get the HAML template context. This merges the local
|
56
|
+
# and the global template context into a new context.
|
57
|
+
#
|
58
|
+
# @param locals [Object] the local template context
|
59
|
+
# @return [Object] the merged context
|
60
|
+
#
|
61
|
+
@context: (locals) ->
|
62
|
+
@extend {}, HAML.globals(), locals
|
63
|
+
|
64
|
+
# Preserve newlines in the text
|
65
|
+
#
|
66
|
+
# @param text [String] the text to preserve
|
67
|
+
# @return [String] the preserved text
|
68
|
+
#
|
69
|
+
@preserve: (text) ->
|
70
|
+
text.replace /\n/g, '
'
|
71
|
+
|
72
|
+
# Find and preserve newlines in the preserving tags
|
73
|
+
#
|
74
|
+
# @param text [String] the text to preserve
|
75
|
+
# @return [String] the preserved text
|
76
|
+
#
|
77
|
+
@findAndPreserve: (text) ->
|
78
|
+
tags = '<%= ::HamlCoffeeAssets.config.preserveTags %>'.split(',').join('|')
|
79
|
+
text = text.replace(/\r/g, '').replace ///<(#{ tags })>([\s\S]*?)<\/\1>///g, (str, tag, content) ->
|
80
|
+
"<#{ tag }>#{ <%= ::HamlCoffeeAssets.config.customPreserve %>(content) }</#{ tag }>"
|
81
|
+
|
82
|
+
# The surround helper surrounds the function output
|
83
|
+
# with the start and end string without whitespace in between.
|
84
|
+
#
|
85
|
+
# @param [String] start the text to prepend to the text
|
86
|
+
# @param [String] end the text to append to the text
|
87
|
+
# @param [Function] fn the text generating function
|
88
|
+
# @return [String] the surrounded text
|
89
|
+
#
|
90
|
+
@surround: (start, end, fn) ->
|
91
|
+
start + fn.call(@)?.replace(/^\s+|\s+$/g, '') + end
|
92
|
+
|
93
|
+
# The succeed helper appends text to the function output
|
94
|
+
# without whitespace in between.
|
95
|
+
#
|
96
|
+
# @param [String] end the text to append to the text
|
97
|
+
# @param [Function] fn the text generating function
|
98
|
+
# @return [String] the succeeded text
|
99
|
+
#
|
100
|
+
@succeed: (end, fn) ->
|
101
|
+
fn.call(@)?.replace(/\s+$/g, '') + end
|
102
|
+
|
103
|
+
# The precede helper prepends text to the function output
|
104
|
+
# without whitespace in between.
|
105
|
+
#
|
106
|
+
# @param [String] start the text to prepend to the text
|
107
|
+
# @param [Function] fn the text generating function
|
108
|
+
# @return [String] the preeceded text
|
109
|
+
#
|
110
|
+
@precede: (start, fn) ->
|
111
|
+
start + fn.call(@)?.replace(/^\s+/g, '')
|
112
|
+
|
113
|
+
# The reference helper creates id and class attributes
|
114
|
+
# for an object reference.
|
115
|
+
#
|
116
|
+
# @param [Object] object the referenced object
|
117
|
+
# @param [String] prefix the optional id and class prefix
|
118
|
+
# @return [String] the id and class attributes
|
119
|
+
#
|
120
|
+
@reference: (object, prefix) ->
|
121
|
+
name = if prefix then prefix + '_' else ''
|
122
|
+
|
123
|
+
if typeof(object.hamlObjectRef) is 'function'
|
124
|
+
name += object.hamlObjectRef()
|
125
|
+
else
|
126
|
+
name += (object.constructor?.name || 'object').replace(/\W+/g, '_').replace(/([a-z\d])([A-Z])/g, '$1_$2').toLowerCase()
|
127
|
+
|
128
|
+
id = if typeof(object.to_key) is 'function'
|
129
|
+
object.to_key()
|
130
|
+
else if typeof(object.id) is 'function'
|
131
|
+
object.id()
|
132
|
+
else if object.id
|
133
|
+
object.id
|
134
|
+
else
|
135
|
+
object
|
136
|
+
|
137
|
+
result = "class='#{ name }'"
|
138
|
+
result += " id='#{ name }_#{ id }'" if id
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/*! jquery.livequery - v1.3.6 - 2013-08-26
|
2
|
+
* Copyright (c)
|
3
|
+
* (c) 2010, Brandon Aaron (http://brandonaaron.net)
|
4
|
+
* (c) 2012 - 2013, Alexander Zaytsev (http://hazzik.ru/en)
|
5
|
+
* Dual licensed under the MIT (MIT_LICENSE.txt)
|
6
|
+
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
|
7
|
+
*/
|
8
|
+
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a,b){function c(a,b,c,d){return!(a.selector!=b.selector||a.context!=b.context||c&&c.$lqguid!=b.fn.$lqguid||d&&d.$lqguid!=b.fn2.$lqguid)}a.extend(a.fn,{livequery:function(b,e){var f,g=this;return a.each(d.queries,function(a,d){return c(g,d,b,e)?(f=d)&&!1:void 0}),f=f||new d(g.selector,g.context,b,e),f.stopped=!1,f.run(),g},expire:function(b,e){var f=this;return a.each(d.queries,function(a,g){c(f,g,b,e)&&!f.stopped&&d.stop(g.id)}),f}});var d=a.livequery=function(b,c,e,f){var g=this;return g.selector=b,g.context=c,g.fn=e,g.fn2=f,g.elements=a([]),g.stopped=!1,g.id=d.queries.push(g)-1,e.$lqguid=e.$lqguid||d.guid++,f&&(f.$lqguid=f.$lqguid||d.guid++),g};d.prototype={stop:function(){var b=this;b.stopped||(b.fn2&&b.elements.each(b.fn2),b.elements=a([]),b.stopped=!0)},run:function(){var b=this;if(!b.stopped){var c=b.elements,d=a(b.selector,b.context),e=d.not(c),f=c.not(d);b.elements=d,e.each(b.fn),b.fn2&&f.each(b.fn2)}}},a.extend(d,{guid:0,queries:[],queue:[],running:!1,timeout:null,registered:[],checkQueue:function(){if(d.running&&d.queue.length)for(var a=d.queue.length;a--;)d.queries[d.queue.shift()].run()},pause:function(){d.running=!1},play:function(){d.running=!0,d.run()},registerPlugin:function(){a.each(arguments,function(b,c){if(a.fn[c]&&!(a.inArray(c,d.registered)>0)){var e=a.fn[c];a.fn[c]=function(){var a=e.apply(this,arguments);return d.run(),a},d.registered.push(c)}})},run:function(c){c!==b?a.inArray(c,d.queue)<0&&d.queue.push(c):a.each(d.queries,function(b){a.inArray(b,d.queue)<0&&d.queue.push(b)}),d.timeout&&clearTimeout(d.timeout),d.timeout=setTimeout(d.checkQueue,20)},stop:function(c){c!==b?d.queries[c].stop():a.each(d.queries,d.prototype.stop)}}),d.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove","html","prop","removeProp"),a(function(){d.play()})});
|
@@ -1,2 +1,2 @@
|
|
1
|
-
minispade.register('log', "(function() {(function() {\n\n this.Log = function() {\n this.autoCloseFold = true;\n this.listeners = [];\n this.renderer = new Log.Renderer;\n this.children = new Log.Nodes(this);\n this.parts = {};\n this.folds = new Log.Folds(this);\n this.times = new Log.Times(this);\n return this;\n };\n\n Log.extend = function(one, other) {\n var name;\n for (name in other) {\n one[name] = other[name];\n }\n return one;\n };\n\n Log.extend(Log, {\n DEBUG: true,\n SLICE: 500,\n TIMEOUT: 25,\n FOLD: /fold:(start|end):([\\w_\\-\\.]+)/,\n TIME: /time:(start|end):([\\w_\\-\\.]+):?([\\w_\\-\\.\\=\\,]*)/,\n create: function(options) {\n var listener, log, _i, _len, _ref;\n options || (options = {});\n log = new Log();\n if (options.limit) {\n log.listeners.push(log.limit = new Log.Limit(options.limit));\n }\n _ref = options.listeners || [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n listener = _ref[_i];\n log.listeners.push(listener);\n }\n return log;\n }\n });\nminispade.require('log/nodes');\n\n Log.prototype = Log.extend(new Log.Node, {\n set: function(num, string) {\n if (this.parts[num]) {\n return console.log(\"part \" + num + \" exists\");\n } else {\n this.parts[num] = true;\n return Log.Part.create(this, num, string);\n }\n },\n insert: function(data, pos) {\n this.trigger('insert', data, pos);\n return this.renderer.insert(data, pos);\n },\n remove: function(node) {\n this.trigger('remove', node);\n return this.renderer.remove(node);\n },\n hide: function(node) {\n this.trigger('hide', node);\n return this.renderer.hide(node);\n },\n trigger: function() {\n var args, ix, listener, _i, _len, _ref, _results;\n args = [this].concat(Array.prototype.slice.apply(arguments));\n _ref = this.listeners;\n _results = [];\n for (ix = _i = 0, _len = _ref.length; _i < _len; ix = ++_i) {\n listener = _ref[ix];\n _results.push(listener.notify.apply(listener, args));\n }\n return _results;\n }\n });\n\n Log.Listener = function() {};\n\n Log.extend(Log.Listener.prototype, {\n notify: function(log, event) {\n if (this[event]) {\n return this[event].apply(this, [log].concat(Array.prototype.slice.call(arguments, 2)));\n }\n }\n });\nminispade.require('log/folds');\nminispade.require('log/times');\nminispade.require('log/deansi');\nminispade.require('log/limit');\nminispade.require('log/renderer');\n\n}).call(this);\n\n})();\n//@ sourceURL=log");minispade.register('log/deansi', "(function() {(function() {\n\n Log.Deansi = {\n CLEAR_ANSI: /(?:\\033)(?:\\[0?c|\\[[0356]n|\\[7[lh]|\\[\\?25[lh]|\\(B|H|\\[(?:\\d+(;\\d+){,2})?G|\\[(?:[12])?[JK]|[DM]|\\[0K)/gm,\n apply: function(string) {\n var nodes,\n _this = this;\n if (!string) {\n return [];\n }\n string = string.replace(this.CLEAR_ANSI, '');\n nodes = ansiparse(string).map(function(part) {\n return _this.node(part);\n });\n return nodes;\n },\n node: function(part) {\n var classes, node;\n node = {\n type: 'span',\n text: part.text\n };\n if (classes = this.classes(part)) {\n node[\"class\"] = classes.join(' ');\n }\n return node;\n },\n classes: function(part) {\n var result;\n result = [];\n result = result.concat(this.colors(part));\n if (result.length > 0) {\n return result;\n }\n },\n colors: function(part) {\n var colors;\n colors = [];\n if (part.foreground) {\n colors.push(part.foreground);\n }\n if (part.background) {\n colors.push(\"bg-\" + part.background);\n }\n if (part.bold) {\n colors.push('bold');\n }\n if (part.italic) {\n colors.push('italic');\n }\n if (part.underline) {\n colors.push('underline');\n }\n return colors;\n },\n hidden: function(part) {\n if (part.text.match(/\\r/)) {\n part.text = part.text.replace(/^.*\\r/gm, '');\n return true;\n }\n }\n };\n\n}).call(this);\n\n})();\n//@ sourceURL=log/deansi");minispade.register('log/folds', "(function() {(function() {\n\n Log.Folds = function(log) {\n this.log = log;\n this.folds = {};\n return this;\n };\n\n Log.extend(Log.Folds.prototype, {\n add: function(data) {\n var fold, _base, _name;\n fold = (_base = this.folds)[_name = data.name] || (_base[_name] = new Log.Folds.Fold);\n fold.receive(data, {\n autoCloseFold: this.log.autoCloseFold\n });\n return fold.active;\n }\n });\n\n Log.Folds.Fold = function() {\n return this;\n };\n\n Log.extend(Log.Folds.Fold.prototype, {\n receive: function(data, options) {\n this[data.event] = data.id;\n if (this.start && this.end && !this.active) {\n return this.activate(options);\n }\n },\n activate: function(options) {\n var fragment, nextSibling, node, parentNode, toRemove, _i, _len, _ref;\n options || (options = {});\n if (Log.DEBUG) {\n console.log(\"F.n - activate \" + this.start);\n }\n toRemove = this.fold.parentNode;\n parentNode = toRemove.parentNode;\n nextSibling = toRemove.nextSibling;\n parentNode.removeChild(toRemove);\n fragment = document.createDocumentFragment();\n _ref = this.nodes;\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n node = _ref[_i];\n fragment.appendChild(node);\n }\n this.fold.appendChild(fragment);\n parentNode.insertBefore(toRemove, nextSibling);\n this.fold.setAttribute('class', this.classes(options['autoCloseFold']));\n return this.active = true;\n },\n classes: function(autoCloseFold) {\n var classes;\n classes = this.fold.getAttribute('class').split(' ');\n classes.push('fold');\n if (!autoCloseFold) {\n classes.push('open');\n }\n if (this.fold.childNodes.length > 2) {\n classes.push('active');\n }\n return classes.join(' ');\n }\n });\n\n Object.defineProperty(Log.Folds.Fold.prototype, 'fold', {\n get: function() {\n return this._fold || (this._fold = document.getElementById(this.start));\n }\n });\n\n Object.defineProperty(Log.Folds.Fold.prototype, 'nodes', {\n get: function() {\n var node, nodes;\n node = this.fold;\n nodes = [];\n while ((node = node.nextSibling) && node.id !== this.end) {\n nodes.push(node);\n }\n return nodes;\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/folds");minispade.register('log/limit', "(function() {(function() {\n\n Log.Limit = function(max_lines) {\n this.max_lines = max_lines || 1000;\n return this;\n };\n\n Log.Limit.prototype = Log.extend(new Log.Listener, {\n count: 0,\n insert: function(log, node, pos) {\n if (node.type === 'paragraph' && !node.hidden) {\n return this.count += 1;\n }\n }\n });\n\n Object.defineProperty(Log.Limit.prototype, 'limited', {\n get: function() {\n return this.count >= this.max_lines;\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/limit");minispade.register('log/nodes', "(function() {(function() {\n var newLineAtTheEndRegexp, newLineRegexp, rRegexp, removeCarriageReturns;\n\n Log.Node = function(id, num) {\n this.id = id;\n this.num = num;\n this.key = Log.Node.key(this.id);\n this.children = new Log.Nodes(this);\n return this;\n };\n\n Log.extend(Log.Node, {\n key: function(id) {\n if (id) {\n return id.split('-').map(function(i) {\n return '000000'.concat(i).slice(-6);\n }).join('');\n }\n }\n });\n\n Log.extend(Log.Node.prototype, {\n addChild: function(node) {\n return this.children.add(node);\n },\n remove: function() {\n this.log.remove(this.element);\n return this.parent.children.remove(this);\n }\n });\n\n Object.defineProperty(Log.Node.prototype, 'log', {\n get: function() {\n var _ref;\n return this._log || (this._log = ((_ref = this.parent) != null ? _ref.log : void 0) || this.parent);\n }\n });\n\n Object.defineProperty(Log.Node.prototype, 'firstChild', {\n get: function() {\n return this.children.first;\n }\n });\n\n Object.defineProperty(Log.Node.prototype, 'lastChild', {\n get: function() {\n return this.children.last;\n }\n });\n\n Log.Nodes = function(parent) {\n if (parent) {\n this.parent = parent;\n }\n this.items = [];\n this.index = {};\n return this;\n };\n\n Log.extend(Log.Nodes.prototype, {\n add: function(item) {\n var ix, next, prev, _ref, _ref1;\n ix = this.position(item) || 0;\n this.items.splice(ix, 0, item);\n if (this.parent) {\n item.parent = this.parent;\n }\n prev = function(item) {\n while (item && !item.children.last) {\n item = item.prev;\n }\n return item != null ? item.children.last : void 0;\n };\n next = function(item) {\n while (item && !item.children.first) {\n item = item.next;\n }\n return item != null ? item.children.first : void 0;\n };\n if (item.prev = this.items[ix - 1] || prev((_ref = this.parent) != null ? _ref.prev : void 0)) {\n item.prev.next = item;\n }\n if (item.next = this.items[ix + 1] || next((_ref1 = this.parent) != null ? _ref1.next : void 0)) {\n item.next.prev = item;\n }\n return item;\n },\n remove: function(item) {\n this.items.splice(this.items.indexOf(item), 1);\n if (item.next) {\n item.next.prev = item.prev;\n }\n if (item.prev) {\n item.prev.next = item.next;\n }\n if (this.items.length === 0) {\n return this.parent.remove();\n }\n },\n position: function(item) {\n var ix, _i, _ref;\n for (ix = _i = _ref = this.items.length - 1; _i >= 0; ix = _i += -1) {\n if (this.items[ix].key < item.key) {\n return ix + 1;\n }\n }\n },\n indexOf: function() {\n return this.items.indexOf.apply(this.items, arguments);\n },\n slice: function() {\n return this.items.slice.apply(this.items, arguments);\n },\n each: function(func) {\n return this.items.slice().forEach(func);\n },\n map: function(func) {\n return this.items.map(func);\n }\n });\n\n Object.defineProperty(Log.Nodes.prototype, 'first', {\n get: function() {\n return this.items[0];\n }\n });\n\n Object.defineProperty(Log.Nodes.prototype, 'last', {\n get: function() {\n return this.items[this.length - 1];\n }\n });\n\n Object.defineProperty(Log.Nodes.prototype, 'length', {\n get: function() {\n return this.items.length;\n }\n });\n\n Log.Part = function(id, num, string) {\n Log.Node.apply(this, arguments);\n this.string = string || '';\n this.string = this.string.replace(/\\033\\[1000D/gm, '\\r');\n this.string = this.string.replace(/\\r+\\n/gm, '\\n');\n this.strings = this.string.split(/^/gm) || [];\n this.slices = ((function() {\n var _results;\n _results = [];\n while (this.strings.length > 0) {\n _results.push(this.strings.splice(0, Log.SLICE));\n }\n return _results;\n }).call(this));\n return this;\n };\n\n Log.extend(Log.Part, {\n create: function(log, num, string) {\n var part;\n part = new Log.Part(num.toString(), num, string);\n log.addChild(part);\n return part.process(0, -1);\n }\n });\n\n Log.Part.prototype = Log.extend(new Log.Node, {\n remove: function() {},\n process: function(slice, num) {\n var node, span, spans, string, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _ref4,\n _this = this;\n _ref = this.slices[slice] || [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n string = _ref[_i];\n if ((_ref1 = this.log.limit) != null ? _ref1.limited : void 0) {\n return;\n }\n spans = [];\n _ref2 = Log.Deansi.apply(string);\n for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {\n node = _ref2[_j];\n span = Log.Span.create(this, \"\" + this.id + \"-\" + (num += 1), num, node.text, node[\"class\"]);\n span.render();\n spans.push(span);\n }\n if ((_ref3 = spans[0]) != null ? (_ref4 = _ref3.line) != null ? _ref4.cr : void 0 : void 0) {\n spans[0].line.clear();\n }\n }\n if (!(slice >= this.slices.length - 1)) {\n return setTimeout((function() {\n return _this.process(slice + 1, num);\n }), Log.TIMEOUT);\n }\n }\n });\n\n newLineAtTheEndRegexp = new RegExp(\"\\n$\");\n\n newLineRegexp = new RegExp(\"\\n\");\n\n rRegexp = new RegExp(\"\\r\");\n\n removeCarriageReturns = function(string) {\n var index;\n index = string.lastIndexOf(\"\\r\");\n if (index === -1) {\n return string;\n }\n return string.substr(index + 1);\n };\n\n Log.Span = function(id, num, text, classes) {\n var fold, time, _ref;\n Log.Node.apply(this, arguments);\n if (fold = text.match(Log.FOLD)) {\n this.fold = true;\n this.event = fold[1];\n this.text = this.name = fold[2];\n } else if (time = text.match(Log.TIME)) {\n this.time = true;\n this.event = time[1];\n this.name = time[2];\n this.stats = time[3];\n } else {\n this.text = text;\n this.text = removeCarriageReturns(this.text);\n this.text = this.text.replace(newLineAtTheEndRegexp, '');\n this.nl = !!((_ref = text[text.length - 1]) != null ? _ref.match(newLineRegexp) : void 0);\n this.cr = !!text.match(rRegexp);\n this[\"class\"] = this.cr && ['clears'] || classes;\n }\n return this;\n };\n\n Log.extend(Log.Span, {\n create: function(parent, id, num, text, classes) {\n var span;\n span = new Log.Span(id, num, text, classes);\n parent.addChild(span);\n return span;\n },\n render: function(parent, id, num, text, classes) {\n var span;\n span = this.create(parent, id, num, text, classes);\n return span.render();\n }\n });\n\n Log.Span.prototype = Log.extend(new Log.Node, {\n render: function() {\n var tail;\n if (this.time && this.event === 'end' && this.prev) {\n if (Log.DEBUG) {\n console.log(\"S.0 insert \" + this.id + \" after prev \" + this.prev.id);\n }\n this.nl = this.prev.nl;\n this.log.insert(this.data, {\n after: this.prev.element\n });\n this.line = this.prev.line;\n } else if (!this.fold && this.prev && !this.prev.fold && !this.prev.nl) {\n if (Log.DEBUG) {\n console.log(\"S.1 insert \" + this.id + \" after prev \" + this.prev.id);\n }\n this.log.insert(this.data, {\n after: this.prev.element\n });\n this.line = this.prev.line;\n } else if (!this.fold && this.next && !this.next.fold && !this.next.time) {\n if (Log.DEBUG) {\n console.log(\"S.2 insert \" + this.id + \" before next \" + this.next.id);\n }\n this.log.insert(this.data, {\n before: this.next.element\n });\n this.line = this.next.line;\n } else {\n this.line = Log.Line.create(this.log, [this]);\n this.line.render();\n }\n if (this.nl && (tail = this.tail).length > 0) {\n this.split(tail);\n }\n if (this.time) {\n return this.log.times.add(this);\n }\n },\n remove: function() {\n Log.Node.prototype.remove.apply(this);\n if (this.line) {\n return this.line.remove(this);\n }\n },\n split: function(spans) {\n var line, span, _i, _len;\n if (Log.DEBUG) {\n console.log(\"S.4 split [\" + (spans.map(function(span) {\n return span.id;\n }).join(', ')) + \"]\");\n }\n for (_i = 0, _len = spans.length; _i < _len; _i++) {\n span = spans[_i];\n this.log.remove(span.element);\n }\n line = Log.Line.create(this.log, spans);\n line.render();\n if (line.cr) {\n return line.clear();\n }\n },\n clear: function() {\n if (this.prev && this.isSibling(this.prev) && this.isSequence(this.prev)) {\n this.prev.clear();\n return this.prev.remove();\n }\n },\n isSequence: function(other) {\n return this.parent.num - other.parent.num === this.log.children.indexOf(this.parent) - this.log.children.indexOf(other.parent);\n },\n isSibling: function(other) {\n var _ref, _ref1;\n return ((_ref = this.element) != null ? _ref.parentNode : void 0) === ((_ref1 = other.element) != null ? _ref1.parentNode : void 0);\n },\n siblings: function(type) {\n var siblings, span;\n siblings = [];\n while ((span = (span || this)[type]) && this.isSibling(span)) {\n siblings.push(span);\n }\n return siblings;\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'data', {\n get: function() {\n return {\n id: this.id,\n type: 'span',\n text: this.text,\n \"class\": this[\"class\"],\n time: this.time\n };\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'line', {\n get: function() {\n return this._line;\n },\n set: function(line) {\n if (this.line) {\n this.line.remove(this);\n }\n this._line = line;\n if (this.line) {\n return this.line.add(this);\n }\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'element', {\n get: function() {\n return document.getElementById(this.id);\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'head', {\n get: function() {\n return this.siblings('prev').reverse();\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'tail', {\n get: function() {\n return this.siblings('next');\n }\n });\n\n Log.Line = function(log) {\n this.log = log;\n this.spans = [];\n return this;\n };\n\n Log.extend(Log.Line, {\n create: function(log, spans) {\n var line, span, _i, _len;\n if ((span = spans[0]) && span.fold) {\n line = new Log.Fold(log, span.event, span.name);\n } else {\n line = new Log.Line(log);\n }\n for (_i = 0, _len = spans.length; _i < _len; _i++) {\n span = spans[_i];\n span.line = line;\n }\n return line;\n }\n });\n\n Log.extend(Log.Line.prototype, {\n add: function(span) {\n var ix;\n if (span.cr) {\n this.cr = true;\n }\n if (this.spans.indexOf(span) > -1) {\n\n } else if ((ix = this.spans.indexOf(span.prev)) > -1) {\n return this.spans.splice(ix + 1, 0, span);\n } else if ((ix = this.spans.indexOf(span.next)) > -1) {\n return this.spans.splice(ix, 0, span);\n } else {\n return this.spans.push(span);\n }\n },\n remove: function(span) {\n var ix;\n if ((ix = this.spans.indexOf(span)) > -1) {\n return this.spans.splice(ix, 1);\n }\n },\n render: function() {\n var fold;\n if ((fold = this.prev) && fold.event === 'start' && fold.active) {\n if (this.next && !this.next.fold) {\n if (Log.DEBUG) {\n console.log(\"L.0 insert \" + this.id + \" before next \" + this.next.id);\n }\n return this.element = this.log.insert(this.data, {\n before: this.next.element\n });\n } else {\n if (Log.DEBUG) {\n console.log(\"L.0 insert \" + this.id + \" into fold \" + fold.id);\n }\n fold = this.log.folds.folds[fold.name].fold;\n return this.element = this.log.insert(this.data, {\n into: fold\n });\n }\n } else if (this.prev) {\n if (Log.DEBUG) {\n console.log(\"L.1 insert \" + this.spans[0].id + \" after prev \" + this.prev.id);\n }\n return this.element = this.log.insert(this.data, {\n after: this.prev.element\n });\n } else if (this.next) {\n if (Log.DEBUG) {\n console.log(\"L.2 insert \" + this.spans[0].id + \" before next \" + this.next.id);\n }\n return this.element = this.log.insert(this.data, {\n before: this.next.element\n });\n } else {\n if (Log.DEBUG) {\n console.log(\"L.3 insert \" + this.spans[0].id + \" into #log\");\n }\n return this.element = this.log.insert(this.data);\n }\n },\n clear: function() {\n var cr, _i, _len, _ref, _results;\n _ref = this.crs;\n _results = [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n cr = _ref[_i];\n _results.push(cr.clear());\n }\n return _results;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'id', {\n get: function() {\n var _ref;\n return (_ref = this.spans[0]) != null ? _ref.id : void 0;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'data', {\n get: function() {\n return {\n type: 'paragraph',\n nodes: this.nodes\n };\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'nodes', {\n get: function() {\n return this.spans.map(function(span) {\n return span.data;\n });\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'prev', {\n get: function() {\n var _ref;\n return (_ref = this.spans[0].prev) != null ? _ref.line : void 0;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'next', {\n get: function() {\n var _ref;\n return (_ref = this.spans[this.spans.length - 1].next) != null ? _ref.line : void 0;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'crs', {\n get: function() {\n return this.spans.filter(function(span) {\n return span.cr;\n });\n }\n });\n\n Log.Fold = function(log, event, name) {\n Log.Line.apply(this, arguments);\n this.fold = true;\n this.event = event;\n this.name = name;\n return this;\n };\n\n Log.Fold.prototype = Log.extend(new Log.Line, {\n render: function() {\n var element, _ref;\n if (this.prev && this.prev.element) {\n if (Log.DEBUG) {\n console.log(\"F.1 insert \" + this.id + \" after prev \" + this.prev.id);\n }\n element = this.prev.element;\n this.element = this.log.insert(this.data, {\n after: element\n });\n } else if (this.next) {\n if (Log.DEBUG) {\n console.log(\"F.2 insert \" + this.id + \" before next \" + this.next.id);\n }\n element = this.next.element || this.next.element.parentNode;\n this.element = this.log.insert(this.data, {\n before: element\n });\n } else {\n if (Log.DEBUG) {\n console.log(\"F.3 insert \" + this.id);\n }\n this.element = this.log.insert(this.data);\n }\n if (this.span.next && ((_ref = this.span.prev) != null ? _ref.isSibling(this.span.next) : void 0)) {\n this.span.prev.split([this.span.next].concat(this.span.next.tail));\n }\n return this.active = this.log.folds.add(this.data);\n }\n });\n\n Object.defineProperty(Log.Fold.prototype, 'id', {\n get: function() {\n return \"fold-\" + this.event + \"-\" + this.name;\n }\n });\n\n Object.defineProperty(Log.Fold.prototype, 'span', {\n get: function() {\n return this.spans[0];\n }\n });\n\n Object.defineProperty(Log.Fold.prototype, 'data', {\n get: function() {\n return {\n type: 'fold',\n id: this.id,\n event: this.event,\n name: this.name\n };\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/nodes");minispade.register('log/renderer', "(function() {(function() {\n\n Log.Renderer = function() {\n this.frag = document.createDocumentFragment();\n this.para = this.createParagraph();\n this.span = this.createSpan();\n this.text = document.createTextNode('');\n this.fold = this.createFold();\n return this;\n };\n\n Log.extend(Log.Renderer.prototype, {\n insert: function(data, pos) {\n var after, before, into, node;\n node = this.render(data);\n if (into = pos != null ? pos.into : void 0) {\n if (typeof into === 'String') {\n into = document.getElementById(pos != null ? pos.into : void 0);\n }\n if (pos != null ? pos.prepend : void 0) {\n this.prependTo(node, into);\n } else {\n this.appendTo(node, into);\n }\n } else if (after = pos != null ? pos.after : void 0) {\n if (typeof after === 'String') {\n after = document.getElementById(pos);\n }\n this.insertAfter(node, after);\n } else if (before = pos != null ? pos.before : void 0) {\n if (typeof before === 'String') {\n before = document.getElementById(pos != null ? pos.before : void 0);\n }\n this.insertBefore(node, before);\n } else {\n this.insertBefore(node);\n }\n return node;\n },\n hide: function(node) {\n node.setAttribute('class', this.addClass(node.getAttribute('class'), 'hidden'));\n return node;\n },\n remove: function(node) {\n if (node) {\n node.parentNode.removeChild(node);\n }\n return node;\n },\n render: function(data) {\n var frag, node, type, _i, _len;\n if (data instanceof Array) {\n frag = this.frag.cloneNode(true);\n for (_i = 0, _len = data.length; _i < _len; _i++) {\n node = data[_i];\n node = this.render(node);\n if (node) {\n frag.appendChild(node);\n }\n }\n return frag;\n } else {\n data.type || (data.type = 'paragraph');\n type = data.type[0].toUpperCase() + data.type.slice(1);\n return this[\"render\" + type](data);\n }\n },\n renderParagraph: function(data) {\n var node, para, type, _i, _len, _ref;\n para = this.para.cloneNode(true);\n if (data.id) {\n para.setAttribute('id', data.id);\n }\n if (data.hidden) {\n para.setAttribute('style', 'display: none;');\n }\n _ref = data.nodes || [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n node = _ref[_i];\n type = node.type[0].toUpperCase() + node.type.slice(1);\n node = this[\"render\" + type](node);\n para.appendChild(node);\n }\n return para;\n },\n renderFold: function(data) {\n var fold;\n fold = this.fold.cloneNode(true);\n fold.setAttribute('id', data.id || (\"fold-\" + data.event + \"-\" + data.name));\n fold.setAttribute('class', \"fold-\" + data.event);\n if (data.event === 'start') {\n fold.lastChild.lastChild.nodeValue = data.name;\n } else {\n fold.removeChild(fold.lastChild);\n }\n return fold;\n },\n renderSpan: function(data) {\n var span;\n span = this.span.cloneNode(true);\n if (data.id) {\n span.setAttribute('id', data.id);\n }\n if (data[\"class\"]) {\n span.setAttribute('class', data[\"class\"]);\n }\n span.lastChild.nodeValue = data.text || '';\n return span;\n },\n renderText: function(data) {\n var text;\n text = this.text.cloneNode(true);\n text.nodeValue = data.text;\n return text;\n },\n createParagraph: function() {\n var para;\n para = document.createElement('p');\n para.appendChild(document.createElement('a'));\n return para;\n },\n createFold: function() {\n var fold;\n fold = document.createElement('div');\n fold.appendChild(this.createSpan());\n fold.lastChild.setAttribute('class', 'fold-name');\n return fold;\n },\n createSpan: function() {\n var span;\n span = document.createElement('span');\n span.appendChild(document.createTextNode(' '));\n return span;\n },\n insertBefore: function(node, other) {\n var log;\n if (other) {\n return other.parentNode.insertBefore(node, other);\n } else {\n log = document.getElementById('log');\n return log.insertBefore(node, log.firstChild);\n }\n },\n insertAfter: function(node, other) {\n if (other.nextSibling) {\n return this.insertBefore(node, other.nextSibling);\n } else {\n return this.appendTo(node, other.parentNode);\n }\n },\n prependTo: function(node, other) {\n if (other.firstChild) {\n return other.insertBefore(node, other.firstChild);\n } else {\n return appendTo(node, other);\n }\n },\n appendTo: function(node, other) {\n return other.appendChild(node);\n },\n addClass: function(classes, string) {\n if (classes != null ? classes.indexOf(string) : void 0) {\n return;\n }\n if (classes) {\n return \"\" + classes + \" \" + string;\n } else {\n return string;\n }\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/renderer");minispade.register('log/times', "(function() {(function() {\n\n Log.Times = function(log) {\n this.log = log;\n this.times = {};\n return this;\n };\n\n Log.extend(Log.Times.prototype, {\n add: function(node) {\n var time, _base, _name;\n time = (_base = this.times)[_name = node.name] || (_base[_name] = new Log.Times.Time);\n return time.receive(node);\n },\n duration: function(name) {\n if (this.times[name]) {\n return this.times[name].duration;\n }\n }\n });\n\n Log.Times.Time = function() {\n return this;\n };\n\n Log.extend(Log.Times.Time.prototype, {\n receive: function(node) {\n this[node.event] = node;\n if (Log.DEBUG) {\n console.log(\"T.0 - \" + node.event + \" \" + node.name);\n }\n if (this.start && this.end) {\n return this.finish();\n }\n },\n finish: function() {\n var element;\n if (Log.DEBUG) {\n console.log(\"T.1 - finish \" + this.start.name);\n }\n element = document.getElementById(this.start.id);\n if (element) {\n return this.update(element);\n }\n },\n update: function(element) {\n element.setAttribute('class', 'duration');\n element.setAttribute('title', \"This command finished after \" + this.duration + \" seconds.\");\n return element.lastChild.nodeValue = \"\" + this.duration + \"s\";\n }\n });\n\n Object.defineProperty(Log.Times.Time.prototype, 'duration', {\n get: function() {\n var duration;\n duration = this.stats.duration / 1000 / 1000 / 1000;\n return duration.toFixed(2);\n }\n });\n\n Object.defineProperty(Log.Times.Time.prototype, 'stats', {\n get: function() {\n var stat, stats, _i, _len, _ref;\n if (!(this.end && this.end.stats)) {\n return {};\n }\n stats = {};\n _ref = this.end.stats.split(',');\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n stat = _ref[_i];\n stat = stat.split('=');\n stats[stat[0]] = stat[1];\n }\n return stats;\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/times");
|
1
|
+
minispade.register('log', "(function() {(function() {\n\n this.Log = function() {\n this.autoCloseFold = true;\n this.listeners = [];\n this.renderer = new Log.Renderer;\n this.children = new Log.Nodes(this);\n this.parts = {};\n this.folds = new Log.Folds(this);\n this.times = new Log.Times(this);\n return this;\n };\n\n Log.extend = function(one, other) {\n var name;\n for (name in other) {\n one[name] = other[name];\n }\n return one;\n };\n\n Log.extend(Log, {\n DEBUG: true,\n SLICE: 500,\n TIMEOUT: 25,\n FOLD: /fold:(start|end):([\\w_\\-\\.]+)/,\n TIME: /time:(start|end):([\\w_\\-\\.]+):?([\\w_\\-\\.\\=\\,]*)/,\n create: function(options) {\n var listener, log, _i, _len, _ref;\n options || (options = {});\n log = new Log();\n if (options.limit) {\n log.listeners.push(log.limit = new Log.Limit(options.limit));\n }\n _ref = options.listeners || [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n listener = _ref[_i];\n log.listeners.push(listener);\n }\n return log;\n }\n });\nminispade.require('log/nodes');\n\n Log.prototype = Log.extend(new Log.Node, {\n set: function(num, string) {\n if (this.parts[num]) { } else {\n this.parts[num] = true;\n return Log.Part.create(this, num, string);\n }\n },\n insert: function(data, pos) {\n this.trigger('insert', data, pos);\n return this.renderer.insert(data, pos);\n },\n remove: function(node) {\n this.trigger('remove', node);\n return this.renderer.remove(node);\n },\n hide: function(node) {\n this.trigger('hide', node);\n return this.renderer.hide(node);\n },\n trigger: function() {\n var args, ix, listener, _i, _len, _ref, _results;\n args = [this].concat(Array.prototype.slice.apply(arguments));\n _ref = this.listeners;\n _results = [];\n for (ix = _i = 0, _len = _ref.length; _i < _len; ix = ++_i) {\n listener = _ref[ix];\n _results.push(listener.notify.apply(listener, args));\n }\n return _results;\n }\n });\n\n Log.Listener = function() {};\n\n Log.extend(Log.Listener.prototype, {\n notify: function(log, event) {\n if (this[event]) {\n return this[event].apply(this, [log].concat(Array.prototype.slice.call(arguments, 2)));\n }\n }\n });\nminispade.require('log/folds');\nminispade.require('log/times');\nminispade.require('log/deansi');\nminispade.require('log/limit');\nminispade.require('log/renderer');\n\n}).call(this);\n\n})();\n//@ sourceURL=log");minispade.register('log/deansi', "(function() {(function() {\n\n Log.Deansi = {\n CLEAR_ANSI: /(?:\\033)(?:\\[0?c|\\[[0356]n|\\[7[lh]|\\[\\?25[lh]|\\(B|H|\\[(?:\\d+(;\\d+){,2})?G|\\[(?:[12])?[JK]|[DM]|\\[0K)/gm,\n apply: function(string) {\n var nodes,\n _this = this;\n if (!string) {\n return [];\n }\n string = string.replace(this.CLEAR_ANSI, '');\n nodes = ansiparse(string).map(function(part) {\n return _this.node(part);\n });\n return nodes;\n },\n node: function(part) {\n var classes, node;\n node = {\n type: 'span',\n text: part.text\n };\n if (classes = this.classes(part)) {\n node[\"class\"] = classes.join(' ');\n }\n return node;\n },\n classes: function(part) {\n var result;\n result = [];\n result = result.concat(this.colors(part));\n if (result.length > 0) {\n return result;\n }\n },\n colors: function(part) {\n var colors;\n colors = [];\n if (part.foreground) {\n colors.push(part.foreground);\n }\n if (part.background) {\n colors.push(\"bg-\" + part.background);\n }\n if (part.bold) {\n colors.push('bold');\n }\n if (part.italic) {\n colors.push('italic');\n }\n if (part.underline) {\n colors.push('underline');\n }\n return colors;\n },\n hidden: function(part) {\n if (part.text.match(/\\r/)) {\n part.text = part.text.replace(/^.*\\r/gm, '');\n return true;\n }\n }\n };\n\n}).call(this);\n\n})();\n//@ sourceURL=log/deansi");minispade.register('log/folds', "(function() {(function() {\n\n Log.Folds = function(log) {\n this.log = log;\n this.folds = {};\n return this;\n };\n\n Log.extend(Log.Folds.prototype, {\n add: function(data) {\n var fold, _base, _name;\n fold = (_base = this.folds)[_name = data.name] || (_base[_name] = new Log.Folds.Fold);\n fold.receive(data, {\n autoCloseFold: this.log.autoCloseFold\n });\n return fold.active;\n }\n });\n\n Log.Folds.Fold = function() {\n return this;\n };\n\n Log.extend(Log.Folds.Fold.prototype, {\n receive: function(data, options) {\n this[data.event] = data.id;\n if (this.start && this.end && !this.active) {\n return this.activate(options);\n }\n },\n activate: function(options) {\n var fragment, nextSibling, node, parentNode, toRemove, _i, _len, _ref;\n options || (options = {});\n if (Log.DEBUG) {\n console.log(\"F.n - activate \" + this.start);\n }\n toRemove = this.fold.parentNode;\n parentNode = toRemove.parentNode;\n nextSibling = toRemove.nextSibling;\n parentNode.removeChild(toRemove);\n fragment = document.createDocumentFragment();\n _ref = this.nodes;\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n node = _ref[_i];\n fragment.appendChild(node);\n }\n this.fold.appendChild(fragment);\n parentNode.insertBefore(toRemove, nextSibling);\n this.fold.setAttribute('class', this.classes(options['autoCloseFold']));\n return this.active = true;\n },\n classes: function(autoCloseFold) {\n var classes;\n classes = this.fold.getAttribute('class').split(' ');\n classes.push('fold');\n if (!autoCloseFold) {\n classes.push('open');\n }\n if (this.fold.childNodes.length > 2) {\n classes.push('active');\n }\n return classes.join(' ');\n }\n });\n\n Object.defineProperty(Log.Folds.Fold.prototype, 'fold', {\n get: function() {\n return this._fold || (this._fold = document.getElementById(this.start));\n }\n });\n\n Object.defineProperty(Log.Folds.Fold.prototype, 'nodes', {\n get: function() {\n var node, nodes;\n node = this.fold;\n nodes = [];\n while ((node = node.nextSibling) && node.id !== this.end) {\n nodes.push(node);\n }\n return nodes;\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/folds");minispade.register('log/limit', "(function() {(function() {\n\n Log.Limit = function(max_lines) {\n this.max_lines = max_lines || 1000;\n return this;\n };\n\n Log.Limit.prototype = Log.extend(new Log.Listener, {\n count: 0,\n insert: function(log, node, pos) {\n if (node.type === 'paragraph' && !node.hidden) {\n return this.count += 1;\n }\n }\n });\n\n Object.defineProperty(Log.Limit.prototype, 'limited', {\n get: function() {\n return this.count >= this.max_lines;\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/limit");minispade.register('log/nodes', "(function() {(function() {\n var newLineAtTheEndRegexp, newLineRegexp, rRegexp, removeCarriageReturns;\n\n Log.Node = function(id, num) {\n this.id = id;\n this.num = num;\n this.key = Log.Node.key(this.id);\n this.children = new Log.Nodes(this);\n return this;\n };\n\n Log.extend(Log.Node, {\n key: function(id) {\n if (id) {\n return id.split('-').map(function(i) {\n return '000000'.concat(i).slice(-6);\n }).join('');\n }\n }\n });\n\n Log.extend(Log.Node.prototype, {\n addChild: function(node) {\n return this.children.add(node);\n },\n remove: function() {\n this.log.remove(this.element);\n return this.parent.children.remove(this);\n }\n });\n\n Object.defineProperty(Log.Node.prototype, 'log', {\n get: function() {\n var _ref;\n return this._log || (this._log = ((_ref = this.parent) != null ? _ref.log : void 0) || this.parent);\n }\n });\n\n Object.defineProperty(Log.Node.prototype, 'firstChild', {\n get: function() {\n return this.children.first;\n }\n });\n\n Object.defineProperty(Log.Node.prototype, 'lastChild', {\n get: function() {\n return this.children.last;\n }\n });\n\n Log.Nodes = function(parent) {\n if (parent) {\n this.parent = parent;\n }\n this.items = [];\n this.index = {};\n return this;\n };\n\n Log.extend(Log.Nodes.prototype, {\n add: function(item) {\n var ix, next, prev, _ref, _ref1;\n ix = this.position(item) || 0;\n this.items.splice(ix, 0, item);\n if (this.parent) {\n item.parent = this.parent;\n }\n prev = function(item) {\n while (item && !item.children.last) {\n item = item.prev;\n }\n return item != null ? item.children.last : void 0;\n };\n next = function(item) {\n while (item && !item.children.first) {\n item = item.next;\n }\n return item != null ? item.children.first : void 0;\n };\n if (item.prev = this.items[ix - 1] || prev((_ref = this.parent) != null ? _ref.prev : void 0)) {\n item.prev.next = item;\n }\n if (item.next = this.items[ix + 1] || next((_ref1 = this.parent) != null ? _ref1.next : void 0)) {\n item.next.prev = item;\n }\n return item;\n },\n remove: function(item) {\n this.items.splice(this.items.indexOf(item), 1);\n if (item.next) {\n item.next.prev = item.prev;\n }\n if (item.prev) {\n item.prev.next = item.next;\n }\n if (this.items.length === 0) {\n return this.parent.remove();\n }\n },\n position: function(item) {\n var ix, _i, _ref;\n for (ix = _i = _ref = this.items.length - 1; _i >= 0; ix = _i += -1) {\n if (this.items[ix].key < item.key) {\n return ix + 1;\n }\n }\n },\n indexOf: function() {\n return this.items.indexOf.apply(this.items, arguments);\n },\n slice: function() {\n return this.items.slice.apply(this.items, arguments);\n },\n each: function(func) {\n return this.items.slice().forEach(func);\n },\n map: function(func) {\n return this.items.map(func);\n }\n });\n\n Object.defineProperty(Log.Nodes.prototype, 'first', {\n get: function() {\n return this.items[0];\n }\n });\n\n Object.defineProperty(Log.Nodes.prototype, 'last', {\n get: function() {\n return this.items[this.length - 1];\n }\n });\n\n Object.defineProperty(Log.Nodes.prototype, 'length', {\n get: function() {\n return this.items.length;\n }\n });\n\n Log.Part = function(id, num, string) {\n Log.Node.apply(this, arguments);\n this.string = string || '';\n this.string = this.string.replace(/\\033\\[1000D/gm, '\\r');\n this.string = this.string.replace(/\\r+\\n/gm, '\\n');\n this.strings = this.string.split(/^/gm) || [];\n this.slices = ((function() {\n var _results;\n _results = [];\n while (this.strings.length > 0) {\n _results.push(this.strings.splice(0, Log.SLICE));\n }\n return _results;\n }).call(this));\n return this;\n };\n\n Log.extend(Log.Part, {\n create: function(log, num, string) {\n var part;\n part = new Log.Part(num.toString(), num, string);\n log.addChild(part);\n return part.process(0, -1);\n }\n });\n\n Log.Part.prototype = Log.extend(new Log.Node, {\n remove: function() {},\n process: function(slice, num) {\n var node, span, spans, string, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _ref4,\n _this = this;\n _ref = this.slices[slice] || [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n string = _ref[_i];\n if ((_ref1 = this.log.limit) != null ? _ref1.limited : void 0) {\n return;\n }\n spans = [];\n _ref2 = Log.Deansi.apply(string);\n for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {\n node = _ref2[_j];\n span = Log.Span.create(this, \"\" + this.id + \"-\" + (num += 1), num, node.text, node[\"class\"]);\n span.render();\n spans.push(span);\n }\n if ((_ref3 = spans[0]) != null ? (_ref4 = _ref3.line) != null ? _ref4.cr : void 0 : void 0) {\n spans[0].line.clear();\n }\n }\n if (!(slice >= this.slices.length - 1)) {\n return setTimeout((function() {\n return _this.process(slice + 1, num);\n }), Log.TIMEOUT);\n }\n }\n });\n\n newLineAtTheEndRegexp = new RegExp(\"\\n$\");\n\n newLineRegexp = new RegExp(\"\\n\");\n\n rRegexp = new RegExp(\"\\r\");\n\n removeCarriageReturns = function(string) {\n var index;\n index = string.lastIndexOf(\"\\r\");\n if (index === -1) {\n return string;\n }\n return string.substr(index + 1);\n };\n\n Log.Span = function(id, num, text, classes) {\n var fold, time, _ref;\n Log.Node.apply(this, arguments);\n if (fold = text.match(Log.FOLD)) {\n this.fold = true;\n this.event = fold[1];\n this.text = this.name = fold[2];\n } else if (time = text.match(Log.TIME)) {\n this.time = true;\n this.event = time[1];\n this.name = time[2];\n this.stats = time[3];\n } else {\n this.text = text;\n this.text = removeCarriageReturns(this.text);\n this.text = this.text.replace(newLineAtTheEndRegexp, '');\n this.nl = !!((_ref = text[text.length - 1]) != null ? _ref.match(newLineRegexp) : void 0);\n this.cr = !!text.match(rRegexp);\n this[\"class\"] = this.cr && ['clears'] || classes;\n }\n return this;\n };\n\n Log.extend(Log.Span, {\n create: function(parent, id, num, text, classes) {\n var span;\n span = new Log.Span(id, num, text, classes);\n parent.addChild(span);\n return span;\n },\n render: function(parent, id, num, text, classes) {\n var span;\n span = this.create(parent, id, num, text, classes);\n return span.render();\n }\n });\n\n Log.Span.prototype = Log.extend(new Log.Node, {\n render: function() {\n var tail;\n if (this.time && this.event === 'end' && this.prev) {\n if (Log.DEBUG) {\n console.log(\"S.0 insert \" + this.id + \" after prev \" + this.prev.id);\n }\n this.nl = this.prev.nl;\n this.log.insert(this.data, {\n after: this.prev.element\n });\n this.line = this.prev.line;\n } else if (!this.fold && this.prev && !this.prev.fold && !this.prev.nl) {\n if (Log.DEBUG) {\n console.log(\"S.1 insert \" + this.id + \" after prev \" + this.prev.id);\n }\n this.log.insert(this.data, {\n after: this.prev.element\n });\n this.line = this.prev.line;\n } else if (!this.fold && this.next && !this.next.fold && !this.next.time) {\n if (Log.DEBUG) {\n console.log(\"S.2 insert \" + this.id + \" before next \" + this.next.id);\n }\n this.log.insert(this.data, {\n before: this.next.element\n });\n this.line = this.next.line;\n } else {\n this.line = Log.Line.create(this.log, [this]);\n this.line.render();\n }\n if (this.nl && (tail = this.tail).length > 0) {\n this.split(tail);\n }\n if (this.time) {\n return this.log.times.add(this);\n }\n },\n remove: function() {\n Log.Node.prototype.remove.apply(this);\n if (this.line) {\n return this.line.remove(this);\n }\n },\n split: function(spans) {\n var line, span, _i, _len;\n if (Log.DEBUG) {\n console.log(\"S.4 split [\" + (spans.map(function(span) {\n return span.id;\n }).join(', ')) + \"]\");\n }\n for (_i = 0, _len = spans.length; _i < _len; _i++) {\n span = spans[_i];\n this.log.remove(span.element);\n }\n line = Log.Line.create(this.log, spans);\n line.render();\n if (line.cr) {\n return line.clear();\n }\n },\n clear: function() {\n if (this.prev && this.isSibling(this.prev) && this.isSequence(this.prev)) {\n this.prev.clear();\n return this.prev.remove();\n }\n },\n isSequence: function(other) {\n return this.parent.num - other.parent.num === this.log.children.indexOf(this.parent) - this.log.children.indexOf(other.parent);\n },\n isSibling: function(other) {\n var _ref, _ref1;\n return ((_ref = this.element) != null ? _ref.parentNode : void 0) === ((_ref1 = other.element) != null ? _ref1.parentNode : void 0);\n },\n siblings: function(type) {\n var siblings, span;\n siblings = [];\n while ((span = (span || this)[type]) && this.isSibling(span)) {\n siblings.push(span);\n }\n return siblings;\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'data', {\n get: function() {\n return {\n id: this.id,\n type: 'span',\n text: this.text,\n \"class\": this[\"class\"],\n time: this.time\n };\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'line', {\n get: function() {\n return this._line;\n },\n set: function(line) {\n if (this.line) {\n this.line.remove(this);\n }\n this._line = line;\n if (this.line) {\n return this.line.add(this);\n }\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'element', {\n get: function() {\n return document.getElementById(this.id);\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'head', {\n get: function() {\n return this.siblings('prev').reverse();\n }\n });\n\n Object.defineProperty(Log.Span.prototype, 'tail', {\n get: function() {\n return this.siblings('next');\n }\n });\n\n Log.Line = function(log) {\n this.log = log;\n this.spans = [];\n return this;\n };\n\n Log.extend(Log.Line, {\n create: function(log, spans) {\n var line, span, _i, _len;\n if ((span = spans[0]) && span.fold) {\n line = new Log.Fold(log, span.event, span.name);\n } else {\n line = new Log.Line(log);\n }\n for (_i = 0, _len = spans.length; _i < _len; _i++) {\n span = spans[_i];\n span.line = line;\n }\n return line;\n }\n });\n\n Log.extend(Log.Line.prototype, {\n add: function(span) {\n var ix;\n if (span.cr) {\n this.cr = true;\n }\n if (this.spans.indexOf(span) > -1) {\n\n } else if ((ix = this.spans.indexOf(span.prev)) > -1) {\n return this.spans.splice(ix + 1, 0, span);\n } else if ((ix = this.spans.indexOf(span.next)) > -1) {\n return this.spans.splice(ix, 0, span);\n } else {\n return this.spans.push(span);\n }\n },\n remove: function(span) {\n var ix;\n if ((ix = this.spans.indexOf(span)) > -1) {\n return this.spans.splice(ix, 1);\n }\n },\n render: function() {\n var fold;\n if ((fold = this.prev) && fold.event === 'start' && fold.active) {\n if (this.next && !this.next.fold) {\n if (Log.DEBUG) {\n console.log(\"L.0 insert \" + this.id + \" before next \" + this.next.id);\n }\n return this.element = this.log.insert(this.data, {\n before: this.next.element\n });\n } else {\n if (Log.DEBUG) {\n console.log(\"L.0 insert \" + this.id + \" into fold \" + fold.id);\n }\n fold = this.log.folds.folds[fold.name].fold;\n return this.element = this.log.insert(this.data, {\n into: fold\n });\n }\n } else if (this.prev) {\n if (Log.DEBUG) {\n console.log(\"L.1 insert \" + this.spans[0].id + \" after prev \" + this.prev.id);\n }\n return this.element = this.log.insert(this.data, {\n after: this.prev.element\n });\n } else if (this.next) {\n if (Log.DEBUG) {\n console.log(\"L.2 insert \" + this.spans[0].id + \" before next \" + this.next.id);\n }\n return this.element = this.log.insert(this.data, {\n before: this.next.element\n });\n } else {\n if (Log.DEBUG) {\n console.log(\"L.3 insert \" + this.spans[0].id + \" into #log\");\n }\n return this.element = this.log.insert(this.data);\n }\n },\n clear: function() {\n var cr, _i, _len, _ref, _results;\n _ref = this.crs;\n _results = [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n cr = _ref[_i];\n _results.push(cr.clear());\n }\n return _results;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'id', {\n get: function() {\n var _ref;\n return (_ref = this.spans[0]) != null ? _ref.id : void 0;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'data', {\n get: function() {\n return {\n type: 'paragraph',\n nodes: this.nodes\n };\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'nodes', {\n get: function() {\n return this.spans.map(function(span) {\n return span.data;\n });\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'prev', {\n get: function() {\n var _ref;\n return (_ref = this.spans[0].prev) != null ? _ref.line : void 0;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'next', {\n get: function() {\n var _ref;\n return (_ref = this.spans[this.spans.length - 1].next) != null ? _ref.line : void 0;\n }\n });\n\n Object.defineProperty(Log.Line.prototype, 'crs', {\n get: function() {\n return this.spans.filter(function(span) {\n return span.cr;\n });\n }\n });\n\n Log.Fold = function(log, event, name) {\n Log.Line.apply(this, arguments);\n this.fold = true;\n this.event = event;\n this.name = name;\n return this;\n };\n\n Log.Fold.prototype = Log.extend(new Log.Line, {\n render: function() {\n var element, _ref;\n if (this.prev && this.prev.element) {\n if (Log.DEBUG) {\n console.log(\"F.1 insert \" + this.id + \" after prev \" + this.prev.id);\n }\n element = this.prev.element;\n this.element = this.log.insert(this.data, {\n after: element\n });\n } else if (this.next) {\n if (Log.DEBUG) {\n console.log(\"F.2 insert \" + this.id + \" before next \" + this.next.id);\n }\n element = this.next.element || this.next.element.parentNode;\n this.element = this.log.insert(this.data, {\n before: element\n });\n } else {\n if (Log.DEBUG) {\n console.log(\"F.3 insert \" + this.id);\n }\n this.element = this.log.insert(this.data);\n }\n if (this.span.next && ((_ref = this.span.prev) != null ? _ref.isSibling(this.span.next) : void 0)) {\n this.span.prev.split([this.span.next].concat(this.span.next.tail));\n }\n return this.active = this.log.folds.add(this.data);\n }\n });\n\n Object.defineProperty(Log.Fold.prototype, 'id', {\n get: function() {\n return \"fold-\" + this.event + \"-\" + this.name;\n }\n });\n\n Object.defineProperty(Log.Fold.prototype, 'span', {\n get: function() {\n return this.spans[0];\n }\n });\n\n Object.defineProperty(Log.Fold.prototype, 'data', {\n get: function() {\n return {\n type: 'fold',\n id: this.id,\n event: this.event,\n name: this.name\n };\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/nodes");minispade.register('log/renderer', "(function() {(function() {\n\n Log.Renderer = function() {\n this.frag = document.createDocumentFragment();\n this.para = this.createParagraph();\n this.span = this.createSpan();\n this.text = document.createTextNode('');\n this.fold = this.createFold();\n return this;\n };\n\n Log.extend(Log.Renderer.prototype, {\n insert: function(data, pos) {\n var after, before, into, node;\n node = this.render(data);\n if (into = pos != null ? pos.into : void 0) {\n if (typeof into === 'String') {\n into = document.getElementById(pos != null ? pos.into : void 0);\n }\n if (pos != null ? pos.prepend : void 0) {\n this.prependTo(node, into);\n } else {\n this.appendTo(node, into);\n }\n } else if (after = pos != null ? pos.after : void 0) {\n if (typeof after === 'String') {\n after = document.getElementById(pos);\n }\n this.insertAfter(node, after);\n } else if (before = pos != null ? pos.before : void 0) {\n if (typeof before === 'String') {\n before = document.getElementById(pos != null ? pos.before : void 0);\n }\n this.insertBefore(node, before);\n } else {\n this.insertBefore(node);\n }\n return node;\n },\n hide: function(node) {\n node.setAttribute('class', this.addClass(node.getAttribute('class'), 'hidden'));\n return node;\n },\n remove: function(node) {\n if (node) {\n node.parentNode.removeChild(node);\n }\n return node;\n },\n render: function(data) {\n var frag, node, type, _i, _len;\n if (data instanceof Array) {\n frag = this.frag.cloneNode(true);\n for (_i = 0, _len = data.length; _i < _len; _i++) {\n node = data[_i];\n node = this.render(node);\n if (node) {\n frag.appendChild(node);\n }\n }\n return frag;\n } else {\n data.type || (data.type = 'paragraph');\n type = data.type[0].toUpperCase() + data.type.slice(1);\n return this[\"render\" + type](data);\n }\n },\n renderParagraph: function(data) {\n var node, para, type, _i, _len, _ref;\n para = this.para.cloneNode(true);\n if (data.id) {\n para.setAttribute('id', data.id);\n }\n if (data.hidden) {\n para.setAttribute('style', 'display: none;');\n }\n _ref = data.nodes || [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n node = _ref[_i];\n type = node.type[0].toUpperCase() + node.type.slice(1);\n node = this[\"render\" + type](node);\n para.appendChild(node);\n }\n return para;\n },\n renderFold: function(data) {\n var fold;\n fold = this.fold.cloneNode(true);\n fold.setAttribute('id', data.id || (\"fold-\" + data.event + \"-\" + data.name));\n fold.setAttribute('class', \"fold-\" + data.event);\n if (data.event === 'start') {\n fold.lastChild.lastChild.nodeValue = data.name;\n } else {\n fold.removeChild(fold.lastChild);\n }\n return fold;\n },\n renderSpan: function(data) {\n var span;\n span = this.span.cloneNode(true);\n if (data.id) {\n span.setAttribute('id', data.id);\n }\n if (data[\"class\"]) {\n span.setAttribute('class', data[\"class\"]);\n }\n span.lastChild.nodeValue = data.text || '';\n return span;\n },\n renderText: function(data) {\n var text;\n text = this.text.cloneNode(true);\n text.nodeValue = data.text;\n return text;\n },\n createParagraph: function() {\n var para;\n para = document.createElement('p');\n para.appendChild(document.createElement('a'));\n return para;\n },\n createFold: function() {\n var fold;\n fold = document.createElement('div');\n fold.appendChild(this.createSpan());\n fold.lastChild.setAttribute('class', 'fold-name');\n return fold;\n },\n createSpan: function() {\n var span;\n span = document.createElement('span');\n span.appendChild(document.createTextNode(' '));\n return span;\n },\n insertBefore: function(node, other) {\n var log;\n if (other) {\n return other.parentNode.insertBefore(node, other);\n } else {\n log = document.getElementById('log');\n return log.insertBefore(node, log.firstChild);\n }\n },\n insertAfter: function(node, other) {\n if (other.nextSibling) {\n return this.insertBefore(node, other.nextSibling);\n } else {\n return this.appendTo(node, other.parentNode);\n }\n },\n prependTo: function(node, other) {\n if (other.firstChild) {\n return other.insertBefore(node, other.firstChild);\n } else {\n return appendTo(node, other);\n }\n },\n appendTo: function(node, other) {\n return other.appendChild(node);\n },\n addClass: function(classes, string) {\n if (classes != null ? classes.indexOf(string) : void 0) {\n return;\n }\n if (classes) {\n return \"\" + classes + \" \" + string;\n } else {\n return string;\n }\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/renderer");minispade.register('log/times', "(function() {(function() {\n\n Log.Times = function(log) {\n this.log = log;\n this.times = {};\n return this;\n };\n\n Log.extend(Log.Times.prototype, {\n add: function(node) {\n var time, _base, _name;\n time = (_base = this.times)[_name = node.name] || (_base[_name] = new Log.Times.Time);\n return time.receive(node);\n },\n duration: function(name) {\n if (this.times[name]) {\n return this.times[name].duration;\n }\n }\n });\n\n Log.Times.Time = function() {\n return this;\n };\n\n Log.extend(Log.Times.Time.prototype, {\n receive: function(node) {\n this[node.event] = node;\n if (Log.DEBUG) {\n console.log(\"T.0 - \" + node.event + \" \" + node.name);\n }\n if (this.start && this.end) {\n return this.finish();\n }\n },\n finish: function() {\n var element;\n if (Log.DEBUG) {\n console.log(\"T.1 - finish \" + this.start.name);\n }\n element = document.getElementById(this.start.id);\n if (element) {\n return this.update(element);\n }\n },\n update: function(element) {\n element.setAttribute('class', 'duration');\n element.setAttribute('title', \"This command finished after \" + this.duration + \" seconds.\");\n return element.lastChild.nodeValue = \"\" + this.duration + \"s\";\n }\n });\n\n Object.defineProperty(Log.Times.Time.prototype, 'duration', {\n get: function() {\n var duration;\n duration = this.stats.duration / 1000 / 1000 / 1000;\n return duration.toFixed(2);\n }\n });\n\n Object.defineProperty(Log.Times.Time.prototype, 'stats', {\n get: function() {\n var stat, stats, _i, _len, _ref;\n if (!(this.end && this.end.stats)) {\n return {};\n }\n stats = {};\n _ref = this.end.stats.split(',');\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n stat = _ref[_i];\n stat = stat.split('=');\n stats[stat[0]] = stat[1];\n }\n return stats;\n }\n });\n\n}).call(this);\n\n})();\n//@ sourceURL=log/times");
|
2
2
|
|
@@ -0,0 +1,207 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* MD5 (Message-Digest Algorithm)
|
4
|
+
* http://www.webtoolkit.info/
|
5
|
+
*
|
6
|
+
**/
|
7
|
+
|
8
|
+
var MD5 = function (string) {
|
9
|
+
|
10
|
+
function RotateLeft(lValue, iShiftBits) {
|
11
|
+
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
|
12
|
+
}
|
13
|
+
|
14
|
+
function AddUnsigned(lX,lY) {
|
15
|
+
var lX4,lY4,lX8,lY8,lResult;
|
16
|
+
lX8 = (lX & 0x80000000);
|
17
|
+
lY8 = (lY & 0x80000000);
|
18
|
+
lX4 = (lX & 0x40000000);
|
19
|
+
lY4 = (lY & 0x40000000);
|
20
|
+
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
|
21
|
+
if (lX4 & lY4) {
|
22
|
+
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
|
23
|
+
}
|
24
|
+
if (lX4 | lY4) {
|
25
|
+
if (lResult & 0x40000000) {
|
26
|
+
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
|
27
|
+
} else {
|
28
|
+
return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
|
29
|
+
}
|
30
|
+
} else {
|
31
|
+
return (lResult ^ lX8 ^ lY8);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
function F(x,y,z) { return (x & y) | ((~x) & z); }
|
36
|
+
function G(x,y,z) { return (x & z) | (y & (~z)); }
|
37
|
+
function H(x,y,z) { return (x ^ y ^ z); }
|
38
|
+
function I(x,y,z) { return (y ^ (x | (~z))); }
|
39
|
+
|
40
|
+
function FF(a,b,c,d,x,s,ac) {
|
41
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
|
42
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
43
|
+
};
|
44
|
+
|
45
|
+
function GG(a,b,c,d,x,s,ac) {
|
46
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
|
47
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
48
|
+
};
|
49
|
+
|
50
|
+
function HH(a,b,c,d,x,s,ac) {
|
51
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
|
52
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
53
|
+
};
|
54
|
+
|
55
|
+
function II(a,b,c,d,x,s,ac) {
|
56
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
|
57
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
58
|
+
};
|
59
|
+
|
60
|
+
function ConvertToWordArray(string) {
|
61
|
+
var lWordCount;
|
62
|
+
var lMessageLength = string.length;
|
63
|
+
var lNumberOfWords_temp1=lMessageLength + 8;
|
64
|
+
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
|
65
|
+
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
|
66
|
+
var lWordArray=Array(lNumberOfWords-1);
|
67
|
+
var lBytePosition = 0;
|
68
|
+
var lByteCount = 0;
|
69
|
+
while ( lByteCount < lMessageLength ) {
|
70
|
+
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
71
|
+
lBytePosition = (lByteCount % 4)*8;
|
72
|
+
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
|
73
|
+
lByteCount++;
|
74
|
+
}
|
75
|
+
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
76
|
+
lBytePosition = (lByteCount % 4)*8;
|
77
|
+
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
|
78
|
+
lWordArray[lNumberOfWords-2] = lMessageLength<<3;
|
79
|
+
lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
|
80
|
+
return lWordArray;
|
81
|
+
};
|
82
|
+
|
83
|
+
function WordToHex(lValue) {
|
84
|
+
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
|
85
|
+
for (lCount = 0;lCount<=3;lCount++) {
|
86
|
+
lByte = (lValue>>>(lCount*8)) & 255;
|
87
|
+
WordToHexValue_temp = "0" + lByte.toString(16);
|
88
|
+
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
|
89
|
+
}
|
90
|
+
return WordToHexValue;
|
91
|
+
};
|
92
|
+
|
93
|
+
function Utf8Encode(string) {
|
94
|
+
string = string.replace(/\r\n/g,"\n");
|
95
|
+
var utftext = "";
|
96
|
+
|
97
|
+
for (var n = 0; n < string.length; n++) {
|
98
|
+
|
99
|
+
var c = string.charCodeAt(n);
|
100
|
+
|
101
|
+
if (c < 128) {
|
102
|
+
utftext += String.fromCharCode(c);
|
103
|
+
}
|
104
|
+
else if((c > 127) && (c < 2048)) {
|
105
|
+
utftext += String.fromCharCode((c >> 6) | 192);
|
106
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
utftext += String.fromCharCode((c >> 12) | 224);
|
110
|
+
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
111
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
112
|
+
}
|
113
|
+
|
114
|
+
}
|
115
|
+
|
116
|
+
return utftext;
|
117
|
+
};
|
118
|
+
|
119
|
+
var x=Array();
|
120
|
+
var k,AA,BB,CC,DD,a,b,c,d;
|
121
|
+
var S11=7, S12=12, S13=17, S14=22;
|
122
|
+
var S21=5, S22=9 , S23=14, S24=20;
|
123
|
+
var S31=4, S32=11, S33=16, S34=23;
|
124
|
+
var S41=6, S42=10, S43=15, S44=21;
|
125
|
+
|
126
|
+
string = Utf8Encode(string);
|
127
|
+
|
128
|
+
x = ConvertToWordArray(string);
|
129
|
+
|
130
|
+
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
131
|
+
|
132
|
+
for (k=0;k<x.length;k+=16) {
|
133
|
+
AA=a; BB=b; CC=c; DD=d;
|
134
|
+
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
135
|
+
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
136
|
+
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
137
|
+
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
138
|
+
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
139
|
+
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
140
|
+
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
141
|
+
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
142
|
+
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
143
|
+
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
144
|
+
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
145
|
+
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
146
|
+
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
147
|
+
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
148
|
+
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
149
|
+
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
150
|
+
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
151
|
+
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
152
|
+
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
153
|
+
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
154
|
+
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
155
|
+
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
156
|
+
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
157
|
+
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
158
|
+
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
159
|
+
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
160
|
+
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
161
|
+
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
162
|
+
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
163
|
+
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
164
|
+
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
165
|
+
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
166
|
+
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
167
|
+
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
168
|
+
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
169
|
+
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
170
|
+
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
171
|
+
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
172
|
+
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
173
|
+
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
174
|
+
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
175
|
+
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
176
|
+
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
177
|
+
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
178
|
+
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
179
|
+
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
180
|
+
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
181
|
+
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
182
|
+
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
183
|
+
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
184
|
+
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
185
|
+
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
186
|
+
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
187
|
+
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
188
|
+
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
189
|
+
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
190
|
+
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
191
|
+
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
192
|
+
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
193
|
+
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
194
|
+
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
195
|
+
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
196
|
+
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
197
|
+
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
198
|
+
a=AddUnsigned(a,AA);
|
199
|
+
b=AddUnsigned(b,BB);
|
200
|
+
c=AddUnsigned(c,CC);
|
201
|
+
d=AddUnsigned(d,DD);
|
202
|
+
}
|
203
|
+
|
204
|
+
var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
|
205
|
+
|
206
|
+
return temp.toLowerCase();
|
207
|
+
}
|