atome 0.5.6.3.1 → 0.5.6.3.5

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.
@@ -0,0 +1,280 @@
1
+ # frozen_string_literal: true
2
+ text(:hello)
3
+ class Atome
4
+
5
+ def build_tool(&bloc)
6
+ # alert params[:tool]
7
+ a = Atome.instance_exec(&bloc)
8
+ puts "===> a is : #{a[:action]}"
9
+ # check below
10
+ wait 2 do
11
+ send a[:action]
12
+ end
13
+ grab(:toolbox).box({color: :white, width: 33, height: 33})
14
+ end
15
+ end
16
+
17
+ class Object
18
+ def new(params, &bloc)
19
+ # Genesis = Genesis.Genesis
20
+ if params.key?(:atome)
21
+ Universe.add_atomes_specificities params[:atome]
22
+ Genesis.build_atome(params[:atome], &bloc)
23
+ elsif params.key?(:particle)
24
+ Atome.instance_variable_set("@main_#{params[:particle]}", bloc)
25
+ # render indicate if the particle needs to be rendered
26
+ # store tell the system if it need to store the particle value
27
+ # type help the system what type of type the particle will receive and store
28
+ Genesis.build_particle(params[:particle], { render: params[:render], return: params[:return],
29
+ store: params[:store], type: params[:type] }, &bloc)
30
+ elsif params.key?(:sanitizer)
31
+ Genesis.build_sanitizer(params[:sanitizer], &bloc)
32
+ elsif params.key?(:pre)
33
+ Atome.instance_variable_set("@pre_#{params[:pre]}", bloc)
34
+ elsif params.key?(:post)
35
+ Atome.instance_variable_set("@post_#{params[:post]}", bloc)
36
+ elsif params.key?(:after)
37
+ Atome.instance_variable_set("@after_#{params[:after]}", bloc)
38
+ elsif params.key?(:read)
39
+ Atome.instance_variable_set("@read_#{params[:read]}", bloc)
40
+ elsif params[:renderer]
41
+ renderer_found = params[:renderer]
42
+ if params[:specific]
43
+ Universe.set_atomes_specificities(params)
44
+ params[:specific] = "#{params[:specific]}_"
45
+ end
46
+ render_method = "#{renderer_found}_#{params[:specific]}#{params[:method]}"
47
+ Genesis.build_render(render_method, &bloc)
48
+ elsif params.key?(:callback)
49
+ particle_targetted = params[:callback]
50
+ Atome.define_method "#{particle_targetted}_callback" do
51
+ bloc.call
52
+ end
53
+ elsif params.key?(:tool)
54
+ A.build_tool(&bloc)
55
+ end
56
+ end
57
+ end
58
+
59
+ grab(:intuition).box({id: :toolbox, top: :auto, bottom: 0, left: 0, width: 50, height: 255})
60
+
61
+ def record_tool
62
+ grab(Universe.current_user).selection
63
+ alert "must get selection to treat it "
64
+ end
65
+
66
+
67
+ module Intuition
68
+ def intuition_int8
69
+ # tool taxonomy and list
70
+ {
71
+ capture: { int8: { french: :enregistrement, english: :record, german: :datensatz } },
72
+ communication: { french: :communication, english: :communication, german: :communication },
73
+ tool: { french: :outils, english: :tools, german: :werkzeuge },
74
+ view: { french: :vue, english: :view, german: :aussicht },
75
+ time: { french: :horloge, english: :clock, german: :Uhr },
76
+ find: { french: :trouve, english: :find, german: :finden },
77
+ home: { french: :accueil, english: :home, german: :zuhause },
78
+ code: { french: :code, english: :code, german: :code },
79
+ impulse: { french: :impulse, english: :impulse, german: :impulse },
80
+ }
81
+ end
82
+ def intuition_taxonomy
83
+
84
+ end
85
+
86
+ def impulse
87
+ # tool start point
88
+ [:capture, :communication, :tool, :view, :time, :find, :home]
89
+ end
90
+
91
+ # def capture
92
+ # categories=ATOME.methods_categories
93
+ # [categories[:inputs]]
94
+ # end
95
+ #
96
+ # def communication
97
+ # categories=ATOME.methods_categories
98
+ # [categories[:communications]]
99
+ # end
100
+ #
101
+ # def toolz
102
+ # categories=ATOME.methods_categories
103
+ # [categories[:spatials],categories[:helpers],categories[:materials],
104
+ # categories[:geometries],categories[:effects],
105
+ # categories[:medias],categories[:hierarchies],categories[:utilities],categories[:events]]
106
+ # end
107
+ #
108
+ # def tool_style(size = 33)
109
+ # # styling
110
+ # shadows = [{ x: size / 15, y: size / 15, thickness: 0, blur: size / 3, color: { red: 0, green: 0, blue: 0, alpha: 0.3 } }, { x: -size / 15, y: -size / 15, thickness: 0, blur: size / 6, color: { red: 1, green: 1, blue: 1, alpha: 0.3 } }]
111
+ # style = { type: :tool, content: { points: 4 }, color: { red: 0.9, green: 0.9, blue: 0.9, alpha: 0.15 }, parent: :intuition, shadow: shadows, blur: { value: 6, invert: true } }
112
+ # return style
113
+ # end
114
+ #
115
+ # def open_tool(tool_id, widthness=3, orientation=:x, speed=0.6)
116
+ # if orientation == :x
117
+ # orientation = :width
118
+ # value = grab(tool_id).width
119
+ # else
120
+ # orientation = :height
121
+ # value = grab(tool_id).height
122
+ # end
123
+ # animate({
124
+ # start: { orientation => value },
125
+ # end: { orientation => value * widthness },
126
+ # duration: speed * 1000,
127
+ # loop: 0,
128
+ # curve: :easing,
129
+ # target: tool_id
130
+ # })
131
+ # notification "find why this id #{self.atome_id}, add annimation callback to set overflow when anim complete"
132
+ # grab(tool_id).overflow(:visible)
133
+ # end
134
+ #
135
+ # def close_tool(tool_id, widthness, orientation, speed)
136
+ # if orientation == :x
137
+ # orientation = :width
138
+ # value = grab(tool_id).width
139
+ # else
140
+ # orientation = :height
141
+ # value = grab(tool_id).height
142
+ # end
143
+ # animate({
144
+ # start: { orientation => value * widthness },
145
+ # end: { orientation => value },
146
+ # duration: speed * 1000,
147
+ # loop: 0,
148
+ # curve: :easing,
149
+ # target: tool_id
150
+ # })
151
+ # # grab(tool_id).overflow(:hidden)
152
+ # end
153
+ #
154
+ # def create_tool(tool_name, size = 33, x_pos = 0, y_pos = 33, offsset=0)
155
+ # tool_created = tool(self.tool_style(size).merge({ parent: :main_menu, atome_id: "tool_" + tool_name, id: "tool_" + tool_name,
156
+ # width: size, height: size, smooth: size / 9, overflow: :hidden, x: x_pos, y: y_pos, z: 1, content: [] }))
157
+ # icon=tool_created.shape({ path: tool_name, width: size - size / 2, height: size - size / 2, center: true })
158
+ # # name = intuition_list[tool_name][language]
159
+ # particle({ atome_id: :tools_property_container, color: { red: 0.6, green: 0.6, blue: 0.6 } })
160
+ # # we get the plugin code only if the plugin hasn't been interpreted before (unless condition below)
161
+ # unless grab(:intuition).content.include? tool_name
162
+ # ATOME.reader("./medias/e_rubies/tools/#{tool_name}.rb") do |data|
163
+ # # todo add a security parser here
164
+ # # we set the variable tool that can be used to facilitate plugin creation
165
+ # data="tool=grab(:#{tool_created.atome_id})\n"+data
166
+ # compile(data)
167
+ # # we add the tool to the intuition content so it won't be loaded twice
168
+ # grab(:intuition).content |= [tool_name]
169
+ # end
170
+ # end
171
+ # # end
172
+ # tool_created.active({ exec: false })
173
+ # tool_created.inactive({ exec: false })
174
+ # icon.touch(stop: true) do
175
+ # if tool_created.active[:exec] == true
176
+ # tool_created.color(:transparent)
177
+ # tool_created.active(exec: false, proc: tool_created.active[:proc] )
178
+ # tool_created.inactive(exec: true, proc: tool_created.inactive[:proc] )
179
+ # else
180
+ # tool_created.color({alpha: 0.3})
181
+ # tool_created.active({ exec: true, proc: tool_created.active[:proc] })
182
+ # end
183
+ # end
184
+ # end
185
+ #
186
+ # # we get menu entry point
187
+ # def open_intuition(position = {})
188
+ # position = { x: 0, yy: 0, size: 33, orientation: :vertical, offset: 0 }.merge(position)
189
+ # # we get content language from view's language
190
+ # if grab(:main_menu)
191
+ # grab(:main_menu).delete
192
+ # else
193
+ # grab(:view).language
194
+ # self.language(grab(:view).language)
195
+ # orientation = position.delete(:orientation)
196
+ # size = position.delete(:size)
197
+ # offset = position.delete(:offset)
198
+ # # positioning and scaling
199
+ # if orientation == :vertical
200
+ # requested_width = size
201
+ # requested_height = (size+offset)* impulse.length
202
+ # else
203
+ # requested_width = (size+offset) * impulse.length
204
+ # requested_height = size
205
+ # end
206
+ # tool({ atome_id: :main_menu, parent: :intuition, color: { alpha: 0 } }.merge(position).merge(width: requested_width, height: requested_height))
207
+ # impulse.each_with_index do |item, index|
208
+ # if orientation == :vertical
209
+ # create_tool(item, size, 0, index * (size+offset))
210
+ # else
211
+ # create_tool(item, size, index * (size+offset), 0)
212
+ # end
213
+ # end
214
+ # end
215
+ # end
216
+ end
217
+ # atome class extension for eVe
218
+
219
+ class Atome
220
+ include Intuition
221
+ # def atome(requested_property)
222
+ # # add component list iin the content we maybe ahave to create a tool object because box can't handle this type of content
223
+ # new_atome=self.tool({ atome_id: "#{self.atome_id}_#{requested_property}_atome_#{self.content.length}", x: 66})
224
+ # new_atome.touch({ stop: true, option: :down}) do
225
+ # color(:red)
226
+ # new_atome.height = new_atome.height*3
227
+ # end
228
+ # new_atome.touch({ stop: true, option: :up}) do
229
+ # color(:red)
230
+ # new_atome.height = new_atome.height/3
231
+ # end
232
+ # notification "now we have to add an object or a new property (style) to store complete tool style including size and
233
+ # orientation so we can position the new atome correctly"
234
+ # # alert self.content.class
235
+ # # alert self.content.length
236
+ # # alert tool_style
237
+ # end
238
+ end
239
+
240
+ # # we initialise the toolbox here :
241
+ #
242
+ # # the launch bar
243
+ # launch_bar = box({ x: 0, y: 0, width: 33, height: "100%", parent: :intuition, z: 0, color: { alpha: 0 } })
244
+ # launch_bar.touch({ option: :long }) do |evt|
245
+ # size = 33
246
+ # yy_touch_position = grab(:view).convert(:height) - evt.page_y
247
+ # if yy_touch_position < size
248
+ # #if the long touch is within the wanted area( in this at bottom of the screen) we open the menu
249
+ # # launch_bar.open_intuition({ x: size, yy: 6,offset: 6, orientation: :horizontal, size: size })
250
+ # launch_bar.open_intuition({ x: 6, yy: size,offset: 6, orientation: :vertical, size: size })
251
+ # end
252
+ # end
253
+ #
254
+ # # # # # # # # # # # # # # # tests below # # # # # # # # # # # # #
255
+ #
256
+ # list = molecule_analysis(@molecules_list)
257
+ # notif list[:tools]
258
+ # notif "======"
259
+ # notif list[:molecules]
260
+ # notif "======"
261
+ # notif list[:atomes]
262
+ # notif "======"
263
+ # notif list[:molecules][:shadow]
264
+
265
+ new({ tool: :capture }) do |params|
266
+ tool = { id: :rec_01,
267
+
268
+ name: :record, icon: :record, action: {open: [:sub_menu]}, code: :record_tool, position: { root: 1 }, # position can be multiple
269
+ option: { opt1: :method_2 }, int8: { french: :enregistrement, english: :record, german: :datensatz } }
270
+ tool
271
+ end
272
+
273
+
274
+ puts A.impulse
275
+ # def fill_toolzone(tools_ids)
276
+ #
277
+ # end
278
+ #
279
+ # fill_toolzone(%i[files edition select group link copy undo settings])
280
+
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+
5
+ b=box({color: :red})
6
+ b.touch(true) do
7
+ JS.eval('loadFeature()') # found in atome.js file
8
+ end
9
+
@@ -15,6 +15,7 @@ require 'roda'
15
15
  require 'rufus-scheduler'
16
16
  require 'securerandom'
17
17
  require 'sequel'
18
+
18
19
  require './eDen'
19
20
  require './database'
20
21
  require './extensions'
@@ -24,7 +25,7 @@ Faye::WebSocket.load_adapter('puma')
24
25
  class App < Roda
25
26
  index_content = File.read("../src/index_server.html")
26
27
  opts[:root] = '../src'
27
- plugin :static, %w[/css /js /medias], root: '../src'
28
+ plugin :static, %w[/css /js /medias /wasm], root: '../src'
28
29
  route do |r|
29
30
  r.root do
30
31
  if Faye::WebSocket.websocket?(r.env)
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # atome server
4
+
4
5
  require 'em/pure_ruby' if RUBY_PLATFORM == 'x64-mingw32'
6
+ require 'fileutils'
5
7
  require '../src/utilities/aui'
6
8
  require 'digest/sha2'
7
9
  require 'faye/websocket'
@@ -14,99 +16,39 @@ require 'rufus-scheduler'
14
16
  require 'securerandom'
15
17
  require 'sequel'
16
18
 
17
- Faye::WebSocket.load_adapter('puma') # Utilisez l'adaptateur 'thin' pour Faye
18
-
19
- class String
20
- def is_json?
21
- begin
22
- !JSON.parse(self).nil?
23
- rescue
24
- false
25
- end
26
- end
27
- end
19
+ require './eDen'
20
+ require './database'
21
+ require './extensions'
28
22
 
29
- # class Database
30
- # def self.connect_database
31
- # if File.exist?("eden.sqlite3")
32
- # eden = Sequel.connect("sqlite://eden.sqlite3")
33
- # else
34
- # eden = Sequel.connect("sqlite://eden.sqlite3")
35
- # eden.create_table :atome do
36
- # primary_key :atome_id
37
- # String :aui
38
- # String :id
39
- # String :type
40
- # String :name
41
- # String :content
42
- # String :position
43
- # String :dimension
44
- # String :color
45
- # String :right
46
- # String :effect
47
- # String :shadow
48
- # String :border
49
- # String :fill
50
- # Float :x
51
- # Float :xx
52
- # Float :y
53
- # Float :yy
54
- # Float :z
55
- # Float :zz
56
- # Float :width
57
- # Float :height
58
- # Float :depth
59
- # end
60
- #
61
- # end
62
- # eden
63
- # end
64
- #
65
- # end
23
+ Faye::WebSocket.load_adapter('puma')
66
24
 
67
25
  class App < Roda
68
- # comment below when test will be done
69
- # File.delete("./eden.sqlite3") if File.exist?("./eden.sqlite3")
70
- eden = Database.connect_database
71
- items = eden[:atome]
72
-
73
- # populate the table
74
- items.insert(name: 'abc', width: rand * 100)
75
- items.insert(name: 'def', width: rand * 100)
76
- items.insert(name: 'ghi', width: rand * 100)
77
-
78
- puts "Item count: #{items.count}"
79
-
80
- puts "The average price is: #{items.avg(:width)}"
81
-
82
26
  index_content = File.read("../src/index_server_wasm.html")
83
-
84
27
  opts[:root] = '../src'
85
- plugin :static, %w[/css /js /medias], root: '../src'
28
+ plugin :static, %w[/css /js /medias /wasm], root: '../src'
86
29
  route do |r|
87
30
  r.root do
88
31
  if Faye::WebSocket.websocket?(r.env)
89
32
  ws = Faye::WebSocket.new(r.env)
90
-
91
- ws.on :open do |event|
92
- ws.send('server ready'.to_json)
93
- # ws.send('asking for synchro data'.to_json)
33
+ ws.on :open do |_event|
34
+ ws.send({ return: 'server ready' }.to_json)
94
35
  end
95
-
96
36
  ws.on(:message) do |event|
97
- #TODO : encode event on both client and server
98
- ws.send(event.data.reverse.to_json) # Envoie le message inversé au client
37
+ json_string = event.data.gsub(/(\w+):/) { "\"#{$1}\":" }.gsub('=>', ':')
38
+ full_data = JSON.parse(json_string)
39
+ data = full_data['data']
40
+ action_requested = full_data['action']
41
+ message_id = full_data['message_id']
42
+ return_message = EDen.safe_send(action_requested, data, message_id)
43
+ ws.send(return_message.to_json)
99
44
  end
100
-
101
45
  ws.on(:close) do |event|
102
46
  puts "server closed with status #{event.code}"
103
47
  end
104
48
  ws.rack_response
105
49
  end
106
-
107
50
  index_content
108
51
  end
109
-
110
52
  end
111
53
 
112
54
  end
@@ -40,7 +40,7 @@ class Database
40
40
  end
41
41
  end.apply(eden, :up)
42
42
  rescue Sequel::DatabaseError => e
43
- puts "Erreur lors de l'ajout de la colonne : #{e.message}"
43
+ puts "error adding column : #{e.message}"
44
44
  end
45
45
  end
46
46
  end
@@ -30,7 +30,7 @@
30
30
  </head>
31
31
  <body id='user_view' class='atome'>
32
32
 
33
- <div id='copyright'>©atome 2023</div>
33
+ <div id='copyright'>©atome 2024</div>
34
34
  </body>
35
35
  <script type="text/ruby">
36
36
  require 'js'
@@ -43,5 +43,8 @@
43
43
  atome_infos
44
44
  </script>
45
45
  <script defer src="js/atome/specific/wasm.js" type="text/javascript"></script>
46
+ <script type="text/javascript">
47
+ const NativeMode = true; // used by atome.js to load code on the fly
48
+ </script>
46
49
  <script defer src="js/atome/atome.js" type="text/javascript"></script>
47
50
  </html>
@@ -23,6 +23,7 @@
23
23
  <script defer defer src='js/host_mode.js'></script>
24
24
  <script src='js/opal/atome_opal_extensions.js' defer></script>
25
25
  <script src='js/atome/kernel.js' defer></script>
26
+ <!-- <script src='js/atome/eVe_kernel.js' defer></script>-->
26
27
  <script defer src="js/atome/atome_helpers/communication.js" type="text/javascript"></script>
27
28
  <script defer src="js/atome/atome_helpers/file.js" type="text/javascript"></script>
28
29
  <!-- <script>-->
@@ -34,9 +35,12 @@
34
35
  <title>atome</title>
35
36
  </head>
36
37
  <body id='user_view' class='atome'>
37
- <div id='copyright'>©atome 2027</div>
38
+ <div id='copyright'>©atome 2024</div>
38
39
  </body>
39
40
  <script defer src="js/atome/specific/opal.js" type="text/javascript"></script>
41
+ <script type="text/javascript">
42
+ const NativeMode = false; // used by atome.js to load code on the fly
43
+ </script>
40
44
  <script defer src="js/atome/atome.js" type="text/javascript"></script>
41
45
  <script src='js/application.js' defer></script>
42
46
  <script>
@@ -34,9 +34,12 @@
34
34
  <title>atome</title>
35
35
  </head>
36
36
  <body id='user_view' class='atome'>
37
- <div id='copyright'>©atome 2027</div>
37
+ <div id='copyright'>©atome 2024</div>
38
38
  </body>
39
39
  <script defer src="js/atome/specific/opal.js" type="text/javascript"></script>
40
+ <script type="text/javascript">
41
+ const NativeMode = false; // used by atome.js to load code on the fly
42
+ </script>
40
43
  <script defer src="js/atome/atome.js" type="text/javascript"></script>
41
44
  <script>
