flammarion 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +62 -1
- data/Readme.md +91 -5
- data/electron/preload.coffee +3 -5
- data/electron/preload.js +6 -0
- data/lib/flammarion.rb +0 -6
- data/lib/flammarion/about.rb +3 -0
- data/lib/flammarion/pane.rb +2 -1
- data/lib/flammarion/version.rb +3 -3
- data/lib/flammarion/writeable.rb +4 -2
- data/lib/html/build/index.html +1 -1
- data/lib/html/build/javascripts/actions.js +24 -143
- data/lib/html/build/javascripts/all.js +177 -101
- data/lib/html/build/javascripts/input.js +372 -0
- data/lib/html/build/javascripts/map.js +20 -7
- data/lib/html/build/javascripts/searchbar.js +28 -0
- data/lib/html/build/javascripts/websocket.js +20 -7
- data/lib/html/build/stylesheets/all.css +20 -0
- data/lib/html/build/stylesheets/frontend.css +5 -0
- data/lib/html/build/stylesheets/searchbar.css +15 -0
- data/lib/html/source/index.html.slim +3 -1
- data/lib/html/source/javascripts/actions.coffee +4 -100
- data/lib/html/source/javascripts/input.coffee +117 -0
- data/lib/html/source/javascripts/searchbar.coffee +19 -0
- data/lib/html/source/javascripts/websocket.coffee +7 -4
- data/lib/html/source/stylesheets/buttons.styl +1 -2
- data/lib/html/source/stylesheets/frontend.styl +5 -0
- data/lib/html/source/stylesheets/searchbar.styl +16 -0
- metadata +7 -1
@@ -110,28 +110,41 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
|
|
110
110
|
};
|
111
111
|
|
112
112
|
WSClient.prototype.resize_panes = function(data) {
|
113
|
-
var allPanes,
|
113
|
+
var allPanes, i, j, len, orientation, p_height, pane, results, target, total_weight;
|
114
114
|
if (data.target) {
|
115
115
|
target = this.check_target(data);
|
116
116
|
} else {
|
117
117
|
target = $('#panes');
|
118
118
|
}
|
119
119
|
allPanes = target.find('> .pane');
|
120
|
-
height = (100.0 / allPanes.size()).toFixed(0) + "%";
|
121
120
|
if (target.hasClass('horizontal')) {
|
122
121
|
orientation = 'horizontal';
|
123
122
|
} else {
|
124
123
|
orientation = 'vertical';
|
125
124
|
}
|
126
|
-
|
125
|
+
total_weight = ((function() {
|
126
|
+
var j, len, results;
|
127
|
+
results = [];
|
128
|
+
for (j = 0, len = allPanes.length; j < len; j++) {
|
129
|
+
i = allPanes[j];
|
130
|
+
results.push(parseFloat($(i).attr('pane-weight') || 1.0));
|
131
|
+
}
|
132
|
+
return results;
|
133
|
+
})()).reduce(function(t, s) {
|
134
|
+
return t + s;
|
135
|
+
});
|
136
|
+
p_height = function(pane) {
|
137
|
+
return (parseFloat($(pane).attr('pane-weight') || 1.0) / total_weight * 100).toFixed(0) + "%";
|
138
|
+
};
|
139
|
+
console.log(target, allPanes.size(), 100.0 / allPanes.size(), total_weight, orientation);
|
127
140
|
results = [];
|
128
|
-
for (
|
129
|
-
pane = allPanes[
|
141
|
+
for (j = 0, len = allPanes.length; j < len; j++) {
|
142
|
+
pane = allPanes[j];
|
130
143
|
if (orientation === 'horizontal') {
|
131
|
-
$(pane).css("width",
|
144
|
+
$(pane).css("width", p_height(pane));
|
132
145
|
results.push($(pane).css("height", '100%'));
|
133
146
|
} else {
|
134
|
-
$(pane).css("height",
|
147
|
+
$(pane).css("height", p_height(pane));
|
135
148
|
results.push($(pane).css("width", '100%'));
|
136
149
|
}
|
137
150
|
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
(function() {
|
2
|
+
window.show_search_bar = function() {
|
3
|
+
$('#searchbar').show();
|
4
|
+
return $('#searchbar > input').focus();
|
5
|
+
};
|
6
|
+
|
7
|
+
$(document).ready(function() {
|
8
|
+
return $('#searchbar > input').change(function() {
|
9
|
+
var anchor, text;
|
10
|
+
text = $('#searchbar > input')[0].value;
|
11
|
+
$('#searchbar').hide();
|
12
|
+
$('#searchbar > input')[0].value = "";
|
13
|
+
console.log("Searching " + text);
|
14
|
+
if (window.find(text, 0, 0, 1)) {
|
15
|
+
console.log("Found " + text);
|
16
|
+
anchor = window.getSelection().anchorNode;
|
17
|
+
if (anchor.nodeType !== 1) {
|
18
|
+
anchor = anchor.parentNode;
|
19
|
+
}
|
20
|
+
anchor.focus();
|
21
|
+
return anchor.scrollIntoView();
|
22
|
+
} else {
|
23
|
+
return alert("Cannot find " + text);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
}).call(this);
|
@@ -110,28 +110,41 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
|
|
110
110
|
};
|
111
111
|
|
112
112
|
WSClient.prototype.resize_panes = function(data) {
|
113
|
-
var allPanes,
|
113
|
+
var allPanes, i, j, len, orientation, p_height, pane, results, target, total_weight;
|
114
114
|
if (data.target) {
|
115
115
|
target = this.check_target(data);
|
116
116
|
} else {
|
117
117
|
target = $('#panes');
|
118
118
|
}
|
119
119
|
allPanes = target.find('> .pane');
|
120
|
-
height = (100.0 / allPanes.size()).toFixed(0) + "%";
|
121
120
|
if (target.hasClass('horizontal')) {
|
122
121
|
orientation = 'horizontal';
|
123
122
|
} else {
|
124
123
|
orientation = 'vertical';
|
125
124
|
}
|
126
|
-
|
125
|
+
total_weight = ((function() {
|
126
|
+
var j, len, results;
|
127
|
+
results = [];
|
128
|
+
for (j = 0, len = allPanes.length; j < len; j++) {
|
129
|
+
i = allPanes[j];
|
130
|
+
results.push(parseFloat($(i).attr('pane-weight') || 1.0));
|
131
|
+
}
|
132
|
+
return results;
|
133
|
+
})()).reduce(function(t, s) {
|
134
|
+
return t + s;
|
135
|
+
});
|
136
|
+
p_height = function(pane) {
|
137
|
+
return (parseFloat($(pane).attr('pane-weight') || 1.0) / total_weight * 100).toFixed(0) + "%";
|
138
|
+
};
|
139
|
+
console.log(target, allPanes.size(), 100.0 / allPanes.size(), total_weight, orientation);
|
127
140
|
results = [];
|
128
|
-
for (
|
129
|
-
pane = allPanes[
|
141
|
+
for (j = 0, len = allPanes.length; j < len; j++) {
|
142
|
+
pane = allPanes[j];
|
130
143
|
if (orientation === 'horizontal') {
|
131
|
-
$(pane).css("width",
|
144
|
+
$(pane).css("width", p_height(pane));
|
132
145
|
results.push($(pane).css("height", '100%'));
|
133
146
|
} else {
|
134
|
-
$(pane).css("height",
|
147
|
+
$(pane).css("height", p_height(pane));
|
135
148
|
results.push($(pane).css("width", '100%'));
|
136
149
|
}
|
137
150
|
}
|
@@ -2783,6 +2783,11 @@ html {
|
|
2783
2783
|
pointer-events: none;
|
2784
2784
|
border: 1px solid #012;
|
2785
2785
|
}
|
2786
|
+
hr {
|
2787
|
+
width: 95%;
|
2788
|
+
background-color: #333;
|
2789
|
+
border: 1px solid #d6d6d6;
|
2790
|
+
}
|
2786
2791
|
/* required styles */
|
2787
2792
|
|
2788
2793
|
|
@@ -3289,6 +3294,21 @@ html {
|
|
3289
3294
|
background: #bebebe;
|
3290
3295
|
box-shadow: inset 0px 0px 1px 1px #d6d6d6;
|
3291
3296
|
}
|
3297
|
+
#searchbar {
|
3298
|
+
position: absolute;
|
3299
|
+
right: 10%;
|
3300
|
+
top: 0px;
|
3301
|
+
padding: 5px;
|
3302
|
+
padding-top: 0px;
|
3303
|
+
background-color: #eee;
|
3304
|
+
border: 1px solid #242424;
|
3305
|
+
border-top: 0px;
|
3306
|
+
border-radius: 0 0 4px 4px;
|
3307
|
+
box-shadow: 2px 2px 4px 2px #bebebe;
|
3308
|
+
}
|
3309
|
+
#searchbar > input {
|
3310
|
+
margin-left: 1em;
|
3311
|
+
}
|
3292
3312
|
#status {
|
3293
3313
|
background-color: #aaa;
|
3294
3314
|
margin: 0px;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#searchbar {
|
2
|
+
position: absolute;
|
3
|
+
right: 10%;
|
4
|
+
top: 0px;
|
5
|
+
padding: 5px;
|
6
|
+
padding-top: 0px;
|
7
|
+
background-color: #eee;
|
8
|
+
border: 1px solid #242424;
|
9
|
+
border-top: 0px;
|
10
|
+
border-radius: 0 0 4px 4px;
|
11
|
+
box-shadow: 2px 2px 4px 2px #bebebe;
|
12
|
+
}
|
13
|
+
#searchbar > input {
|
14
|
+
margin-left: 1em;
|
15
|
+
}
|
@@ -33,7 +33,10 @@ $.extend WSClient.prototype.actions,
|
|
33
33
|
else
|
34
34
|
target = $('#panes')
|
35
35
|
|
36
|
-
|
36
|
+
if target.find("#console-#{data.name}").size() is 0
|
37
|
+
element = $("<pre class='pane full-pane' id='console-#{data.name}'><pre>")
|
38
|
+
element.attr('pane-weight', data.weight || 1)
|
39
|
+
target.append(element)
|
37
40
|
@__parent.resize_panes(data)
|
38
41
|
|
39
42
|
closepane: (data) ->
|
@@ -80,34 +83,6 @@ $.extend WSClient.prototype.actions,
|
|
80
83
|
@__parent.add(newblock, target, data)
|
81
84
|
hljs.highlightBlock(code) for code in newblock.find('code')
|
82
85
|
|
83
|
-
button: (data) ->
|
84
|
-
target = @__parent.check_target(data)
|
85
|
-
class_name = if data.inline then 'inline-button' else 'full-button'
|
86
|
-
left_icon = ""
|
87
|
-
data.right_icon ||= data.icon
|
88
|
-
left_icon = "<i class='fa fa-#{data.left_icon} label-icon-left'></i>" if data.left_icon
|
89
|
-
right_icon = ""
|
90
|
-
right_icon = "<i class='fa fa-#{data.right_icon} label-icon-right'></i>" if data.right_icon
|
91
|
-
|
92
|
-
element = $("<a href='#' class='#{class_name}'>#{left_icon}#{@__parent.escape(data.label, data)}#{right_icon}</a>")
|
93
|
-
element.click =>
|
94
|
-
@__parent.send({
|
95
|
-
id:data.id
|
96
|
-
action:'callback'
|
97
|
-
source:'button'
|
98
|
-
original_msg:data
|
99
|
-
})
|
100
|
-
target.append element
|
101
|
-
|
102
|
-
buttonbox: (data) ->
|
103
|
-
target = @__parent.check_target(data)
|
104
|
-
|
105
|
-
element = target.find("#console-#{data.name}")
|
106
|
-
if element.size() is 0
|
107
|
-
target.prepend("<pre class='button-box' id='console-#{data.name}'></pre>")
|
108
|
-
else
|
109
|
-
element.addClass('button-box')
|
110
|
-
|
111
86
|
break: (data) ->
|
112
87
|
target = @__parent.check_target(data)
|
113
88
|
code = $("<hr>")
|
@@ -120,77 +95,6 @@ $.extend WSClient.prototype.actions,
|
|
120
95
|
other_classes = "subpane-fill" if data.fill
|
121
96
|
target.append("<pre id='console-#{data.name}' class='subpane pane #{other_classes}'></pre>")
|
122
97
|
|
123
|
-
input: (data) ->
|
124
|
-
target = @__parent.check_target(data)
|
125
|
-
if data.multiline
|
126
|
-
element = $("<textarea placeholder='#{data.label}' class='inline-text-input'></textarea>")
|
127
|
-
else
|
128
|
-
element = $("<input type='text' placeholder='#{data.label}' class='inline-text-input'>")
|
129
|
-
if data.value
|
130
|
-
element[0].value = data.value
|
131
|
-
|
132
|
-
element.change =>
|
133
|
-
unless element.hasClass("unclicked")
|
134
|
-
@__parent.send({
|
135
|
-
id:data.id
|
136
|
-
action:'callback'
|
137
|
-
source:'input'
|
138
|
-
text: element[0].value
|
139
|
-
original_msg:data
|
140
|
-
})
|
141
|
-
if data.once
|
142
|
-
replaceText = @__parent.escape("#{element[0].value}\n")
|
143
|
-
replaceText = "#{data.label}#{replaceText}" if data.keep_label
|
144
|
-
element.replaceWith(replaceText)
|
145
|
-
if data.autoclear
|
146
|
-
element[0].value = ""
|
147
|
-
|
148
|
-
target.append(element)
|
149
|
-
|
150
|
-
if data.focus
|
151
|
-
element.focus()
|
152
|
-
|
153
|
-
checkbox: (data) ->
|
154
|
-
target = @__parent.check_target(data)
|
155
|
-
element = $("<label class='inline-checkbox'><input type='checkbox'><span>#{@__parent.escape(data.label,data)}</span></label>'")
|
156
|
-
if data.value
|
157
|
-
element.find('input').attr "checked", true
|
158
|
-
element.addClass "checked"
|
159
|
-
element.change (e) =>
|
160
|
-
element.toggleClass("checked", element.find('input').prop('checked'))
|
161
|
-
@__parent.send({
|
162
|
-
id:data.id
|
163
|
-
action:'callback'
|
164
|
-
source:'input'
|
165
|
-
checked: element.find('input').prop('checked')
|
166
|
-
original_msg:data
|
167
|
-
})
|
168
|
-
element.click (e) =>
|
169
|
-
if e.shiftKey and @__lastChecked
|
170
|
-
all_boxes = $('.inline-checkbox')
|
171
|
-
start = all_boxes.index(@__lastChecked)
|
172
|
-
stop = all_boxes.index(element)
|
173
|
-
console.log start, stop
|
174
|
-
|
175
|
-
all_boxes.slice(Math.min(start, stop), Math.max(start, stop) + 1).find('input').prop("checked", @__lastChecked.find('input').prop("checked"))
|
176
|
-
all_boxes.change()
|
177
|
-
else
|
178
|
-
@__lastChecked = element
|
179
|
-
target.append(element)
|
180
|
-
|
181
|
-
dropdown: (data) ->
|
182
|
-
target = @__parent.check_target(data)
|
183
|
-
element = $("<select class='inline-dropdown' name='#{data.id}'></select>")
|
184
|
-
element.append($("<option>#{item}</option>")) for item in data.options
|
185
|
-
element.change (e) =>
|
186
|
-
@__parent.send({
|
187
|
-
id:data.id
|
188
|
-
action:'callback'
|
189
|
-
source:'dropdown'
|
190
|
-
text: element.find('option:selected').text()
|
191
|
-
})
|
192
|
-
@__parent.add(element, target, data)
|
193
|
-
|
194
98
|
alert: (data) ->
|
195
99
|
alert(data.text)
|
196
100
|
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#= require websocket.coffee
|
2
|
+
$.extend WSClient.prototype.actions,
|
3
|
+
button: (data) ->
|
4
|
+
target = @__parent.check_target(data)
|
5
|
+
class_name = if data.inline then 'inline-button' else 'full-button'
|
6
|
+
left_icon = ""
|
7
|
+
data.right_icon ||= data.icon
|
8
|
+
left_icon = "<i class='fa fa-#{data.left_icon} label-icon-left'></i>" if data.left_icon
|
9
|
+
right_icon = ""
|
10
|
+
right_icon = "<i class='fa fa-#{data.right_icon} label-icon-right'></i>" if data.right_icon
|
11
|
+
|
12
|
+
element = $("<a href='#' class='#{class_name}'>#{left_icon}#{@__parent.escape(data.label, data)}#{right_icon}</a>")
|
13
|
+
element.click =>
|
14
|
+
@__parent.send({
|
15
|
+
id:data.id
|
16
|
+
action:'callback'
|
17
|
+
source:'button'
|
18
|
+
original_msg:data
|
19
|
+
})
|
20
|
+
target.append element
|
21
|
+
|
22
|
+
buttonbox: (data) ->
|
23
|
+
target = @__parent.check_target(data)
|
24
|
+
|
25
|
+
element = target.find("#console-#{data.name}")
|
26
|
+
if element.size() is 0
|
27
|
+
target.prepend("<pre class='button-box' id='console-#{data.name}'></pre>")
|
28
|
+
else
|
29
|
+
element.addClass('button-box')
|
30
|
+
|
31
|
+
input: (data) ->
|
32
|
+
target = @__parent.check_target(data)
|
33
|
+
if data.multiline
|
34
|
+
element = $("<textarea placeholder='#{data.label}' class='inline-text-input'></textarea>")
|
35
|
+
else
|
36
|
+
element = $("<input type='text' placeholder='#{data.label}' class='inline-text-input'>")
|
37
|
+
if data.value
|
38
|
+
element[0].value = data.value
|
39
|
+
|
40
|
+
element.change =>
|
41
|
+
unless element.hasClass("unclicked")
|
42
|
+
@__parent.send({
|
43
|
+
id:data.id
|
44
|
+
action:'callback'
|
45
|
+
source:'input'
|
46
|
+
text: element[0].value
|
47
|
+
original_msg:data
|
48
|
+
})
|
49
|
+
if data.once
|
50
|
+
replaceText = @__parent.escape("#{element[0].value}\n")
|
51
|
+
replaceText = "#{data.label}#{replaceText}" if data.keep_label
|
52
|
+
element.replaceWith(replaceText)
|
53
|
+
if data.history
|
54
|
+
history = element.data('history') || []
|
55
|
+
history.push element[0].value
|
56
|
+
element.data('history', history)
|
57
|
+
element.data('history-index', history.length)
|
58
|
+
if data.autoclear
|
59
|
+
element[0].value = ""
|
60
|
+
|
61
|
+
offset_history = (e, amt) =>
|
62
|
+
history = element.data('history') || []
|
63
|
+
i = element.data('history-index') + amt
|
64
|
+
e.preventDefault()
|
65
|
+
if i >= 0 and i < history.length
|
66
|
+
element[0].value = history[i]
|
67
|
+
element.data('history-index', i)
|
68
|
+
|
69
|
+
element.keydown (e) =>
|
70
|
+
offset_history(e, -1) if e.which is 38 and data.history
|
71
|
+
offset_history(e, +1) if e.which is 40 and data.history
|
72
|
+
|
73
|
+
target.append(element)
|
74
|
+
|
75
|
+
if data.focus
|
76
|
+
element.focus()
|
77
|
+
|
78
|
+
checkbox: (data) ->
|
79
|
+
target = @__parent.check_target(data)
|
80
|
+
element = $("<label class='inline-checkbox'><input type='checkbox'><span>#{@__parent.escape(data.label,data)}</span></label>'")
|
81
|
+
if data.value
|
82
|
+
element.find('input').attr "checked", true
|
83
|
+
element.addClass "checked"
|
84
|
+
element.change (e) =>
|
85
|
+
element.toggleClass("checked", element.find('input').prop('checked'))
|
86
|
+
@__parent.send({
|
87
|
+
id:data.id
|
88
|
+
action:'callback'
|
89
|
+
source:'input'
|
90
|
+
checked: element.find('input').prop('checked')
|
91
|
+
original_msg:data
|
92
|
+
})
|
93
|
+
element.click (e) =>
|
94
|
+
if e.shiftKey and @__lastChecked
|
95
|
+
all_boxes = $('.inline-checkbox')
|
96
|
+
start = all_boxes.index(@__lastChecked)
|
97
|
+
stop = all_boxes.index(element)
|
98
|
+
console.log start, stop
|
99
|
+
|
100
|
+
all_boxes.slice(Math.min(start, stop), Math.max(start, stop) + 1).find('input').prop("checked", @__lastChecked.find('input').prop("checked"))
|
101
|
+
all_boxes.change()
|
102
|
+
else
|
103
|
+
@__lastChecked = element
|
104
|
+
target.append(element)
|
105
|
+
|
106
|
+
dropdown: (data) ->
|
107
|
+
target = @__parent.check_target(data)
|
108
|
+
element = $("<select class='inline-dropdown' name='#{data.id}'></select>")
|
109
|
+
element.append($("<option>#{item}</option>")) for item in data.options
|
110
|
+
element.change (e) =>
|
111
|
+
@__parent.send({
|
112
|
+
id:data.id
|
113
|
+
action:'callback'
|
114
|
+
source:'dropdown'
|
115
|
+
text: element.find('option:selected').text()
|
116
|
+
})
|
117
|
+
@__parent.add(element, target, data)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
window.show_search_bar = ->
|
2
|
+
$('#searchbar').show()
|
3
|
+
$('#searchbar > input').focus()
|
4
|
+
|
5
|
+
$(document).ready ->
|
6
|
+
$('#searchbar > input').change ->
|
7
|
+
text = $('#searchbar > input')[0].value
|
8
|
+
$('#searchbar').hide()
|
9
|
+
$('#searchbar > input')[0].value = ""
|
10
|
+
console.log "Searching #{text}"
|
11
|
+
if window.find(text, 0, 0, 1)
|
12
|
+
console.log "Found #{text}"
|
13
|
+
anchor = window.getSelection().anchorNode
|
14
|
+
anchor = anchor.parentNode unless anchor.nodeType == 1
|
15
|
+
anchor.focus()
|
16
|
+
anchor.scrollIntoView()
|
17
|
+
else
|
18
|
+
alert("Cannot find #{text}")
|
19
|
+
# $('#searchbar > input')[0].value = text
|