atome 0.5.6.6.9 → 0.5.6.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/exe/atome +22 -7
  3. data/lib/atome/atome.rb +1 -1
  4. data/lib/atome/extensions/atome.rb +45 -2
  5. data/lib/atome/genesis/genesis.rb +1 -1
  6. data/lib/atome/genesis/sparkle.rb +17 -19
  7. data/lib/atome/kernel/universe.rb +7 -6
  8. data/lib/atome/utilities/utilities.rb +47 -37
  9. data/lib/atome/version.rb +1 -1
  10. data/lib/atome.rb +1 -0
  11. data/lib/atome_relative.rb +1 -0
  12. data/lib/molecules/intuition/sliders.rb +31 -45
  13. data/lib/renderers/html/html.rb +3 -0
  14. data/vendor/assets/application/examples/affect.rb +1 -1
  15. data/vendor/assets/application/examples/allow_copy.rb +13 -0
  16. data/vendor/assets/application/examples/allow_system_right_click.rb +16 -0
  17. data/vendor/assets/application/examples/alternate.rb +18 -0
  18. data/vendor/assets/application/examples/js&ruby.rb +8 -21
  19. data/vendor/assets/application/examples/localstorage.rb +19 -0
  20. data/vendor/assets/application/examples/matrix.rb +8 -8
  21. data/vendor/assets/application/examples/sliders.rb +6 -0
  22. data/vendor/assets/application/examples/test.rb +0 -19
  23. data/vendor/assets/application/examples/tools.rb +302 -300
  24. data/vendor/assets/src/index_opal.html +1 -5
  25. data/vendor/assets/src/index_server.html +13 -18
  26. data/vendor/assets/src/index_server_wasm.html +1 -6
  27. data/vendor/assets/src/index_wasm.html +6 -6
  28. data/vendor/assets/src/js/atome/atome.js +8 -4
  29. data/vendor/assets/src/js/atome/atome_helpers/communication.js +0 -94
  30. data/vendor/assets/src/js/atome/specific/opal.js +93 -0
  31. data/vendor/assets/src/js/atome/specific/wasm.js +99 -7
  32. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b169503f78f879fea8335938cae3163960a85a2eb561956d3e39d48fc252866
4
- data.tar.gz: 26136e4215e1f80dbb644552c49b917b5c76f41375d8f30169c8c8a59a54abba
3
+ metadata.gz: a70eb64a2402c7ff8ef5283e66c92e88aa1b500e78d77401f481da4a58e9ea6b
4
+ data.tar.gz: 312dbb9d6a1f4d66bdcc37270ab05b38d80ecc69c56263233f460902a48b9555
5
5
  SHA512:
6
- metadata.gz: b8d08c0f3f2fe78f10989f52dd4521c8330754f5911fb5ce0c18689b77d59d14e3f0c50dd68d7b01917741d9be3bb557f58e11ae21587e47eca12a73a98c9805
7
- data.tar.gz: ee5092720184ad6f81ab86f3c3fd32161647377325f9455581a029bb4ac7e91e6596b42b96a527492aa8a6a3b7fde006f8f821b11861e07a59ec2b4a66663de3
6
+ metadata.gz: 2b5953ab99450d1088a3f3bdee7bf303d0c6c7cec8875ba6dd20171edf7d9e358b2ed09305162ae2b8e840162954e9b02ce4a8812671764cc8476bf6021d4064
7
+ data.tar.gz: a7bd8f735d5101c8958bc0832a9e0c803dfadf812f51636e59b2c01629bf1580d796fe7725bfa8b97ca411b2bf65f9f6f61250616be6f3b89c6b3fc3a74b6228
data/exe/atome CHANGED
@@ -574,7 +574,26 @@ if ARGV.include?('create')
574
574
  end
575
575
 
576
576
  if ARGV.include?('update')
