jsajax_wizard 0.2.1 → 0.2.2

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: 4238870adbe4854914ad49fa84eb800431c57897f12022b9e5f8c16806e03c80
4
- data.tar.gz: 46604e0fce9e1c6343e0f07f67ec4508bc606d730830cb84340414b69cfbcfc3
3
+ metadata.gz: d9109f2df9aa36be696a07f567abb93063d6d1c52922fd1e238a6eb4d40b711e
4
+ data.tar.gz: 275891dcee8e8b5aeb6adaeab39e93af233461d6504e3f2c926b0d7546910fab
5
5
  SHA512:
6
- metadata.gz: b2daebf40564434ceb951a70328ed57b5a7fa4c1cc952b977937f1bfeb24e4b8ad8a26b95718ede4c2b9e8e15913061283e78984c404e9f3e00f2617c8f097d7
7
- data.tar.gz: 957f30ca97421af559736cc1d22ece748d160fea34a36f5870133df9b13f0d2e68f5aa3029fd3a41a02df387c384cafc3e1e4df7ac8fdff7e32f6acf46c75148
6
+ metadata.gz: bb78b176471f9ebd9b701ff5db8e151edc30ff0b391da62ba0d0c565ea571f8d4754e910556db85e7a03bb4d90434efa84e87840ca4381f94567e84cd03c52ac
7
+ data.tar.gz: 3fbf00b323808692e7550940c44a6feb8a8da1ad634b63a87f82915f8b58037fc2ce972ca36357b837490df7a31f7d2d3c3aa9331739dda28fdea8961164b26b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -23,6 +23,7 @@
23
23
 
24
24
 
25
25
 
26
+
26
27
  require 'rexle'
27
28
  require 'rexle-builder'
28
29
 
@@ -31,8 +32,11 @@ class JsAjaxWizard
31
32
 
32
33
  def initialize(html='', debug: false)
33
34
 
34
- @html, @debug = html, debug
35
+ @html, @debug = RXFHelper.read(html).first, debug
35
36
  @requests = []
37
+
38
+ # search for AJAX placeholders
39
+ scan_requests(@html)
36
40
 
37
41
  end
38
42
 
@@ -65,15 +69,16 @@ class JsAjaxWizard
65
69
  selector = if element[:id] then
66
70
  '#' + element[:id]
67
71
  elsif element[:type]
68
- "*[type=%s]" % element[:type]
72
+ "*[@type='%s']" % element[:type]
69
73
  end
70
74
 
71
75
  if @debug then
72
- puts "selector: *|%s|*" % selector.inspect
76
+ puts ("selector: %s" % selector.inspect).debug
73
77
  puts 'doc: ' + doc.xml(pretty: true).inspect
74
78
  end
75
79
 
76
80
  e = doc.at_css(selector)
81
+ puts ('e: ' + e.inspect).debug if @debug
77
82
  next unless e
78
83
  puts ('e: ' + e.inspect).debug if @debug
79
84
 
@@ -222,5 +227,55 @@ function ajaxResponse#{i+1}(xhttp) {
222
227
  "\n <script>\n%s\n </script>\n" % s
223
228
 
224
229
  end
230
+
231
+ # find the ajax requests
232
+ #
233
+ def scan_requests(html)
234
+
235
+
236
+ a = html.scan(/\$\[([^\]])+\]\(([^\)]+)/)
237
+
238
+ a.each do |var, url|
239
+
240
+ #== fetch the trigger element details
241
+
242
+ tag = html[/<[^<]+\$\[([^\]])+\]\(#{url}[^\>]+>/]
243
+ element_name = tag[/(?<=<)\w+/]
244
+ event = tag[/(\w+)=["']\$\[([^\]])+\]\(#{url}/,1]
245
+
246
+ # is there an id?
247
+ id = tag[/(?<=id=["'])[^"']+/]
248
+
249
+ h2 = if id then
250
+ {id: id}
251
+ else
252
+ {type: element_name.to_sym }
253
+ end
254
+
255
+ element = h2.merge(event: event)
256
+
257
+ #== fetch the target element details
258
+
259
+ tag2 = html[/<[^<]+>\$#{var}</]
260
+ # is there an id?
261
+ target_id = tag2[/(?<=id=["'])[^"']+/]
262
+
263
+ inner_html = tag2 =~ />\$#{var}</
264
+
265
+ property = if inner_html then
266
+
267
+ html.sub!(/>\$#{var}</,'')
268
+ :innerHTML
269
+
270
+ end
271
+
272
+ target_element = {id: target_id, property: property}
273
+
274
+ add_request(server: url, element: element,
275
+ target_element: target_element)
276
+
277
+ end
278
+
279
+ end
225
280
 
226
281
  end
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.2.1
4
+ version: 0.2.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-24 00:00:00.000000000 Z
38
+ date: 2019-10-02 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.0.1
86
+ rubygems_version: 3.0.3
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Makes building an AJAX web page easier than copying and pasting an example.
metadata.gz.sig CHANGED
Binary file