atome 0.5.5.7.7 → 0.5.5.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/atome +110 -91
- data/lib/atome/atome.rb +4 -1
- data/lib/atome/extensions/atome.rb +319 -2
- data/lib/atome/genesis/generators/atome.rb +10 -1
- data/lib/atome/genesis/generators/communication.rb +10 -2
- data/lib/atome/genesis/generators/effect.rb +7 -1
- data/lib/atome/genesis/generators/event.rb +4 -3
- data/lib/atome/genesis/generators/geometry.rb +31 -4
- data/lib/atome/genesis/generators/identity.rb +3 -0
- data/lib/atome/genesis/generators/material.rb +1 -0
- data/lib/atome/genesis/generators/property.rb +76 -0
- data/lib/atome/genesis/generators/security.rb +4 -2
- data/lib/atome/genesis/generators/utility.rb +27 -12
- data/lib/atome/genesis/sparkle.rb +3 -2
- data/lib/atome/helpers/essentials.rb +3 -2
- data/lib/atome/version.rb +1 -1
- data/lib/platform_specific/opal/extensions/js.rb +1 -2
- data/lib/renderers/html/atome.rb +0 -1
- data/lib/renderers/html/effect.rb +7 -3
- data/lib/renderers/html/geometry.rb +11 -5
- data/lib/renderers/html/hierarchy.rb +1 -1
- data/lib/renderers/html/html.rb +304 -19
- data/lib/renderers/html/identity.rb +8 -0
- data/lib/renderers/html/material.rb +14 -0
- data/lib/renderers/html/property.rb +35 -0
- data/lib/renderers/html/spatial.rb +14 -5
- data/lib/renderers/html/utility.rb +25 -1
- data/sig/global_variables.rbs +1 -0
- data/vendor/assets/application/examples/a_concat.rb +3 -0
- data/vendor/assets/application/examples/atomizer.rb +86 -0
- data/vendor/assets/application/examples/blur.rb +6 -0
- data/vendor/assets/application/examples/border.rb +6 -0
- data/vendor/assets/application/examples/compute.rb +16 -0
- data/vendor/assets/application/examples/console.rb +4 -0
- data/vendor/assets/application/examples/dig.rb +13 -0
- data/vendor/assets/application/examples/fit.rb +26 -0
- data/vendor/assets/application/examples/import.rb +33 -0
- data/vendor/assets/application/examples/infos.rb +10 -0
- data/vendor/assets/application/examples/messaging.rb +17 -4
- data/vendor/assets/application/examples/shortcut.rb +25 -0
- data/vendor/assets/application/examples/size.rb +17 -0
- data/vendor/assets/application/examples/table.rb +76 -0
- data/vendor/assets/application/examples/text.rb +1 -1
- data/vendor/assets/application/works/vie.rb +3 -0
- data/vendor/assets/server/atome_server.rb +40 -7
- data/vendor/assets/server/capture.rb +1 -1
- data/vendor/assets/src/index.html +7 -6
- data/vendor/assets/src/index_opal.html +11 -6
- data/vendor/assets/src/index_server.html +11 -7
- data/vendor/assets/src/index_server_wasm.html +7 -6
- data/vendor/assets/src/js/atome/atome.js +0 -95
- data/vendor/assets/src/js/atome/atome_helpers/communication.js +9 -7
- metadata +15 -2
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
c = circle({ height: 400, width: 200, top: 100, left:99, top: 79 })
|
5
|
+
b = c.box({ width: 200, height: 100, left: 280, top: 190, id: :my_box })
|
6
|
+
i= image(:red_planet)
|
7
|
+
c.touch(true) do
|
8
|
+
c.fit({ value: 100, axis: :x })
|
9
|
+
end
|
10
|
+
|
11
|
+
puts '------'
|
12
|
+
puts "b.compute left return the position on the screen of the item : #{b.compute({reference: c.id, particle: :left, unit: :pixel})}"
|
13
|
+
puts "b.compute left : #{b.compute({ particle: :left })[:value]}, c left : #{b.left}"
|
14
|
+
puts "b.compute top :#{b.compute({ particle: :top })[:value]}, c top: #{b.top}"
|
15
|
+
alert "i.compute width :#{i.compute({ particle: :width })[:value]}, i width: #{i.width}"
|
16
|
+
alert "i.compute height :#{i.compute({ particle: :height })[:value]}, i height: #{i.height}"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
c = circle({ height: 400, width: 200, top: 100, left: 0, top: 100 , id: :the_circle})
|
5
|
+
b = c.box({ width: 200, height: 100, left: 600, top: 200, id: :my_box })
|
6
|
+
c.circle({ width: 200, height: 100, left: 120, top: -80, id: :my_text, data: :hi })
|
7
|
+
b.circle({ color: :yellow, width: 55, height: 88, left: 100 })
|
8
|
+
b.box
|
9
|
+
|
10
|
+
|
11
|
+
atome_founds = c.dig
|
12
|
+
puts "dig allow to retrieve all attached atomes recursively,
|
13
|
+
it return a table of ID including the ID of the parent (here : :the_circle) :\n#{atome_founds}"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
c = circle({ height: 400, width: 200, top: 100, left: 0, top: 100 })
|
4
|
+
b = c.box({ width: 200, height: 100, left: 600, top: 200, id: :my_box })
|
5
|
+
c.circle({ width: 200, height: 100, left: 120, top: -80, id: :my_text, data: :hi })
|
6
|
+
b.circle({ color: :yellow, width: 55, height: 88, left: 100 })
|
7
|
+
b.box
|
8
|
+
i=c.image({path: 'medias/images/red_planet.png', id: :the_pix })
|
9
|
+
# b.text(:red_planet)
|
10
|
+
|
11
|
+
wait 1 do
|
12
|
+
|
13
|
+
c.fit({ value: 100, axis: :x })
|
14
|
+
|
15
|
+
wait 1 do
|
16
|
+
c.fit({ value: 66, axis: :y })
|
17
|
+
wait 1 do
|
18
|
+
c.fit({ value: 600, axis: :x })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
# alert i.width
|
23
|
+
# alert i.height
|
24
|
+
# i.fit({ value: 66, axis: :x })
|
25
|
+
# i.width(66)
|
26
|
+
# i.height(66)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
support = box({ top: 250, left: 12, width: 300, height: 40, smooth: 9, color: { red: 0.3, green: 0.3, blue: 0.3 }, id: :support })
|
4
|
+
|
5
|
+
support.shadow({
|
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
|
+
|
12
|
+
|
13
|
+
|
14
|
+
box({ id: :the_boxy })
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
support.import(true) do |content|
|
19
|
+
puts "add code here, content: #{content}"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
importer do |val|
|
24
|
+
alert "case 21 #{val}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# importer(:all) do |val|
|
28
|
+
# alert "case 21 #{val}"
|
29
|
+
# end
|
30
|
+
|
31
|
+
importer('the_boxy') do |val|
|
32
|
+
alert "yes !!! exception found : #{val}"
|
33
|
+
end
|
@@ -1,16 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
b = box({ color: :red })
|
4
2
|
|
3
|
+
user_password = {global: :all_star, read: { atome: :all_star }, write: { atome: :all_star } }
|
4
|
+
|
5
|
+
human({ id: :jeezs, login: true, password: user_password, data: { birthday: '10/05/2016' },selection: [], tag: { system: true } , attach: :user_view })
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
b = box({ color: :red, id: :my_box })
|
10
|
+
b.connection('localhost:9292') do |params|
|
11
|
+
alert " the connection is : #{params}"
|
12
|
+
end
|
5
13
|
b.touch(true) do
|
6
14
|
b.connection('localhost:9292') do |params|
|
7
15
|
alert " the connection is : #{params}"
|
8
16
|
end
|
9
17
|
end
|
10
18
|
|
19
|
+
|
11
20
|
c = box({ color: :yellow, left: 333 })
|
12
21
|
|
13
22
|
c.touch(true) do
|
14
|
-
b.message('
|
23
|
+
b.message({message: 'cd ..;cd server;ls; pwd', action: :terminal })
|
24
|
+
b.message({message: 'capture.rb', action: :file, option: :read })
|
25
|
+
b.message({message: 'tototo.rb', action: :file, option: :write, value: :hello })
|
26
|
+
# b.message({message: 'cd ..;cd server;ls; pwd'})
|
15
27
|
# c = box({ color: :red, left: 333 })
|
16
|
-
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
box({id: :my_box})
|
5
|
+
circle({id: :my_circle, left: 333})
|
6
|
+
box({id: :red_box, left: 666, color: :red})
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
shortcut(key: :b, affect: :all) do |key, object_id|
|
11
|
+
puts "Key #{key} press on #{object_id}"
|
12
|
+
end
|
13
|
+
text({data: "Key 'b' on :all", top: 0})
|
14
|
+
|
15
|
+
shortcut(key: :e, option: :meta,affect: [:my_circle, :red_box]) do |key, object_id|
|
16
|
+
puts "Key #{key} press on #{object_id}"
|
17
|
+
end
|
18
|
+
text({data: "Key 'e' with Meta on [:my_circle, :red_box]", top: 30, left: 0, position: :absolute})
|
19
|
+
|
20
|
+
|
21
|
+
shortcut(key: :j, option: :ctrl, affect: :all, exclude: [:my_circle, :my_box]) do |key, object_id|
|
22
|
+
puts "Key #{key} with Ctrl press on #{object_id}"
|
23
|
+
end
|
24
|
+
text({data: "Key 'j' with Ctrl on :all but [:my_circle, :my_box]", top: 50,left: 0, position: :absolute})
|
25
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
c = circle({ height: 400, width: 200, top: 100, left: 0, top: 100 })
|
4
|
+
b = c.box({ width: 200, height: 100, left: 600, top: 200, id: :my_box })
|
5
|
+
c.circle({ width: 200, height: 100, left: 120, top: -80, id: :my_text, data: :hi })
|
6
|
+
b.circle({ color: :yellow, width: 55, height: 88, left: 500 })
|
7
|
+
b.box
|
8
|
+
|
9
|
+
wait 1 do
|
10
|
+
# recursive apply the new size to all attached atomes recursively
|
11
|
+
# reference : change the size according the to wanted axis
|
12
|
+
c.size({value: 50, recursive: true, reference: :y })
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
c = circle({ id: :my_cirle, color: :red, drag: true })
|
5
|
+
c.box({ left: 0, width: 22, height: 22, top: 65 })
|
6
|
+
c.touch(true) do
|
7
|
+
alert :okk
|
8
|
+
end
|
9
|
+
m = matrix({ renderers: [:html], attach: :view, id: :my_test_box, type: :matrix, apply: [:shape_color],
|
10
|
+
left: 333, top: 0, width: 600, smooth: 15, height: 900, overflow: :scroll, option: { header: true },
|
11
|
+
component: {
|
12
|
+
border: { thickness: 5, color: color(:blue), pattern: :dotted },
|
13
|
+
overflow: :auto,
|
14
|
+
color: "white",
|
15
|
+
shadow: {
|
16
|
+
id: :s4,
|
17
|
+
left: 20, top: 0, blur: 9,
|
18
|
+
option: :natural,
|
19
|
+
red: 0, green: 1, blue: 0, alpha: 1
|
20
|
+
},
|
21
|
+
height: 50,
|
22
|
+
width: 50,
|
23
|
+
component: { size: 12, color: :black }
|
24
|
+
},
|
25
|
+
data: [
|
26
|
+
{ titi: :toto },
|
27
|
+
{ dfgdf: 1, name: 'Alice', age: 30, no: 'oko', t: 123, r: 654, f: 123, g: 654, w: 123, x: 654, c: 123, v: 654 },
|
28
|
+
{ id: 2, name: 'Bob', age: 22 },
|
29
|
+
{ dfg: 4, name: 'Vincent', age: 33, no: grab(:my_cirle) },
|
30
|
+
{ dfgd: 3, name: 'Roger', age: 18, no: image(:red_planet), now: :nothing }
|
31
|
+
|
32
|
+
]
|
33
|
+
})
|
34
|
+
|
35
|
+
# tests
|
36
|
+
m.color(:orange)
|
37
|
+
m.border({ thickness: 5, color: color(:blue), pattern: :dotted })
|
38
|
+
|
39
|
+
puts m.get({ cell: [1, 2] })
|
40
|
+
wait 2 do
|
41
|
+
m.insert({ cell: [2, 2], content: 999 })
|
42
|
+
m.insert({ row: 1 })
|
43
|
+
wait 1 do
|
44
|
+
m.remove({ row: 2 })
|
45
|
+
end
|
46
|
+
wait 2 do
|
47
|
+
m.remove({ column: 1 })
|
48
|
+
end
|
49
|
+
wait 3 do
|
50
|
+
m.insert({ column: 3 })
|
51
|
+
end
|
52
|
+
|
53
|
+
wait 4 do
|
54
|
+
m.sort({ column: 1, method: :alphabetic })
|
55
|
+
puts 1
|
56
|
+
wait 1 do
|
57
|
+
puts 2
|
58
|
+
m.sort({ column: 2, method: :numeric })
|
59
|
+
wait 1 do
|
60
|
+
puts 3
|
61
|
+
m.sort({ column: 3, method: :numeric })
|
62
|
+
wait 1 do
|
63
|
+
puts 4
|
64
|
+
m.sort({ column: 1, method: :numeric })
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
# cell.fusion() # to be implemented later
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
frozen_string_literal
|
1
|
+
# frozen_string_literal
|
2
2
|
|
3
3
|
t2 = text({ data: ['this is ', :super, { data: 'cool', color: :red, id: :new_one }], component: { size: 33 }, left: 120 })
|
4
4
|
the_text = text({ data: 'hello for al the people in front of their machine', center: true, top: 120, width: 77, component: { size: 11 } })
|
@@ -138,6 +138,7 @@ cursor.drag({ restrict: {max:{ left: 309, top: 0}} }) do |event|
|
|
138
138
|
|
139
139
|
end
|
140
140
|
|
141
|
+
# new({ particle: :import })
|
141
142
|
|
142
143
|
support=box({top: 250, left: 12, width: 300, height: 40, smooth: 9, color:{red: 0.3, green: 0.3, blue: 0.3}, id: :support })
|
143
144
|
|
@@ -147,6 +148,8 @@ support.shadow({
|
|
147
148
|
invert: true,
|
148
149
|
red: 0, green: 0, blue: 0, alpha: 0.7
|
149
150
|
})
|
151
|
+
|
152
|
+
# support.duplicate
|
150
153
|
support.import(true) do |content|
|
151
154
|
puts "add code here, content: #{content}"
|
152
155
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# atome server
|
4
4
|
require 'em/pure_ruby' if RUBY_PLATFORM == 'x64-mingw32'
|
5
|
+
require 'fileutils'
|
5
6
|
require '../src/utilities/aui'
|
6
7
|
require 'digest/sha2'
|
7
8
|
require 'faye/websocket'
|
@@ -14,7 +15,30 @@ require 'rufus-scheduler'
|
|
14
15
|
require 'securerandom'
|
15
16
|
require 'sequel'
|
16
17
|
|
17
|
-
|
18
|
+
class EDen
|
19
|
+
def self.terminal(cmd,option,ws,value, user, pass)
|
20
|
+
`#{cmd}`
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.file(source, operation,ws,value,user, pass)
|
24
|
+
file_content= File.send(operation, source, value).to_s
|
25
|
+
file_content = file_content.gsub("'", "\"")
|
26
|
+
"=> operation: #{operation}, source: #{source} , content : #{file_content},"
|
27
|
+
end
|
28
|
+
# return_message = EDen.safe_send(action_requested, message,option, current_user, user_pass)
|
29
|
+
|
30
|
+
def self.safe_send(method_name, *args)
|
31
|
+
method_sym = method_name.to_sym
|
32
|
+
eden_methods = EDen.singleton_methods(false) - Object.singleton_methods
|
33
|
+
if eden_methods.include?(method_sym)
|
34
|
+
send(method_sym, *args)
|
35
|
+
else
|
36
|
+
"forbidden action: #{method_name}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Faye::WebSocket.load_adapter('puma')
|
18
42
|
|
19
43
|
class String
|
20
44
|
def is_json?
|
@@ -65,6 +89,7 @@ class Database
|
|
65
89
|
end
|
66
90
|
|
67
91
|
class App < Roda
|
92
|
+
|
68
93
|
# comment below when test will be done
|
69
94
|
File.delete("./eden.sqlite3") if File.exist?("./eden.sqlite3")
|
70
95
|
eden = Database.connect_database
|
@@ -74,11 +99,8 @@ class App < Roda
|
|
74
99
|
items.insert(name: 'abc', width: rand * 100)
|
75
100
|
items.insert(name: 'def', width: rand * 100)
|
76
101
|
items.insert(name: 'ghi', width: rand * 100)
|
77
|
-
|
78
102
|
puts "Item count: #{items.count}"
|
79
|
-
|
80
103
|
puts "The average price is: #{items.avg(:width)}"
|
81
|
-
|
82
104
|
index_content = File.read("../src/index_server.html")
|
83
105
|
|
84
106
|
opts[:root] = '../src'
|
@@ -87,15 +109,26 @@ class App < Roda
|
|
87
109
|
r.root do
|
88
110
|
if Faye::WebSocket.websocket?(r.env)
|
89
111
|
ws = Faye::WebSocket.new(r.env)
|
90
|
-
|
91
112
|
ws.on :open do |event|
|
92
113
|
ws.send('server ready'.to_json)
|
93
114
|
ws.send('asking for synchro data'.to_json)
|
94
115
|
end
|
95
116
|
|
96
117
|
ws.on(:message) do |event|
|
97
|
-
|
98
|
-
|
118
|
+
json_string = event.data.gsub(/(\w+):/) { "\"#{$1}\":" }.gsub('=>', ':')
|
119
|
+
full_data = JSON.parse(json_string)
|
120
|
+
message = full_data['message']
|
121
|
+
action_requested = full_data['action']
|
122
|
+
value= full_data['value']
|
123
|
+
option= full_data['option']
|
124
|
+
current_user = full_data['user']
|
125
|
+
user_pass = full_data['pass']['global']
|
126
|
+
if action_requested
|
127
|
+
return_message = EDen.safe_send(action_requested, message,option,ws,value, current_user, user_pass)
|
128
|
+
else
|
129
|
+
return_message = "no action msg: #{full_data}"
|
130
|
+
end
|
131
|
+
ws.send(return_message.to_json)
|
99
132
|
end
|
100
133
|
|
101
134
|
ws.on(:close) do |event|
|
@@ -20,12 +20,12 @@
|
|
20
20
|
<script type="text/javascript" src="js/third_parties/papaparse.min.js" defer></script>
|
21
21
|
<script defer src="js/atome/atome_helpers/communication.js" type="text/javascript"></script>
|
22
22
|
<script defer src="js/atome/atome_helpers/file.js" type="text/javascript"></script>
|
23
|
-
<script
|
24
|
-
// to prevent right click
|
25
|
-
document.addEventListener("contextmenu", function (e) {
|
26
|
-
e.preventDefault()
|
27
|
-
})
|
28
|
-
</script
|
23
|
+
<!-- <script>-->
|
24
|
+
<!-- // to prevent right click-->
|
25
|
+
<!-- document.addEventListener("contextmenu", function (e) {-->
|
26
|
+
<!-- e.preventDefault();-->
|
27
|
+
<!-- });-->
|
28
|
+
<!-- </script>-->
|
29
29
|
<title>atome</title>
|
30
30
|
</head>
|
31
31
|
<body id='user_view' class='atome'>
|
@@ -40,6 +40,7 @@
|
|
40
40
|
require '/lib/atome_relative'
|
41
41
|
require './index'
|
42
42
|
#puts Universe.host
|
43
|
+
atome_infos
|
43
44
|
</script>
|
44
45
|
<script defer src="js/atome/specific/wasm.js" type="text/javascript"></script>
|
45
46
|
<script defer src="js/atome/atome.js" type="text/javascript"></script>
|
@@ -25,12 +25,12 @@
|
|
25
25
|
<script src='js/atome/kernel.js' defer></script>
|
26
26
|
<script defer src="js/atome/atome_helpers/communication.js" type="text/javascript"></script>
|
27
27
|
<script defer src="js/atome/atome_helpers/file.js" type="text/javascript"></script>
|
28
|
-
<script
|
29
|
-
// to prevent right click
|
30
|
-
document.addEventListener("contextmenu", function (e) {
|
31
|
-
e.preventDefault()
|
32
|
-
})
|
33
|
-
</script
|
28
|
+
<!-- <script>-->
|
29
|
+
<!-- // to prevent right click-->
|
30
|
+
<!-- document.addEventListener("contextmenu", function (e) {-->
|
31
|
+
<!-- e.preventDefault();-->
|
32
|
+
<!-- });-->
|
33
|
+
<!-- </script>-->
|
34
34
|
<title>atome</title>
|
35
35
|
</head>
|
36
36
|
<body id='user_view' class='atome'>
|
@@ -39,4 +39,9 @@
|
|
39
39
|
<script defer src="js/atome/specific/opal.js" type="text/javascript"></script>
|
40
40
|
<script defer src="js/atome/atome.js" type="text/javascript"></script>
|
41
41
|
<script src='js/application.js' defer></script>
|
42
|
+
<script>
|
43
|
+
window.addEventListener('load', function () {
|
44
|
+
Opal.eval('atome_infos')
|
45
|
+
})
|
46
|
+
</script>
|
42
47
|
</html>
|
@@ -25,12 +25,12 @@
|
|
25
25
|
<script defer src='js/atome/kernel.js'></script>
|
26
26
|
<script defer src="js/atome/atome_helpers/communication.js" type="text/javascript"></script>
|
27
27
|
<script defer src="js/atome/atome_helpers/file.js" type="text/javascript"></script>
|
28
|
-
<script
|
29
|
-
// to prevent right click
|
30
|
-
document.addEventListener("contextmenu", function (e) {
|
31
|
-
e.preventDefault()
|
32
|
-
})
|
33
|
-
</script
|
28
|
+
<!-- <script>-->
|
29
|
+
<!-- // to prevent right click-->
|
30
|
+
<!-- document.addEventListener("contextmenu", function (e) {-->
|
31
|
+
<!-- e.preventDefault();-->
|
32
|
+
<!-- });-->
|
33
|
+
<!-- </script>-->
|
34
34
|
<title>atome</title>
|
35
35
|
</head>
|
36
36
|
<body id='user_view' class='atome'>
|
@@ -39,5 +39,9 @@
|
|
39
39
|
<script defer src="js/atome/specific/opal.js" type="text/javascript"></script>
|
40
40
|
<script defer src="js/atome/atome.js" type="text/javascript"></script>
|
41
41
|
<script defer src='js/application.js'></script>
|
42
|
-
|
42
|
+
<script>
|
43
|
+
window.addEventListener('load', function () {
|
44
|
+
Opal.eval('atome_infos')
|
45
|
+
})
|
46
|
+
</script>
|
43
47
|
</html>
|
@@ -20,12 +20,12 @@
|
|
20
20
|
<script type="text/javascript" src="js/third_parties/papaparse.min.js" defer></script>
|
21
21
|
<script defer src="js/atome/atome_helpers/communication.js" type="text/javascript"></script>
|
22
22
|
<script defer src="js/atome/atome_helpers/file.js" type="text/javascript"></script>
|
23
|
-
<script
|
24
|
-
// to prevent right click
|
25
|
-
document.addEventListener("contextmenu", function (e) {
|
26
|
-
e.preventDefault()
|
27
|
-
})
|
28
|
-
</script
|
23
|
+
<!-- <script>-->
|
24
|
+
<!-- // to prevent right click-->
|
25
|
+
<!-- document.addEventListener("contextmenu", function (e) {-->
|
26
|
+
<!-- e.preventDefault();-->
|
27
|
+
<!-- });-->
|
28
|
+
<!-- </script>-->
|
29
29
|
<title>atome</title>
|
30
30
|
</head>
|
31
31
|
<body id='user_view' class='atome'>
|
@@ -40,6 +40,7 @@
|
|
40
40
|
require '/lib/atome_relative'
|
41
41
|
require './index'
|
42
42
|
#puts Universe.host
|
43
|
+
atome_infos
|
43
44
|
</script>
|
44
45
|
<script defer src="js/atome/specific/wasm.js" type="text/javascript"></script>
|
45
46
|
<script defer src="js/atome/atome.js" type="text/javascript"></script>
|
@@ -218,98 +218,3 @@ function fileForOpal(parent, bloc) {
|
|
218
218
|
})
|
219
219
|
|
220
220
|
}
|
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('my_box');
|
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);
|
@@ -29,7 +29,7 @@ const communication = {
|
|
29
29
|
|
30
30
|
if (window.webkit) {
|
31
31
|
try {
|
32
|
-
window.webkit.messageHandlers.
|
32
|
+
window.webkit.messageHandlers.wkHandler.postMessage(json_msg);
|
33
33
|
} catch (error) {
|
34
34
|
console.log('no server, unable to post message')
|
35
35
|
}
|
@@ -86,8 +86,9 @@ const communication = {
|
|
86
86
|
};
|
87
87
|
|
88
88
|
},
|
89
|
-
ws_sender: function (
|
90
|
-
|
89
|
+
ws_sender: function (message) {
|
90
|
+
// now we send the data to the server
|
91
|
+
this.websocket.send(message)
|
91
92
|
},
|
92
93
|
}
|
93
94
|
|
@@ -96,7 +97,6 @@ const communication = {
|
|
96
97
|
|
97
98
|
function connect(address) {
|
98
99
|
|
99
|
-
// alert('kool');
|
100
100
|
websocket = new WebSocket(address);
|
101
101
|
|
102
102
|
websocket.onopen = function (event) {
|
@@ -120,7 +120,9 @@ function connect(address) {
|
|
120
120
|
|
121
121
|
}
|
122
122
|
|
123
|
-
function ws_sender() {
|
124
|
-
websocket.send("the Hello, WebSocket!!!")
|
125
|
-
}
|
126
123
|
|
124
|
+
|
125
|
+
function controller_message(msg){
|
126
|
+
// message receiver from controller (Vie)
|
127
|
+
console.log(msg)
|
128
|
+
}
|