577
- `gem install atome`
577
+
578
+ gem_name = 'atome'
579
+ local_gem_spec = Gem::Specification.find_by_name(gem_name) rescue nil
580
+ if local_gem_spec.nil?
581
+ puts " #{gem_name} gem is not install will install from distant server"
582
+ system("gem update #{gem_name}")
583
+ else
584
+ available_versions = Gem::Specification.find_all_by_name(gem_name).map(&:version)
585
+
586
+ latest_version = available_versions.max
587
+
588
+ if latest_version > local_gem_spec.version
589
+ puts "update availlable: #{local_gem_spec.version} -> #{latest_version}"
590
+ system("gem update #{gem_name}")
591
+ else
592
+ puts "No update necessary '#{gem_name}'. current version : #{local_gem_spec.version}"
593
+ end
594
+ end
595
+
596
+
578
597
  # TODO: also update index.html and all other files except the application folder
579
598
  # we check we are in atome app
580
599
  if Dir.exist?("#{destination}/application") && !Dir.exist?("#{destination}/vendor")
@@ -619,12 +638,8 @@ src/favicon.ico src/index_wasm.html src/index_opal.html src/index_server.html sr
619
638
 
620
639
  # now we get the version of the atome gem
621
640
  gem_name = 'atome'
622
-
623
- # Obtenez les informations du gem depuis RubyGems.org
624
- gem_info = Gems.info(gem_name)
625
-
626
- # Extrait la version la plus récente du gem
627
- latest_version = gem_info['version']
641
+ local_gem_spec = Gem::Specification.find_by_name(gem_name) rescue nil
642
+ latest_version=local_gem_spec.version
628
643
  puts "#{gem_name} #{latest_version} is now installed "
629
644
 
630
645
  end
data/lib/atome/atome.rb CHANGED
@@ -109,9 +109,9 @@ class Atome
109
109
  # post rendering processor
110
110
  params = particle_post(element, params, &user_proc)
111
111
  instance_variable_set("@#{element}", params) if store
112
+ Universe.historicize(@aid, :write, element, params)
112
113
  # after storage processor
113
114
  particle_after(element, params, &user_proc)
114
-
115
115
  # self
116
116
  end
117
117
 
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ObjectExtension
3
4
 
5
+
4
6
  def new(params, &bloc)
5
7
  # Genesis = Genesis.Genesis
6
8
  if params.key?(:atome)
@@ -580,6 +582,48 @@ class Object
580
582
  # convert any foreign object (think HTML) to a pseudo atome objet , that embed foreign objet
581
583
  end
582
584
 
585
+
586
+ JS.eval(<<~JS)
587
+ window.preventDefaultAction = function(e) {
588
+ e.preventDefault();
589
+ }
590
+ JS
591
+
592
+ def touch_allow(allow)
593
+ if allow
594
+ # Retire l'écouteur d'événements en utilisant la fonction globale
595
+ JS.eval('document.removeEventListener("contextmenu", window.preventDefaultAction);')
596
+ else
597
+ # Ajoute l'écouteur d'événements en utilisant la fonction globale
598
+ JS.eval('document.addEventListener("contextmenu", window.preventDefaultAction);')
599
+ end
600
+ end
601
+
602
+
603
+ def allow_copy(allow)
604
+ if allow
605
+ # Rétablir la sélection et la copie de texte
606
+ JS.eval(<<~JS)
607
+ document.body.style.userSelect = 'auto'; // Permet la sélection de texte
608
+ document.removeEventListener('copy', preventDefaultAction); // Permet la copie
609
+ JS
610
+ else
611
+ # Bloquer la sélection et la copie de texte
612
+ JS.eval(<<~JS)
613
+ document.body.style.userSelect = 'none'; // Bloque la sélection de texte
614
+ document.addEventListener('copy', preventDefaultAction); // Bloque la copie
615
+ JS
616
+ end
617
+ end
618
+
619
+ # Définit la fonction preventDefaultAction dans un contexte global pour être utilisée par allow_copy
620
+ JS.eval(<<~JS)
621
+ window.preventDefaultAction = function(e) {
622
+ e.preventDefault();
623
+ }
624
+ JS
625
+
626
+
583
627
  end
