browser_app_base 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3565687a000a2d7a0636d2ac47c09de24d87cfe1554777b58d8f9d9ab494102d
4
- data.tar.gz: a305213755edff63ab70edff0f2011d52c33ee6fd53b9aaddce80865440107c3
3
+ metadata.gz: ee14b20cd2c842b0c470d9b96f31549ae576912a5e79afcbb4b44b35d3cfc740
4
+ data.tar.gz: 746081592fef24334ae14f50fbcddb672fa29103b800ea8bd84048711ff0ec9e
5
5
  SHA512:
6
- metadata.gz: f2f2cb63d6ff01e6bb39731fd36944a8a4ff96c9b5370ed9b386383bc6c67fe55586d1e6f278d8af17713b542079f1850de0afd820c9b78357d7afc4debb63d8
7
- data.tar.gz: 200b7d9a67ef7421f52a2d3887b91d3d9c5ab99eda27ccebbf1725718204d25945bc0f31679811d0d4e959561ebed2906de8b98900c9272f80196b6fa9f7640a
6
+ metadata.gz: a0360895d392e1fdbf2930c73c82ba09a8551ea15014ee30f5e71393b4b04d48ea52773f174cc4eb884eea85574e338bf0d8661362c3c4f1cda8512429466f4c
7
+ data.tar.gz: a48af4eeb30f310d5f601e19a212fb2c4e4239b61952ab33b2cc50d9e2392dc14b7fec672abc64507aadf55d415831cb194048af9c8903e7fb7e604476895441
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrowserAppBase
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
@@ -30,6 +30,28 @@ get "/config/*.*" do |file, ext|
30
30
  File.read "config/#{file}.#{ext}"
31
31
  end
32
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
+
33
55
  map "/search" do
34
56
  run Search
35
57
  end
@@ -52,6 +74,6 @@ configure do
52
74
 
53
75
  end
54
76
 
55
- #\ --port 52538
77
+ #\ --port 54068
56
78
 
57
79
  run Sinatra::Application
