atome 0.5.5.6.4 → 0.5.5.6.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 +4 -4
- data/Rakefile +112 -15
- data/exe/atome +119 -14
- data/lib/atome/atome.rb +2 -3
- data/lib/atome/genesis/generators/identity.rb +1 -1
- data/lib/atome/genesis/generators/spatial.rb +90 -0
- data/lib/atome/genesis/generators/utility.rb +7 -3
- data/lib/atome/genesis/sparkle.rb +3 -0
- data/lib/atome/helpers/utilities.rb +31 -0
- data/lib/atome/version.rb +1 -1
- data/lib/platform_specific/opal/atome_opal_extensions.rb +1 -0
- data/lib/renderers/html/html.rb +1 -1
- data/lib/renderers/html/spatial.rb +12 -0
- data/lib/renderers/html/utility.rb +46 -0
- data/vendor/assets/application/examples/duplicate.rb +2 -0
- data/vendor/assets/application/examples/file.rb +11 -46
- data/vendor/assets/application/examples/layout.rb +15 -191
- data/vendor/assets/application/examples/security.rb +5 -5
- data/vendor/assets/application/examples/selected.rb +0 -1
- data/vendor/assets/src/css/style.css +1 -1
- data/vendor/assets/src/js/atome/atome.js +155 -20
- metadata +2 -3
- data/app_builder_helpers/Rakefile +0 -278
@@ -36,3 +36,49 @@ new({renderer: :html, method: :match}) do |params, bloc|
|
|
36
36
|
html.match(params)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
|
41
|
+
new({ renderer: :html, method: :import, type: :blob }) do |_params, bloc|
|
42
|
+
|
43
|
+
if Atome::host == 'web-opal'
|
44
|
+
file_for_opal(@id, bloc) do |file_content|
|
45
|
+
bloc.call(file_content)
|
46
|
+
end
|
47
|
+
|
48
|
+
else
|
49
|
+
# Wasm version
|
50
|
+
def create_file_browser(_options = '', &bloc)
|
51
|
+
div_element = JS.global[:document].getElementById(@id.to_s)
|
52
|
+
input_element = JS.global[:document].createElement("input")
|
53
|
+
input_element[:type] = "file"
|
54
|
+
input_element[:style][:position] = "absolute"
|
55
|
+
input_element[:style][:display] = "none"
|
56
|
+
input_element[:style][:width] = "0px"
|
57
|
+
input_element[:style][:height] = "0px"
|
58
|
+
|
59
|
+
input_element.addEventListener("change") do |native_event|
|
60
|
+
event = Native(native_event)
|
61
|
+
file = event[:target][:files][0]
|
62
|
+
if file
|
63
|
+
puts "file requested: #{file[:name]}"
|
64
|
+
file_reader = JS.global[:FileReader].new
|
65
|
+
file_reader.addEventListener("load") do |load_event|
|
66
|
+
file_content = load_event[:target][:result]
|
67
|
+
Atome.file_handler(@id, file_content, bloc)
|
68
|
+
end
|
69
|
+
file_reader.readAsText(file)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
div_element.addEventListener("mousedown") do |event|
|
74
|
+
input_element.click
|
75
|
+
end
|
76
|
+
div_element.appendChild(input_element)
|
77
|
+
end
|
78
|
+
create_file_browser(:options) do |file_content|
|
79
|
+
# puts "wasm ===>#{file_content}"
|
80
|
+
bloc.call(file_content)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -57,8 +57,10 @@ b = circle({ id: :the_cirlce })
|
|
57
57
|
b.text(:hello)
|
58
58
|
bb = b.duplicate({ width: 33, left: 234, top: 222 })
|
59
59
|
bb.color(:red)
|
60
|
+
wait 1 do
|
60
61
|
bb2 = b.duplicate({ width: 33, left: 12 })
|
61
62
|
bb3 = b.duplicate({ width: 33, left: 444 })
|
62
63
|
bb3.color(:green)
|
63
64
|
bb2.color(:orange)
|
65
|
+
end
|
64
66
|
|
@@ -1,50 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
# id: :s3,
|
7
|
-
# left: 3, top: 3, blur: 9,
|
8
|
-
# invert: true,
|
9
|
-
# red: 0, green: 0, blue: 0, alpha: 0.7
|
10
|
-
# })
|
11
|
-
def create_file_browser
|
12
|
-
div_element = JS.global[:document].createElement("div")
|
13
|
-
|
14
|
-
# Définir les propriétés CSS de l'élément div
|
15
|
-
div_element[:style][:width] = "33px" # Taille: largeur de 100 pixels
|
16
|
-
div_element[:style][:height] = "33px" # Taille: hauteur de 100 pixels
|
17
|
-
div_element[:style][:backgroundColor] = "rgba(255,0,0,0.3)" # Couleur de fond rouge
|
18
|
-
div_element[:style][:position] = "absolute" # Positionnement absolu
|
19
|
-
div_element[:style][:top] = "0px" # Position par rapport au haut de l'écran
|
20
|
-
div_element[:style][:left] = "0px" # Position par rapport à la gauche de l'écran
|
21
|
-
|
22
|
-
# Définir un ID pour l'élément div
|
23
|
-
div_element[:id] = "monDiv"
|
24
|
-
|
25
|
-
input_element = JS.global[:document].createElement("input")
|
26
|
-
input_element[:type] = "file"
|
27
|
-
input_element[:style][:position] = "absolute"
|
28
|
-
input_element[:style][:display] = "none"
|
29
|
-
input_element[:style][:width] = "0px"
|
30
|
-
input_element[:style][:height] = "0px"
|
31
|
-
input_element.addEventListener("change") do |native_event|
|
32
|
-
event = Native(native_event)
|
33
|
-
file = event[:target][:files][0]
|
34
|
-
if file
|
35
|
-
puts "file requested: #{file[:name]}"
|
36
|
-
# support.controller({ action: :loadProject, params: { path: file[:name]} })
|
37
|
-
end
|
38
|
-
end
|
39
|
-
div_element.addEventListener("mousedown") do |event|
|
40
|
-
# Déclenchez manuellement un clic sur l'input
|
41
|
-
input_element.click
|
42
|
-
end
|
43
|
-
view_div = JS.global[:document].querySelector("#view")
|
44
|
-
|
45
|
-
view_div.appendChild(input_element)
|
46
|
-
view_div.appendChild(div_element)
|
47
|
-
|
3
|
+
b = box({ drag: true })
|
4
|
+
b.import(true) do |content|
|
5
|
+
puts "add code here, content: #{content}"
|
48
6
|
end
|
49
7
|
|
50
|
-
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -1,179 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# class HTML
|
4
|
-
#
|
5
|
-
# def layout_style(option = {})
|
6
|
-
# element_style = {
|
7
|
-
# backgroundColor: 'rebeccapurple',
|
8
|
-
# width: '100%',remove_layout
|
9
|
-
# height: '29px',
|
10
|
-
# borderRadius: '59px',
|
11
|
-
# display: 'flex',
|
12
|
-
# justifyContent: 'center',
|
13
|
-
# alignItems: 'center',
|
14
|
-
# flexDirection: 'column',
|
15
|
-
# marginBottom: '20px',
|
16
|
-
# padding: '0px',
|
17
|
-
# # transform: 'rotate(22deg)',
|
18
|
-
#
|
19
|
-
# }
|
20
|
-
#
|
21
|
-
# container_style = {
|
22
|
-
# display: :grid,
|
23
|
-
# gridTemplateColumns: 'repeat(4, 1fr)',
|
24
|
-
# overflow: :scroll,
|
25
|
-
# flexDirection: 'column',
|
26
|
-
# gap: '20px',
|
27
|
-
# padding: '0px',
|
28
|
-
#
|
29
|
-
# }
|
30
|
-
# element_style = element_style.merge(option[:element]) if option[:element]
|
31
|
-
# container_style = container_style.merge(option[:container]) if option[:container]
|
32
|
-
# @layout_style = { element: element_style, container: container_style }
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# def remove_webview_layout(element, container)
|
36
|
-
# element[:classList].add('atome')
|
37
|
-
# element[:classList].remove('matrix_element')
|
38
|
-
# end
|
39
|
-
#
|
40
|
-
# def layout(params)
|
41
|
-
#
|
42
|
-
# id_found = params[:id]
|
43
|
-
# mode_found = params[:mode]
|
44
|
-
# width_found = params[:width]
|
45
|
-
# height_found = params[:height]
|
46
|
-
# layout_container = JS.global[:document].getElementById(id_found.to_s)
|
47
|
-
# layout_elements = JS.global[:document].querySelectorAll(".#{id_found}")
|
48
|
-
# if mode_found == :default
|
49
|
-
# # we revert all elements to default state / layout
|
50
|
-
# layout_elements.to_a.each do |element|
|
51
|
-
# element[:classList].remove('matrix_element')
|
52
|
-
# element[:classList].add('atome')
|
53
|
-
# end
|
54
|
-
# else
|
55
|
-
# # we apply new layout to elements
|
56
|
-
# layout_style({ element: { backgroundColor: :purple } })
|
57
|
-
# layout_container[:classList].remove('atome')
|
58
|
-
# layout_container[:classList].add('matrix')
|
59
|
-
# layout_elements.to_a.each do |element|
|
60
|
-
# # we check if current state is default if yes we store the layout to be able to restore it
|
61
|
-
# element[:style][:borderRadius] = '59px'
|
62
|
-
# element[:classList].remove('atome')
|
63
|
-
# # element[:classList].add('matrix_element')
|
64
|
-
# end
|
65
|
-
# end
|
66
|
-
#
|
67
|
-
# end
|
68
|
-
# end
|
69
|
-
|
70
|
-
class Atome
|
71
|
-
def remove_layout
|
72
|
-
display[:mode] = :default
|
73
|
-
# we get the current parent (the previous layout)
|
74
|
-
parent_found = grab(attach)
|
75
|
-
# we get the parent of the parent
|
76
|
-
grand_parent = parent_found.attach
|
77
|
-
# and attach the item to the grand parent
|
78
|
-
# we remove the parent category and restore atome category
|
79
|
-
remove({ category: attach})
|
80
|
-
category(:atome)
|
81
|
-
attach(grand_parent)
|
82
|
-
# we delete the parent (the layout) if it no more children attached
|
83
|
-
if parent_found.attached.length == 0
|
84
|
-
parent_found.delete(true)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
new({ particle: :layout }) do |params|
|
90
|
-
mode_found = params.delete(:mode) || :list
|
91
|
-
elements_style= params.delete(:element) || {}
|
92
|
-
# layout_width = params[:width] ||= 333
|
93
|
-
# layout_height = params[:height] ||= 333
|
94
|
-
# now we get the list of the atome to layout
|
95
|
-
atomes_to_layout = []
|
96
|
-
if type == :group
|
97
|
-
atomes_to_layout = collect
|
98
|
-
end
|
99
|
-
# if params[:list] is specified group collection is override
|
100
|
-
atomes_to_layout = params[:list] if params[:list]
|
101
|
-
|
102
|
-
if mode_found == :default
|
103
|
-
# the user want to revert the layout to the default
|
104
|
-
atomes_to_layout.each do |atome_id_to_layout|
|
105
|
-
atome_to_layout = grab(atome_id_to_layout)
|
106
|
-
unless params[:id]
|
107
|
-
params[:id] = atome_to_layout.display[:layout]
|
108
|
-
end
|
109
|
-
# now we get the default particles and restore it
|
110
|
-
atome_to_layout.display[:default].each do |particle, value|
|
111
|
-
atome_to_layout.send(:delete,particle)
|
112
|
-
atome_to_layout.send(particle,value)
|
113
|
-
end
|
114
|
-
|
115
|
-
atome_to_layout.remove_layout
|
116
|
-
end
|
117
|
-
else
|
118
|
-
if params[:id]
|
119
|
-
container_name = params[:id]
|
120
|
-
container = grab(:view).box({ id: container_name })
|
121
|
-
container_class = container_name
|
122
|
-
else
|
123
|
-
container = grab(:view).box
|
124
|
-
id_found = container.id
|
125
|
-
params[:id] = id_found
|
126
|
-
container_class = id_found
|
127
|
-
end
|
128
|
-
# container.width = layout_width
|
129
|
-
# container.height = layout_height
|
130
|
-
container.remove({ category: :atome})
|
131
|
-
container.category(:matrix)
|
132
|
-
alert ">> #{mode_found}"
|
133
|
-
params.each do |particle, value|
|
134
|
-
container.send(particle, value)
|
135
|
-
end
|
136
|
-
# now we add user wanted particles
|
137
|
-
alert params
|
138
|
-
|
139
|
-
atomes_to_layout.each do |atome_id_to_layout|
|
140
|
-
atome_to_layout = grab(atome_id_to_layout)
|
141
|
-
# we remove previous display mode
|
142
|
-
atome_to_layout.remove_layout
|
143
|
-
atome_to_layout.display[:mode] = mode_found
|
144
|
-
atome_to_layout.display[:layout] = id_found
|
145
|
-
atome_to_layout.attach(container_class)
|
146
|
-
atome_to_layout.remove({ category: :atome})
|
147
|
-
atome_to_layout.category(container_class)
|
148
|
-
#the hash below is used to restore element state
|
149
|
-
original_state={}
|
150
|
-
elements_style.each do |particle, value|
|
151
|
-
# we have to store all elements particle to restore it later
|
152
|
-
original_state[particle]=atome_to_layout.send(particle)
|
153
|
-
atome_to_layout.send(particle, value)
|
154
|
-
end
|
155
|
-
atome_to_layout.display[:default]=original_state
|
156
|
-
# puts "display is : #{atome_to_layout.display}"
|
157
|
-
# atome_to_layout.html.add_class(container_class)
|
158
|
-
# puts container_class
|
159
|
-
end
|
160
|
-
end
|
161
|
-
params
|
162
|
-
end
|
163
|
-
|
164
|
-
# new({ renderer: :html, method: :layout, type: :hash }) do |params, _user_proc|
|
165
|
-
# html.layout(params)
|
166
|
-
# end
|
167
|
-
|
168
|
-
new({ particle: :display })
|
169
|
-
|
170
|
-
# system
|
171
|
-
Atome.new({ renderers: [:html], id: :selector, collect: [], type: :group, tag: { system: true } })
|
172
|
-
|
173
|
-
############### tests
|
174
|
-
|
175
3
|
b = box({ color: :red, id: :the_box, left: 3 })
|
176
|
-
|
4
|
+
5.times do |index|
|
177
5
|
width_found = b.width
|
178
6
|
b.duplicate({ left: b.left + index * (width_found + 45), top: 0, category: :custom_category })
|
179
7
|
end
|
@@ -182,7 +10,7 @@ grab(:view).attached.each do |atome_found|
|
|
182
10
|
grab(atome_found).selected(true)
|
183
11
|
end
|
184
12
|
grab(:the_box_copy_1).text(:hello)
|
185
|
-
|
13
|
+
|
186
14
|
selected_items = grab(Universe.current_user).selection # we create a group
|
187
15
|
# we collect all atomes in the view
|
188
16
|
atomes_found = []
|
@@ -190,38 +18,34 @@ selected_items.each do |atome_found|
|
|
190
18
|
atomes_found << atome_found
|
191
19
|
end
|
192
20
|
|
193
|
-
random_found = atomes_found.sample(17)
|
194
|
-
|
21
|
+
# random_found = atomes_found.sample(17)
|
22
|
+
#
|
195
23
|
# random_found.each do |atome_id|
|
196
24
|
# atome_found = grab(atome_id)
|
197
25
|
# if atome_found.type == :shape
|
198
26
|
# atome_found.left(rand(700))
|
199
|
-
# atome_found.width(rand(
|
200
|
-
# atome_found.height(rand(
|
27
|
+
# atome_found.width(rand(200))
|
28
|
+
# atome_found.height(rand(200))
|
29
|
+
# # atome_found.rotate(rand(90))
|
201
30
|
# atome_found.smooth(rand(120))
|
202
31
|
# atome_found.color({ red: rand, green: rand, blue: rand })
|
203
32
|
# end
|
204
33
|
# end
|
34
|
+
|
35
|
+
selected_items.layout({ mode: :default, width: 500, height: 22 })
|
36
|
+
|
205
37
|
wait 1 do
|
206
|
-
selected_items.layout({ mode: :grid, width: 900, height: 500, color: :green,element: {
|
207
|
-
# alert grab('the_box_copy_4').display
|
38
|
+
selected_items.layout({ mode: :grid, width: 900, height: 500, color: :green, element: { rotate: 22, height: 100, width: 150 } })
|
208
39
|
wait 1 do
|
209
|
-
|
40
|
+
selected_items.layout({ mode: :grid, width: 1200, height: 500, overflow: :scroll })
|
210
41
|
wait 1 do
|
211
|
-
selected_items.layout({ mode: :default, width: 500, height:
|
212
|
-
# alert grab('the_box_copy_4').display
|
42
|
+
selected_items.layout({ mode: :default, width: 500, height: 22 })
|
213
43
|
wait 1 do
|
214
|
-
selected_items.layout({ id: :my_layout, mode: :list, width:
|
44
|
+
selected_items.layout({ id: :my_layout, mode: :list, width: 800, height: 800, overflow: :scroll, element: { height: 22, width: 800 } })
|
215
45
|
wait 1 do
|
216
|
-
selected_items.layout({ mode: :default
|
46
|
+
selected_items.layout({ mode: :default })
|
217
47
|
end
|
218
48
|
end
|
219
49
|
end
|
220
50
|
end
|
221
51
|
end
|
222
|
-
|
223
|
-
# JS.global[:console].clear()
|
224
|
-
|
225
|
-
|
226
|
-
# b=box
|
227
|
-
# alert ">> #{b.display}"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
c=circle({left: 220})
|
5
|
-
t=text({left: 550,data: :hello,password: { read: {atome: :my_secret} }})
|
5
|
+
t=text({left: 550,data: :hello,password: { read: { atome: :my_secret} }})
|
6
6
|
b = box({ id: :the_box, left: 66,smooth: 1.789,
|
7
7
|
password: {
|
8
8
|
read: {
|
@@ -18,16 +18,16 @@ b = box({ id: :the_box, left: 66,smooth: 1.789,
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
b.authorise({ read: {atome: :the_pass,smooth: :read_pass }, write: {smooth: :write_pass}, destroy: true} )
|
21
|
+
b.authorise({ read: { atome: :the_pass, smooth: :read_pass }, write: { smooth: :write_pass}, destroy: true} )
|
22
22
|
puts b.smooth
|
23
23
|
# next will be rejected because destroy: true
|
24
24
|
puts b.smooth
|
25
25
|
#
|
26
|
-
b.authorise({ read: {atome: :wrong_pass,smooth: :no_read_pass }, write: {smooth: :wrong_write_pass}, destroy: false} )
|
26
|
+
b.authorise({ read: { atome: :wrong_pass, smooth: :no_read_pass }, write: { smooth: :wrong_write_pass}, destroy: false} )
|
27
27
|
puts 'will send the wrong password'
|
28
28
|
puts b.smooth
|
29
29
|
|
30
|
-
b.authorise({ read: {atome: :wrong_pass,smooth: :read_pass }, write: {smooth: :wrong_write_pass}, destroy: false} )
|
30
|
+
b.authorise({ read: { atome: :wrong_pass, smooth: :read_pass }, write: { smooth: :wrong_write_pass}, destroy: false} )
|
31
31
|
puts "'with send the right password it'll works"
|
32
32
|
puts b.smooth
|
33
33
|
# authorise has two params the first is the password to authorise the second is used to destroy the password or keep for
|
@@ -41,7 +41,7 @@ wait 1 do
|
|
41
41
|
b.authorise({write: {smooth: :write_pass}, destroy: false} )
|
42
42
|
b.smooth(66)
|
43
43
|
wait 1 do
|
44
|
-
b.authorise({write: {smooth: :false_pass, atome: :no_apss, destroy: true}} )
|
44
|
+
b.authorise({write: { smooth: :false_pass, atome: :no_apss, destroy: true}} )
|
45
45
|
b.smooth(6)
|
46
46
|
end
|
47
47
|
end
|
@@ -63,8 +63,6 @@ async function changeCurrentDirectory(atome_id, newPath) {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
|
66
|
-
|
67
|
-
|
68
66
|
// Terminal
|
69
67
|
|
70
68
|
async function terminal(atome_id, cmd) {
|
@@ -152,29 +150,166 @@ function createSvgElement(tagName, attributes) {
|
|
152
150
|
return elem;
|
153
151
|
}
|
154
152
|
|
153
|
+
//
|
154
|
+
// function sanitizeString(str) {
|
155
|
+
// return str.replace(/'/g, "\\'");
|
156
|
+
// }
|
157
|
+
// function fileread(){
|
158
|
+
// var inputElement = document.createElement("input");
|
159
|
+
// inputElement.type = "file";
|
160
|
+
//
|
161
|
+
// inputElement.addEventListener("change", function(event) {
|
162
|
+
// var file = event.target.files[0];
|
163
|
+
// var reader = new FileReader();
|
164
|
+
//
|
165
|
+
// reader.onload = function(event) {
|
166
|
+
// var content = event.target.result;
|
167
|
+
// var sanitizedContent = sanitizeString(content);
|
168
|
+
// rubyVMCallback("input_callback('"+sanitizedContent+"')");
|
169
|
+
// };
|
170
|
+
//
|
171
|
+
// reader.readAsText(file);
|
172
|
+
// });
|
173
|
+
//
|
174
|
+
// // Ajout de l'élément input à la div
|
175
|
+
// var viewDiv = document.querySelector("#support");
|
176
|
+
// viewDiv.appendChild(inputElement);
|
177
|
+
// }
|
155
178
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
179
|
+
|
180
|
+
function fileForOpal(parent, bloc) {
|
181
|
+
let input = document.createElement('input');
|
182
|
+
input.type = 'file';
|
183
|
+
input.style.position = "absolute";
|
184
|
+
input.style.display = "none";
|
185
|
+
input.style.width = "0px";
|
186
|
+
input.style.height = "0px";
|
187
|
+
input.addEventListener('change', function (event) {
|
188
|
+
let file = event.target.files[0];
|
189
|
+
let reader = new FileReader();
|
190
|
+
|
191
|
+
reader.onloadstart = function () {
|
192
|
+
console.log("Load start");
|
193
|
+
};
|
194
|
+
|
195
|
+
reader.onprogress = function (e) {
|
196
|
+
console.log("Loading: " + (e.loaded / e.total * 100) + '%');
|
197
|
+
};
|
198
|
+
|
199
|
+
reader.onload = function (e) {
|
200
|
+
var content = e.target.result;
|
201
|
+
Opal.Atome.$file_handler(parent, content, bloc)
|
202
|
+
};
|
203
|
+
|
204
|
+
reader.onloadend = function () {
|
205
|
+
console.log("Load end");
|
206
|
+
};
|
207
|
+
|
208
|
+
reader.onerror = function () {
|
209
|
+
console.error("Error reading file");
|
171
210
|
};
|
172
211
|
|
173
212
|
reader.readAsText(file);
|
174
213
|
});
|
214
|
+
let div_element = document.getElementById(parent);
|
215
|
+
div_element.appendChild(input);
|
216
|
+
div_element.addEventListener('mousedown', function (event) {
|
217
|
+
input.click()
|
218
|
+
})
|
175
219
|
|
176
|
-
// Ajout de l'élément input à la div
|
177
|
-
var viewDiv = document.querySelector("#support");
|
178
|
-
viewDiv.appendChild(inputElement);
|
179
220
|
}
|
180
221
|
|
222
|
+
function importer(){
|
223
|
+
|
224
|
+
// Gestionnaire pour le drag and drop de fichiers
|
225
|
+
document.body.addEventListener('dragover', function(e) {
|
226
|
+
e.preventDefault(); // Nécessaire pour autoriser le drop
|
227
|
+
// Modifier le style si nécessaire
|
228
|
+
});
|
229
|
+
|
230
|
+
document.body.addEventListener('drop', function(e) {
|
231
|
+
e.preventDefault();
|
232
|
+
let files = e.dataTransfer.files; // Obtention de la liste des fichiers déposés
|
233
|
+
|
234
|
+
if (files.length) {
|
235
|
+
// Parcourir chaque fichier
|
236
|
+
for (let i = 0; i < files.length; i++) {
|
237
|
+
let file = files[i];
|
238
|
+
let reader = new FileReader();
|
239
|
+
|
240
|
+
// Lire le fichier en tant que texte
|
241
|
+
reader.readAsText(file);
|
242
|
+
|
243
|
+
// Événement déclenché une fois la lecture terminée
|
244
|
+
reader.onload = function() {
|
245
|
+
console.log('Contenu du fichier #' + (i + 1));
|
246
|
+
console.log('Nom: ' + file.name);
|
247
|
+
console.log('Type: ' + file.type);
|
248
|
+
console.log('Taille: ' + file.size + ' octets');
|
249
|
+
console.log('Contenu: \n' + reader.result); // Affichage du contenu du fichier
|
250
|
+
};
|
251
|
+
|
252
|
+
// Gestion des erreurs de lecture
|
253
|
+
reader.onerror = function() {
|
254
|
+
console.error('Erreur de lecture du fichier: ' + file.name);
|
255
|
+
};
|
256
|
+
}
|
257
|
+
}
|
258
|
+
// if (e.dataTransfer.files.length) {
|
259
|
+
// alert (e.dataTransfer.files);
|
260
|
+
// // Traiter les fichiers déposés
|
261
|
+
// }
|
262
|
+
});
|
263
|
+
|
264
|
+
// Gestionnaire pour les éléments div
|
265
|
+
var divs = document.querySelectorAll('.draggable-div');
|
266
|
+
divs.forEach(function(div) {
|
267
|
+
div.addEventListener('dragstart', function(e) {
|
268
|
+
e.dataTransfer.setData('text/plain', 'some-data');
|
269
|
+
e.stopPropagation(); // Empêcher la propagation au body
|
270
|
+
});
|
271
|
+
});
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
importer()
|
276
|
+
|
277
|
+
|
278
|
+
function exception_import (){
|
279
|
+
// Sélectionner la div spéciale par son ID
|
280
|
+
var specialDiv = document.getElementById('exept');
|
281
|
+
|
282
|
+
// Gestionnaire d'événements pour la 'special-div' pour le drag over
|
283
|
+
specialDiv.addEventListener('dragover', function(e) {
|
284
|
+
|
285
|
+
specialDiv.style.backgroundColor= 'red';
|
286
|
+
e.preventDefault(); // Prévenir le comportement par défaut
|
287
|
+
e.stopPropagation(); // Arrêter la propagation de l'événement
|
288
|
+
});
|
289
|
+
specialDiv.addEventListener('dragleave', function(e) {
|
290
|
+
specialDiv.style.backgroundColor = 'yellow'; // Réinitialiser la couleur de fond lors du drag out
|
291
|
+
e.stopPropagation(); // Arrêter la propagation de l'événement
|
292
|
+
});
|
293
|
+
// Gestionnaire d'événements pour la 'special-div' pour le drop
|
294
|
+
specialDiv.addEventListener('drop', function(e) {
|
295
|
+
e.preventDefault(); // Prévenir le comportement par défaut
|
296
|
+
e.stopPropagation(); // Arrêter la propagation de l'événement
|
297
|
+
|
298
|
+
// Traitement spécifique pour les fichiers déposés sur la 'special-div'
|
299
|
+
console.log('Fichier déposé dans la zone spéciale');
|
300
|
+
});
|
301
|
+
|
302
|
+
// Gestionnaire d'événements pour le body pour le drop
|
303
|
+
// document.body.addEventListener('drop', function(e) {
|
304
|
+
// e.preventDefault(); // Prévenir le comportement par défaut
|
305
|
+
//
|
306
|
+
// // Traitement pour les fichiers déposés en dehors de la 'special-div'
|
307
|
+
// console.log('Fichier déposé hors de la zone spéciale');
|
308
|
+
// });
|
309
|
+
|
310
|
+
|
311
|
+
}
|
312
|
+
setTimeout(function () {
|
313
|
+
exception_import();
|
314
|
+
console.log('ready');
|
315
|
+
}, 3000);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.5.6.
|
4
|
+
version: 0.5.5.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Eric Godard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arduino_firmata
|
@@ -346,7 +346,6 @@ files:
|
|
346
346
|
- LICENSE.txt
|
347
347
|
- README.md
|
348
348
|
- Rakefile
|
349
|
-
- app_builder_helpers/Rakefile
|
350
349
|
- documentation/atome.md
|
351
350
|
- documentation/basic.md
|
352
351
|
- documentation/database.JPG
|