584
628
 
585
629
  class CssProxy
@@ -617,7 +661,6 @@ class CssProxy
617
661
  @current_atome.instance_variable_get('@css').to_s
618
662
  end
619
663
 
664
+ end
620
665
 
621
666
 
622
-
623
- end
@@ -100,7 +100,7 @@ class Genesis
100
100
 
101
101
  # we historicize all write action below
102
102
  # we add the changes to the stack that must be synchronised
103
- Universe.historicize(@aid, :write, element, params)
103
+ # Universe.historicize(@aid, :write, element, params)
104
104
  computed_params
105
105
  elsif params || params == false
106
106
  "send a valid password to write #{element} value"
@@ -110,10 +110,6 @@ def atome_infos
110
110
  puts "users: #{Universe.users}"
111
111
  puts "current user: #{Universe.current_user}"
112
112
  puts "machine: #{Universe.current_machine}"
113
- server = Universe.current_server
114
- server ||= 'disconnected'
115
- puts "server: #{server}"
116
-
117
113
  end
118
114
 
119
115
  # help and example below :
@@ -141,21 +137,23 @@ end
141
137
  # the method below init the user
142
138
  def atome_genesis
143
139
  atome_infos
144
- A.server({ address: 'localhost:9292', type: 'ws' })
145
- A.init_websocket do |msg|
146
- puts "websocket initialised #{msg}"
140
+ server = Universe.current_server
141
+ server ||= 'disconnected'
142
+ puts "server: #{server}"
143
+
144
+ if server.start_with?('http')
145
+ A.server({ address: 'localhost:9292', type: 'ws' })
146
+ A.init_websocket do |msg|
147
+ puts "websocket initialised #{msg}"
148
+ end
147
149
  end
150
+
148
151
  end
149
152
 
150
153
  def init_database # this method is call from JS (atome/communication) at WS connection
151
154
  # we init the db file eDen
152
155
  A.sync({ action: :init_db, data: { database: :eDen } }) do |data|
153
-
154
- if data[:data][:message] == 'database_ready'
155
- Universe.database_ready = true
156
- else
157
- Universe.database_ready = false
158
- end
156
+ Universe.database_ready = data[:data][:message] == 'database_ready'
159
157
  end
160
158
  # authentication : email, pass
161
159
  # atome : date, particles
@@ -163,7 +161,7 @@ def init_database # this method is call from JS (atome/communication) at WS conn
163
161
 
164
162
  particles = Universe.particle_list
165
163
  # now we populate the DB
166
- A.sync({ action: :crate_db_table, data: { table: :user, type: :string } }) do |_db_state|
164
+ A.sync({ action: :crate_db_table, data: { table: :user, type: :string } }) do |_db_state|
167
165
  # puts "===> #{_db_state}"
168
166
  end
169
167
 
@@ -193,10 +191,9 @@ def init_database # this method is call from JS (atome/communication) at WS conn
193
191
  end
194
192
 
195
193
  # now we send localstorage content to the server
196
- puts "now we send localstorage send_localstorage_content to the server"
197
- send_localstorage_content
198
- # A.message({ action: :localstorage, data: get_localstorage_content }) do |_db_state|
199
- # end
194
+ puts "sending localstorage"
195
+ Atome.send_localstorage_content
196
+
200
197
  end
201
198
 
202
199
  def user_login
@@ -211,4 +208,5 @@ def user_login
211
208
 
212
209
  end
213
210
 
214
- Universe.allow_history=true
211
+ Universe.allow_history = true
212
+ touch_allow(false) # this lock the system right click in web view
@@ -105,6 +105,7 @@ class Universe
105
105
  def id_to_aid(id, aid)
106
106
  @atomes_ids[id] = aid
107
107
  end