@@ -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 {
@@ -49,8 +50,8 @@ textarea.long {
49
50
  }
50
51
 
51
52
  .ui-autocomplete {
52
- max-height: 200px;
53
- max-width: 500px;
53
+ max-height: 45vh;
54
+ max-width: 90wh;
54
55
  overflow-y: auto;
55
56
  overflow-x: auto;
56
57
  padding-right: 10px;
@@ -98,6 +99,6 @@ textarea.long {
98
99
 
99
100
  ul.log {
100
101
  list-style-type: decimal;
101
- font-size: 10px;
102
+ font-size: 12px;
102
103
  color: #5d0a94;
103
104
  }
@@ -11,12 +11,12 @@
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:52538/js/main.js"></script>
15
- <link rel="stylesheet" href="http://localhost:52538/css/index.css" type="text/css">
14
+ <script src="http://localhost:54068/js/main.js"></script>
15
+ <link rel="stylesheet" href="http://localhost:54068/css/index.css" type="text/css">
16
16
  </head>
17
17
 
18
18
  <body>
19
- <h3>サンプル</h3>
19
+ <h4>サンプル</h4>
20
20
  <hr>
21
21
  <table>
22
22
  <tr>
@@ -2,6 +2,29 @@
2
2
 
3
3
  var $ws = null;
4
4
  var $auto_scroll = true;
5
+ var dialog = null;
6
+
7
+ function open_dialog(msg) {
8
+ var top = window.screenTop + 10;
9
+ var left = window.screenLeft + 10;
10
+ if (dialog != null) {
11
+ dialog.close();
12
+ }
13
+ var dialog = window.open(
14
+ "/open_dialog?msg=" + msg,
15
+ "pop",
16
+ "width=300, height=100, left=" + left + ", top=" + top
17
+ );
18
+ console.log("open dialog dialog=" + dialog);
19
+ if (dialog == null) {
20
+ console.log("open dialog retry");
21
+ setTimeout(function () {
22
+ open_dialog(msg);
23
+ }, 1000);
24
+ } else {
25
+ dialog.focus();
26
+ }
27
+ }
5
28
 
6
29
  function server_connect(url) {
7
30
  var ws = new WebSocket(url);
@@ -11,9 +34,16 @@ function server_connect(url) {
11
34
  };
12
35
  ws.onmessage = function (evt) {
13
36
  //alert(evt.data);
37
+
14
38
  if (evt.data.match(/^startup:/)) {
15
39
  file_name = evt.data.replace(/^startup:/, "");
16
40
  //alert(file_name);
41
+ }
42
+ else if (evt.data.match(/^app_end:normal/)) {
43
+ open_dialog("終了しました");
44
+ }
45
+ else if (evt.data.match(/^app_end:error/)) {
46
+ open_dialog("<font color='red'>エラーが発生しました</font>");
17
47
  } else {
18
48
  var log = "<li>" + evt.data + "</li>";
19
49
  $('#log').append(log);
@@ -43,14 +73,14 @@ function autocomp(id, file_kind) {
43
73
  minLength: 0,
44
74
  delay: 0,
45
75
  select: function (event, ui) {
46
- console.log(ui.item.value);
76
+ //console.log(ui.item.value);
47
77
  jQuery("#" + id).val(ui.item.value);
48
78
  //jQuery(this).autocomplete("search", "");
49
79
  $(this).keydown();
50
80
  },
51
81
  source: function (req, resp) {
52
82
  $.ajax({
53
- url: "http://localhost:52538/search?path=" + $("#" + id).val() + "&kind=" + file_kind,
83
+ url: "http://localhost:54068/search?path=" + $("#" + id).val() + "&kind=" + file_kind,
54
84
  type: "GET",
55
85
  cache: false,
56
86
  dataType: "json",
@@ -139,7 +169,7 @@ function setting_dialog(open_id, dialog_id, json_file) {
139
169
  h += "</tr></table>";
140
170
  $("dl#wrap").append(h);
141
171
  } else {
142
- console.log("type=" + s[i].type);
172
+ //console.log("type=" + s[i].type);
143
173
  }
144
174
  }
145
175
  });
@@ -159,7 +189,7 @@ function setting_dialog(open_id, dialog_id, json_file) {
159
189
  var json_data = []
160
190
  $.getJSON(json_file, function (s) {
161
191
  for (var i in s) {
162
- console.log(s[i].name);
192
+ //console.log(s[i].name);
163
193
  if (s[i].type == "input") {
164
194
  var data = {};
165
195
  data["name"] = s[i].name;
@@ -190,7 +220,7 @@ function setting_dialog(open_id, dialog_id, json_file) {
190
220
  data["description"] = s[i].description;
191
221
  json_data.push(data);
192
222
  } else {
193
- console.log("type=" + s[i].type);
223
+ //console.log("type=" + s[i].type);
194
224
  }
195
225
  }
196
226
  $ws.send("setting:" + JSON.stringify(json_data));
@@ -218,24 +248,32 @@ function dispFile() {
218
248
  alert('選択したファイルの値は' + fName + 'です');
219
249
  }
220
250
 
251
+ function openFile(file) {
252
+ $ws.send("openfile:" + file);
253
+ }
254
+
221
255
  // 起動時の処理
222
256
  $(document).ready(function () {
223
257
  // サーバに接続
224
- server_connect("ws://localhost:52538/wsserver")
258
+ server_connect("ws://localhost:54068/wsserver")
225
259
  // ウインドウサイズ
226
260
  var width = 800;
227
261
  var height = 600;
262
+ $(window).resize(function() {
263
+ $(".outarea").height( $(window).height() - 250 );
264
+ });
228
265
  // ウインドウの位置
229
266
  $(function () {
230
267
  window.resizeTo(width, height);
231
268
  window.moveTo((window.screen.width / 2) - (width / 2), (screen.height / 2) - (height / 2));
232
269
  //window.moveTo(0,0);
270
+ $(".outarea").height( $(window).height() - 250 );
233
271
  });
234
272
 
235
273
  $('.outarea').scroll(function () {
236
274
  var h = $('.outarea').get(0).scrollHeight - $('.outarea').innerHeight();
237
- console.log("scrollEnd=" + Math.abs($('.outarea').scrollTop() - h));
238
- if (Math.abs($('.outarea').scrollTop() - h) < 5) {
275
+ //console.log("scrollEnd=" + Math.abs($('.outarea').scrollTop() - h));
276
+ if (Math.abs($('.outarea').scrollTop() - h) < 30) {
239
277
  // 最後までスクロールしている
240
278
  // 自動スクロールON
241
279
  $auto_scroll = true;
@@ -1,5 +1,6 @@
1
1
  require "./server_app_base"
2
2
  require "json"
3
+ require "cgi"
3
4
 
4
5
  def config_json_hash(json)
5
6
  config = {}
@@ -31,11 +32,24 @@ class WsServer < Sinatra::Base
31
32
  $app.set_config(json_config)
32
33
  argv = msg.gsub(/^exec:/, "")
33
34
  exec_thread = Thread.new {
34
- $app.start(argv.split(",")) do |out|
35
- ws.send(out)
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
36
48
  end
37
- exec_thread = nil
38
49
  }
50
+ else
51
+ puts "app_end:err"
52
+ ws.send("app_end:error")
39
53
  end
40
54
  end
41
55
  if msg =~ /^stop/
@@ -62,6 +76,12 @@ class WsServer < Sinatra::Base
62
76
  json_config = config_json_hash(json)
63
77
  $app.set_config(json_config)
64
78
  end
79
+ if msg =~ /^openfile:/
80
+ file = msg.gsub(/^openfile:/, "")
81
+ Thread.new {
82
+ system "#{json_config["editor"]} #{CGI.unescapeHTML(file)}"
83
+ }
84
+ end
65
85
 
66
86
  if msg == "exit"
67
87
  unless ENV["OCRA"] == "true"
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.5
4
+ version: 0.0.6
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-09-20 00:00:00.000000000 Z
11
+ date: 2021-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra