jsajax_wizard 0.1.0
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/jsajax_wizard.rb +107 -0
- metadata +90 -0
- metadata.gz.sig +3 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7761d8bce118b8403557bf3c14e2dbee9f58835afa03ea3347c438ccd508ae31
|
4
|
+
data.tar.gz: 3d7093f914261c0a75fc51d79a061e08e782a4c6314790d1f36d478e7f1df384
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b586743634fd2bedc552a0bdcf61f74a18069ad9dbd15bc0604053589cc0b0c1d9a51bec3a206edfc99690a0bffebcd59b3a2079bb7d2754e27df94b1b7ffc6
|
7
|
+
data.tar.gz: c50093eac78558a7d64909040b81e22651ad5783a63e35cd9796001d28a0193dc287251c925cc24011a7661aff21347c18a95ffb4e0f79e9ee649f184b0862cc
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: jsajax_wizard.rb
|
4
|
+
|
5
|
+
# description: Makes building an AJAX web page easier than
|
6
|
+
# copying and pasting an example.
|
7
|
+
|
8
|
+
require 'rexle'
|
9
|
+
|
10
|
+
class JsAjaxWizard
|
11
|
+
|
12
|
+
def initialize(html: '', debug: false)
|
13
|
+
|
14
|
+
@debug = debug
|
15
|
+
@requests = []
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_request(server: '', element: {}, target_element: {})
|
20
|
+
@requests << [server, element, target_element]
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_html()
|
24
|
+
|
25
|
+
a = RexleBuilder.build do |xml|
|
26
|
+
xml.html do
|
27
|
+
xml.head do
|
28
|
+
xml.meta name: "viewport", content: \
|
29
|
+
"width=device-width, initial-scale=1"
|
30
|
+
xml.style "\nbody {font-family: Arial;}\n\n"
|
31
|
+
end
|
32
|
+
xml.body build_html + "\n" + build_js()
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
doc = Rexle.new(a)
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def build_html()
|
43
|
+
|
44
|
+
html = @requests.map.with_index do |x,i|
|
45
|
+
|
46
|
+
e, e2 = x[1..-1]
|
47
|
+
|
48
|
+
# e = element e.g. {type: 'button', event: 'onclick'}
|
49
|
+
# e2 = target_element: {id: '', property: :innerHTML}
|
50
|
+
|
51
|
+
a = if e[:type] == 'button' then
|
52
|
+
["<button type='button' %s='ajaxCall%s()'>Change Content</button>" \
|
53
|
+
% [e[:event], i+1]]
|
54
|
+
else
|
55
|
+
''
|
56
|
+
end
|
57
|
+
|
58
|
+
a << "<div id='%s'></div>" % [e2[:id]]
|
59
|
+
a.join("\n")
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
html.join("\n")
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_js()
|
68
|
+
|
69
|
+
func_calls = @requests.length.times.map do |i|
|
70
|
+
"// ajaxCall#{i+1}();"
|
71
|
+
end
|
72
|
+
|
73
|
+
ajax=<<EOF
|
74
|
+
function ajaxRequest(url, cFunction) {
|
75
|
+
var xhttp;
|
76
|
+
xhttp = new XMLHttpRequest();
|
77
|
+
xhttp.onreadystatechange = function() {
|
78
|
+
if (this.readyState == 4 && this.status == 200) {
|
79
|
+
cFunction(this);
|
80
|
+
}
|
81
|
+
};
|
82
|
+
xhttp.open("GET", url, true);
|
83
|
+
xhttp.send();
|
84
|
+
}
|
85
|
+
EOF
|
86
|
+
|
87
|
+
funcs_defined = @requests.map.with_index do |x,i|
|
88
|
+
|
89
|
+
server, element, target_element = x
|
90
|
+
"
|
91
|
+
function ajaxCall#{i+1}() {
|
92
|
+
ajaxRequest('#{server}', ajaxResponse#{i+1})
|
93
|
+
}
|
94
|
+
|
95
|
+
function ajaxResponse#{i+1}(xhttp) {
|
96
|
+
document.getElementById('#{target_element[:id]}').innerHTML = xhttp.responseText;
|
97
|
+
}
|
98
|
+
"
|
99
|
+
end
|
100
|
+
|
101
|
+
s = func_calls.join("\n") + "\n\n" + ajax + "\n\n" + funcs_defined.join
|
102
|
+
"\n <script>\n%s\n </script>\n" % s
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jsajax_wizard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwODA3MTgzMjU4WhcN
|
15
|
+
MjAwODA2MTgzMjU4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDHbyTR
|
17
|
+
sAvmNdzPD/IcsL8myPAB65R6LNfSRCO2uTnqmLzu342CpX9O0lQQdO2xnzfAQwTb
|
18
|
+
Obh7t2g3lajDWPFXZv0QPxTF6HMNbG0Zp5GbpGg4dLgwS7G+rDPqfHqbVmLSyBfM
|
19
|
+
rwje/alLPjKz7AcEIuR2vI6VCwDJsXzbKGYDCiJFlq2iCYcl0MLS+/52UUCg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xIUPf77zHAbLndMWqHiU5mxsN1kZE9DLF
|
35
|
+
pZTsghadsRxoGiI7mehrgxkeLLA7q3Zpafsvw3mLrERdifNsVFNBUDMjfE/OnJq8
|
36
|
+
EOz+UVQEw8EJ9wHqaJYIbHBq
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: rexle
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.5'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.5.2
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.5'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.5.2
|
60
|
+
description:
|
61
|
+
email: james@jamesrobertson.eu
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- lib/jsajax_wizard.rb
|
67
|
+
homepage: https://github.com/jrobertson/jsajax_wizard
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.0.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Makes building an AJAX web page easier than copying and pasting an example.
|
90
|
+
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
C����2DGc�.ꇡɜ��+2�" ����ք�p��td���FP�pNv�
|
2
|
+
�N��{R����j������7�E�="���Nt3�)��X*��J � ߙG��0����PR�������^�tڕG�S�1�Ⴇ�i1�G�c�\'n��9/�� �Q���u˔��4'��X�+���a�M�g�i�P+�(0?�?��Dž2$㱜/�4�W�$���]e��d�1�@2�C��
|
3
|
+
�ױJ�8���|Wn����c��Ȼ!m.�sllҽ��B^��<l(����!]Z�<�HVϥ{���F�����O�)2j� �� _�G�K�26�e�Z�Z�cl��4������d�htJ�wO���p��A>8��]�\��
|