108
+
108
109
  # def update_atome_id(aid, atome, prev_id)
109
110
  # @atomes[id] = atome
110
111
  # @atomes.delete(prev_id)
@@ -197,10 +198,8 @@ class Universe
197
198
  end
198
199
 
199
200
  def current_server
200
- # Remplacez 'atome' par la valeur correcte pour votre environnement Atome
201
- return unless RUBY_ENGINE.downcase == 'opal'
201
+ # return unless RUBY_ENGINE.downcase == 'opal'
202
202
  JS.global[:location][:href].to_s
203
-
204
203
  end
205
204
 
206
205
  def current_user
@@ -248,14 +247,16 @@ class Universe
248
247
  def historicize(id, operation, element, params)
249
248
 
250
249
  # if @allow_history && @database_ready
251
- if @allow_history
252
- # A.sync({ action: :historicize, data: { table: :user } }) do |_db_state|
253
- # end
250
+ if @allow_history
251
+ # A.sync({ action: :historicize, data: { table: :user } }) do |_db_state|
252
+ # end
254
253
  operation_timing = Time.now.strftime("%Y%m%d%H%M%S%3N") + @increment.to_s
255
254
  @increment += 1
256
255
  @increment = @increment % 100
256
+
257
257
  JS.global[:localStorage].setItem(operation_timing, "{ #{id} => { #{operation} => { #{element} => #{params} } }, sync: false }")
258
258
  @history[@history.length] = { operation_timing => { id => { operation => { element => params } }, sync: false, time: Time.now } }
259
+
259
260
  end
260
261
  end
261
262
 
@@ -6,8 +6,36 @@ require 'json'
6
6
  class Atome
7
7
  class << self
8
8
  attr_accessor :initialized
9
+ def sanitize_data_for_json(data)
10
+ data = data.gsub('"', '\\"')
11
+ # case data
12
+ # when String
13
+ # data.gsub('"', '\\"')
14
+ # when Hash
15
+ # data.transform_values { |value| sanitize_data(value) }
16
+ # when Array
17
+ # data.map { |value| sanitize_data(value) }
18
+ # else
19
+ # data
20
+ # end
21
+ data
22
+ end
23
+
24
+
25
+ def send_localstorage_content
26
+ storage = JS.global[:localStorage]
27
+ storage_array = storage.to_a
28
+ storage_array.each_with_index do |_i, index|
29
+ key = JS.global[:localStorage].key(index)
30
+ sanitize_data_for_json(storage.getItem(key))
31
+ end
32
+ end
33
+
34
+ def server_receiver(params)
35
+ callback_found = Universe.messages[params[:message_id]]
36
+ callback_found.call(params) if callback_found.is_a? Proc
37
+ end
9
38
 
10
- # end
11
39
  def file_handler(parent, content, bloc)
12
40
  grab(parent).instance_exec(content, &bloc)
13
41
  end
@@ -403,10 +431,6 @@ class Atome
403
431
  end
404
432
  end
405
433
 
406
- def server_receiver(params)
407
- callback_found = Universe.messages[params[:message_id]]
408
- callback_found.call(params) if callback_found.is_a? Proc
409
- end
410
434
 
411
435
  def init_websocket
412
436
  connection(@current_server)
@@ -434,39 +458,7 @@ class Atome
434
458
  storage_items
435
459
  end
436
460
 
437
- def sanitize_data_for_json(data)
438
- data = data.gsub('"', '\\"')
439
- # case data
440
- # when String
441
- # data.gsub('"', '\\"')
442
- # when Hash
443
- # data.transform_values { |value| sanitize_data(value) }
444
- # when Array
445
- # data.map { |value| sanitize_data(value) }
446
- # else
447
- # data
448
- # end
449
- data
450
- end
451
461
 
