browser_app_base 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.vscode/launch.json +1 -0
- data/README.md +83 -0
- data/bin/start_sample.rb +11 -2
- data/img/app.png +0 -0
- data/img/setting.png +0 -0
- data/img/setting_menu.png +0 -0
- data/lib/browser_app_base/version.rb +1 -1
- data/lib/template/config/setting.json +53 -50
- data/lib/template/config.ru +1 -1
- data/lib/template/css/index.css +54 -0
- data/lib/template/history/history.json +3 -0
- data/lib/template/html/index.html +29 -18
- data/lib/template/js/main.js +123 -44
- data/lib/template/start.rb +7 -1
- data/lib/template/wsserver.rb +11 -6
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e70b7356798ba86108a09eccf20c56fff9579fec267338e0a7b8c893a266cc9
|
4
|
+
data.tar.gz: c3f655708ab1d67d5041fadd8a05e228545fe3ed9c2d0d70a93a89034d42d8ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a7fcdd313ef16d4a090bf4f80d3acfce824fd8d9ac8c7501ae503cf4490a8197a728ac21d3893574592507c0a793436342e9a967812eb77452b4c021c009803
|
7
|
+
data.tar.gz: 4fcd5968c219fbc3a787d99a0ec000201ce2d5b908a24c50007dc9efde2437f8f321630074610b9ae38efe3e4b02443e8fde321dd3cf58b8cc18b3d4d3d17658
|
data/.gitignore
CHANGED
data/.vscode/launch.json
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,8 @@ ui application sample
|
|
62
62
|
$ /tmp/test/bin/start_my_app.rb
|
63
63
|
```
|
64
64
|
|
65
|
+
![app](img/app.png)
|
66
|
+
|
65
67
|
## browser setting
|
66
68
|
|
67
69
|
${home}/${app_nane}/config/browser.json
|
@@ -103,6 +105,87 @@ class MyApp < AppMainBase
|
|
103
105
|
end
|
104
106
|
```
|
105
107
|
|
108
|
+
## Application Setting
|
109
|
+
|
110
|
+
${home}/${app_nane}/config/setting.json
|
111
|
+
|
112
|
+
|
113
|
+
```json
|
114
|
+
{
|
115
|
+
"version": 0.1,
|
116
|
+
"setting_list": [
|
117
|
+
{
|
118
|
+
"name": "name1",
|
119
|
+
"value": "value1 2 3 4",
|
120
|
+
"type": "input",
|
121
|
+
"select": "",
|
122
|
+
"description": "設定項目1"
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"name": "name2",
|
126
|
+
"value": true,
|
127
|
+
"type": "checkbox",
|
128
|
+
"select": "",
|
129
|
+
"description": "有効にする場合はチェック"
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"name": "name3",
|
133
|
+
"value": "3",
|
134
|
+
"type": "select",
|
135
|
+
"select": [
|
136
|
+
"1",
|
137
|
+
"2",
|
138
|
+
"3",
|
139
|
+
"4",
|
140
|
+
"5"
|
141
|
+
],
|
142
|
+
"description": "選択項目"
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"name": "name4",
|
146
|
+
"value": "value4",
|
147
|
+
"type": "input",
|
148
|
+
"select": "",
|
149
|
+
"description": "設定項目4"
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"name": "name5",
|
153
|
+
"value": "value5",
|
154
|
+
"type": "input",
|
155
|
+
"select": "",
|
156
|
+
"description": "設定項目5"
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"name": "name6",
|
160
|
+
"value": "value6",
|
161
|
+
"type": "input",
|
162
|
+
"select": "",
|
163
|
+
"description": "設定項目6"
|
164
|
+
}
|
165
|
+
]
|
166
|
+
}```
|
167
|
+
```ruby
|
168
|
+
class MyApp < AppMainBase
|
169
|
+
def start(argv)
|
170
|
+
# popup message
|
171
|
+
app_send("popup:message string")
|
172
|
+
|
173
|
+
# log message
|
174
|
+
yield "log message"
|
175
|
+
end
|
176
|
+
|
177
|
+
# read setting
|
178
|
+
puts @config["name1"]
|
179
|
+
end
|
180
|
+
```
|
181
|
+
|
182
|
+
Setting menu
|
183
|
+
![app](img/setting_menu.png)
|
184
|
+
|
185
|
+
|
186
|
+
Setting screen
|
187
|
+
![app](img/setting.png)
|
188
|
+
|
106
189
|
## Development
|
107
190
|
|
108
191
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
data/bin/start_sample.rb
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
require "fileutils"
|
4
4
|
require "facter"
|
5
5
|
require "tmpdir"
|
6
|
+
require "json"
|
6
7
|
|
7
8
|
# tmpdirディレクトリにコピー
|
8
9
|
dir = File.dirname(File.expand_path(__FILE__ + "/../"))
|
9
|
-
home_dir = ENV["HOME"] + "/" + dir.split("/")[-1]
|
10
|
-
puts "home_dir=#{
|
10
|
+
home_dir = ENV["HOME"] + "/" + dir.split("/")[-1].gsub(/-[0-9\.-]+/,"")
|
11
|
+
puts "home_dir=#{home_dir}"
|
11
12
|
Dir.mktmpdir { |tmpdir|
|
12
13
|
outdir = tmpdir + "/" + dir.split("/")[-1]
|
13
14
|
FileUtils.mkdir_p outdir
|
@@ -25,6 +26,14 @@ Dir.mktmpdir { |tmpdir|
|
|
25
26
|
FileUtils.cp_r f, "#{outdir}/"
|
26
27
|
end
|
27
28
|
end
|
29
|
+
json = JSON.parse(File.read("#{home_dir}/config/setting.json"))
|
30
|
+
old_version = json["version"]
|
31
|
+
json = JSON.parse(File.read("#{dir}/lib/config/setting.json"))
|
32
|
+
new_version = json["version"]
|
33
|
+
puts "#{old_version} == #{new_version}"
|
34
|
+
if old_version.to_s == new_version.to_s
|
35
|
+
FileUtils.cp "#{dir}/lib/config/setting.json", "#{home_dir}/config/setting.json"
|
36
|
+
end
|
28
37
|
|
29
38
|
FileUtils.cd "#{outdir}"
|
30
39
|
kernel = Facter.value(:kernel)
|
data/img/app.png
ADDED
Binary file
|
data/img/setting.png
ADDED
Binary file
|
Binary file
|
@@ -1,50 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
"
|
22
|
-
"
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
1
|
+
{
|
2
|
+
"version": 0.1,
|
3
|
+
"setting_list": [
|
4
|
+
{
|
5
|
+
"name": "name1",
|
6
|
+
"value": "value1 2 3 4",
|
7
|
+
"type": "input",
|
8
|
+
"select": "",
|
9
|
+
"description": "設定項目1"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"name": "name2",
|
13
|
+
"value": true,
|
14
|
+
"type": "checkbox",
|
15
|
+
"select": "",
|
16
|
+
"description": "有効にする場合はチェック"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"name": "name3",
|
20
|
+
"value": "3",
|
21
|
+
"type": "select",
|
22
|
+
"select": [
|
23
|
+
"1",
|
24
|
+
"2",
|
25
|
+
"3",
|
26
|
+
"4",
|
27
|
+
"5"
|
28
|
+
],
|
29
|
+
"description": "選択項目"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"name": "name4",
|
33
|
+
"value": "value4",
|
34
|
+
"type": "input",
|
35
|
+
"select": "",
|
36
|
+
"description": "設定項目4"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "name5",
|
40
|
+
"value": "value5",
|
41
|
+
"type": "input",
|
42
|
+
"select": "",
|
43
|
+
"description": "設定項目5"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "name6",
|
47
|
+
"value": "value6",
|
48
|
+
"type": "input",
|
49
|
+
"select": "",
|
50
|
+
"description": "設定項目6"
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
data/lib/template/config.ru
CHANGED
data/lib/template/css/index.css
CHANGED
@@ -121,4 +121,58 @@ input[type="search"] {
|
|
121
121
|
|
122
122
|
input[type="search"]::-webkit-search-cancel-button {
|
123
123
|
-webkit-appearance: searchfield-cancel-button;
|
124
|
+
}
|
125
|
+
|
126
|
+
/* menu */
|
127
|
+
.menu {
|
128
|
+
display: flex;
|
129
|
+
justify-content: flex-start;
|
130
|
+
list-style-type: none;
|
131
|
+
color: #393737;
|
132
|
+
padding: 0;
|
133
|
+
font-size: 12px;
|
134
|
+
font-weight: bold;
|
135
|
+
}
|
136
|
+
|
137
|
+
.menu li {
|
138
|
+
position: relative;
|
139
|
+
width: 100px;
|
140
|
+
margin-left: 1px;
|
141
|
+
padding: 5px;
|
142
|
+
background: #d8dada;
|
143
|
+
list-style-type: none;
|
144
|
+
}
|
145
|
+
|
146
|
+
.menu li a {
|
147
|
+
color: rgb(20, 114, 192);
|
148
|
+
}
|
149
|
+
|
150
|
+
.menu li a:hover {
|
151
|
+
background: #eba399;
|
152
|
+
}
|
153
|
+
|
154
|
+
.menuSub {
|
155
|
+
position: absolute;
|
156
|
+
margin-left: -6px;
|
157
|
+
padding: 0;
|
158
|
+
display: none;
|
159
|
+
}
|
160
|
+
|
161
|
+
/*.openが付与された時、表示の設定*/
|
162
|
+
.menuSub.open {
|
163
|
+
display: block;
|
164
|
+
}
|
165
|
+
|
166
|
+
.menuSub li a {
|
167
|
+
padding: 5px;
|
168
|
+
margin-left: -5px;
|
169
|
+
margin-right: -5px;
|
170
|
+
margin-bottom: -5px;
|
171
|
+
display: block;
|
172
|
+
color: rgb(20, 114, 192);
|
173
|
+
text-decoration: none;
|
174
|
+
}
|
175
|
+
|
176
|
+
.menuSub li a:hover {
|
177
|
+
background: #eba399;
|
124
178
|
}
|
@@ -11,8 +11,8 @@
|
|
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="
|
15
|
-
<link rel="stylesheet" href="
|
14
|
+
<script src="js/main.js"></script>
|
15
|
+
<link rel="stylesheet" href="css/index.css" type="text/css">
|
16
16
|
</head>
|
17
17
|
|
18
18
|
<body>
|
@@ -21,22 +21,33 @@
|
|
21
21
|
</div>
|
22
22
|
<h4>RubyAppBase</h4>
|
23
23
|
<hr>
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
24
|
+
<!-- menu -->
|
25
|
+
<div id="setting_dialog" style="display:none;">
|
26
|
+
<dl id="wrap"></dl>
|
27
|
+
</div>
|
28
|
+
<div>
|
29
|
+
<ul class="menu">
|
30
|
+
<Li><a href="#" id="exec" name="exec">実行</a></li>
|
31
|
+
<li><a href="#" id="stop" name="stop">停止</a></li>
|
32
|
+
<li>
|
33
|
+
設定
|
34
|
+
<ul class="menuSub">
|
35
|
+
<li><a href="#" id="setting">設定</a></li>
|
36
|
+
<li><a href="#" id="save_setting">設定保存</a></li>
|
37
|
+
<li><a href="#" id="load_setting">設定読み込み</a></li>
|
38
|
+
</ul>
|
39
|
+
</li>
|
40
|
+
<!--
|
41
|
+
<li>
|
42
|
+
menu3
|
43
|
+
<ul class="menuSub">
|
44
|
+
<li><a href="#">menu3-1</a></li>
|
45
|
+
<li><a href="#">menu3-2</a></li>
|
46
|
+
</ul>
|
47
|
+
</li>
|
48
|
+
-->
|
49
|
+
</ul>
|
50
|
+
</div>
|
40
51
|
|
41
52
|
<div id="dialog1" style="display:none;">
|
42
53
|
<input class="inarea" type="search" name="search_str" id="search_str">
|
data/lib/template/js/main.js
CHANGED
@@ -115,7 +115,7 @@ function autocomp(id, file_kind) {
|
|
115
115
|
},
|
116
116
|
source: function (req, resp) {
|
117
117
|
$.ajax({
|
118
|
-
url: "
|
118
|
+
url: "search?path=" + $("#" + id).val() + "&kind=" + file_kind,
|
119
119
|
type: "GET",
|
120
120
|
cache: false,
|
121
121
|
dataType: "json",
|
@@ -148,7 +148,7 @@ function autocomp_history(id, file_name) {
|
|
148
148
|
},
|
149
149
|
source: function (req, resp) {
|
150
150
|
$.ajax({
|
151
|
-
url: "
|
151
|
+
url: "history/" + file_name,
|
152
152
|
type: "POST",
|
153
153
|
cache: false,
|
154
154
|
dataType: "json",
|
@@ -201,33 +201,35 @@ function select_file_dialog(search_id, file_kind, dialog_id, select_file, file_n
|
|
201
201
|
}
|
202
202
|
|
203
203
|
function setting_dialog(open_id, dialog_id, json_file) {
|
204
|
+
var version;
|
204
205
|
$("#" + open_id).click(function () {
|
205
206
|
$("#" + dialog_id).val = $(function () {
|
206
207
|
$("dl#wrap").empty();
|
207
208
|
$.getJSON(json_file, function (s) {
|
208
|
-
|
209
|
-
|
209
|
+
version = s["version"];
|
210
|
+
for (var i in s["setting_list"]) {
|
211
|
+
if (s["setting_list"][i].type == "input") {
|
210
212
|
var h = "<table><tr>"
|
211
|
-
+ "<td class='setting_name'>" + s[i].description + "</td>"
|
212
|
-
+ "<td><input class='setting_value' type='text' " + "id=" + s[i].name + "_value " + "value=" + "'" + s[i].value + "'" + ">"
|
213
|
+
+ "<td class='setting_name'>" + s["setting_list"][i].description + "</td>"
|
214
|
+
+ "<td><input class='setting_value' type='text' " + "id=" + s["setting_list"][i].name + "_value " + "value=" + "'" + s["setting_list"][i].value + "'" + ">"
|
213
215
|
+ "</td></tr></table>"
|
214
216
|
$("dl#wrap").append(h);
|
215
|
-
} else if (s[i].type == "checkbox") {
|
217
|
+
} else if (s["setting_list"][i].type == "checkbox") {
|
216
218
|
var h = "<table><tr>";
|
217
|
-
h += "<td class='setting_name'>" + s[i].description + "</td>";
|
218
|
-
if (s[i].value == true) {
|
219
|
-
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value checked ></td>";
|
219
|
+
h += "<td class='setting_name'>" + s["setting_list"][i].description + "</td>";
|
220
|
+
if (s["setting_list"][i].value == true) {
|
221
|
+
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s["setting_list"][i].name + "_value checked ></td>";
|
220
222
|
} else {
|
221
|
-
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s[i].name + "_value ></td>";
|
223
|
+
h += "<td><input class='setting_checkbox' type='checkbox' " + "id=" + s["setting_list"][i].name + "_value ></td>";
|
222
224
|
}
|
223
225
|
h += "</tr></table>";
|
224
226
|
$("dl#wrap").append(h);
|
225
|
-
} else if (s[i].type == "select") {
|
227
|
+
} else if (s["setting_list"][i].type == "select") {
|
226
228
|
var h = "<table><tr>";
|
227
|
-
h += "<td class='setting_name'>" + s[i].description + "</td>";
|
228
|
-
h += "<td> <select class='setting_value' id=" + s[i].name + "_value " + ">";
|
229
|
-
s[i].select.forEach(e => {
|
230
|
-
if (e == s[i].value) {
|
229
|
+
h += "<td class='setting_name'>" + s["setting_list"][i].description + "</td>";
|
230
|
+
h += "<td> <select class='setting_value' id=" + s["setting_list"][i].name + "_value " + ">";
|
231
|
+
s["setting_list"][i].select.forEach(e => {
|
232
|
+
if (e == s["setting_list"][i].value) {
|
231
233
|
h += "<option value=" + e + " selected >" + e + "</option>";
|
232
234
|
} else {
|
233
235
|
h += "<option value=" + e + ">" + e + "</option>";
|
@@ -237,7 +239,7 @@ function setting_dialog(open_id, dialog_id, json_file) {
|
|
237
239
|
h += "</tr></table>";
|
238
240
|
$("dl#wrap").append(h);
|
239
241
|
} else {
|
240
|
-
//console.log("type=" + s[i].type);
|
242
|
+
//console.log("type=" + s["setting_list"][i].type);
|
241
243
|
}
|
242
244
|
}
|
243
245
|
});
|
@@ -254,44 +256,48 @@ function setting_dialog(open_id, dialog_id, json_file) {
|
|
254
256
|
, draggable: true //ダイアログの移動を可に
|
255
257
|
, buttons: {
|
256
258
|
"OK": function () { //OKボタン
|
257
|
-
var
|
259
|
+
var json_obj = {};
|
260
|
+
var json_data = [];
|
258
261
|
$.getJSON(json_file, function (s) {
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
+
json_obj["version"] = s["version"];
|
263
|
+
for (var i in s["setting_list"]) {
|
264
|
+
//console.log(s["setting_list"][i].name);
|
265
|
+
if (s["setting_list"][i].type == "input") {
|
262
266
|
var data = {};
|
263
|
-
data["name"] = s[i].name;
|
264
|
-
data["value"] = $("#" + s[i].name + "_value").val();
|
265
|
-
data["type"] = s[i].type;
|
266
|
-
data["select"] = s[i].select;
|
267
|
-
data["description"] = s[i].description;
|
267
|
+
data["name"] = s["setting_list"][i].name;
|
268
|
+
data["value"] = $("#" + s["setting_list"][i].name + "_value").val();
|
269
|
+
data["type"] = s["setting_list"][i].type;
|
270
|
+
data["select"] = s["setting_list"][i].select;
|
271
|
+
data["description"] = s["setting_list"][i].description;
|
268
272
|
json_data.push(data);
|
269
273
|
}
|
270
|
-
else if (s[i].type == "checkbox") {
|
274
|
+
else if (s["setting_list"][i].type == "checkbox") {
|
271
275
|
var data = {};
|
272
|
-
data["name"] = s[i].name;
|
273
|
-
if ($("#" + s[i].name + "_value:checked").val() == "on") {
|
276
|
+
data["name"] = s["setting_list"][i].name;
|
277
|
+
if ($("#" + s["setting_list"][i].name + "_value:checked").val() == "on") {
|
274
278
|
data["value"] = true;
|
275
279
|
} else {
|
276
280
|
data["value"] = false;
|
277
281
|
}
|
278
|
-
data["type"] = s[i].type;
|
279
|
-
data["select"] = s[i].select;
|
280
|
-
data["description"] = s[i].description;
|
282
|
+
data["type"] = s["setting_list"][i].type;
|
283
|
+
data["select"] = s["setting_list"][i].select;
|
284
|
+
data["description"] = s["setting_list"][i].description;
|
281
285
|
json_data.push(data);
|
282
|
-
} else if (s[i].type == "select") {
|
286
|
+
} else if (s["setting_list"][i].type == "select") {
|
283
287
|
var data = {};
|
284
|
-
data["name"] = s[i].name;
|
285
|
-
data["value"] = $("#" + s[i].name + "_value" + " option:selected").val();
|
286
|
-
data["type"] = s[i].type;
|
287
|
-
data["select"] = s[i].select;
|
288
|
-
data["description"] = s[i].description;
|
288
|
+
data["name"] = s["setting_list"][i].name;
|
289
|
+
data["value"] = $("#" + s["setting_list"][i].name + "_value" + " option:selected").val();
|
290
|
+
data["type"] = s["setting_list"][i].type;
|
291
|
+
data["select"] = s["setting_list"][i].select;
|
292
|
+
data["description"] = s["setting_list"][i].description;
|
289
293
|
json_data.push(data);
|
290
294
|
} else {
|
291
|
-
//console.log("type=" + s[i].type);
|
295
|
+
//console.log("type=" + s["setting_list"][i].type);
|
292
296
|
}
|
293
297
|
}
|
294
|
-
|
298
|
+
// Jsonデータをサーバに送信
|
299
|
+
json_obj["setting_list"] = json_data;
|
300
|
+
$ws.send("setting:" + JSON.stringify(json_obj));
|
295
301
|
});
|
296
302
|
$(this).dialog("close");
|
297
303
|
},
|
@@ -303,6 +309,57 @@ function setting_dialog(open_id, dialog_id, json_file) {
|
|
303
309
|
});
|
304
310
|
}
|
305
311
|
|
312
|
+
// 設定読み込み
|
313
|
+
function load_setting(open_id) {
|
314
|
+
document.getElementById(open_id).onclick = async () => {
|
315
|
+
[fileHandle] = await window.showOpenFilePicker();
|
316
|
+
const file = await fileHandle.getFile();
|
317
|
+
const json_data = await file.text();
|
318
|
+
console.log(json_data);
|
319
|
+
// Jsonデータをサーバに送信
|
320
|
+
$ws.send("setting:" + json_data);
|
321
|
+
};
|
322
|
+
}
|
323
|
+
|
324
|
+
// 設定保存
|
325
|
+
function save_setting(open_id, json_file) {
|
326
|
+
document.getElementById(open_id).onclick = async () => {
|
327
|
+
var json_data = ""
|
328
|
+
$.ajax({
|
329
|
+
// jsonの読み込み
|
330
|
+
type: "GET",
|
331
|
+
url: json_file, // ファイルパス(相対パス)
|
332
|
+
dataType: "json", // ファイル形式
|
333
|
+
async: false // 非同期通信フラグ
|
334
|
+
}).then(
|
335
|
+
function (json) {
|
336
|
+
// 読み込み成功時の処理
|
337
|
+
json_data = JSON.stringify(json, null, 2);
|
338
|
+
console.log("json=" + json_data);
|
339
|
+
},
|
340
|
+
function () {
|
341
|
+
// 読み込み失敗時の処理
|
342
|
+
console.log("読み込みに失敗しました");
|
343
|
+
}
|
344
|
+
);
|
345
|
+
// Jsonを保存
|
346
|
+
const opts = {
|
347
|
+
suggestedName: 'setting.json',
|
348
|
+
types: [{
|
349
|
+
description: 'Text file',
|
350
|
+
accept: { 'text/plain': ['.json'] },
|
351
|
+
}],
|
352
|
+
};
|
353
|
+
// ファイルをどこにどんな名前で保存するか訊くダイアログを表示
|
354
|
+
const saveHandle = await window.showSaveFilePicker(opts)
|
355
|
+
// 保存先ファイルに書き込み準備
|
356
|
+
const writable = await saveHandle.createWritable();
|
357
|
+
// 先程同様に書き込んで終了
|
358
|
+
await writable.write(json_data);
|
359
|
+
await writable.close();
|
360
|
+
};
|
361
|
+
}
|
362
|
+
|
306
363
|
function get_dirname(path) {
|
307
364
|
var result = path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '');
|
308
365
|
if (result.match(/^[^\/]*\.[^\/\.]*$/)) {
|
@@ -324,12 +381,26 @@ function openFile(file) {
|
|
324
381
|
$(document).ready(function () {
|
325
382
|
|
326
383
|
// サーバに接続
|
327
|
-
server_connect("ws://localhost:
|
384
|
+
server_connect("ws://localhost:41617/wsserver")
|
328
385
|
window.onload = function (e) {
|
329
386
|
// サーバに接続
|
330
|
-
//server_connect("ws://localhost:
|
387
|
+
//server_connect("ws://localhost:41617/wsserver")
|
331
388
|
}
|
332
389
|
|
390
|
+
// menu
|
391
|
+
$(function () {
|
392
|
+
$(".menu li").hover(
|
393
|
+
function () {
|
394
|
+
//クラス名「open」を付与する
|
395
|
+
$(this).children(".menuSub").addClass("open");
|
396
|
+
//hoverが外れた場合
|
397
|
+
}, function () {
|
398
|
+
//クラス名「open」を取り除く
|
399
|
+
$(this).children(".menuSub").removeClass("open");
|
400
|
+
}
|
401
|
+
);
|
402
|
+
});
|
403
|
+
|
333
404
|
// ウインドウサイズ
|
334
405
|
var width = 800;
|
335
406
|
var height = 600;
|
@@ -358,6 +429,15 @@ $(document).ready(function () {
|
|
358
429
|
//console.log("auto_scroll=" + $auto_scroll);
|
359
430
|
});
|
360
431
|
|
432
|
+
// 設定ダイアログ
|
433
|
+
setting_dialog("setting", "setting_dialog", "config/setting.json");
|
434
|
+
|
435
|
+
// 設定保存
|
436
|
+
save_setting("save_setting", "config/setting.json");
|
437
|
+
|
438
|
+
// 設定読み込み
|
439
|
+
load_setting("load_setting");
|
440
|
+
|
361
441
|
// ハンドラ登録
|
362
442
|
$("#stop").click(function () {
|
363
443
|
send_message("stop");
|
@@ -368,12 +448,11 @@ $(document).ready(function () {
|
|
368
448
|
send_message("exec:" + $("#upFile").val());
|
369
449
|
});
|
370
450
|
|
451
|
+
|
371
452
|
select_file_dialog("search_str", "file", "dialog1", "select_file", "upFile");
|
372
453
|
|
373
454
|
select_file_dialog("search_str2", "dir", "dialog2", "select_dir", "upDir");
|
374
455
|
|
375
|
-
setting_dialog("setting", "setting_dialog", "config/setting.json");
|
376
|
-
|
377
456
|
autocomp_history("upFile", "history.json")
|
378
457
|
|
379
458
|
});
|
data/lib/template/start.rb
CHANGED
@@ -51,7 +51,13 @@ dir = File.dirname(File.expand_path(__FILE__))
|
|
51
51
|
FileUtils.cd dir
|
52
52
|
|
53
53
|
# ディレクトリ作成
|
54
|
-
|
54
|
+
pp ARGV
|
55
|
+
if ARGV[0] == "test"
|
56
|
+
$home_dir = "./"
|
57
|
+
ARGV = []
|
58
|
+
else
|
59
|
+
$home_dir = ENV["HOME"] + "/" + dir.split("/")[-1].gsub(/-[0-9\.-]+/,"")
|
60
|
+
end
|
55
61
|
puts "home_dir=#{$home_dir}"
|
56
62
|
FileUtils.mkdir_p("#{$home_dir}/logs")
|
57
63
|
FileUtils.mkdir_p("#{$home_dir}/history")
|
data/lib/template/wsserver.rb
CHANGED
@@ -5,7 +5,7 @@ require "thread"
|
|
5
5
|
|
6
6
|
def config_json_hash(json)
|
7
7
|
config = {}
|
8
|
-
json.each do |j|
|
8
|
+
json["setting_list"].each do |j|
|
9
9
|
config[j["name"]] = j["value"]
|
10
10
|
end
|
11
11
|
return config
|
@@ -97,12 +97,17 @@ class WsServer < Sinatra::Base
|
|
97
97
|
end
|
98
98
|
if msg =~ /^setting:/
|
99
99
|
json_string = msg.gsub(/^setting:/, "")
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
begin
|
101
|
+
json = JSON.parse(json_string)
|
102
|
+
File.open("#{$home_dir}/config/setting.json", "w") do |w|
|
103
|
+
w.puts JSON.pretty_generate(json)
|
104
|
+
end
|
105
|
+
json_config = config_json_hash(json)
|
106
|
+
$app.set_config(json_config)
|
107
|
+
rescue
|
108
|
+
# jsonファイルではない
|
109
|
+
ws_send("app_end:error")
|
103
110
|
end
|
104
|
-
json_config = config_json_hash(json)
|
105
|
-
$app.set_config(json_config)
|
106
111
|
end
|
107
112
|
if msg =~ /^openfile:/
|
108
113
|
file = msg.gsub(/^openfile:/, "")
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masataka kuwayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -113,6 +113,9 @@ files:
|
|
113
113
|
- bin/create_browser_app.rb
|
114
114
|
- bin/start_sample.rb
|
115
115
|
- browser_app_base.gemspec
|
116
|
+
- img/app.png
|
117
|
+
- img/setting.png
|
118
|
+
- img/setting_menu.png
|
116
119
|
- lib/browser_app_base.rb
|
117
120
|
- lib/browser_app_base/version.rb
|
118
121
|
- lib/template/app_load.rb
|