webview 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ef23af7af89282bc314cb434fda468c1b90aa8ceeef46da9796a4cf7d123cc5
4
- data.tar.gz: e95812999329317ce6567c536fa3dbf17a3d042b405c189567924d68cd8f1c82
3
+ metadata.gz: 8e1807345149b5a05d24e6cd5dcbcf045176b2b2a2e09e73f7b53aeb8516b816
4
+ data.tar.gz: b19c960a4d477ce74aa637d8a710006de2d5076c679ecaa91d44767bf3d297df
5
5
  SHA512:
6
- metadata.gz: b20a1a7eead80f163afdba01f0fa13d25493eeb817075ea58f3d238e8f7770dc091058c42abfa40aff0e768db55640b4a59a8d529eca5cbf9a57cf95cd2396b3
7
- data.tar.gz: 005020b674fa1e7109c854b508becf447cdfc14cb630fe5e906aea5aa073e048bdae0d8b591ee4e93f4734995ac147965e515f4f432d31780348e1593b9553ec
6
+ metadata.gz: e445a56b4fb64ac8edb61b96548cfddd1951f32a5e9f4daccd9ab66721fe9d1a951e23fcd8f67870f97e703b10a94cf598a4cd0b502d14f4bac31e1b232a0587
7
+ data.tar.gz: 354efbac5797f39232211edefbc35d7db24b0853f5406a00266e9ab88576ed8b396cc21995c4049a07768c42bccdbc19a45e25ee0e5446e9c16a40a5a6269ba9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webview (0.1.5)
4
+ webview (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'webview'
4
+
5
+ app = Webview::App.new(title: 'Ruby Language')
6
+ filepath = File.expand_path('../rpc.html', __FILE__)
7
+ app.open("file://#{filepath}")
8
+
9
+ at_exit { app.close }
10
+ begin
11
+ app.join
12
+ rescue Interrupt
13
+ app.close
14
+ end
15
+
@@ -0,0 +1,41 @@
1
+ <html>
2
+ <head>
3
+ </head>
4
+
5
+ <body>
6
+ <button data-rpc='openfile'>OpenFile</button>
7
+ <button data-rpc='opendir'>OpenDir</button>
8
+ <button data-rpc='fullscreen'>Fullscreen</button>
9
+ <button data-rpc='unfullscreen'>Unfullscreen</button>
10
+ <button data-rpc='savefile'>SaveFile</button>
11
+ <button data-rpc='close'>Close</button>
12
+
13
+ <br />
14
+ <br />
15
+ <hr />
16
+
17
+ <strong>Output: </strong>
18
+ <div id='output'></div>
19
+
20
+ <script type='text/javascript'>
21
+ var output = document.querySelector('#output')
22
+
23
+ window.rpc_cb = function(type, value, userdata) {
24
+ output.innerHTML = output.innerHTML + "<br />" +
25
+ 'RPC callback "' + type + '", "' + value + '", "' + userdata + '"';
26
+ }
27
+
28
+ var elems = document.querySelectorAll('button[data-rpc]');
29
+ for (var i = 0; i < elems.length; i++) {
30
+ var elem = elems[i];
31
+ elem.onclick = function(e) {
32
+ var action = e.target.dataset.rpc;
33
+ var userdata = new Date().getTime().toString();
34
+ var data = action + ',' + userdata
35
+ output.innerHTML = output.innerHTML + "<br /> invoke data: \"" + data + '"';
36
+ window.external.invoke(data);
37
+ }
38
+ }
39
+ </script>
40
+ </body>
41
+ </html>
@@ -7,11 +7,18 @@ import "flag"
7
7
  import "fmt"
8
8
  import "os"
9
9
  import "strings"
10
+ import "runtime"
10
11
 
11
12
  func EvalCallback(w webview.WebView, name string, value string, userdata string) {
12
13
  value = strings.Replace(value, "'", "\\'", -1)
13
14
  userdata = strings.Replace(userdata, "'", "\\'", -1)
14
15
 
16
+ // for windows path
17
+ if runtime.GOOS == "windows" {
18
+ value = strings.Replace(value, "\\", "\\\\", -1)
19
+ userdata = strings.Replace(userdata, "\\", "\\\\", -1)
20
+ }
21
+
15
22
  w.Eval(fmt.Sprintf(`
16
23
  (function(){
17
24
  var cb = window.rpc_cb;
@@ -1,3 +1,3 @@
1
1
  module Webview
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiangzhi.xie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-12 00:00:00.000000000 Z
11
+ date: 2019-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,8 @@ files:
72
72
  - bin/console
73
73
  - bin/setup
74
74
  - examples/app.rb
75
+ - examples/htmlfile.rb
76
+ - examples/rpc.html
75
77
  - ext/Makefile
76
78
  - ext/extconf.rb
77
79
  - ext/webview/main.go