jsajax_wizard 0.1.1 → 0.1.2

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: 64c87a3e66fe500aaecdacd6c5f6a7e21b8cf5ec4aac7037b4d8a734d14a239d
4
- data.tar.gz: bff2e1917665304f1e6f5670c09fdd8befbf4d237d944210ba9bef4a5e153b94
3
+ metadata.gz: b0bd3b1c41b5d9bbb8500c3d0d0ebcb6d7a4c0324443e1e7e993df4ddda6537d
4
+ data.tar.gz: 3dcc5ed2af475d525f39eb4e749e4396c1e2630c57a3c0b04d5ffc01e3cdb7f3
5
5
  SHA512:
6
- metadata.gz: 00b8587e56aea826fb580e12d946eb0482ed669433fc3240c47d9edda2144ded969b3797d5ce579ae042acaae4bb028e8e0e6563831d7778a14ebe9ebad633e7
7
- data.tar.gz: 2330171bc522fb2ff1fbcd4bd201df4a03ee479c65f5a2fae5c58bc30871cab3ebcaa58483d8eb5aedcd43dcbf3223572e864cb38b0d27103855ec3caa343c9a
6
+ metadata.gz: 92ae05fa525f340700c44ee70c13dda97a884af72fad9e55c2f21c6f16c7521831878bf7dc54da65adf02b20b65678fa58ddb73c59327fd07edca335fc94bfce
7
+ data.tar.gz: 8632b42955a032d696560e017a397c1ab6805598e162a9eae55b90289b5df221b8458e1f3d0fe876629bdd67273ad333b442034ca2b0670436f0d5042f7d60a0
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/jsajax_wizard.rb CHANGED
@@ -12,7 +12,7 @@ class JsAjaxWizard
12
12
 
13
13
  def initialize(html: '', debug: false)
14
14
 
15
- @debug = debug
15
+ @html, @debug = html, debug
16
16
  @requests = []
17
17
 
18
18
  end
@@ -49,9 +49,17 @@ class JsAjaxWizard
49
49
  # e = element e.g. {type: 'button', event: 'onclick'}
50
50
  # e2 = target_element: {id: '', property: :innerHTML}
51
51
 
52
- a = if e[:type] == 'button' then
52
+ a = if e[:type].to_s == 'button' then
53
+
54
+ e[:event] = :onclick unless e[:event]
53
55
  ["<button type='button' %s='ajaxCall%s()'>Change Content</button>" \
54
- % [e[:event], i+1]]
56
+ % [e[:event].to_s, i+1]]
57
+
58
+ elsif e[:type].to_s == 'text' then
59
+
60
+ e[:event] = :onkeyup unless e[:event]
61
+ ["<input type='text' %s='ajaxCall%s(this)'/>" % [e[:event].to_s, i+1]]
62
+
55
63
  else
56
64
  ''
57
65
  end
@@ -86,17 +94,31 @@ function ajaxRequest(url, cFunction) {
86
94
  EOF
87
95
 
88
96
  funcs_defined = @requests.map.with_index do |x,i|
89
-
97
+
98
+ a = []
90
99
  server, element, target_element = x
100
+
101
+ a << if element[:type] == 'text' then
102
+ "
103
+ function ajaxCall#{i+1}() {
104
+ ajaxRequest('#{server}', ajaxResponse#{i+1})
105
+ }
106
+ "
107
+ else
91
108
  "
92
109
  function ajaxCall#{i+1}() {
93
110
  ajaxRequest('#{server}', ajaxResponse#{i+1})
94
111
  }
112
+ "
113
+ end
95
114
 
115
+ a << "
96
116
  function ajaxResponse#{i+1}(xhttp) {
97
117
  document.getElementById('#{target_element[:id]}').innerHTML = xhttp.responseText;
98
118
  }
99
- "
119
+ "
120
+
121
+ a.join
100
122
  end
101
123
 
102
124
  s = func_calls.join("\n") + "\n\n" + ajax + "\n\n" + funcs_defined.join
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsajax_wizard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  pZTsghadsRxoGiI7mehrgxkeLLA7q3Zpafsvw3mLrERdifNsVFNBUDMjfE/OnJq8
36
36
  EOz+UVQEw8EJ9wHqaJYIbHBq
37
37
  -----END CERTIFICATE-----
38
- date: 2019-08-07 00:00:00.000000000 Z
38
+ date: 2019-08-08 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
metadata.gz.sig CHANGED
Binary file