Преглед на файлове

templating changes

master
jfinn преди 1 година
родител
ревизия
1d22e5ea67
променени са 6 файла, в които са добавени 1744 реда и са изтрити 140 реда
  1. 13
    91
      js_client/jsync_lib.js
  2. 1695
    0
      js_client/jsync_lib.old.js
  3. 0
    0
      js_client/jsync_lib0.old.js
  4. 16
    6
      js_client/jsync_lib_template.js
  5. 20
    5
      make.py
  6. 0
    38
      old.make.py

+ 13
- 91
js_client/jsync_lib.js Целия файл

1
 "use strict";
1
 "use strict";
2
 
2
 
3
+// makestache template info 
4
+// the following string tells my make scripts its fine to overwtite this the library would have had a template str in the middle of the str
5
+// BUILT_FILE_OVERWRITE_ALLOWED
6
+//  ... C:\ws\repos\jitsi_main\jsync\jsyncdb\js_client\jsync_lib.js
7
+// /* */ 
8
+
3
 (function (){
9
 (function (){
4
 var isProxy,tlu,msto_z
10
 var isProxy,tlu,msto_z
5
 var pf,msto_prx
11
 var pf,msto_prx
383
 	clog("WS_CLOSE",{that:this,readyState:this.readyState,args:[...arguments]})
389
 	clog("WS_CLOSE",{that:this,readyState:this.readyState,args:[...arguments]})
384
 	// glob_u.ws.sockets.ws1.params.ord.run_cbs("WS_CLOSE:",{event,that:this})
390
 	// glob_u.ws.sockets.ws1.params.ord.run_cbs("WS_CLOSE:",{event,that:this})
385
 	glob_u.ws.sockets[this.params.socket_name].params.ord.run_cbs("WS_CLOSE:",{event,that:this})
391
 	glob_u.ws.sockets[this.params.socket_name].params.ord.run_cbs("WS_CLOSE:",{event,that:this})
386
-	let  timeout0 = this.params.timeout0 || 100
387
-	let timeout_multi = this.params.timeout_multi || 3000
388
-	let t =timeout_multi
389
-	// let now = Date.now()
390
-	if (this.params.HAS_OPENED && timeout_multi<Date.now()-this.params.OPEN_TIME){
391
-		t=timeout0
392
-	}
393
-	// clog(":TIME:",now,this.params.OPEN_TIME,now-this.params.OPEN_TIME)
394
-	this.params.HAS_OPENED = 0
395
-	setTimeout(this.params.fns.reconnect,t)
392
+	setTimeout(this.params.fns.reconnect,1000)
396
 }
393
 }
397
 
394
 
398
 window.glob_u.ws.fns.onmessage = function onmessage(event){
395
 window.glob_u.ws.fns.onmessage = function onmessage(event){
409
 
406
 
410
 }
407
 }
411
 window.glob_u.ws.fns.onopen = function onopen(event){
408
 window.glob_u.ws.fns.onopen = function onopen(event){
412
-	this.params.HAS_OPENED = 1
413
-	this.params.OPEN_TIME = Date.now()
414
 
409
 
415
-	clog("WS_OPEN???",{that:this,args:[...arguments]},{on_open_once:this.on_open_once,on_open_cbs:this.params.on_open_cbs})
410
+	// clog("WS_OPEN???",{that:this,args:[...arguments]},{on_open_once:this.on_open_once,on_open_cbs:this.params.on_open_cbs})
416
 	// glob_u.ws.sockets.ws1.params.ord.run_cbs("WS_OPEN:",{event,that:this})
411
 	// glob_u.ws.sockets.ws1.params.ord.run_cbs("WS_OPEN:",{event,that:this})
417
 	glob_u.ws.sockets[this.params.socket_name].params.ord.run_cbs("WS_OPEN:",{event,that:this})
412
 	glob_u.ws.sockets[this.params.socket_name].params.ord.run_cbs("WS_OPEN:",{event,that:this})
418
 	return
413
 	return
473
 	return fns
468
 	return fns
474
 }
469
 }
475
 
470
 
476
-Object.defineProperty(window,'a',{
477
-    get: function(){
478
-        console.log('windowProperty is being get...',arguments);
479
-        glob_u.ws.sockets.ws1.send(`{"a":2.01}`)
480
-        return 'windowProperty'
481
-    },
482
-
483
-    set: function(val){
484
-        console.log('windowProperty is being set',arguments);
485
-    },
486
-
487
-    configurable: true,
488
-});
489
 
471
 
490
 function connect_ws(o= {}){
472
 function connect_ws(o= {}){
491
 	// clog("connect_ws:",o,jc(o))
473
 	// clog("connect_ws:",o,jc(o))
501
 		return
483
 		return
502
 
484
 
503
 	}
485
 	}
504
-	var old_url = o.url
505
-	// location.protocol == "https:" ? clog("HTTPS") : clog("HTTP?")
506
-	// let vx1
507
-	// let vx1;location.protocol == "https:" ?  vx1 = "HTTPS" : vx1 = "HTTP?"
508
-	// clog("VAR DECS",vx1)
509
-	// o.url = "ws://127.0.0.1:5000/djc_srv/ws/chat/"
510
-	// o.url = "ws://127.0.0.1:5000/djc_srv/ws/chat"
511
-	// o.url = "ws://127.0.0.1:5000/echo_c1"
512
-	// o.url = `ws://${location.hostname}:5000/echo_c1?HELLO__________________________________________________________________________=1`
513
-	// o.url = `ws://${location.hostname}:5000/echo_c1${location.search}`
514
-	// o.url = `ws://${location.hostname}:5000/echo_c1?HELLO+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=1`
515
-	clog("new WebSocket(o.url)",o,o.url,old_url)
516
-	// var socket = new WebSocket(o.url,["PROTOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"])
486
+
517
 	var socket = new WebSocket(o.url)
487
 	var socket = new WebSocket(o.url)
518
 	socket.on_open_once = []
488
 	socket.on_open_once = []
519
 	socket.pre_init_msgs = []
489
 	socket.pre_init_msgs = []
563
 window.glob_u.ws.fns.dispatch = function dispatch(o,obj_x,info){
533
 window.glob_u.ws.fns.dispatch = function dispatch(o,obj_x,info){
564
 	var event = o.event
534
 	var event = o.event
565
 	// socket = o.that
535
 	// socket = o.that
566
-	if (event.data == "::CLOSE::"){
567
-		clog("comand_CLOSE!!!")
568
-		o.that.close()
569
-	}
570
-	// clog(":event.data:",event.data,[this,o,obj_x,info])
571
 	var data = JSON.parse(event.data)
536
 	var data = JSON.parse(event.data)
572
 	// clog("WS_dispatch",data,socket.params.ord,data["CLIENT_KEY"])
537
 	// clog("WS_dispatch",data,socket.params.ord,data["CLIENT_KEY"])
573
 	// clog("trc:sto:ws_rec",data.CLIENT_KEY,data.sto_event_type,data)
538
 	// clog("trc:sto:ws_rec",data.CLIENT_KEY,data.sto_event_type,data)
610
 
575
 
611
 
576
 
612
 function get_room_name(){
577
 function get_room_name(){
613
-	// return 
614
-	var s=location.search
615
-	// if s[0]=="?"){}
616
-	s[0]=="?" ?  s = s.slice(1):0
617
-	var param
618
-	for (param of s.split("&")){
619
-
620
-		let kv = param.split("=")
621
-		if (kv[0]=="room"){
622
-			return kv[1]
623
-		}
624
-		clog("::",param,kv)
625
-		// clog("::",param,kv,"")
626
-	}
627
-
628
-	// var 
629
-	return "room_name"
630
-	var room_name=location.pathname.match(/\/loc.([^\/]*)\//)
631
-	if (room_name){
632
-		room_name = room_name[1]
633
-	} else {
634
-	room_name = location.pathname.split("/").pop()
635
-
636
-	}
637
-	return room_name
638
-
639
-}
640
-function get_room_name_old(){
641
 
578
 
642
 	var room_name=location.pathname.match(/\/loc.([^\/]*)\//)
579
 	var room_name=location.pathname.match(/\/loc.([^\/]*)\//)
643
 	if (room_name){
580
 	if (room_name){
754
 				if (glob_u.prom.init_db_resolve.resolved_inited == 2){
691
 				if (glob_u.prom.init_db_resolve.resolved_inited == 2){
755
 
692
 
756
 				tmsgx4({sto_event_type:"db_sync_response",payload:jc(pf.root),request_from:parsed.from,request_rn_from:parsed.request_rn,"CLIENT_KEY":"ws_sto"})
693
 				tmsgx4({sto_event_type:"db_sync_response",payload:jc(pf.root),request_from:parsed.from,request_rn_from:parsed.request_rn,"CLIENT_KEY":"ws_sto"})
757
-				clog("SENDING!@#$%^&*(")
758
 				}
694
 				}
759
 
695
 
760
 			break;
696
 			break;
761
 			case "db_sync_response":
697
 			case "db_sync_response":
762
 
698
 
763
-			// clog("PROC db_sync_response",parsed,_o)
764
-
765
 					if (glob_u.prom.init_db_resolve && parsed.request_rn_from  == glob_u.prom.init_db_resolve.rn){
699
 					if (glob_u.prom.init_db_resolve && parsed.request_rn_from  == glob_u.prom.init_db_resolve.rn){
766
-			// clog("::PROC db_sync_response::",parsed,_o)
767
 						glob_u.prom.init_db_resolve({aaa:"dsr",pl:parsed.payload})
700
 						glob_u.prom.init_db_resolve({aaa:"dsr",pl:parsed.payload})
768
-					} else {
769
-			// clog("NO PROC::PROC db_sync_response::",parsed,_o)
770
-
771
 					}
701
 					}
772
-			clog("::PROC db_sync_response::",glob_u.prom.init_db_resolve.rn==parsed.request_rn_from,glob_u.prom.init_db_resolve.rn,parsed.request_rn_from,parsed,_o)
773
 				// clog("db_sync_response",parsed)
702
 				// clog("db_sync_response",parsed)
774
 			break;
703
 			break;
775
 
704
 
1366
 }
1295
 }
1367
 
1296
 
1368
 function ws_sto_connected(a,b){
1297
 function ws_sto_connected(a,b){
1369
-	// clog("")
1370
 
1298
 
1371
 	glob_u.cb.ws.run_cbs("WS_MSTO_INITED")
1299
 	glob_u.cb.ws.run_cbs("WS_MSTO_INITED")
1372
 
1300
 
1617
 
1545
 
1618
 // TODO:Fix bug caused by a user disconnecting before the connection is properly established
1546
 // TODO:Fix bug caused by a user disconnecting before the connection is properly established
1619
 function connection_info_handler(o,scope,info){
1547
 function connection_info_handler(o,scope,info){
1620
-	// clog("**************************************************************8:",o,scope,info)
1621
 	if (o.data.sto_event_type=="connection_info"){
1548
 	if (o.data.sto_event_type=="connection_info"){
1622
-	clog("connection_info_handler:",o,scope,info)
1549
+	// clog("connection_info_handler:",o,scope,info)
1623
 		glob_u.data.group_name = o.data.group_name
1550
 		glob_u.data.group_name = o.data.group_name
1624
 		glob_u.data.channel_name = o.data.channel_name
1551
 		glob_u.data.channel_name = o.data.channel_name
1625
 		clog("jsyncdb connected","room name:",glob_u.data.group_name)
1552
 		clog("jsyncdb connected","room name:",glob_u.data.group_name)
1626
 	} else if (o.data.sto_event_type=="user_disconnected"){
1553
 	} else if (o.data.sto_event_type=="user_disconnected"){
1627
-	clog("user_disconnected_handler:",o,scope,info)
1628
-
1629
 	var last_conn =1
1554
 	var last_conn =1
1630
 	var k,v
1555
 	var k,v
1631
 	var ws_conn_data = jc(msto.ws_channels[o.data.channel_name])
1556
 	var ws_conn_data = jc(msto.ws_channels[o.data.channel_name])
1632
 	delete msto.ws_channels[o.data.channel_name]
1557
 	delete msto.ws_channels[o.data.channel_name]
1633
 		for ([k,v] of Object.entries(msto.ws_channels)){
1558
 		for ([k,v] of Object.entries(msto.ws_channels)){
1634
-		clog("ERR!",{channel_name:jc(o.data.channel_name),ws_channels:jc(msto.ws_channels),z:{o,data:o.data}})
1635
-		clog("ERR?",k,v,ws_conn_data)
1636
-		clog("ERR??",jc(msto.ws_channels))
1637
-		clog("ERR???",jc(o.data))
1638
 		if (v.id == ws_conn_data.id){
1559
 		if (v.id == ws_conn_data.id){
1639
 			last_conn = 0
1560
 			last_conn = 0
1640
 		}
1561
 		}
1682
 // console.log("??...")
1603
 // console.log("??...")
1683
 
1604
 
1684
 
1605
 
1685
-// clog("?????")
1606
+// clog("???")
1686
 // 
1607
 // 
1687
 
1608
 
1688
 
1609
 
1689
 
1610
 
1611
+
1690
 // glob_u.fns.get_room_name=get_room_name
1612
 // glob_u.fns.get_room_name=get_room_name
1691
 // window.ds_test=ds_test
1613
 // window.ds_test=ds_test
1692
 // glob_u.fns.ds_test=ds_test
1614
 // glob_u.fns.ds_test=ds_test
1693
 // window.msto_prx=msto_prx
1615
 // window.msto_prx=msto_prx
1694
 
1616
 
1695
-})()
1617
+})()

+ 1695
- 0
js_client/jsync_lib.old.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


js_client/jsync_lib0.js → js_client/jsync_lib0.old.js Целия файл


+ 16
- 6
js_client/jsync_lib_template.js Целия файл

1
 "use strict";
1
 "use strict";
2
 
2
 
3
+// makestache template info {{{makestache_template_info}}}
4
+// the following string tells my make scripts its fine to overwtite this the library would have had a template str in the middle of the str
5
+// BUILT_FILE_{{{"makestache_template"}}}OVERWRITE_ALLOWED
6
+// {{{out_file_hint>jsync_lib*js}}} ... {{{output_filename}}}
7
+{{#is_makestache_template}}
8
+THIS_FILE_IS_A_MAKESTACHE_TEMPLATE
9
+{{/is_makestache_template}}
10
+// /* */ 
11
+
3
 (function (){
12
 (function (){
4
 var isProxy,tlu,msto_z
13
 var isProxy,tlu,msto_z
5
 var pf,msto_prx
14
 var pf,msto_prx
7
 
16
 
8
 // jsync:dep.js
17
 // jsync:dep.js
9
 // ------------------------------------------------------------------------------------------------
18
 // ------------------------------------------------------------------------------------------------
10
-{{{jsync_dep}}}
19
+{{{jsync_dep*js}}}
11
 // jsync:ord.js
20
 // jsync:ord.js
12
 // ------------------------------------------------------------------------------------------------
21
 // ------------------------------------------------------------------------------------------------
13
-{{{jsync_ord}}}
22
+{{{jsync_ord*js}}}
14
 // jsync:ws.js
23
 // jsync:ws.js
15
 // ------------------------------------------------------------------------------------------------
24
 // ------------------------------------------------------------------------------------------------
16
-{{{jsync_ws}}}
25
+{{{jsync_ws*js}}}
17
 // jsync:sto.js
26
 // jsync:sto.js
18
 // ------------------------------------------------------------------------------------------------
27
 // ------------------------------------------------------------------------------------------------
19
-{{{jsync_sto}}}
28
+{{{jsync_sto*js}}}
20
 // jsync:init.js
29
 // jsync:init.js
21
 // ------------------------------------------------------------------------------------------------
30
 // ------------------------------------------------------------------------------------------------
22
-{{{jsync_init}}}
31
+{{{jsync_init*js}}}
23
 
32
 
24
 // jsync:test.js
33
 // jsync:test.js
25
 // ------------------------------------------------------------------------------------------------
34
 // ------------------------------------------------------------------------------------------------
26
-{{{jsync_test}}}
35
+{{{jsync_test*js}}}
36
+
27
 
37
 
28
 
38
 
29
 
39
 

+ 20
- 5
make.py Целия файл

91
 		p("\t\\t\tFILE ERR:::",file_name)
91
 		p("\t\\t\tFILE ERR:::",file_name)
92
 		p("")
92
 		p("")
93
 
93
 
94
-	p("LRN",len(ftxt))
94
+	# p("LRN",len(ftxt))
95
 	return r
95
 	return r
96
 
96
 
97
 
97
 
134
 	os.chdir(tglob["OUT_DIR"])
134
 	os.chdir(tglob["OUT_DIR"])
135
 
135
 
136
 	# dbg_out
136
 	# dbg_out
137
-	wfile("mgen1.js",out)
138
-	wfile("mgen2.js",out2)
137
+	# wfile("mgen1.js",out)
138
+	# wfile("mgen2.js",out2)
139
 	p()
139
 	p()
140
 	if mdict["output_ok"]:
140
 	if mdict["output_ok"]:
141
 		p(mdict["outfile"]["_path"])
141
 		p(mdict["outfile"]["_path"])
222
 
222
 
223
 
223
 
224
 	o = {}
224
 	o = {}
225
+	p("checking files...")
225
 	# for en in os.scandir(r"C:\ws\repos\script_utils\makestache"):
226
 	# for en in os.scandir(r"C:\ws\repos\script_utils\makestache"):
226
 	for en in os.scandir():
227
 	for en in os.scandir():
227
 		if isfile(en):
228
 		if isfile(en):
228
 			o[en] = is_template_file(en)
229
 			o[en] = is_template_file(en)
229
-			p([en],isfile(en))
230
+			# p([en],isfile(en))
231
+			# p(en.name,en.path)
232
+			if (o[en]["is_template"]):
233
+				p(":",en.path,"TEMPLATE")
234
+			else:
235
+				p(en.path)
236
+			# p(en.path,"is_template:",bool(o[en]["is_template"]))
230
 			r'''
237
 			r'''
231
 			for en2 in dir(en):
238
 			for en2 in dir(en):
232
 				if en2[:2]=="__":
239
 				if en2[:2]=="__":
251
 tglob["IN_DIR"] = r"C:\ws\repos\script_utils\makestache\test_src"
258
 tglob["IN_DIR"] = r"C:\ws\repos\script_utils\makestache\test_src"
252
 tglob["OUT_DIR"] = r"C:\ws\repos\script_utils\makestache\test_src"
259
 tglob["OUT_DIR"] = r"C:\ws\repos\script_utils\makestache\test_src"
253
 
260
 
261
+tglob["IN_DIR"]  = os.path.abspath(r"./js_client")
262
+tglob["OUT_DIR"] = os.path.abspath(r"./js_client")
254
 
263
 
255
 
264
 
256
-
265
+orig_dir = os.getcwd()
257
 
266
 
258
 
267
 
259
 dev_main()
268
 dev_main()
269
+os.chdir(orig_dir)
270
+
271
+# this should exist only on the authors computer (it copies make.py to here so i can run make.py twice and get any file changes)
272
+if os.path.isfile("udep.bat"):
273
+	os.system("udep.bat")
274
+

+ 0
- 38
old.make.py Целия файл

1
-import chevron
2
-
3
-
4
-
5
-files={
6
-"jsync_dep"  : "jsync_dep.js",
7
-"jsync_ord"  : "jsync_ord.js",
8
-"jsync_ws"   : "jsync_ws.js",
9
-"jsync_sto"  : "jsync_sto.js",
10
-"jsync_test" : "jsync_test.js",
11
-"jsync_test2" : "jsync_test2.js",
12
-"jsync_init" : "jsync_init.js",
13
-}
14
-
15
-def wfile(file_name,out):
16
-	f = open(file_name,"w")
17
-	f.write(out)
18
-	f.close()
19
-def rfile(file_name):
20
-	f = open(file_name,"r")
21
-	ftxt = f.read()
22
-	f.close()
23
-	return ftxt
24
-
25
-# C:\bspace\repos\jc4\ign4\indx\jsyncdb\jsync_lib_template.js
26
-def run_now():
27
-	path = r"C:\bspace\repos\jc4\ign4\indx\jsyncdb" + "\\"
28
-	files2 = {}
29
-	for k,v in files.items():
30
-		ftxt = rfile(path+v)
31
-		files2[k] = ftxt
32
-	template = rfile(path+"jsync_lib_template.js")
33
-	out = chevron.render(template,files2)
34
-	# wfile("jsync_lib_out.js",out)
35
-	wfile(path+"jsync_lib.js",out)
36
-
37
-# run_now()
38
-print("This was the old file I used to render the template the new one should keep all (or) most logic in the template")

Loading…
Отказ
Запис