-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathj.js
executable file
·3689 lines (3473 loc) · 140 KB
/
j.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function update_settings(){
let grList = ["Lagna","Sun","Moon","Mercury","Mars",
"Saturn","Venus","Jupiter","Rahu"];
for (gr of grList) {
c_gr = gr.slice(0,2);
c_deg = divisional_data['d1']['degree_of_grahas'][c_gr][0];
c_min = divisional_data['d1']['degree_of_grahas'][c_gr][1];
c_sec = divisional_data['d1']['degree_of_grahas'][c_gr][2];
document.getElementById(c_gr.toLowerCase()+'_deg').value = c_deg;
document.getElementById(c_gr.toLowerCase()+'_min').value = c_min;
document.getElementById(c_gr.toLowerCase()+'_sec').value = c_sec;
}
//
for (gr of retro_planet_list) {
document.getElementById(gr+'_retrocbox').checked=true;
}
d1_rashiNum_asc = divisional_data['d1']['rashiNum_asc'];
// console.log(divisional_data);
for (let house=1; house<=12; house++) {
// get rashi in the house
var house_rashiNum = (parseInt(d1_rashiNum_asc)+house-1)%12;
if (house_rashiNum==0) {house_rashiNum=12};
if (house_rashiNum==d1_rashiNum_asc)
document.getElementById('lagna').value = house_rashiNum;
// console.log("house_rashiNum is now : " + house_rashiNum);
for (graha of divisional_data['d1']['grahas_in_rashi'][parseInt(house_rashiNum)]) {
if (graha=='La' || graha=='Ke') continue;
// document.getElementById('h_'+ graha.toLowerCase()).value = "h" + house_rashiNum;
document.getElementById('h_'+ graha.toLowerCase()).value = "h" + house.toString();
}
}
}
function disp_degree(action) {
if (typeof l_out['settings'] === 'undefined') { initialize_l_out(); }
if (action==='show') {
$('#hide_degree').removeClass('d-none');
$('#show_degree').addClass('d-none');
l_out['settings']['disp_degree']=1;
} else {
$('#hide_degree').addClass('d-none');
$('#show_degree').removeClass('d-none');
l_out['settings']['disp_degree']=0;
}
var all_inputs = document.querySelectorAll('.deg');
for (x = 0 ; x < all_inputs.length ; x++){
myid = all_inputs[x].getAttribute("id");
if (action==='show') { $('#'+myid).removeClass('d-none');}
else { $('#'+myid).addClass('d-none');}
}
// console.log("disp_degree");
// console.log(l_out);
}
function displayJustme(my_class,my_id) {
var all_entries = document.querySelectorAll('.'+my_class);
for (x = 0 ; x < all_entries.length ; x++){
entry_id = all_entries[x].getAttribute("id");
$('#'+entry_id).addClass('d-none');
}
$('#'+my_id).removeClass('d-none');
}
function highlightJustme(my_class,my_id) {
var all_entries = document.querySelectorAll('.'+my_class);
for (x = 0 ; x < all_entries.length ; x++){
entry_id = all_entries[x].getAttribute("id");
// if (action==='show') { $('#'+entry_id).removeClass('d-none');}
// else { $('#'+entry_id).addClass('d-none');}
$('#'+entry_id).removeClass('bg-warning');
}
$('#'+my_id).addClass('bg-warning');
}
function disp_rotate_links(action) {
if (action==='show') {
$('#hide_rotate_links').removeClass('d-none');
$('#show_rotate_links').addClass('d-none');
} else {
$('#hide_rotate_links').addClass('d-none');
$('#show_rotate_links').removeClass('d-none');
}
var all_inputs = document.querySelectorAll('.rot');
for (x = 0 ; x < all_inputs.length ; x++){
myid = all_inputs[x].getAttribute("id");
if (action==='show') { $('#'+myid).removeClass('d-none');}
else { $('#'+myid).addClass('d-none');}
}
}
function choose_view_generate_form(loc) {
if (loc.length==0) { loc='00';}
return '<span class=\'h5 text-danger font-weight-bold\'>'
+ 'Choose View</span><br>'
+ '<span onclick="view_dN(\''+loc+'\',\'d3\');" class="m-1 btn btn-link border border-danger">D3</span>'
+ '<span onclick="view_dN(\''+loc+'\',\'d4\');" class="m-1 btn btn-link border border-danger">D4</span>'
+ '<span onclick="view_dN(\''+loc+'\',\'d7\');" class="m-1 btn btn-link border border-danger">D7</span>'
+ '<span onclick="view_dN(\''+loc+'\',\'d9\');" class="m-1 btn btn-link border border-danger">D9</span>'
+ '<span onclick="view_dN(\''+loc+'\',\'d10\');" class="m-1 btn btn-link border border-danger">D10</span><br>'
+ '<span onclick="view_d1(\''+loc+'\');" class="m-1 btn btn-link border border-danger">D1</span>'
+ '<span onclick="view_d1(\''+loc+'\',\'Mo\');" class="m-1 btn btn-link border border-danger">D1-Mo</span>'
+ '<span onclick="view_d1(\''+loc+'\',\'Ve\');" class="m-1 btn btn-link border border-danger">D1-Ve</span>'
+ '<span onclick="view_d1(\''+loc+'\',\'Ju\');" class="m-1 btn btn-link border border-danger">D1-Ju</span>';
// + '<span onclick="clear_all_view_divs(\''+loc+'\');" class="m-1 btn btn-link border border-danger">Clear-test</span>'
// + '<span onclick="view_d9(\''+loc+'\');" class="m-1 btn btn-link border border-danger">D9</span>'
}
function process_jh_freeForm_settings() {
document.getElementById('modalB').style.display = 'none';
var tarea0 = document.getElementById('free_form_settings').value.split('\n');
// let deg = document.getElementById(gr.toLowerCase()+'_deg').value;
let i = 0;
var x_loc='00';
let grList = ["Lagna","Sun","Moon","Mercury","Mars",
"Saturn","Venus","Jupiter","Rahu"];
const rasiNumByName = { "Mesh":"1", "Vrish":"2", "Mith":"3", "Kark":"4", "Simh":"5", "Kanya":"6",
"Tula":"7", "Vrisch":"8", "Dhanu":"9", "Makar":"10", "Kumbh":"11", "Meen":"12"
};
if (typeof divisional_data['d1'] === 'undefined') { initialize_div_d1(); }
if (typeof l_out[x_loc] === 'undefined') { initialize_l_out(x_loc); }
//
for (let raNum=1; raNum<=12; raNum++) { grahas_in_rashi[raNum.toString()]=[]; }
//
while (i < tarea0.length) {
var lineArray = tarea0[i].split(/(\s+)/);
// console.log(tarea0[i]);
// console.log(lineArray);
// Saturn (R) - MK 8 Mith 57' 51.78" Ardr 1 Mith Dhanu
// Lagna 12 Dhanu 13' 01.23" Mool 4 Dhanu Kark
//[ "Lagna", " ", "12", " ", "Dhanu", " ", "13' 01.23\" Mool", " ", "4", " ", "Dhanu", " ", "Kark" ]
let c_gr = lineArray[0];
if (grList.includes(c_gr)) {
// console.log(lineArray);
// console.log(c_gr + " is graha");
var c_rashinum = ''; var c_gr_x ='';
var c_deg =''; var c_min =''; var c_sec ='';
var k = 0;
while (k < lineArray.length) {
// console.log(k + " is now k");
if (lineArray[k] in rasiNumByName) {
c_rashinum = rasiNumByName[lineArray[k]];
c_deg = lineArray[k-2];
c_min = lineArray[k+2].replace(/\D/g,''); // strip non digits
c_sec = lineArray[k+4].replace(/["]+/g,''); // remove double quotes
c_gr_x = c_gr.slice(0,2);
if (c_gr_x == "La") {
rashiNum_asc = c_rashinum.toString();
divisional_data['d1']['rashiNum_asc'] = c_rashinum;
l_out[x_loc]['rashiNum_asc'] = c_rashinum;
}
// console.log( "Gr:"+ c_gr_x + " - "+c_rashinum + "Rashi @ "+ c_deg + ":" + c_min + ":" + c_sec);
document.getElementById(c_gr_x.toLowerCase()+'_deg').value = c_deg;
document.getElementById(c_gr_x.toLowerCase()+'_min').value = c_min;
document.getElementById(c_gr_x.toLowerCase()+'_sec').value = c_sec;
degree_of_grahas[c_gr_x] = [];
degree_of_grahas[c_gr_x][0]=c_deg;
degree_of_grahas[c_gr_x][1]=c_min;
degree_of_grahas[c_gr_x][2]=c_sec;
divisional_data['d1']['degree_of_grahas']=degree_of_grahas;
l_out[x_loc]['degree_of_grahas']=degree_of_grahas;
if (c_gr_x != "La") {
grahas_in_rashi[c_rashinum].push(c_gr_x);
divisional_data['d1']['grahas_in_rashi']=grahas_in_rashi;
l_out[x_loc]['grahas_in_rashi']=grahas_in_rashi;
}
// if Retro mark as required and update arrays as needed
if (tarea0[i].includes("(R)")) {
retro_planet_list.push(c_gr_x);
document.getElementById(c_gr_x+'_retrocbox').checked=true;
}
//
if (c_gr_x == "Ra") {
// find the 7th house from Ra house - for Ke house
var ke_rashinum = (parseInt(c_rashinum)+6)%12;
if (ke_rashinum==0) { ke_rashinum=12; }
grahas_in_rashi[ke_rashinum.toString()].push('Ke');
divisional_data['d1']['grahas_in_rashi']=grahas_in_rashi;
l_out[x_loc]['grahas_in_rashi']=grahas_in_rashi;
}
break;
}
k++;
if (tarea0[i].includes("-")) { if (k>11) break;
} else { if (k>9) break; }
}
}
i++;
}
l_out[x_loc]['rashiNum_h1'] = rashiNum_asc
l_out[x_loc]['chart_title'] = 'D1';
// console.log(rashiNum_asc);
// console.log(grahas_in_rashi);
// console.log(degree_of_grahas);
// display_saved_degree();
// place_rashi_num_in_houses(rashiNum_asc);
// populate_graha_in_rashi();
// chart_d1();
view_1x1(x_loc);
// change settings of Gr drop down menu values
var arn = rashiNum_asc;
var gir = grahas_in_rashi;
var dog = degree_of_grahas;
//
for (let house=1; house<=12; house++) {
// get rashi in the house
house_rashinum = document.getElementById('rashi_in_h'+ house.toString()+'_'+x_loc).innerHTML;
// console.log(house_rashinum + " is now house_rashinum");
if (house_rashinum==rashiNum_asc)
document.getElementById('lagna').value = house_rashinum;
for ( graha of gir[house_rashinum]) {
if (graha=='La' || graha=='Ke') continue;
// console.log("graha is now " + graha);
// console.log("settting h_" + graha.toLowerCase().value + " to h" + house_rashinum);
document.getElementById('h_'+ graha.toLowerCase()).value = "h" + house.toString();
}
}
calc_all_divisional();
// console.log("l_out here");
// console.log(l_out);
// console.log("divisional here");
// console.log(divisional_data);
}
function calc_all_divisional(){
calc_div("d3");
calc_div("d4");
calc_div("d7");
calc_div("d9");
calc_div("d10");
}
function openFile() {
var input = document.getElementById("file-input");
input.click();
}
function read_url(url) {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
return xmlhttp.responseText;
}
}
xmlhttp.open("GET",url,true);
// xmlhttp.setRequestHeader('mode','no-cors');
xmlhttp.setRequestHeader('Accept','text/html');
xmlhttp.setRequestHeader('Content-Type','text/html');
xmlhttp.send();
}
function incr_font_size(c,f){
var inputs = document.getElementsByClassName(c);
for (x = 0 ; x < inputs.length ; x++){
var fontSize = inputs[x].style.fontSize;
inputs[x].style.fontSize = (parseFloat(fontSize) + f) + '%';
font_size[inputs[x].id] = inputs[x].style.fontSize;
// alert(parseFloat(fontSize));
// inputs[x].style.fontSize = fontSize + "4px";
// inputs[x].style.fontSize = fontSize + "10%";
}
l_out_save_fontSize();
// console.log(font_size);
}
function l_out_save_fontSize() {
var s_loc="";
if (curr_layout_name==='1x1') s_loc='00';
if (curr_layout_name==='1x2') s_loc='11';
if (curr_layout_name==='2x2') s_loc='211';
// save rashinum fontsize
// <div class="rb3 h5 rashinum font-weight-bold text-black"
// style="z-index:2;font-size: 120%; " id="rashi_in_h3_00">1</div>
if (typeof l_out['fontSize'] === 'undefined') { l_out['fontSize']={}; }
if (typeof l_out['fontSize'][curr_layout_name] === 'undefined') { l_out['fontSize'][curr_layout_name]=[]; }
l_out['fontSize'][curr_layout_name][0] = document.getElementById("rashi_in_h1_"+s_loc).style.fontSize;
// save graha fontsize
// <span class="lh-sm my-0 py-0 h3 graha font-weight-bold text-success"
// style="line-height:90%;font-size: 180%;" id="Ve"><br class="p-0 m-0">Ve</span>
l_out['fontSize'][curr_layout_name][1] = document.getElementById("h1_"+s_loc).style.fontSize;
}
function change_view(viewObj) {
let n_view = viewObj.value;
// let o_view = viewObj.oldvalue;
// console.log("Changing from view:" + viewObj.oldvalue + " to view: " + n_view);
// console.log(views[n_view]);
// save_view(o_view);
document.getElementById('j_comments').value = views[n_view]['j_comments'];
document.getElementById('j_notes').value = views[n_view]['j_notes'];
document.getElementById('j_title').value = views[n_view]['j_title'];
curr_drawing_idList = views[n_view]['drawing_idList'];
document.getElementById('j_drawings').innerHTML = "";
document.getElementById('title').innerHTML = n_view + '-Title';
document.getElementById('comments').innerHTML = n_view + '-Comments';
document.getElementById('notes').innerHTML = n_view + '-Notes';
document.getElementById('drawings').innerHTML = n_view + '-Drawings';
if (curr_drawing_idList.length>0) {
for (d_id of curr_drawing_idList)
document.getElementById('j_drawings').innerHTML += return_drawing_btnStr(d_id);
}
}
function add_view() {
save_view();
let view = document.getElementById('j_new_view').value;
if (view.length>9) view=view.slice(0,9);
if (view in views) {
add_view_form();
document.getElementById('modal2M').innerHTML +=
"<br><span class='text-danger font-weight-bold'>#ERROR# View Already Present!!</span>";
return;
}
views[view] = {};
document.getElementById('modal2B').style.display = 'none';
var select = document.getElementById('j_view');
select.options[select.options.length] = new Option(view,view);
//empty all fields
document.getElementById('j_view').value=view;
document.getElementById('j_title').value='';
document.getElementById('j_notes').value='';
document.getElementById('j_comments').value='';
document.getElementById('j_drawings').innerHTML='';
document.getElementById('title').innerHTML = view + '-Title';
document.getElementById('comments').innerHTML = view + '-Comments';
document.getElementById('notes').innerHTML = view + '-Notes';
document.getElementById('drawings').innerHTML = view + '-Drawings';
curr_drawing_idList = [];
}
function add_view_form() {
document.getElementById('modal2B').style.display = 'block';
document.getElementById('modal2M').innerHTML =
'<div class="h5 font-weight-bold text-black"> Adding View:</div>' +
"<input id='j_new_view' type='text' class='text-primary font-weight-bold h6'/>";
document.getElementById('modal2M').innerHTML +=
"<span class='btn btn-primary' onclick='add_view();'>Add</span>";
document.getElementById('j_new_view').value ='';
}
function return_drawing_btnStr(d_id) {
let c_btn_str = "";
c_btn_str += '<btn ';
c_btn_str += ' id="b'+d_id+'" ';
c_btn_str += ' onclick=disp_drawing(\''+d_id+'\'); ';
c_btn_str += ' class="small font-weight-bold btn-link border border-primary py-0 px-1 mx-0">';
c_btn_str += d_id;
c_btn_str += '</btn>';
c_btn_str += '<img id="del_'+d_id+'" ';
c_btn_str += ' onclick="del_drawing(\''+d_id+'\');"';
c_btn_str += ' class="ml-0 mr-1" src="images/clear.png" height="11"/></span>';
return c_btn_str;
}
// function save_drawing() {
// if (typeof drawings_arr == 'undefined') { drawings_arr=['printme']; }
// if (typeof drawings == 'undefined') { drawings={}; }
// var currentdate = new Date();
// var drawing_id = 'd'+currentdate.getHours()+currentdate.getMinutes()+currentdate.getSeconds();
// // console.log(drawing_id); // For debugging.
// drawings_arr.push(drawing_id);
// var btn_str = '<btn ';
// btn_str += ' id="b'+drawing_id+'" ';
// btn_str += ' onclick=disp_drawing(\''+drawing_id+'\'); ';
// btn_str += ' class="font-weight-bold btn-link border border-primary py-0 px-1 mx-0">';
// btn_str += drawing_id;
// // 17/1/2024 @ 10:39:55
// // var currentdate = new Date();
// // btn_str += + (currentdate.getMonth()+1) + "/" + currentdate.getFullYear() + " @ "
// // + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
// btn_str += '</btn>';
// // document.getElementById('j_view_formats').innerHTML += btn_str;
// document.getElementById('j_drawings').innerHTML += btn_str;
// save_view();
// //empty all fields
// // document.getElementById('j_title').value='';
// // document.getElementById('j_notes').value='';
// // document.getElementById('j_comments').value='';
// }
function save_view(view="") {
if (view.length==0) {
var currentdate = new Date();
view = 'v'+currentdate.getHours()+currentdate.getMinutes()+currentdate.getSeconds();
if (document.getElementById('j_view').value) {
view = document.getElementById('j_view').value;
}
}
// console.log("Saving view: " + view);
views[view] = {};
if (document.getElementById('j_notes').value) {
views[view]["j_notes"] = document.getElementById('j_notes').value;
} else { views[view]["j_notes"] = "NONE"; }
if (document.getElementById('j_title').value) {
views[view]["j_title"] = document.getElementById('j_title').value;
} else { views[view]["j_title"] = "NONE"; }
if (document.getElementById('j_comments').value) {
views[view]["j_comments"] = document.getElementById('j_comments').value;
} else { views[view]["j_comments"] = "NONE"; }
// if (document.getElementById('j_drawings').innerHTML) {
// views[view]["j_drawings"] = document.getElementById('j_drawings').innerHTML;
// } else { views[view]["j_drawings"] = ""; }
// console.log(views);
views[view]['drawing_idList'] = curr_drawing_idList;
}
// function save_view() {
// var currentdate = new Date();
// let view = 'v'+currentdate.getHours()+currentdate.getMinutes()+currentdate.getSeconds();
// if (document.getElementById('j_view').value) {
// view = document.getElementById('j_view').value;
// }
// views[view] = {};
// if (document.getElementById('j_notes').value) {
// views[view]["j_notes"] = document.getElementById('j_notes').value;
// } else { views[view]["j_notes"] = "NONE"; }
// if (document.getElementById('j_title').value) {
// views[view]["j_title"] = document.getElementById('j_title').value;
// } else { views[view]["j_title"] = "NONE"; }
// if (document.getElementById('j_comments').value) {
// views[view]["j_comments"] = document.getElementById('j_comments').value;
// } else { views[view]["j_comments"] = "NONE"; }
// views[view]["j_drawings"] = document.getElementById('j_drawings').innerHTML;
// views[view]['drawing_idList'] = curr_drawing_idList;
// // console.log(views);
// }
function del_drawing(d_id) {
let cDiv = document.getElementById('b'+ d_id);
if (cDiv) cDiv.parentNode.removeChild(cDiv);
cDiv = document.getElementById('del_'+ d_id);
if (cDiv) cDiv.parentNode.removeChild(cDiv);
delete drawings[d_id];
// console.log(drawings);
}
function save_drawing() {
if (typeof drawings_arr == 'undefined') { drawings_arr=['printme']; }
var currentdate = new Date();
var drawing_id = 'd'+currentdate.getHours()+currentdate.getMinutes()+currentdate.getSeconds();
// console.log(drawing_id); // For debugging.
drawings_arr.push(drawing_id);
var btn_str = '';
// console.log("length of drawings is " + Object.keys(drawings).length);
if (Object.keys(drawings).length>0 && Object.keys(drawings).length % 5 === 0) {
btn_str += '<br>';
// console.log(btn_str);
}
curr_drawing_idList.push(drawing_id);
document.getElementById('j_drawings').innerHTML += return_drawing_btnStr(drawing_id);
// save lines from current drawing
drawings[drawing_id] = {};
// drawings[drawing_id]['lines'] = lines;
drawings[drawing_id]['curr_layout_name'] = curr_layout_name;
drawings[drawing_id]['curr_vars'] = curr_vars;
drawings[drawing_id]['title'] = drawing_id;
drawings[drawing_id]['lines'] = structuredClone(lines);
drawings[drawing_id]['lines_by_color'] = structuredClone(lines_by_color);
//
drawings[drawing_id]["degree_of_grahas"] = degree_of_grahas;
// drawings[drawing_id]["rashiNum_asc"] = rashiNum_asc;
drawings[drawing_id]["comments"] = document.getElementById('j_comments').value;
drawings[drawing_id]["rashiNum_h1"] = {};
drawings[drawing_id]["rashiNum_asc"] = {};
drawings[drawing_id]["grahas_in_rashi"] = {};
drawings[drawing_id]["degree_of_grahas"] = {};
drawings[drawing_id]['chart_title'] = {};
// console.log(l_out);
for (xloc of l_out['locList'][curr_layout_name]) {
drawings[drawing_id]["rashiNum_h1"][xloc] =
document.getElementById('rashi_in_h1_'+xloc).innerHTML;
drawings[drawing_id]["rashiNum_asc"][xloc] = l_out[xloc]['rashiNum_asc'];
drawings[drawing_id]["grahas_in_rashi"][xloc] = l_out[xloc]["grahas_in_rashi"];
drawings[drawing_id]["degree_of_grahas"][xloc] = l_out[xloc]["degree_of_grahas"];
drawings[drawing_id]["chart_title"][xloc] = l_out[xloc]["chart_title"];
}
// console.log(curr_drawing_idList);
// console.log(drawings);
}
function save_drawing0() {
if (typeof drawings_arr == 'undefined') { drawings_arr=['printme']; }
var currentdate = new Date();
var drawing_id = 'd'+currentdate.getHours()+currentdate.getMinutes()+currentdate.getSeconds();
// console.log(drawing_id); // For debugging.
drawings_arr.push(drawing_id);
var btn_str = '';
// console.log("Hi");
// console.log("length of drawings is " + Object.keys(drawings).length);
if (Object.keys(drawings).length>0 && Object.keys(drawings).length % 5 === 0) {
btn_str += '<br>';
// console.log(btn_str);
}
// btn_str += '<btn ';
// btn_str += ' id="b'+drawing_id+'" ';
// btn_str += ' onclick=disp_drawing(\''+drawing_id+'\'); ';
// btn_str += ' class="small font-weight-bold btn-link border border-primary py-0 px-1 mx-0">';
// btn_str += drawing_id;
// // 17/1/2024 @ 10:39:55
// // var currentdate = new Date();
// // btn_str += + (currentdate.getMonth()+1) + "/" + currentdate.getFullYear() + " @ "
// // + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
// btn_str += '</btn>';
// btn_str += '<img id="del_'+drawing_id+'" ';
// btn_str += ' onclick="del_drawing(\''+drawing_id+'\');"';
// btn_str += ' class="ml-0 mr-1" src="images/clear.png" height="11"/></span>';
curr_drawing_idList.push(drawing_id);
// document.getElementById('j_view_formats').innerHTML += btn_str;
// document.getElementById('j_drawings').innerHTML += btn_str;
document.getElementById('j_drawings').innerHTML += return_drawing_btnStr(drawing_id);
// if (drawings_arr.length==2) { $('#j_view_formats').removeClass('d-none');}
// save lines from current drawing
drawings[drawing_id] = {};
// drawings[drawing_id]['lines'] = lines;
drawings[drawing_id]['curr_layout_name'] = curr_layout_name;
drawings[drawing_id]['title'] = drawing_id;
drawings[drawing_id]['lines'] = structuredClone(lines);
drawings[drawing_id]['lines_by_color'] = structuredClone(lines_by_color);
//
drawings[drawing_id]["grahas_in_rashi"] = grahas_in_rashi;
drawings[drawing_id]["degree_of_grahas"] = degree_of_grahas;
// drawings[drawing_id]["rashiNum_asc"] = rashiNum_asc;
drawings[drawing_id]["comments"] = document.getElementById('j_comments').value;
drawings[drawing_id]["rashiNum_h1"] = {};
drawings[drawing_id]["rashiNum_asc"] = {};
for (xloc of l_out['locList'][curr_layout_name]) {
drawings[drawing_id]["rashiNum_h1"][xloc] =
document.getElementById('rashi_in_h1_'+xloc).innerHTML;
drawings[drawing_id]["rashiNum_asc"][xloc] = l_out[xloc]['rashiNum_asc'];
}
// console.log(drawings);
// console.log(curr_drawing_idList);
}
function undo_stroke(){
clear_canvas();
// console.log(lines);
lines = lines.slice(0,-2)
lines_by_color = lines_by_color.slice(0,-2)
// const index = array.indexOf(lines.length);
// if (index > -1) {
// array.splice(index, 1); // 1 means remove one item only
// }
// console.log(lines);
draw_saved_strokes();
// console.log("just popped");
}
function draw_saved_strokes() {
if (lines_by_color.length>0) {
let old_xcoord = 0;
let old_ycoord=0; let strokeColor='red';
let c_canvas_height = 0; let c_canvas_width=0;
for (c_line in lines_by_color) {
strokeColor=lines_by_color[c_line]['color'];
strokeColor=lines_by_color[c_line]['color'];
c_canvas_height=lines_by_color[c_line]['canvas_dims'][0];
c_canvas_width=lines_by_color[c_line]['canvas_dims'][1];
y_ratio = canvas.width/c_canvas_width;
x_ratio = canvas.height/c_canvas_height;
if (lines_by_color[c_line]['coords'].length==0) continue;
old_xcoord = Math.floor(lines_by_color[c_line]['coords'][0][0] * x_ratio);
old_ycoord = Math.floor(lines_by_color[c_line]['coords'][0][1] * y_ratio);
for (let e=1;e<lines_by_color[c_line]['coords'].length;e++) {
// console.log(e);
new_xcoord = Math.floor(lines_by_color[c_line]['coords'][e][0] * x_ratio);
new_ycoord = Math.floor(lines_by_color[c_line]['coords'][e][1] * y_ratio);
ctx.beginPath();
// getPosition(event);
ctx.lineWidth = 5;
ctx.lineCap = 'round';
ctx.strokeStyle = strokeColor;
ctx.moveTo(old_xcoord, old_ycoord);
ctx.lineTo(new_xcoord, new_ycoord);
ctx.stroke();
old_xcoord = new_xcoord;
old_ycoord = new_ycoord;
}
}
}
}
function draw_saved_strokes1() {
// version 1 using efficient code - but still no color
if (lines.length>0) {
let old_xcoord = 0; let old_ycoord=0;
for (c_line in lines) {
old_xcoord = lines[c_line][0][0];
old_ycoord = lines[c_line][0][1];
for (let e=1;e<lines[c_line].length;e++) {
// console.log(e);
new_xcoord = lines[c_line][e][0];
new_ycoord = lines[c_line][e][1];
ctx.beginPath();
// getPosition(event);
ctx.lineWidth = 5;
ctx.lineCap = 'round';
ctx.strokeStyle = strokeColor;
ctx.moveTo(old_xcoord, old_ycoord);
ctx.lineTo(new_xcoord, new_ycoord);
ctx.stroke();
old_xcoord = new_xcoord;
old_ycoord = new_ycoord;
}
}
}
}
function draw_saved_strokes0() {
// version 0 using less efficient code
if (lines.length>0) {
let old_xcoord = 0; let old_ycoord=0;
for (c_line in lines) {
// console.log(lines[c_line]);
for (e in lines[c_line]) {
// console.log(e);
new_xcoord = lines[c_line][e][0];
new_ycoord = lines[c_line][e][1];
// console.log("new_xcoord " + new_xcoord + " new_ycoord " + new_ycoord);
ctx.beginPath();
// getPosition(event);
ctx.lineWidth = 5;
ctx.lineCap = 'round';
ctx.strokeStyle = strokeColor;
if (old_xcoord==0) {
old_xcoord = new_xcoord;
old_ycoord = new_ycoord;
}
ctx.moveTo(old_xcoord, old_ycoord);
ctx.lineTo(new_xcoord, new_ycoord);
ctx.stroke();
old_xcoord = new_xcoord;
old_ycoord = new_ycoord;
}
old_xcoord = 0; old_ycoord=0;
}
}
}
function update_obs_title(d_id) {
document.getElementById('modal2B').style.display = 'none';
drawings[d_id]['title'] = document.getElementById('new_obs_title').value;
document.getElementById('j_comm_title').innerHTML = document.getElementById('new_obs_title').value;
}
function obs_update_title_form(d_id) {
document.getElementById('modal2B').style.display = 'block';
// document.getElementById('modal2M').innerHTML = '<div class="h5 font-weight-bold text-black"> Rename Observation Title:</div>';
// document.getElementById('modal2M').innerHTML += '<input id="new_obs_title" type="text" value="'+ d_id +'" ';
// document.getElementById('modal2M').innerHTML += ' class="text-primary font-weight-bold h6"/>';
document.getElementById('modal2M').innerHTML = '<div class="h5 font-weight-bold text-black"> Rename Observation Title:</div>';
document.getElementById('modal2M').innerHTML += '<input id="new_obs_title" type="text" value="'+ drawings[d_id]['title'] +'" class="text-primary font-weight-bold h6"/>';
document.getElementById('modal2M').innerHTML += '<span class="btn btn-primary" onclick="update_obs_title(\''+d_id +'\');">Update</span>';
}
function disp_layout(l_view="") {
if (l_view.length==0) { l_view=curr_layout_name; }
// console.log(l_view + " is now l_view");
if (l_view==='1x1') { view_1x1(); }
if (l_view==='1x2') { view_1x2(); }
if (l_view==='2x2') { view_2x2(); }
}
function disp_drawing(c_drawing_id){
let l_data = drawings[c_drawing_id];
if ("curr_layout_name" in l_data) {
curr_layout_name = l_data["curr_layout_name"];
}
if ("rashiNum_asc" in l_data) {
for (xloc of l_out['locList'][curr_layout_name]) {
l_out[xloc]['rashiNum_asc'] = drawings[c_drawing_id]["rashiNum_asc"][xloc];
}
}
if ("title" in l_data) {
document.getElementById('j_comm_title').innerHTML = l_data["title"];
btn_str = '<img ';
btn_str += ' onclick="obs_update_title_form(\''+c_drawing_id+'\');" ';
btn_str += ' class="ml-0 mr-1" src="images/edit.png" height="11"/>';
document.getElementById('j_comm_title').innerHTML += btn_str;
} else {
drawings[c_drawing_id]["title"] = c_drawing_id;
btn_str = '<img ';
btn_str += ' onclick="obs_update_title_form(\''+c_drawing_id+'\');" ';
btn_str += ' class="ml-0 mr-1" src="images/edit.png" height="11"/>';
document.getElementById('j_comm_title').innerHTML += btn_str;
}
if ("comments" in l_data) {
document.getElementById('j_comments').value = l_data["comments"];
}
if ("rashiNum_h1" in l_data) {
for (xloc of l_out['locList'][curr_layout_name]) {
l_out[xloc]['rashiNum_h1'] = drawings[c_drawing_id]["rashiNum_h1"][xloc];
}
}
if ("retro_planet_list" in l_data) {
retro_planet_list = l_data["retro_planet_list"];
}
// let grahas_in_rashi = {}
if ("degree_of_grahas" in l_data) {
// degree_of_grahas = l_data["degree_of_grahas"];
for (xloc of l_out['locList'][curr_layout_name]) {
l_out[xloc]['degree_of_grahas'] = drawings[c_drawing_id]["degree_of_grahas"][xloc];
}
}
if ("chart_title" in l_data) {
// console.log("chart_title is " + chart_title);
for (xloc of l_out['locList'][curr_layout_name]) {
l_out[xloc]['chart_title'] = drawings[c_drawing_id]["chart_title"][xloc];
create_chart_title_div(xloc);
}
}
if ("grahas_in_rashi" in l_data) {
for (xloc of l_out['locList'][curr_layout_name]) {
l_out[xloc]['grahas_in_rashi'] = drawings[c_drawing_id]["grahas_in_rashi"][xloc];
}
}
if ("lines_by_color" in l_data) {
// lines_by_color = l_data['lines_by_color'];
// lines_by_color = Object.assign({}, l_data['lines_by_color']);
lines_by_color = JSON.parse(JSON.stringify(l_data['lines_by_color']));
clear_canvas();
// redraw the lines from memory
draw_saved_strokes();
}
$('#bprintme').removeClass('bg-warning');
for (p in drawings) {
// $('#'+p).addClass('d-none');
$('#b'+p).removeClass('bg-warning');
}
// $('#'+c_drawing_id).removeClass('d-none');
$('#b'+c_drawing_id).addClass('bg-warning');
disp_layout(curr_layout_name);
//
if ("curr_vars" in l_data) {
curr_vars = l_data["curr_vars"];
deploy_curr_vars();
}
}
function change_ascendant(new_asc) {
// update rashiNum_asc in divisional_data['d1']
// console.log(new_asc);
divisional_data['d1']['rashiNum_asc'] = new_asc.toString();
place_rashi_num_in_houses(new_asc.toString());
// populate_graha_in_rashi();
calc_all_divisional();
view_d1('00');
}
function display_all_graha_degree(loc) {
if (loc.length==0) { loc='00';}
var c_dog = l_out[loc]['degree_of_grahas'];
// "degree_of_grahas": { "La": [ "15", "58", "37.09" ]} deg,min,sec
//
for (const c_gr in c_dog) {
document.getElementById(c_gr.toLowerCase()+'_deg_'+loc).value =
c_dog[c_gr][0];
document.getElementById(c_gr.toLowerCase()+'_min_'+loc).value =
c_dog[c_gr][1];
document.getElementById(c_gr.toLowerCase()+'_sec_'+loc).value =
c_dog[c_gr][2];
}
}
function display_saved_degree(c_dog={}) {
// console.log(c_dog);
let d1_data=0;
if (Object.keys(c_dog).length==0) {
c_dog=degree_of_grahas;
d1_data=1;
}
// console.log(d1_data);
for (const c_gr in c_dog) {
document.getElementById(c_gr.toLowerCase()+'_deg').value =
c_dog[c_gr][0];
document.getElementById(c_gr.toLowerCase()+'_min').value =
c_dog[c_gr][1];
document.getElementById(c_gr.toLowerCase()+'_sec').value =
c_dog[c_gr][2];
}
// now populate grahas where they belong
if (d1_data==1) populate_graha_in_rashi();
}
function populate_all_ggraha_in_rashi(gchar_idx) {
// console.log(gochar_data);
// if (loc.length==0) { loc='00';}
const all_gr = ["Su","Ju","Sa","Me","Ra","Ke","Mo","Ma","Ve"];
var gc_grahas_in_rashi = {};
var gc_retro_list=[];
for (let r=1; r<=12; r++) gc_grahas_in_rashi[r]=[];
for (c_gr of all_gr) {
c_rashi = gochar_data[gchar_idx][c_gr]["rashi"];
c_retro = gochar_data[gchar_idx][c_gr]["retro"];
gc_grahas_in_rashi[c_rashi].push(c_gr);
if (parseInt(c_retro)==1) gc_retro_list.push(c_gr);
}
// console.log("gc_grahas_in_rashi");
// console.log(gc_grahas_in_rashi);
// console.log("gc_retro_list");
// console.log(gc_retro_list);
for (xloc of l_out['locList'][curr_layout_name]) {
for (let house=1; house<=12; house++) {
// empty graha from house innerHTML
rashiIdSuffix = house.toString() + "_" + xloc;
document.getElementById('gh'+ rashiIdSuffix).innerHTML = '';
}
for (let house=1; house<=12; house++) {
// get rashi in the house
rashiIdSuffix = house.toString() + "_" + xloc;
house_rashi = document.getElementById('rashi_in_h'+ rashiIdSuffix).innerHTML;
// if ASC mark it so
for ( graha of gc_grahas_in_rashi[house_rashi.toString()]) {
document.getElementById('gh'+ rashiIdSuffix).innerHTML +=
'<span class="border border-danger text-primary font-weight-bold">'+graha + '</span>';
if (graha=='Ra' || graha=='Ke') continue;
if (gc_retro_list.includes(graha))
document.getElementById('gh'+ rashiIdSuffix).innerHTML += "<span class='small'>(R)</span>";
document.getElementById('gh'+ rashiIdSuffix).innerHTML += " ";
// if (retro_planet_list.includes(graha))
// document.getElementById('h'+ rashiIdSuffix).innerHTML +=
// "<span id='sa_retro' class='h6 text-danger border-danger'>(R)</span>";
}
}
}
// console.log('about to create gchar_title');
remove_gchar_title();
create_gchar_title_div(gochar_data[gchar_idx]["g_event"]);
curr_vars['curr_gchar_idx'] = gchar_idx;
}
function populate_all_graha_in_rashi(loc="") {
// console.log("populate_all_graha_in_rashi - l_out");
// console.log(l_out);
if (loc.length==0) { loc='00';}
var c_arn = l_out[loc]['rashiNum_asc'];
var c_gir = l_out[loc]['grahas_in_rashi'];
var c_dog = l_out[loc]['degree_of_grahas'];
var ketu_rashiIdSuffix = '';
//
var rashiIdSuffix = "";
for (let house=1; house<=12; house++) {
// empty graha from house innerHTML
rashiIdSuffix = house.toString() + "_" + loc;
document.getElementById('h'+ rashiIdSuffix).innerHTML = '';
}
for (let house=1; house<=12; house++) {
// get rashi in the house
rashiIdSuffix = house.toString() + "_" + loc;
// c_dog = {};
house_rashi = document.getElementById('rashi_in_h'+ rashiIdSuffix).innerHTML;
// if ASC mark it so
if (house_rashi==c_arn.toString())
document.getElementById('h'+ rashiIdSuffix).innerHTML += generate_string_gr_deg('La',loc);
if (typeof c_gir[house_rashi.toString()]!== 'undefined') {
for ( graha of c_gir[house_rashi.toString()]) {
if (graha=='Ke') { continue; }
if (graha=='La') { continue; }
document.getElementById('h'+ rashiIdSuffix).innerHTML += generate_string_gr_deg(graha,loc);
if (retro_planet_list.includes(graha))
document.getElementById('h'+ rashiIdSuffix).innerHTML +=
"<span id='sa_retro' class='h6 text-danger border-danger'>(R)</span>";
// get Ke also displayed
if (graha=='Ra') {
ketu_house = (parseInt(house)+6)%12; if (ketu_house==0) { ketu_house=12;}
ketu_rashiIdSuffix = ketu_house.toString() + "_" + loc;
document.getElementById('h'+ketu_rashiIdSuffix).innerHTML +=
generate_string_gr_deg('Ke',loc);
}
}
}
}
}
function populate_graha_in_rashi(c_arn="",c_gir={},c_dog={},loc="") {
//
if (c_arn.length==0) c_arn = rashiNum_asc.toString();
if (Object.keys(c_gir).length==0) c_gir = grahas_in_rashi;
if (Object.keys(c_dog).length==0) c_dog=degree_of_grahas;
// console.log(c_gir);
//
var rashiIdSuffix = "";
for (let house=1; house<=12; house++) {
// get rashi in the house
if (loc.length==0) { loc='00';}
if (loc.length==0) {
rashiIdSuffix = house.toString();
} else {
rashiIdSuffix = house.toString() + "_" + loc;
c_dog = {};
}
house_rashi = document.getElementById('rashi_in_h'+ rashiIdSuffix).innerHTML;
// empty graha from house innerHTML
document.getElementById('h'+ rashiIdSuffix).innerHTML = '';
// if ASC mark it so
// if (house_rashi==rashiNum_asc.toString())
// document.getElementById('h'+ rashiIdSuffix).innerHTML += '<br><b>ASC</b>';
if (house_rashi==c_arn.toString())
document.getElementById('h'+ rashiIdSuffix).innerHTML += format_graha('La',c_dog);
if (typeof c_gir[house_rashi.toString()]!== 'undefined') {
for ( graha of c_gir[house_rashi.toString()]) {
if (graha=='La') { continue; }
document.getElementById('h'+ rashiIdSuffix).innerHTML += format_graha(graha,c_dog);
if (retro_planet_list.includes(graha))
document.getElementById('h'+ rashiIdSuffix).innerHTML +=
"<span id='sa_retro' class='h6 text-danger border-danger'>(R)</span>";
}
}
// restore the graha font size if it was changed
var inputs = document.getElementsByClassName('graha');
for (x = 0 ; x < inputs.length ; x++){
if (inputs[x].id in font_size)
if (loc.length>0) {
inputs[x].style.fontSize = (parseFloat(inputs[x].style.fontSize)- 10) + '%';
} else {
inputs[x].style.fontSize = font_size[inputs[x].id];
}
}
}
}
function place_graha_in_house(graha,house) {
// graha:Su house;h3 <-- need to strip the "h" from the house
// console.log("graha: " + graha + " House: " + house.substring(1));
if (typeof grahas_in_rashi == 'undefined') {
grahas_in_rashi={};
for (let i=1; i<=12; i++) { grahas_in_rashi[i.toString()] = []; }
}
if (typeof divisional_data['d1'] === 'undefined') { divisional_data['d1'] = {}; }
if (!('grahas_in_rashi' in divisional_data['d1'])) {
// console.log("Initializing divisional_data d1 grahas_in_rashi");
divisional_data['d1']['grahas_in_rashi']={};
}
if (!(graha in divisional_data['d1']['degree_of_grahas'])) {
// console.log("Initializing divisional_data d1 degree_of_grahas for graha: " + graha);
divisional_data['d1']['degree_of_grahas'][graha]=[];
}
// console.log(grahas_in_rashi);
// find rashi of the house
rashiNum_h1= divisional_data['d1']['rashiNum_h1'];
c_rashi=((parseInt(rashiNum_h1)+parseInt(house.substring(1))-1)%12);
if (c_rashi==0) { c_rashi=12;}
if (!(c_rashi.toString() in divisional_data['d1']['grahas_in_rashi'])) {
// console.log("Initializing divisional_data d1 grahas_in_rashi for rashi: " + c_rashi.toString());
divisional_data['d1']['grahas_in_rashi'][c_rashi.toString()]=[];
}
// make sure graha exists in just one house
for (let i=1; i<=12; i++) {
if (i.toString() in divisional_data['d1']['grahas_in_rashi']) {
if (divisional_data['d1']['grahas_in_rashi'][i.toString()].includes(graha)) {
// unconditionally remove
const g_idx = divisional_data['d1']['grahas_in_rashi'][i.toString()].indexOf(graha);
// console.log("About to delete idx: " + g_idx + " for rashi " + i.toString());
const x1 = divisional_data['d1']['grahas_in_rashi'][i.toString()].splice(g_idx,1);
}
}
}
divisional_data['d1']['grahas_in_rashi'][c_rashi.toString()].push(graha);
grahas_in_rashi = divisional_data['d1']['grahas_in_rashi'];
populate_all_graha_in_rashi();
}
function save_details() {
save_view();
const saveMe = {};
saveMe["rashiNum_asc"] = rashiNum_asc.toString();
saveMe["divisional_data"] = divisional_data;
saveMe["l_out"] = l_out;
saveMe["gochar_data"] = gochar_data;
// saveMe["rashiNum_h1"] = document.getElementById('rashi_in_h1').innerHTML;
//
saveMe["grahas_in_rashi"] = grahas_in_rashi;
saveMe["degree_of_grahas"] = degree_of_grahas;
saveMe["views"] = views;