jsajax_wizard 0.2.1 → 0.2.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/jsajax_wizard.rb +58 -3
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9109f2df9aa36be696a07f567abb93063d6d1c52922fd1e238a6eb4d40b711e
|
4
|
+
data.tar.gz: 275891dcee8e8b5aeb6adaeab39e93af233461d6504e3f2c926b0d7546910fab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb78b176471f9ebd9b701ff5db8e151edc30ff0b391da62ba0d0c565ea571f8d4754e910556db85e7a03bb4d90434efa84e87840ca4381f94567e84cd03c52ac
|
7
|
+
data.tar.gz: 3fbf00b323808692e7550940c44a6feb8a8da1ad634b63a87f82915f8b58037fc2ce972ca36357b837490df7a31f7d2d3c3aa9331739dda28fdea8961164b26b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/jsajax_wizard.rb
CHANGED
@@ -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
|
72
|
+
"*[@type='%s']" % element[:type]
|
69
73
|
end
|
70
74
|
|
71
75
|
if @debug then
|
72
|
-
puts "selector:
|
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.
|
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-
|
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.
|
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
|