452
- def send_localstorage_content
453
- storage = JS.global[:localStorage]
454
- storage_array = storage.to_a
455
- # storage_items={}
456
- storage_array.each_with_index do |_i, index|
457
- key = JS.global[:localStorage].key(index)
458
- value = sanitize_data_for_json(JS.global[:localStorage].getItem(key))
459
- # storage_items[key] = value
460
- # puts key
461
- # puts value
462
- # A.message({ action: :localstorage, data: {key => value} }) do |_db_state|
463
- # # puts _db_state
464
- # end
465
- end
466
- # A.message({ action: :end_localstorage, data: '' }) do |_db_state|
467
- # puts _db_state
468
- # end
469
- end
470
462
 
471
463
  # def to_sym
472
464
  # puts "sanitizer temp patch when an atome is passed instead of an id"
@@ -480,6 +472,24 @@ class Atome
480
472
  Universe.store_messages({ msg_nb: message_id, proc: bloc })
481
473
  html.send_message(params)
482
474
  end
475
+
476
+ def alternate(*states)
477
+ @alternate ||= { state: 0 }
478
+ @alternate[:data] = states
479
+ if @alternate[:state] < states.length - 1
480
+ @alternate[:state] += 1
481
+ else
482
+ @alternate[:state] = 0
483
+ end
484
+
485
+ current_state = @alternate[:data][@alternate[:state] - 1]
486
+ if current_state.instance_of?(Hash)
487
+ current_state.each do |state, value|
488
+ send(state, value)
489
+ end
490
+ end
491
+ current_state
492
+ end
483
493
  end
484
494
 
485
495
 
data/lib/atome/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # return atome version
4
4
  class Atome
5
- VERSION = '0.5.6.6.9'
5
+ VERSION = '0.5.6.7.4'
6
6
  end
data/lib/atome.rb CHANGED
@@ -36,3 +36,4 @@ require 'renderers/server/index'
36
36
  require 'atome/utilities/sanitizer'
37
37
  require 'atome/genesis/sparkle'
38
38
  require 'molecules/init'
39
+ require 'molecules/intuition/sliders'
@@ -35,3 +35,4 @@ require_relative './renderers/server/index_relative'
35
35
  require_relative './atome/utilities/sanitizer'
36
36
  require_relative './atome/genesis/sparkle'
37
37
  require_relative './molecules/init'
38
+ require_relative './molecules/intuition/sliders'
@@ -1,49 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- button = box({smooth: 6,left: 55,top: 160, color:{red: 0.3, green: 0.3, blue: 0.3},id: :my_box})
4
- button.shadow({
5
- id: :s1,
6
- left: 3, top: 3, blur: 9,
7
- invert: true,
8
- red: 0, green: 0, blue: 0, alpha: 0.7
9
- })
10
- button.touch(true) do
11
- button.controller(:hello)
12
- end
13
- slider=box({ width: 333, height: 25, top: 45, left: 55, smooth: 9, color:{red: 0.3, green: 0.3, blue: 0.3}})
14
- slider.shadow({
15
- id: :s2,
16
- left: 3, top: 3, blur: 9,
17
- invert: true,
18
- red: 0, green: 0, blue: 0, alpha: 0.7
19
- })
20
- cursor= slider.circle({width: 30, height: 30, left: 2, top: 1, color:{red: 0.3, green: 0.3, blue: 0.3}})
21
-
22
- cursor.left(0)
23
- cursor.top(0)
24
- cursor.shadow({
25
- id: :s4,
26
- left: 1, top: 1, blur: 3,
27
- option: :natural,
28
- red: 0, green: 0, blue: 0, alpha: 0.6
29
- })
30
- label=text({data: 0, top: 69, left: 69, component: { size: 12 }, color: :gray})
31
- cursor.drag({ restrict: {max:{ left: 309, top: 0}} }) do |event|
32
- puts cursor.left
33
- value = cursor.left/309*100
34
- label.data(value)
35
- cursor.controller({ action: :setModuleParameterValue, params: { moduleId: 6456549897,parameterId: 9846546, value: value} })
36
3
 