42
45
  function loadApplicationJs() {
@@ -20,17 +20,17 @@
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'>
32
32
 
33
- <div id='copyright'>©atome 2023</div>
33
+ <div id='copyright'>©atome 2024</div>
34
34
  </body>
35
35
  <script type="text/ruby">
36
36
  require 'js'
@@ -39,18 +39,11 @@
39
39
  require '/utilities/host_mode'
40
40
  require '/lib/atome_relative'
41
41
  require './index'
42
- #puts Universe.host
43
- atome_genesis
42
+ atome_infos
44
43
  </script>
45
44
  <script defer src="js/atome/specific/wasm.js" type="text/javascript"></script>
46
- <script>
47
- function loadApplicationJs() {
48
- var script = document.createElement('script');
49
- script.src = 'js/application.js';
50
- script.onload = function() {
51
- rubyVMCallback("A.init_database");
52
- };
53
- document.body.appendChild(script);
54
- }
45
+ <script type="text/javascript">
46
+ const NativeMode = false; // used by atome.js to load code on the fly
55
47
  </script>
48
+ <script defer src="js/atome/atome.js" type="text/javascript"></script>
56
49
  </html>
@@ -20,17 +20,17 @@
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'>
32
32
 
33
- <div id='copyright'>©atome 2023</div>
33
+ <div id='copyright'>©atome 2024</div>
34
34
  </body>
35
35
  <script type="text/ruby">
36
36
  require 'js'
@@ -38,15 +38,12 @@
38
38
  require '/utilities/aui'
39
39
  require '/utilities/host_mode'
40
40
  require '/lib/atome_relative'
41
- # if Universe.eVe
42
- # require './index'
43
- #else
44
- # require './index'
45
- # end
46
- require './index'
47
- #puts Universe.host
41
+ require './index'
48
42
  atome_infos
49
43
  </script>
50
44
  <script defer src="js/atome/specific/wasm.js" type="text/javascript"></script>
45
+ <script type="text/javascript">
46
+ const NativeMode = false; // used by atome.js to load code on the fly
47
+ </script>
51
48
  <script defer src="js/atome/atome.js" type="text/javascript"></script>
52
49
  </html>
@@ -59,7 +59,7 @@ async function changeCurrentDirectory(atome_id, newPath) {
59
59
  } catch (error) {
60
60
  result = error;
61
61
  }
62
- alert('result is : '+ result);
62
+ alert('result is : ' + result);
63
63
  }
64
64
 
65
65
 
@@ -218,3 +218,80 @@ function fileForOpal(parent, bloc) {
218
218
  })
219
219
 
220
220
  }
221
+
222
+
223
+ // function loadFeature() {
224
+ // var script = document.createElement('script');
225
+ // script.src = 'js/molecules/web.js?' + new Date().getTime();
226
+ // // script.onload = function () {
227
+ // // // Code to use loaded features
228
+ // // };
229
+ // // puts to solve native (osx) compatiblity use fetch
230
+ //
231
+ // document.head.appendChild(script);
232
+ // }
233
+
234
+ // function loadFeature() {
235
+ // fetch('js/molecules/web.js')
236
+ // .then(response => {
237
+ // if (response.ok) {
238
+ // return response.text();
239
+ // }
240
+ // throw new Error('Le chargement du fichier a échoué');
241
+ // })
242
+ // .then(data => {
243
+ // console.log(data); // Log le contenu du fichier web.js
244
+ // // Vous pouvez ici utiliser le contenu du fichier comme nécessaire
245
+ // })
246
+ // .catch(error => {
247
+ // console.error('Erreur lors du chargement du fichier:', error);
248
+ // });
249
+ // }
250
+
251
+
252
+ function loadFeature() {
253
+ if (NativeMode) {
254
+ // fetch('js/molecules/web.js')
255
+ // .then(response => {
256
+ // if (response.ok) {
257
+ // return response.text();
258
+ // }
259
+ // throw new Error('Le chargement du fichier a échoué');
260
+ // })
261
+ // .then(data => {
262
+ // // console.log(data);
263
+ // eval(data);
264
+ // // you can use file content as you want
265
+ // })
266
+ // .catch(error => {
267
+ // console.error('Erreur lors du chargement du fichier:', error);
268
+ // });
269
+ fetch('js/molecules/web.js')
270
+ .then(response => {
271
+ if (response.ok) {
272
+ return response.text();
273
+ }
274
+ throw new Error('load fail');
275
+ })
276
+ .then(data => {
277
+ var script = document.createElement('script');
278
+ script.type = 'text/javascript';
279
+ script.text = data;
280
+ document.head.appendChild(script);
281
+ })
282
+ .catch(error => {
283
+ console.error('Erreur lors du chargement du fichier:', error);
284
+ });
285
+
286
+ } else {
287
+ var script = document.createElement('script');
288
+ script.src = 'js/molecules/web.js?' + new Date().getTime();
289
+ // script.onload = function () {
290
+ // // Code to use loaded features
291
+ // };
292
+
293
+ document.head.appendChild(script);
294
+ }
295
+ }
296
+
297
+