browser_app_base 0.0.3 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/browser_app_base/version.rb +1 -1
- data/lib/browser_app_base.rb +18 -3
- data/lib/template/config/browser.json +1 -1
- data/lib/template/config/setting.json +50 -0
- data/lib/template/config.ru +29 -1
- data/lib/template/css/index.css +39 -12
- data/lib/template/index.html +16 -4
- data/lib/template/js/main.js +190 -15
- data/lib/template/my_app_sample.rb +1 -0
- data/lib/template/server.rb +2 -1
- data/lib/template/server_app_base.rb +5 -0
- data/lib/template/start.rb +1 -1
- data/lib/template/wsserver.rb +61 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70e5ff9237fd7823d8fef3d11b63e43cc65129318f9e77d161d835d0d769efda
|
4
|
+
data.tar.gz: 547b18815dc4d1bd495fbaa894fbb61d94af21ae471ee6f05629fd819838b6dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec9f83afee710c1fe4aa984823c7cded71ec3ca24dd586c24c428480156c4a37a7274de7feba4fd7890c7eae2964b6706fc83e53a3d9afe234f770b35323a91
|
7
|
+
data.tar.gz: 49f96d43d8eab8f61ccfc60b7506302d137193965b0f47cdf794c914b7d73e9f232b07b3413d128c4e1e2117a4f52ea6dd15a03d1e0fec452d3736a48a278b4f
|
data/lib/browser_app_base.rb
CHANGED
@@ -19,6 +19,18 @@ module BrowserAppBase
|
|
19
19
|
return app_file_name + ".rb"
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.get_app_name(app)
|
23
|
+
app_name = ""
|
24
|
+
app.each_char do |s|
|
25
|
+
if s =~ /[a-z]/ and app_name.size == 0
|
26
|
+
app_name += s.upcase
|
27
|
+
else
|
28
|
+
app_name += s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
return app_name
|
32
|
+
end
|
33
|
+
|
22
34
|
def self.create(arg)
|
23
35
|
dir = arg[:dir]
|
24
36
|
app = arg[:app]
|
@@ -36,8 +48,8 @@ module BrowserAppBase
|
|
36
48
|
app_file = get_app_file(app)
|
37
49
|
|
38
50
|
load_app = <<"EOS"
|
39
|
-
|
40
|
-
|
51
|
+
require '#{app_file}'
|
52
|
+
$app = #{get_app_name(app)}.new
|
41
53
|
EOS
|
42
54
|
|
43
55
|
File.open("#{dir}/app_load.rb", "w") do |f|
|
@@ -45,7 +57,10 @@ EOS
|
|
45
57
|
end
|
46
58
|
|
47
59
|
puts "create #{app_file}"
|
48
|
-
|
60
|
+
new_file = "#{dir}/#{app_file}"
|
61
|
+
FileUtils.cp("#{dir}/my_app_sample.rb", new_file)
|
62
|
+
buf = File.binread(new_file)
|
63
|
+
File.binwrite(new_file, buf.gsub(/MyApp/, get_app_name(app)))
|
49
64
|
end
|
50
65
|
end
|
51
66
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "name1",
|
4
|
+
"value": "value1",
|
5
|
+
"type": "input",
|
6
|
+
"select": "",
|
7
|
+
"description": "設定項目1"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"name": "name2",
|
11
|
+
"value": true,
|
12
|
+
"type": "checkbox",
|
13
|
+
"select": "",
|
14
|
+
"description": "有効にする場合はチェック"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"name": "name3",
|
18
|
+
"value": "1",
|
19
|
+
"type": "select",
|
20
|
+
"select": [
|
21
|
+
"1",
|
22
|
+
"2",
|
23
|
+
"3",
|
24
|
+
"4",
|
25
|
+
"5"
|
26
|
+
],
|
27
|
+
"description": "選択項目"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "name4",
|
31
|
+
"value": "value4",
|
32
|
+
"type": "input",
|
33
|
+
"select": "",
|
34
|
+
"description": "設定項目4"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"name": "name5",
|
38
|
+
"value": "value5",
|
39
|
+
"type": "input",
|
40
|
+
"select": "",
|
41
|
+
"description": "設定項目5"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"name": "name6",
|
45
|
+
"value": "value6",
|
46
|
+
"type": "input",
|
47
|
+
"select": "",
|
48
|
+
"description": "設定項目6"
|
49
|
+
}
|
50
|
+
]
|
data/lib/template/config.ru
CHANGED
@@ -24,6 +24,34 @@ get "/js/:name.js" do
|
|
24
24
|
File.read "js/#{params[:name]}.js"
|
25
25
|
end
|
26
26
|
|
27
|
+
get "/config/*.*" do |file, ext|
|
28
|
+
content_type "text/json", :charset => "utf-8"
|
29
|
+
puts "#{file}.#{ext}"
|
30
|
+
File.read "config/#{file}.#{ext}"
|
31
|
+
end
|
32
|
+
|
33
|
+
get "/open_dialog" do
|
34
|
+
dialog_html = <<'EOS'
|
35
|
+
<!DOCTYPE html>
|
36
|
+
<html>
|
37
|
+
<head>
|
38
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
39
|
+
<title>Message Dialog</title>
|
40
|
+
<style type="text/css">
|
41
|
+
<!--
|
42
|
+
body {
|
43
|
+
color: #000000;
|
44
|
+
background-color: #ffffff;
|
45
|
+
overflow: hidden;
|
46
|
+
font-size: 12px;
|
47
|
+
}
|
48
|
+
-->
|
49
|
+
</style>
|
50
|
+
</head>
|
51
|
+
EOS
|
52
|
+
dialog_html += "<body>" + params["msg"] + "</body></html>"
|
53
|
+
end
|
54
|
+
|
27
55
|
map "/search" do
|
28
56
|
run Search
|
29
57
|
end
|
@@ -46,6 +74,6 @@ configure do
|
|
46
74
|
|
47
75
|
end
|
48
76
|
|
49
|
-
#\ --port
|
77
|
+
#\ --port 55974
|
50
78
|
|
51
79
|
run Sinatra::Application
|
data/lib/template/css/index.css
CHANGED
@@ -2,6 +2,7 @@ body {
|
|
2
2
|
color: #000000;
|
3
3
|
background-color: #cac3ec4f;
|
4
4
|
overflow: hidden;
|
5
|
+
font-size: 12px;
|
5
6
|
}
|
6
7
|
|
7
8
|
hr {
|
@@ -22,9 +23,9 @@ hr {
|
|
22
23
|
padding: 5px;
|
23
24
|
width: 95vw;
|
24
25
|
height: 50vh;
|
26
|
+
overflow: auto;
|
25
27
|
}
|
26
28
|
|
27
|
-
|
28
29
|
.inarea {
|
29
30
|
border: thin solid #000000;
|
30
31
|
margin: 5px;
|
@@ -32,12 +33,6 @@ hr {
|
|
32
33
|
width: 95%;
|
33
34
|
}
|
34
35
|
|
35
|
-
input {
|
36
|
-
background-color: #FAFAFA;
|
37
|
-
margin: 5px;
|
38
|
-
padding: 5px;
|
39
|
-
}
|
40
|
-
|
41
36
|
input.long {
|
42
37
|
width: 90%;
|
43
38
|
background-color: #FAFAFA;
|
@@ -50,18 +45,22 @@ textarea.long {
|
|
50
45
|
height: 50vh;
|
51
46
|
}
|
52
47
|
|
48
|
+
.ui-widget {
|
49
|
+
font-size: 12px;
|
50
|
+
}
|
51
|
+
|
53
52
|
.ui-autocomplete {
|
54
|
-
max-height:
|
55
|
-
max-width:
|
53
|
+
max-height: 45vh;
|
54
|
+
max-width: 90wh;
|
56
55
|
overflow-y: auto;
|
57
|
-
overflow-x:
|
58
|
-
padding-right:
|
56
|
+
overflow-x: auto;
|
57
|
+
padding-right: 10px;
|
59
58
|
}
|
59
|
+
|
60
60
|
#jquery-ui-autocomplete label {
|
61
61
|
float: left;
|
62
62
|
margin-right: 0.5em;
|
63
63
|
color: black;
|
64
|
-
font-size: 15px;
|
65
64
|
}
|
66
65
|
|
67
66
|
.ui-dialog {
|
@@ -74,4 +73,32 @@ textarea.long {
|
|
74
73
|
|
75
74
|
.long {
|
76
75
|
width: 90%;
|
76
|
+
}
|
77
|
+
|
78
|
+
#setting_dialog {
|
79
|
+
color: #796fe9;
|
80
|
+
background-color: #000000;
|
81
|
+
}
|
82
|
+
|
83
|
+
.setting_name {
|
84
|
+
width: 200px;
|
85
|
+
color: #796fe9;
|
86
|
+
background-color: #000000;
|
87
|
+
}
|
88
|
+
|
89
|
+
.setting_value {
|
90
|
+
width: 300px;
|
91
|
+
color: #796fe9;
|
92
|
+
background-color: #000000;
|
93
|
+
}
|
94
|
+
|
95
|
+
.setting_checkbox {
|
96
|
+
color: #796fe9;
|
97
|
+
background-color: #000000;
|
98
|
+
}
|
99
|
+
|
100
|
+
ul.log {
|
101
|
+
list-style-type: decimal;
|
102
|
+
font-size: 12px;
|
103
|
+
color: #5d0a94;
|
77
104
|
}
|
data/lib/template/index.html
CHANGED
@@ -11,12 +11,15 @@
|
|
11
11
|
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
12
12
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
|
13
13
|
|
14
|
-
<script src="http://localhost:
|
15
|
-
<link rel="stylesheet" href="http://localhost:
|
14
|
+
<script src="http://localhost:55974/js/main.js"></script>
|
15
|
+
<link rel="stylesheet" href="http://localhost:55974/css/index.css" type="text/css">
|
16
16
|
</head>
|
17
17
|
|
18
18
|
<body>
|
19
|
-
<
|
19
|
+
<div id="msg_dialog" style="display:none;">
|
20
|
+
<div id="msg_text">message</div>
|
21
|
+
</div>
|
22
|
+
<h4>GrepFind</h4>
|
20
23
|
<hr>
|
21
24
|
<table>
|
22
25
|
<tr>
|
@@ -26,6 +29,12 @@
|
|
26
29
|
<td>
|
27
30
|
<input type="button" id="stop" name="stop" value="停止">
|
28
31
|
</td>
|
32
|
+
<td>
|
33
|
+
<div id="setting_dialog" style="display:none;">
|
34
|
+
<dl id="wrap"></dl>
|
35
|
+
</div>
|
36
|
+
<input type="button" id="setting" value="設定" />
|
37
|
+
</td>
|
29
38
|
</tr>
|
30
39
|
</table>
|
31
40
|
|
@@ -49,7 +58,10 @@
|
|
49
58
|
</tr>
|
50
59
|
</table>
|
51
60
|
|
52
|
-
<
|
61
|
+
<div class="outarea">
|
62
|
+
<ul name="log" id="log" class="log">
|
63
|
+
</ul>
|
64
|
+
</div>
|
53
65
|
|
54
66
|
</body>
|
55
67
|
|
data/lib/template/js/main.js
CHANGED
@@ -1,6 +1,51 @@
|
|
1
1
|
// main.js
|
2
2
|
|
3
3
|
var $ws = null;
|
4
|
+
var $auto_scroll = true;
|
5
|
+
var dialog = null;
|
6
|
+
|
7
|
+
function open_dialog(msg) {
|
8
|
+
console.log("msg=" + msg);
|
9
|
+
$("#msg_text").html(msg);
|
10
|
+
$("#msg_dialog").dialog({
|
11
|
+
modal: true
|
12
|
+
, show: "slide" //表示時のアニメーション
|
13
|
+
, hide: "slide" //閉じた時のアニメーション
|
14
|
+
, title: "Message" //ダイアログのタイトル
|
15
|
+
, width: 400 //ダイアログの横幅
|
16
|
+
, height: 200 //ダイアログの高さ
|
17
|
+
, resizable: true //リサイズ可
|
18
|
+
, closeOnEscape: false //[ESC]キーで閉じられなくする
|
19
|
+
, draggable: true //ダイアログの移動を可に
|
20
|
+
, buttons: {
|
21
|
+
"OK": function () { //Cancelボタン
|
22
|
+
$(this).dialog("close");
|
23
|
+
}
|
24
|
+
}
|
25
|
+
});
|
26
|
+
}
|
27
|
+
|
28
|
+
function open_dialog_org(msg) {
|
29
|
+
var top = window.screenTop + 10;
|
30
|
+
var left = window.screenLeft + 10;
|
31
|
+
if (dialog != null) {
|
32
|
+
dialog.close();
|
33
|
+
}
|
34
|
+
var dialog = window.open(
|
35
|
+
"/open_dialog?msg=" + msg,
|
36
|
+
"pop",
|
37
|
+
"width=300, height=100, left=" + left + ", top=" + top
|
38
|
+
);
|
39
|
+
console.log("open dialog dialog=" + dialog);
|
40
|
+
if (dialog == null) {
|
41
|
+
console.log("open dialog retry");
|
42
|
+
setTimeout(function () {
|
43
|
+
open_dialog(msg);
|
44
|
+
}, 1000);
|
45
|
+
} else {
|
46
|
+
dialog.focus();
|
47
|
+
}
|
48
|
+
}
|
4
49
|
|
5
50
|
function server_connect(url) {
|
6
51
|
var ws = new WebSocket(url);
|
@@ -10,18 +55,23 @@ function server_connect(url) {
|
|
10
55
|
};
|
11
56
|
ws.onmessage = function (evt) {
|
12
57
|
//alert(evt.data);
|
58
|
+
|
13
59
|
if (evt.data.match(/^startup:/)) {
|
14
60
|
file_name = evt.data.replace(/^startup:/, "");
|
15
61
|
//alert(file_name);
|
62
|
+
}
|
63
|
+
else if (evt.data.match(/^app_end:normal/)) {
|
64
|
+
open_dialog("終了しました");
|
65
|
+
}
|
66
|
+
else if (evt.data.match(/^app_end:error/)) {
|
67
|
+
open_dialog("<font color='red'>エラーが発生しました</font>");
|
16
68
|
} else {
|
17
|
-
var log =
|
18
|
-
$('#log').
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
);
|
69
|
+
var log = "<li>" + evt.data + "</li>";
|
70
|
+
$('#log').append(log);
|
71
|
+
if ($auto_scroll) {
|
72
|
+
$('.outarea').scrollTop($('.outarea').get(0).scrollHeight);
|
73
|
+
}
|
23
74
|
}
|
24
|
-
|
25
75
|
};
|
26
76
|
ws.onclose = function () {
|
27
77
|
alert("アプリケーションが終了しました!!");
|
@@ -44,14 +94,14 @@ function autocomp(id, file_kind) {
|
|
44
94
|
minLength: 0,
|
45
95
|
delay: 0,
|
46
96
|
select: function (event, ui) {
|
47
|
-
console.log(ui.item.value);
|
97
|
+
//console.log(ui.item.value);
|
48
98
|
jQuery("#" + id).val(ui.item.value);
|
49
99
|
//jQuery(this).autocomplete("search", "");
|
50
100
|
$(this).keydown();
|
51
101
|
},
|
52
102
|
source: function (req, resp) {
|
53
103
|
$.ajax({
|
54
|
-
url: "http://localhost:
|
104
|
+
url: "http://localhost:55974/search?path=" + $("#" + id).val() + "&kind=" + file_kind,
|
55
105
|
type: "GET",
|
56
106
|
cache: false,
|
57
107
|
dataType: "json",
|
@@ -68,17 +118,14 @@ function autocomp(id, file_kind) {
|
|
68
118
|
|
69
119
|
}
|
70
120
|
}).focus(function () {
|
71
|
-
console.log("forcus");
|
72
121
|
//jQuery(this).autocomplete("search", "");
|
73
122
|
$(this).keydown();
|
74
123
|
});
|
75
124
|
}
|
76
125
|
|
77
126
|
function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_name) {
|
78
|
-
console.log("select_file_dialog select_file=" + select_file);
|
79
127
|
$("#" + select_file).click(function () {
|
80
128
|
autocomp(search_id, file_kind);
|
81
|
-
console.log("open dialog dialog_id=", dialog_id);
|
82
129
|
$(".ui-autocomplete").css("z-index", 1000);
|
83
130
|
$("#" + search_id).val("/");
|
84
131
|
$("#" + dialog_id).dialog({
|
@@ -88,9 +135,9 @@ function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_n
|
|
88
135
|
, title: "Select File" //ダイアログのタイトル
|
89
136
|
, width: 580 //ダイアログの横幅
|
90
137
|
, height: 400 //ダイアログの高さ
|
91
|
-
, resizable:
|
138
|
+
, resizable: true //リサイズ可
|
92
139
|
, closeOnEscape: false //[ESC]キーで閉じられなくする
|
93
|
-
, draggable:
|
140
|
+
, draggable: true //ダイアログの移動を可に
|
94
141
|
, buttons: {
|
95
142
|
"OK": function () { //OKボタン
|
96
143
|
$("#" + file_name).val($("#" + search_id).val());
|
@@ -106,6 +153,109 @@ function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_n
|
|
106
153
|
});
|
107
154
|
}
|
108
155
|
|
156
|
+
function setting_dialog(open_id, dialog_id, json_file) {
|
157
|
+
$("#" + open_id).click(function () {
|
158
|
+
$("#" + dialog_id).val = $(function () {
|
159
|
+
$("dl#wrap").empty();
|
160
|
+
$.getJSON(json_file, function (s) {
|
161
|
+
for (var i in s) {
|
162
|
+
if (s[i].type == "input") {
|
163
|
+
var h = "<table><tr>"
|
164
|
+
+ "<td class='setting_name'>" + s[i].description + "</td>"
|
165
|
+
+ "<td><input class='setting_value' type='text' " + "id=" + s[i].name + "_value " + "value=" + s[i].value + ">"
|
166
|
+
+ "</td></tr></table>"
|
167
|
+
$("dl#wrap").append(h);
|
168
|
+
} else if (s[i].type == "checkbox") {
|
169
|
+
var h = "<table><tr>";
|
170
|
+
h += "<td class='setting_name'>" + s[i].description + "</td>";
|
171
|
+
if (s[i].value == true) {
|
172
|
+
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value checked ></td>";
|
173
|
+
} else {
|
174
|
+
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value ></td>";
|
175
|
+
}
|
176
|
+
h += "</tr></table>";
|
177
|
+
$("dl#wrap").append(h);
|
178
|
+
} else if (s[i].type == "select") {
|
179
|
+
var h = "<table><tr>";
|
180
|
+
h += "<td class='setting_name'>" + s[i].description + "</td>";
|
181
|
+
h += "<td> <select class='setting_value' id=" + s[i].name + "_value " + ">";
|
182
|
+
s[i].select.forEach(e => {
|
183
|
+
if (e == s[i].value) {
|
184
|
+
h += "<option value=" + e + " selected >" + e + "</option>";
|
185
|
+
} else {
|
186
|
+
h += "<option value=" + e + ">" + e + "</option>";
|
187
|
+
}
|
188
|
+
});
|
189
|
+
h += "</select></td>";
|
190
|
+
h += "</tr></table>";
|
191
|
+
$("dl#wrap").append(h);
|
192
|
+
} else {
|
193
|
+
//console.log("type=" + s[i].type);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
});
|
197
|
+
});
|
198
|
+
$("#" + dialog_id).dialog({
|
199
|
+
modal: true
|
200
|
+
, show: "slide" //表示時のアニメーション
|
201
|
+
, hide: "explode" //閉じた時のアニメーション
|
202
|
+
, title: "Setting" //ダイアログのタイトル
|
203
|
+
, width: 580 //ダイアログの横幅
|
204
|
+
, height: 400 //ダイアログの高さ
|
205
|
+
, resizable: true //リサイズ可
|
206
|
+
, closeOnEscape: false //[ESC]キーで閉じられなくする
|
207
|
+
, draggable: true //ダイアログの移動を可に
|
208
|
+
, buttons: {
|
209
|
+
"OK": function () { //OKボタン
|
210
|
+
var json_data = []
|
211
|
+
$.getJSON(json_file, function (s) {
|
212
|
+
for (var i in s) {
|
213
|
+
//console.log(s[i].name);
|
214
|
+
if (s[i].type == "input") {
|
215
|
+
var data = {};
|
216
|
+
data["name"] = s[i].name;
|
217
|
+
data["value"] = $("#" + s[i].name + "_value").val();
|
218
|
+
data["type"] = s[i].type;
|
219
|
+
data["select"] = s[i].select;
|
220
|
+
data["description"] = s[i].description;
|
221
|
+
json_data.push(data);
|
222
|
+
}
|
223
|
+
else if (s[i].type == "checkbox") {
|
224
|
+
var data = {};
|
225
|
+
data["name"] = s[i].name;
|
226
|
+
if ($("#" + s[i].name + "_value:checked").val() == "on") {
|
227
|
+
data["value"] = true;
|
228
|
+
} else {
|
229
|
+
data["value"] = false;
|
230
|
+
}
|
231
|
+
data["type"] = s[i].type;
|
232
|
+
data["select"] = s[i].select;
|
233
|
+
data["description"] = s[i].description;
|
234
|
+
json_data.push(data);
|
235
|
+
} else if (s[i].type == "select") {
|
236
|
+
var data = {};
|
237
|
+
data["name"] = s[i].name;
|
238
|
+
data["value"] = $("#" + s[i].name + "_value" + " option:selected").val();
|
239
|
+
data["type"] = s[i].type;
|
240
|
+
data["select"] = s[i].select;
|
241
|
+
data["description"] = s[i].description;
|
242
|
+
json_data.push(data);
|
243
|
+
} else {
|
244
|
+
//console.log("type=" + s[i].type);
|
245
|
+
}
|
246
|
+
}
|
247
|
+
$ws.send("setting:" + JSON.stringify(json_data));
|
248
|
+
});
|
249
|
+
$(this).dialog("close");
|
250
|
+
},
|
251
|
+
"Cancel": function () { //Cancelボタン
|
252
|
+
$(this).dialog("close");
|
253
|
+
}
|
254
|
+
}
|
255
|
+
});
|
256
|
+
});
|
257
|
+
}
|
258
|
+
|
109
259
|
function get_dirname(path) {
|
110
260
|
var result = path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '');
|
111
261
|
if (result.match(/^[^\/]*\.[^\/\.]*$/)) {
|
@@ -119,18 +269,40 @@ function dispFile() {
|
|
119
269
|
alert('選択したファイルの値は' + fName + 'です');
|
120
270
|
}
|
121
271
|
|
272
|
+
function openFile(file) {
|
273
|
+
$ws.send("openfile:" + file);
|
274
|
+
}
|
275
|
+
|
122
276
|
// 起動時の処理
|
123
277
|
$(document).ready(function () {
|
124
278
|
// サーバに接続
|
125
|
-
server_connect("ws://localhost:
|
279
|
+
server_connect("ws://localhost:55974/wsserver")
|
126
280
|
// ウインドウサイズ
|
127
281
|
var width = 800;
|
128
282
|
var height = 600;
|
283
|
+
$(window).resize(function () {
|
284
|
+
$(".outarea").height($(window).height() - 300);
|
285
|
+
});
|
129
286
|
// ウインドウの位置
|
130
287
|
$(function () {
|
131
288
|
window.resizeTo(width, height);
|
132
289
|
window.moveTo((window.screen.width / 2) - (width / 2), (screen.height / 2) - (height / 2));
|
133
290
|
//window.moveTo(0,0);
|
291
|
+
$(".outarea").height($(window).height() - 300);
|
292
|
+
});
|
293
|
+
|
294
|
+
$('.outarea').scroll(function () {
|
295
|
+
var h = $('.outarea').get(0).scrollHeight - $('.outarea').innerHeight();
|
296
|
+
//console.log("scrollEnd=" + Math.abs($('.outarea').scrollTop() - h));
|
297
|
+
if (Math.abs($('.outarea').scrollTop() - h) < 30) {
|
298
|
+
// 最後までスクロールしている
|
299
|
+
// 自動スクロールON
|
300
|
+
$auto_scroll = true;
|
301
|
+
} else {
|
302
|
+
// 自動スクロールOFF
|
303
|
+
$auto_scroll = false;
|
304
|
+
}
|
305
|
+
//console.log("auto_scroll=" + $auto_scroll);
|
134
306
|
});
|
135
307
|
|
136
308
|
// ハンドラ登録
|
@@ -139,6 +311,7 @@ $(document).ready(function () {
|
|
139
311
|
});
|
140
312
|
|
141
313
|
$("#exec").click(function () {
|
314
|
+
$('#log').empty();
|
142
315
|
send_message("exec:" + $("#upFile").val());
|
143
316
|
});
|
144
317
|
|
@@ -146,5 +319,7 @@ $(document).ready(function () {
|
|
146
319
|
|
147
320
|
select_file_dialog("search_str2", "dir", "dialog2", "select_dir", "upDir");
|
148
321
|
|
322
|
+
setting_dialog("setting", "setting_dialog", "config/setting.json");
|
323
|
+
|
149
324
|
});
|
150
325
|
|
data/lib/template/server.rb
CHANGED
@@ -48,7 +48,8 @@ class Search < Sinatra::Base
|
|
48
48
|
data = {}
|
49
49
|
next if File.basename(file) == "."
|
50
50
|
next if kind == "dir" and !File.directory?(file)
|
51
|
-
data["label"] = File.
|
51
|
+
data["label"] = File.basename(file)
|
52
|
+
data["label"] += "/" if (File.directory?(file))
|
52
53
|
data["value"] = File.expand_path(file)
|
53
54
|
res.push data
|
54
55
|
end
|
data/lib/template/start.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
# -*- coding: utf-8 -*-
|
2
3
|
$LOAD_PATH << File.dirname(File.expand_path(__FILE__))
|
3
4
|
|
@@ -49,7 +50,6 @@ Thread.start {
|
|
49
50
|
else
|
50
51
|
browser = json["chrome_win"]
|
51
52
|
end
|
52
|
-
#browser = "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" -app=http://localhost:#{port}"
|
53
53
|
browser += " -app=http://localhost:#{port}"
|
54
54
|
puts browser
|
55
55
|
system browser
|
data/lib/template/wsserver.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
require "./server_app_base"
|
2
|
+
require "json"
|
3
|
+
require "cgi"
|
4
|
+
|
5
|
+
def config_json_hash(json)
|
6
|
+
config = {}
|
7
|
+
json.each do |j|
|
8
|
+
config[j["name"]] = j["value"]
|
9
|
+
end
|
10
|
+
return config
|
11
|
+
end
|
2
12
|
|
3
13
|
class WsServer < Sinatra::Base
|
4
14
|
$ws_list = []
|
15
|
+
json_config = nil
|
16
|
+
exec_thread = nil
|
5
17
|
get "" do
|
6
18
|
if !request.websocket?
|
7
19
|
"no supported"
|
@@ -14,21 +26,61 @@ class WsServer < Sinatra::Base
|
|
14
26
|
ws.onmessage do |msg|
|
15
27
|
puts msg
|
16
28
|
if msg =~ /^exec:/
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
if exec_thread == nil
|
30
|
+
json = JSON.parse(File.read("config/setting.json"))
|
31
|
+
json_config = config_json_hash(json)
|
32
|
+
$app.set_config(json_config)
|
33
|
+
argv = msg.gsub(/^exec:/, "")
|
34
|
+
exec_thread = Thread.new {
|
35
|
+
begin
|
36
|
+
$app.start(argv.split(",")) do |out|
|
37
|
+
ws.send(out)
|
38
|
+
end
|
39
|
+
ws.send("app_end:normal")
|
40
|
+
rescue
|
41
|
+
puts $!
|
42
|
+
puts $@
|
43
|
+
puts "app_end:err"
|
44
|
+
ws.send("app_end:error")
|
45
|
+
ensure
|
46
|
+
puts "exit thread"
|
47
|
+
exec_thread = nil
|
48
|
+
end
|
49
|
+
}
|
50
|
+
else
|
51
|
+
puts "app_end:err"
|
52
|
+
ws.send("app_end:error")
|
53
|
+
end
|
23
54
|
end
|
24
55
|
if msg =~ /^stop/
|
25
|
-
|
56
|
+
if exec_thread
|
57
|
+
$app.stop
|
58
|
+
end
|
26
59
|
end
|
27
60
|
if msg =~ /^suspend/
|
28
|
-
|
61
|
+
if exec_thread
|
62
|
+
$app.suspend
|
63
|
+
end
|
29
64
|
end
|
30
65
|
if msg =~ /^resume/
|
31
|
-
|
66
|
+
if exec_thread
|
67
|
+
$app.resume
|
68
|
+
end
|
69
|
+
end
|
70
|
+
if msg =~ /^setting:/
|
71
|
+
json_string = msg.gsub(/^setting:/, "")
|
72
|
+
json = JSON.parse(json_string)
|
73
|
+
File.open("config/setting.json", "w") do |w|
|
74
|
+
w.puts JSON.pretty_generate(json)
|
75
|
+
end
|
76
|
+
json_config = config_json_hash(json)
|
77
|
+
$app.set_config(json_config)
|
78
|
+
end
|
79
|
+
if msg =~ /^openfile:/
|
80
|
+
file = msg.gsub(/^openfile:/, "")
|
81
|
+
Thread.new {
|
82
|
+
system "#{json_config["editor"]} #{CGI.unescapeHTML(file)}"
|
83
|
+
}
|
32
84
|
end
|
33
85
|
|
34
86
|
if msg == "exit"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browser_app_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masataka kuwayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/template/app_load.rb
|
117
117
|
- lib/template/config.ru
|
118
118
|
- lib/template/config/browser.json
|
119
|
+
- lib/template/config/setting.json
|
119
120
|
- lib/template/css/index.css
|
120
121
|
- lib/template/index.html
|
121
122
|
- lib/template/js/main.js
|