4
+ module Molecule
5
+ def slider(params,&bloc)
6
+ slider_width=params[:width] || 333
7
+ cursor_width=33
8
+ cursor_height=33
9
+ left_pos=params[:left] || 0
10
+ top_pos=params[:top] || 0
11
+ attach_to= params[:attach] || :view
12
+ cursor_left=0
13
+ cursor_top=0
14
+ slider=grab(attach_to).box({ top: top_pos, left: left_pos,width: slider_width, height: 25, smooth: 9, color:{red: 0.3, green: 0.3, blue: 0.3}})
15
+ slider.shadow({
16
+ id: :s2,
17
+ left: 3, top: 3, blur: 9,
18
+ invert: true,
19
+ red: 0, green: 0, blue: 0, alpha: 0.7
20
+ })
21
+ cursor= slider.circle({width: cursor_width, height: cursor_height, left: 2, top: 1, color:{red: 0.3, green: 0.3, blue: 0.3}})
22
+ cursor.left(cursor_left)
23
+ cursor.top(cursor_top)
24
+ cursor.shadow({
25
+ id: :s4,
26
+ left: 1, top: 1, blur: 3,
27
+ option: :natural,
28
+ red: 0, green: 0, blue: 0, alpha: 0.6
29
+ })
30
+ cursor.drag({ restrict: {max:{ left: slider_width-cursor_width, top: 0}} }) do |_event|
31
+ value = (cursor.left+cursor.width)/slider_width*100
32
+ bloc.call(value)
33
+ end
34
+ end
37
35
  end
38
- support=box({top: 300, left: 55, width: 300, height: 40, smooth: 9, color:{red: 0.3, green: 0.3, blue: 0.3}, id: :support })
39
- support.shadow({
40
- id: :s3,
41
- left: 3, top: 3, blur: 9,
42
- invert: true,
43
- red: 0, green: 0, blue: 0, alpha: 0.7
44
- })
45
- support.import(true) do |content|
46
- puts "add code here, content: #{content}"
47
- end
48
-
49
- in_box=input_box
@@ -223,6 +223,9 @@ class HTML
223
223
  # particles=params[:particles]
224
224
  # 'atomeJS.connect' is in the communication.js file ( connect: function (type, server, )
225
225
  JS.eval("atomeJS.connect('#{type}','#{server}')")
226
+
227
+ # @websocket = JS.new(JS.global.WebSocket.new("#{type}://#{server}"))
228
+
226
229
  # JS.eval("atomeJS.connect('ws://#{server}')")
227
230
  end
228
231
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  box({ left: 12, id: :the_first_box })
4
- c=color({ id: :the_bananas, blue: 0.21, green: 1 })
4
+ c=color({ id: :the_col, blue: 0.21, green: 1 })
5
5
 
6
6
  wait 1 do
7
7
  c.affect(:the_first_box)
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ t=text(:hello)
5
+ t.edit(true)
6
+ b=box({left: 99})
7
+
8
+ b.touch(true) do
9
+ allow_copy(true)
10
+ touch_allow(true)
11
+ end
12
+
13
+
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ # class Atome
3
+
4
+ b=box({ left: 12, id: :the_first_box })
5
+ b.touch(true) do
6
+
7
+ alt=b.alternate(true, false)
8
+ if alt
9
+ b.color(:green)
10
+ else
11
+ b.color(:red)
12
+ end
13
+ touch_allow(alt)
14
+
15
+ end
16
+
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ b = box({ left: 12, id: :the_first_box, top: 30 })
4
+
5
+ b.touch(true) do
6
+ b.alternate({ width: 33, color: :red, height: 33 , smooth: 0 }, { width: 66, color: :orange, blur: 8}, { height: 66, color: :green, smooth: 9, blur: 0})
7
+ end
8
+
9
+ c = circle({ left: 333 , top: 30})
10
+
11
+ c.touch(true) do
12
+ alt = b.alternate(true, false)
13
+ if alt
14
+ c.color(:yellowgreen)
15
+ else
16
+ c.color(:orange)
17
+ end
18
+ end
@@ -1,31 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
3
  # JS to ruby example & ruby to js example
