forked from KwickerHub/WebCraftifyAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui_dashboard.html
2370 lines (2076 loc) · 78.5 KB
/
ui_dashboard.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- fontawesome cdn -->
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<meta name="description" id ="meta_description" content="Bridging the gap between frontend Developemnt and UI/UX Designs. Introducing the concept of Visual Programming: design and build your website here"/>
<meta name="keywords" content="Create UI/UX Designs, Make Mock-ups, Create Designs, Make Mobile Designs "/>
<link rel='shortcut icon' type='image/x-icon' href='../assets/img/brand_kwickerhub/g83.png' />
<title> Make UI/UX Designs</title>
<script type="text/javascript" src="../assets/vendor/js/access_library.js"></script>
<script type="text/javascript" src="../assets/vendor/js/ui_dashboard.js"></script>
<script type="text/javascript">
/*global height = $("attr_height");
global width = $("attr_width");
global background = $("back_color");*/
var selectedId = 'the_design_dashboard';
var selectedElement;
var pointerX = -1;
var pointerY = -1;
var pointer_elemX = -1;
var pointer_elemY = -1;
var theMouseMode = 0;
// 0 is normal
// 1 is grab/move
// 2 is scale/transform
// 3 is font arena/mode
// window.onload = function(){
// setup();
// alert(document.readyState);
// }
//$(document).ready(setup());
// var the_setuptimer_2 = setInterval(() => {
// if(document.readyState == "complete"){
// main('the_dev_dashboard'); clearInterval(the_setuptimer_2);
// }
// }, 1000);
// var the_setuptimer_2 = setInterval(() => {
// if(document.readyState == "complete"){
// loadSaveContent(); clearInterval(the_setuptimer_2);
// }
// }, 1200);
// var the_setuptimer_3 = setInterval(() => {
// if(document.readyState == "complete"){
// loadElements();; clearInterval(the_setuptimer_3);
// }
// }, 1300);
// var the_setuptimer_4 = setInterval(() => {
// if(document.readyState == "complete"){
// load_Adder_maker('element'); clearInterval(the_setuptimer_4);
// }
// }, 1400);
// var the_setuptimer_5 = setInterval(() => {
// if(document.readyState == "complete"){
// loadAllSides("Style"); clearInterval(the_setuptimer_5);
// }
// }, 1500);
// window.addEventListener("load",function(event) {
// var $input2 = document.getElementById('dec');
// var $input1 = document.getElementById('parenta');
// $input1.addEventListener('keyup', function() {
// $input2.value = $input1.value;
// });
// },false);
//window.addEventListener("load", function(event){main('the_dev_dashboard');}, false);
//window.addEventListener("load", function(event){loadSaveContent();}, false);
//window.addEventListener("load", function(event){setup();}, false);
//window.addEventListener("load", function(event){load_Adder_maker('element');}, false);
//window.addEventListener("load", function(event){loadAllSides("Style");}, false);
function setup(){
// This is the set-up function where all the required components or required data will
// be loaded.
// Same/in the likeness of the function main('the_dev_dashboard'); -- Start
// -- End
// Same/in the likeness of the function loadSaveContent(); -- Start
// -- End
// Same/in the likeness of the function loadElements(); -- Start
// -- End
// Same/in the likeness of the function load_Adder_maker('element'); -- Start
// -- End
// Same/in the likeness of the function loadAllSides("Style"); -- Start
// -- End
}
//window.onload = loadSaveContent();
// window.onload = loadElements();
//window.onload = load_Adder_maker('element');
function main(id){
selectedElement = document.querySelector('#'+id);
selectedId = id;
};
function changeMode(mode){
theMouseMode = mode;
}
//global selectedElement = '#the_dev_dashboard';
function add_element_2_dashboard (tag_name,type, preference_override) {
//specs.element.setAttribute(attribute, value);
//selectedId = "the_design_dashboard";
var newElem = document.createElement(tag_name);
if (preference_override) {
if ( document.getElementById("create_children").checked == true) {
newElem = document.createElement("div");
}else{
newElem = document.createElement("span");
selectedId = "the_design_dashboard";
}
}
//height = ($("#style_height").val() != "") ? $("#style_height").val() : "120px";
//width = ($("#style_width").val() != "") ? $("#style_width").val() : "120px";
//background = ($("#style_background-color").val() != "") ? $("#back_color").val() : "#fed342";
//ondragstart="" draggable="true" style="height: 120px; width: 120px; background-color: blue; position: absolute;"
height = document.getElementById("settings_height").value + document.getElementById("settings_size_representation").value;
width = document.getElementById("settings_width").value + document.getElementById("settings_size_representation").value;
radius = document.getElementById("settings_diameter").value + document.getElementById("settings_size_representation").value;
font_size = document.getElementById("settings_font_size").value + document.getElementById("settings_size_representation").value;
//image_blob = document.getElementById("settings_image").files[0];
image_path = document.getElementById("settings_image").value;
background = colorCodeGenetor(6);
defaultStyle = "";
if (type === 'text'){
newElem.innerHTML = "Hello World. ABC ";
defaultStyle += 'height: '+ height + '; width: '+ width + '; font-size: '+ font_size + ';';
document.getElementById("the_fonts_subsection").scrollIntoView();
} else if (type === 'image') {
/* if (image_blob.length() > 0){
let reader = new FileReader();
reader.onload = function (fileEvent) {
newElem.innerHTML = "<img width=\"" + width + "\" height=" + height + " src=\"" + fileEvent.srcElement.result + "\"/>";
}
reader.readAsDataURL(image_blob);
} else {
alert("The default image was not selected");
} */
if(image_path.length > 0){
newElem = document.createElement("img");
newElem.setAttribute("src", image_path);
defaultStyle += 'height: '+ height + '; width: '+ width + ';';
document.getElementById("the_image_subsection").scrollIntoView();
}else{
alert("The default image was not selected");
}
} else if (type === 'circle'){
defaultStyle += 'border-radius: 50%;' + 'height: '+ radius + '; width: '+ radius + ';';
} else {
defaultStyle += 'height: '+ height + '; width: '+ width + ';';
}
if (document.getElementById("settings_background").checked) {
defaultStyle +='background-color: ' + background + '; position: absolute; right: 45%, left: 45%;';
}
elemId = generate_strings_id(7);
//console.log(elemId);
newElem.setAttribute("style", defaultStyle);
newElem.setAttribute("id", elemId);
newElem.setAttribute("draggable", "true");
newElem.setAttribute("ondragstart", "elem_drag(event, 'span')");
newElem.setAttribute("onmouseenter", "mouseEnterMe(event)");
newElem.setAttribute("onmouseleave", "mouseLeaveMe(event)");
newElem.setAttribute("ondblclick", "change_selected(event, "+ "'"+tag_name+"' , "+ "'"+elemId+"'"+ ")" );
//var ref = document.querySelector('#the_dev_dashboard');
selectedElement = document.getElementById(selectedId);
var ref = selectedElement;
home_msg = ref.textContent;
//alert("flow o");
//alert(home_msg.indexOf("This is the main dashboard arena"));
if ( home_msg.indexOf("This is the main dashboard arena") > -1 ) {
//ref.innerHTML = document.createElement(tag_name).toString();
//var content = '<' + tag_name + ' id="'+elemId+'" ondblclick="change_selected(event, "'+tag_name+'", "'+elemId+'" ) style= "height: '+ height + '; width: '+ width + '; background-color: ' + background + ' ;"' + '></' + tag_name + '>';
/*'<' + tag_name + ' ondblclick="change_selected(event,'+ '"'+tag_name+'"' , '"'+elemId+'"' +') id="'+elemId+'" style= "height: '+ height + '; width: '+ width + '; background-color: ' + background + ' ;"' + '></' + tag_name + '>';*/
ref.innerHTML = "";
proper_fitting = "\n" + "\t";
//alert( document.getElementById('the_dev_dashboard').compareDocumentPosition(ref) );
ref.append(proper_fitting);
ref.appendChild(newElem, ref);
getElementStyleDetails(elemId);
getElementAttrDetails(elemId);
getElementInnerHTML(elemId);
selectCreated(elemId, tag_name);
}else{
proper_fitting = "\n" + "\t";
ref.append(proper_fitting);
//alert( document.getElementById('the_dev_dashboard').compareDocumentPosition(ref) );
ref.appendChild(newElem, ref);
getElementStyleDetails(elemId);
getElementAttrDetails(elemId);
getElementInnerHTML(elemId);
selectCreated(elemId, tag_name);
showPopUpById("the_ui_style_bar");
}
//ref.appendChild(newElem, ref);
}
function selectCreated(id, type){
selectedId = id;
selectedElement = document.getElementById(id);
//$("#the_selected_elem_left").text(type + ' - #' + id + ' : Selected');
//$("#the_style_identity_box").text(type + ' - #' + id + ' : Selected');
}
function generate_strings_id(length){
var alhpa_lets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x','y', 'z'];
var code = '';
for (var i=0; i < length; i++) {
if(i==0){
code = code + alhpa_lets[Math.floor(Math.random() * alhpa_lets.length )];
}
else if (Math.floor(Math.random() * 2) == 1) {
code = code + Math.floor(Math.random() * 10 ).toString();
}else{
code = code + alhpa_lets[Math.floor(Math.random() * alhpa_lets.length )];
}
}
return code;
}
function colorCodeGenetor(length){
alhpa_lets = ['a', 'b', 'c', 'd', 'e', 'f'];
code = '';
for (i=0; i < length; i++) {
if (Math.floor(Math.random() * 2) == 1) {
code = code + Math.floor(Math.random() * 10 ).toString();
}else{
//alhpa_lets.g
code = code + alhpa_lets[Math.floor(Math.random() * alhpa_lets.length )];
}
}
return "#"+code;
}
function elem_allowDrop(ev){
ev.preventDefault();
}
function elem_drag(ev, tag){
//alert(e.target.id);
//ev.dataTransfer.setData("text", ev.target.id);
ev.dataTransfer.setData("ui_content", ev.target.id);
elem = ev.target;
//pointerX = ev.clientX;
//pointerY = ev.clientY;
// valueX = elem.style.width + 0.2;
// valueY = elem.style.height + 0.2;
// elem.style.transform = "scale("+valueX+", "+valueY+")";
pointer_elemX = ev.clientX;
pointer_elemY = ev.clientY;
//alert(elem.offsetTop);
}
function elem_drop(ev){
//alert("done");
ev.preventDefault();
if(theMouseMode == 0){
var tag_id = ev.dataTransfer.getData("ui_content");
var tag = document.getElementById(tag_id);
chipAddonX = pointer_elemX - tag.offsetLeft;
chipAddonY = pointer_elemY - tag.offsetTop;
var new_posX = ev.clientX - chipAddonX;
var new_posY = ev.clientY - chipAddonY;
//alert([tag.offsetLeft, tag.offsetTop, pointer_elemX, pointer_elemY, chipAddonX, new_posX, new_posY]);
//style = 'height: 120px; width: 120px; background-color: blue; position: absolute; left: '+ new_posX + 'px; top: ' + new_posY + 'px; ';
//tag.setAttribute("style", style);
tag.style.left = new_posX + "px";
tag.style.top = new_posY+ "px";
}else if(theMouseMode == 1){
var tag_id = ev.dataTransfer.getData("ui_content");
var tag = document.getElementById(tag_id);
var chipAddonX = tag.offsetLeft+ parseFloat(tag.style.width) - pointer_elemX;
var chipAddonY = tag.offsetTop+ parseFloat(tag.style.height) - pointer_elemY;
//pointer_elemY
var new_posX = ev.clientX - tag.offsetLeft + chipAddonX;
var new_posY = ev.clientY - tag.offsetTop + chipAddonY;
tag.style.height = new_posY + "px";
tag.style.width = new_posX + "px";
}
}
function mouseEnterMe(ev){
if(theMouseMode == 0){
//grab/drag/move
elem = ev.target;
elem.style.cursor = 'grab';
//grab, copy, grabbing, move, default, zoom-in
}else if(theMouseMode == 1){
//Scale mode
elem = ev.target;
elem.style.border = '1px dashed white';
elem.style.boxShadow = '2px 2px 1px green';
}
}
function mouseLeaveMe(ev){
if(theMouseMode == 0){
//grab/drag/move
elem = ev.target;
elem.style.cursor = 'default';
}else if(theMouseMode == 1){
//Scale mode
elem = ev.target;
elem.style.border = 'none';
elem.style.boxShadow = 'none';
}
}
function change_selected(e, type, id){
if(e.target.id == id){
selectedId = id;
selectedElement = document.getElementById(id);
//$("#the_selected_elem_left").text(type + ' - #' + id + ' : Selected');
$("#the_style_identity_box").text(type + ' - #' + id + ' : Selected');
getElementStyleDetails(selectedId);
getElementInnerHTML(selectedId);
//getElementAttrDetails(selectedId);
}
}
// function attr_changed(attribute){
// var statusId = "attr_"+attribute+"_status";
// var attrValue = "attr_"+attribute;
// if ( document.getElementById(statusId).checked == true) {
// var newValue = document.getElementById(attrValue).value;
// //alert(newValue);
// if (newValue != null || newValue !="") {
// document.getElementById(selectedId).setAttribute(attribute, newValue);
// }else{
// document.getElementById(selectedId).removeAttribute(attribute);
// }
// }else{
// var newValue = null;
// document.getElementById(selectedId).removeAttribute(attribute);
// }
// }
function style_changed(property){
var statusId = "style_"+property+"_status";
var propertyValue = "style_"+property;
if ( document.getElementById(statusId).checked == true) {
var newValue = document.getElementById(propertyValue).value;
if (newValue != null || newValue !="") {
//document.getElementById(selectedId).style.property = newValue;
document.getElementById(selectedId).style.cssText += property + ":" + newValue + ";";
}else{
document.getElementById(selectedId).style.removeProperty(property);
}
}else{
var newValue = null;
//document.getElementById(selectedId).style.height = null;
document.getElementById(selectedId).style.removeProperty(property);
}
}
function inner_changed(property){
var statusId = "inner_"+property+"_status";
var textValue = "inner_"+property;
if ( document.getElementById(statusId).checked == true) {
var newValue = document.getElementById(textValue).value;
if (newValue != null || newValue !="") {
//document.getElementById(selectedId).style.property = newValue;
document.getElementById(selectedId).innerHTML = newValue;
}else{
//document.getElementById(selectedId).style.removeProperty(property);
document.getElementById(selectedId).innerHTML = "";
}
}else{
document.getElementById(selectedId).innerHTML = null;
}
}
function getElementStyleDetails(elem_id){
elem = document.getElementById(elem_id);
if (!elem) return []; // Element does not exist, empty list.
var win = document.defaultView || window, style, styleNode = [];
if (win.getComputedStyle) { // Modern browsers
style = win.getComputedStyle(elem, '');
for (var i=0; i<style.length; i++) {
propertyDis = "style_" + style[i].toString();
property = document.getElementById(propertyDis);
if ( property ){
if (style[i].includes("color")) {
//console.log("color is: " + style.getPropertyValue(style[i]).toString() + "converted: "+ rgbToHex(style.getPropertyValue(style[i]).toString()));
property.value = rgbToHex(style.getPropertyValue(style[i]));
}else{
property.value = style.getPropertyValue(style[i]);
}
}
}
} else if (elem.currentStyle) { // IE
style = elem.currentStyle;
for (var name in style) {
propertyDis = "style_" + name;
property = document.getElementById(propertyDis);
if ( !property ){
//property.value = style[name];
if (style[name].includes("color")) {
//console.log("color is: " + style.getPropertyValue(style[i]).toString() + "converted: "+ rgbToHex(style.getPropertyValue(style[i]).toString()));
property.value = rgbToHex(style.getPropertyValue(style[name]));
}else{
property.value = style.getPropertyValue(style[name]);
}
}
}
} else { // Ancient browser..
style = elem.style;
for (var i=0; i<style.length; i++) {
propertyDis = "style_" + style[i].toString();
property = document.getElementById(propertyDis);
if ( !property ){
//property.value = style[style[i]];
if (style[style[i]].includes("color")) {
//console.log("color is: " + style.getPropertyValue(style[i]).toString() + "converted: "+ rgbToHex(style.getPropertyValue(style[i]).toString()));
property.value = rgbToHex(style.getPropertyValue(style[style[i]]));
}else{
property.value = style.getPropertyValue(style[style[i]]);
}
}
}
}
}
function getElementInnerHTML(elem_id){
elem = document.getElementById(elem_id);
name = "font-text";
innerDis = "inner_" + name;
property = document.getElementById(innerDis);
property.value = elem.innerHTML;
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(rgbColor) {
individual_code = rgbColor.replace(/[rgb() ]/g, "");
individual_code = individual_code.split(",");
r = parseInt(individual_code[0].trim()), g = parseInt(individual_code[1].trim()); b = parseInt(individual_code[2].trim());
//console.log(individual_code + g);
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function getElementAttrDetails(elem_id){
el = document.getElementById(elem_id);
var nodes=[], values=[];
for (var att, i = 0, atts = el.attributes, n = atts.length; i < n; i++){
attrDis = "attr_" + atts[i].nodeName.toString();
attributeArea = document.getElementById(attrDis);
if ( attributeArea ){
if(atts[i].nodeValue != null){
attributeArea.value = atts[i].nodeValue;
}else{
attributeArea.value = null;
}
}
}
}
/* <div id="create_project_pop" class="theTextPopUp">
<input type="text" id="the_project_name" name="theTextSide">
<br/>
<button onclick="">Create</button>
<br/><br/>
</div> */
function newProject(){
//$("create_project_pop", "id").fadeIn();
document.getElementById("create_project_pop").style.display = "block";
}
function contains_special_char(str){
regex = "!@#$%^&*()_+\-=\[\]{};':\"\\|,.<>\/?]"
ret = false;
array = regex.split("");
for (let index = 0; index < array.length; index++) {
const element = array[index];
if ( str.includes(element) ){
ret = true;
//alert("Please remove this character:" + element + "from the project name")
break;
}
}
return ret;
}
function makeTheProject(){
var projectName = document.getElementById("the_project_name").value;
var currentPage = window.location.href;
//projectName = projectName.replace(/ /g, "_").toString();
//alert(projectName);
if(contains_special_char(projectName)){
alert("Project name should not include any of the special characters: "+ "!@#$%^&*()_+\-=\[\]{};':\"\\|,.<>\/?]");
}else{
projectName = projectName.replace(/ /g, "_").toString();
//alert(projectName);
if (currentPage.includes("?project_title=")){
saveDevArena();
}else{
var cvalue = document.getElementById("the_dev_dashboard").innerHTML;
var project_description = document.getElementById("the_project_description").value;
value = save_file(projectName, cvalue, project_description, "new");
}
}
}
function bringText(){
var alreadyThere = document.getElementById(selectedId).textContent;
if (alreadyThere != "") {
document.getElementById("theTextPop").value = alreadyThere;
}
/* if (document.getElementById("text_pop_up_side").style.display = "block") {
document.getElementById("text_pop_up_side").style.display = "none"
}else{
document.getElementById("text_pop_up_side").style.display = "block";
} */
document.getElementById("text_pop_up_side").style.display = "block";
}
function addTextBtn(){
//var gotten = $("#theTextPop").val();
var gotten = document.getElementById("theTextPop").value
addText(gotten);
}
function addText(text2add){
var secElem = document.getElementById(selectedId);
var node = document.createTextNode(text2add);
secElem.appendChild(node);
document.getElementById("text_pop_up_side").style.display = "none";
/*var para = document.createElement("p");
para.appendChild(node);*/
}
document.addEventListener("keydown", function (event) {
if (event.key === "Delete" && document.getElementById(selectedId)) {
removeSelected();
}
});
function removeSelected(){
var r = confirm("You are about to remove the selected element");
if (r == true) {
var secElem = document.getElementById(selectedId);
secElem.remove();
selectCreated('the_dev_dashboard', 'div');
} else {
x = "You pressed Cancel!";
}
}
function change2codeMode(){
var bodyElem = document.getElementById("the_dev_dashboard");
var body = bodyElem.innerHTML;
//alert(body);
//var textArea = document.getElementById("the_textarea_4_view");
//if ( typeof(textArea) != 'undefined' && textArea != null ){
var para = document.createElement("textarea");
height = "100%";
width = "100%";
background = colorCodeGenetor(6);
color = colorCodeGenetor(6);
defaultStyle = 'height: '+ height + '; width: '+ width + '; background-color: ' + background + '; ';
para.setAttribute("style", defaultStyle);
para.setAttribute("id", "the_textarea_4_view");
para.innerHTML = body;
//alert(para);
bodyElem.innerHTML = null;
bodyElem.append(para);
/* }else{
alert("already in code view mode");
} */
}
function change2webMode(){
var bodyElem = document.getElementById("the_dev_dashboard");
var body = bodyElem.innerHTML;
var textArea = document.getElementById("the_textarea_4_view");
if ( typeof(textArea) != 'undefined' && textArea != null ){
var para = document.getElementById("the_textarea_4_view").value
//alert(para);
bodyElem.innerHTML = para;
}else{
alert("You are already in Web mode")
}
}
// copied from W3 school... Thank you W3 schools
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
console.log(ca);
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
function checkCookie(cookiename) {
var cookieName = getCookie(cookiename);
ret = false;
if (cookieName != "") {
//alert("Welcome again " + user);
ret = true;
} else {
/* cookieName = prompt("Please enter your name:", "");
if (cookieName != "" && cookieName != null) {
setCookie("username", cookieName, 365);
} */
ret = false;
}
return ret;
}
function saveDevArenaAsCookie(){
var currentPage = window.location.href;
if (currentPage.includes("?project_title=")){
var xmlhttp = new XMLHttpRequest();
var pos = currentPage.indexOf("=");
var findings = currentPage.slice(pos+1);
//$("#meta_description").attr("content", findings);
//var cleaned_findings = findings.replace(/%20/g, " ").toString();
//cleaned_findings = findings.replace(/-/g, " ").toString();
cname = "the_dev_enviro_" + cleaned_findings;
var cvalue = document.getElementById("the_dev_dashboard").innerHTML;
//var body = bodyElem;
//alert(cname + "$#$" + cvalue);
setCookie(cname, btoa(cvalue), 1000);
}else{
alert("could not find project name. Saving as untitle.");
var cvalue = document.getElementById("the_dev_dashboard").innerHTML;
//cname = "the_dev_enviro_" + currentPage;
if (cvalue != "" && cvalue != null) {
//alert(cvalue);
setCookie(currentPage, btoa(cvalue), 1000);
}
}
}
function loadSaveContentAsCookie(){
var currentPage = window.location.href;
if (currentPage.includes("?project_title=")){
var xmlhttp = new XMLHttpRequest();
var pos = currentPage.indexOf("=");
var findings = currentPage.slice(pos+1);
//var cleaned_findings = findings.replace(/%20/g, " ").toString();
//cleaned_findings = findings.replace(/-/g, " ").toString();
cname = "the_dev_enviro_" + cleaned_findings;
if (checkCookie(cname) == true) {
var gottenStuff = atob(getCookie(cname));
document.getElementById("the_dev_dashboard").innerHTML = gottenStuff;
}else{
alert("Sorry, this project could not be retrieved.");
}
}else{
alert("No Project Name. Let's try to retrieve untitle project.");
if (checkCookie(currentPage) == true) {
var gottenStuff = atob(getCookie(currentPage));
//alert(gottenStuff);
document.getElementById("the_dev_dashboard").innerHTML = gottenStuff;
}
}
}
function replaceSelected(){
/*var parent = document.getElementById("div1");
var child = document.getElementById("p1");
parent.replaceChild(para,child);*/
}
function insertElementB4(){
/*var element = document.getElementById("div1");
var child = document.getElementById("p1");
element.insertBefore(para,child);*/
}
function enableCustomiser(side){
var r = confirm("You are about to enable customisation for the entire page. Are you ready?");
if (r == true) {
id =(side == "left") ? "theLeftSideBar" : "theRightSideBar";
selectedId = id;
selectedElement = document.getElementById(id);
$("#the_style_identity_box").text('aside' + ' - #' + id + ' : Selected');
getElementStyleDetails(selectedId);
getElementAttrDetails(selectedId);
} else {
x = "You pressed Cancel!";
}
}
function removetheSideBars(side){
var r = confirm("You are about to remove the entire bar. Please do not proceed If you have not saved your project");
if (r == true) {
id =(side == "left") ? "theLeftSideBar" : "theRightSideBar";
if (id == "theLeftSideBar") {
if ( $("#theLeftSideBar").css("display") == 'block' ) {
document.getElementById('theLeftSideBar').style.display = "none";
document.getElementById('leftBarRestore').style.display = "block";
scaleViewLayoutAdjust();
}
}
else if (id == "theRightSideBar"){
if ( $("#theRightSideBar").css("display") == 'block' ) {
document.getElementById('theRightSideBar').style.display = "none";
document.getElementById('rightBarRestore').style.display = "block";
scaleViewLayoutAdjust();
}
}
} else {
x = "You pressed Cancel!";
}
}
//style_position
function scaleViewLayoutAdjust(){
// if both bars are ON, readjust the main dev
if( document.body.clientWidth >= 960 ){
if ( $("#theLeftSideBar").css("display") == 'block' &&
$("#theRightSideBar").css("display") == 'block' ) {
document.getElementById('theLeftSideBar').style.width = "20%";
document.getElementById('theRightSideBar').style.width = "20%";
document.getElementById('the_dev_dashboard').style.width = "60%";
document.getElementById('theLeftSideBar').style.maxWidth = "20%";
document.getElementById('theRightSideBar').style.maxWidth = "20%";
document.getElementById('the_dev_dashboard').style.maxWidth = "60%";
}
// if one bar is ON, readjust the main dev
else if ($("#theLeftSideBar").css("display") == 'block' &&
$("#theRightSideBar").css("display") == 'none' ) {
document.getElementById('theLeftSideBar').style.width = "20%";
document.getElementById('theRightSideBar').style.width = "0";
document.getElementById('the_dev_dashboard').style.width = "80%";
document.getElementById('theLeftSideBar').style.maxWidth = "20%";
document.getElementById('theRightSideBar').style.maxWidth = "0";
document.getElementById('the_dev_dashboard').style.maxWidth = "80%";
}
else if ($("#theLeftSideBar").css("display") == 'none' &&
$("#theRightSideBar").css("display") == 'block' ) {
document.getElementById('theLeftSideBar').style.width = "0";
document.getElementById('theRightSideBar').style.width = "20%";
document.getElementById('the_dev_dashboard').style.width = "80%";
document.getElementById('theLeftSideBar').style.maxWidth = "0";
document.getElementById('theRightSideBar').style.maxWidth = "20%";
document.getElementById('the_dev_dashboard').style.maxWidth = "80%";
}
// If none of the bar is ON, readjust the main dev
else if ($("#theLeftSideBar").css("display") == 'none' &&
$("#theRightSideBar").css("display") == 'none' ) {
document.getElementById('theLeftSideBar').style.width = "0";
document.getElementById('theRightSideBar').style.width = "0";
document.getElementById('the_dev_dashboard').style.width = "100%";
document.getElementById('theLeftSideBar').style.maxWidth = "0";
document.getElementById('theRightSideBar').style.maxWidth = "0";
document.getElementById('the_dev_dashboard').style.maxWidth = "100%";
}
}else if( document.body.clientWidth < 960 ){
}
}
function removeParent(ev){
ev.target.parentElement.style.display = "none";
}
function removeSpecificId(id){
document.getElementById(id).style.display = "none";
}
function toggleSpecificId(){
if(document.getElementById(id).style.display == "none"){
document.getElementById(id).style.display = "block";
}else{
document.getElementById(id).style.display = "none";
}
}
function loadStyles(){
display_by = document.getElementById("arrangement_type").value;
url = '../../backend/style/get_style.php?echo=json&display_by=' + display_by ;
$.post(url, {
key: "gjhtiidsimi09403jfjkdknf",
},
function(data, status){
dataJson = JSON.parse(data);
//alert(data);
result = dataJson["result"];
if (dataJson["status"] == "true"){
//$("#processor_shower").fadeOut();
//$("#loader_side_success").fadeIn();
//$("#msg_success").text(dataJson["msg"]);
for (let index = 0; index < result.length; index++) {
const element = result[index];
description = element['description'];
style_name = element['style_name'];
//alert(style_name);
}
}else{
console.log('failed to load while using the json_javascript_displayer_function');
}
});
}
function loadAllLeftSides(ev){
if( typeof(ev) == "string" ){
tag = ev;
}else{
selected_Id = ev.target.id;
selected_Element = document.getElementById(selected_Id);
tag = selected_Element.value;
}
//alert(tag);
display_by = document.getElementById("arrangement_type").value;
url = "../../backend/style/get_style.php?echo=raw";
if(tag == 'Style'){
url = '../../backend/style/get_style.php?echo=raw&display_by=' + display_by;
}else if (tag == 'Assitance/Modules'){
url = '../../backend/assistance/get_assistance.php?echo=raw&display_by=' + display_by;
}else if (tag == 'Attributes'){
url = '../../backend/attribute/get_attribute.php?echo=raw&display_by=' + display_by;
}else if(tag == 'Colors'){
url = '../../backend/colors/get_color.php?echo=raw&display_by=' + display_by;
}else if(tag == 'File'){
url = '../../backend/file/get_file.php?echo=raw&display_by=' + display_by;
}
//alert(url);
$.post(url, {
key: "gjhtiidsimi09403jfjkdknf",
},
function(data, status){
//dataJson = JSON.parse(data);
//alert(data);
//result = data["result"];
if (status){
$('.full_left_aside_section').html(data);
$('#The_left_header_side').text(tag);
}else{
console.log('failed to load while using the direct Backend to HTML render.');
}
});
}
function loadAllRightSides(ev){
if( typeof(ev) == "string" ){
tag = ev;
}else{
selected_Id = ev.target.id;
selected_Element = document.getElementById(selected_Id);
tag = selected_Element.value;
}
//alert(tag);
display_by = document.getElementById("arrangement_type").value;
url = "../../backend/style/get_style.php?echo=raw";
if(tag == 'Style'){
url = '../../backend/style/get_style.php?echo=raw&display_by=' + display_by;
}else if (tag == 'Assitance/Modules'){
url = '../../backend/assistance/get_assistance.php?echo=raw&display_by=' + display_by;
}else if (tag == 'Attributes'){
url = '../../backend/attribute/get_attribute.php?echo=raw&display_by=' + display_by;
}else if(tag == 'Colors'){
url = '../../backend/colors/get_color.php?echo=raw&display_by=' + display_by;
}else if(tag == 'File'){
url = '../../backend/file/get_file.php?echo=raw&display_by=' + display_by;
}
//alert(url);
$.post(url, {
key: "gjhtiidsimi09403jfjkdknf",
},
function(data, status){
if (status){
$('.full_right_aside_section').html(data);
$('#The_right_header_side').text(tag);
}else{
console.log('failed to load while using the direct Backend to HTML render.');
}
});
}
function post_request(url, parameters, type){
$.post(url, parameters,
function(data, status){
//alert(data);
if (status) {
if (type == 'json'){
var dataJson = JSON.parse(data);
return dataJson;
}else{
return data;
}
}else{
return 'could not make a successful post request. ****NOT REACHED****';
}
});
}
function loadElements(){
display_by = document.getElementById("arrangement_type").value;
url = '../../backend/elements/get_element.php?echo=raw&display_by=' + display_by ;
$.post(url, {
key: "gjhtiidsimi09403jfjkdknf",
},
function(data, status){
//dataJson = JSON.parse(data);
//alert(data);
//result = data["result"];
if (status){
$('.the_bottom_bar').html(data);
//$('#The_left_header_side').text(tag);
}else{
console.log('failed to load while using the direct Backend to HTML render.');
}
});
}
function save_file(project_name, project_content, project_description, type){
var ret = "";
if (type == "new") {
url = '../../backend/projects/add_project.php';
}else{
url = '../../backend/projects/save_project.php';
}