5
4
 
6
5
  def my_ruby_meth(val)
7
- alert "kool from rb_meth: #{val}"
6
+ puts "=> rb_meth call from js: #{val}"
8
7
  end
9
8
 
10
- opal_js_code=<<STR
11
- function my_js_fct(val){
12
- Opal.eval("my_ruby_meth('"+val+"')");
13
- Opal.Object.$my_ruby_meth(val);
14
- }
15
- STR
16
-
17
-
18
- ruby_wasm_js_code=<<STR
19
- function my_js_fct(val){
20
- rubyVM.eval("my_ruby_meth('"+val+"')");
21
- }
22
- STR
23
-
24
-
25
-
26
- JS.eval("my_js_fct('hello')")
27
- JS.global.my_js_fct('super')
28
-
29
9
 
10
+ if Atome::host.to_s == 'web-opal'
11
+ JS.eval("my_opal_js_fct('js fct call with an eval')")
12
+ JS.global.my_opal_js_fct('js fct call directly')
13
+ elsif Atome::host.to_sym == :pure_wasm
14
+ JS.eval("my_ruby_wasm_js_fct('js fct call with an eval')")
15
+ end
30
16
 
31
17
 
18
+ "js code is in js/atome/atome.js"
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ t=text("touch the box to erase localstorage, long touch on the box to stop historicize")
3
+ b=box({top: 66})
4
+ c=circle({top: 99})
5
+ c.touch(true) do
6
+ c.left(c.left+99)
7
+ # c.left=c.left+33
8
+ # box
9
+ end
10
+ b.touch(true) do
11
+ JS.eval('localStorage.clear()')
12
+ end
13
+
14
+ b.touch(:long) do
15
+ b.color(:red)
16
+ Universe.allow_history = false
17
+
18
+ end
19
+
@@ -113,18 +113,18 @@ module Molecule
113
113
  end
114
114
 
115
115
 
116
- def alternate(states = nil)
117
- if states
118
-
119
- else
120
- @alternate
121
- end
122
-
116
+ def alternate(*states)
117
+ # if states
118
+ #
119
+ # else
120
+ # @alternate
121
+ # end
122
+ alert states
123
123
  end
124
124
  end
125
125
  c= circle({left: 399})
126
126
  test_cell.touch(true) do
127
- test_cell.alternate([{ width: 33, color: :red }, { width: 66, color: :orange }])
127
+ test_cell.alternate({ width: 33, color: :red }, { width: 66, color: :orange })
128
128
  # puts "=> #{Universe.atomes.length}"
129
129
  # puts test_cell.color
130
130
  # if test_cell.data==true
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ label=text({data: 0, top: 69, left: 69,attach: :intuition, component: { size: 12 }, color: :gray})
3
+
4
+ A.slider({width: 333} ) do |value|
5
+ label.data("(#{value})")
6
+ end
@@ -1,31 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
 
4
- # JS to ruby example & ruby to js example
5
4
 
6
- def my_ruby_meth(val)
7
- alert "kool from rb_meth: #{val}"
8
- end
9
5
 
10
- opal_js_code=<<STR
11
- function my_js_fct(val){
12
- Opal.eval("my_ruby_meth('"+val+"')");
13
- Opal.Object.$my_ruby_meth(val);
14
- }
15
- STR
16
6
 
17
7
 
18
- ruby_wasm_js_code=<<STR
19
- function my_js_fct(val){
20
- rubyVM.eval("my_ruby_meth('"+val+"')");
21
- }
22
- STR
23
8
 
24
9
 
25
10
 
26
- JS.eval("my_js_fct('hello')")
27
- JS.global.my_js_fct('super')
28
-
29
-
30
11
 
31
12