1
1
<!DOCTYPE html>
2
- < html >
2
+ < html lang =" en " >
3
3
< head >
4
- < title > </ title >
5
- < script src ="https://code.jquery.com/jquery-1.12.4.min.js "> </ script >
4
+ < title > HTML editor</ title >
5
+ < meta charset ="utf-8 ">
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
7
+
8
+ <!-- Setting fav icon -->
9
+ < link rel ="icon " type ="image/png " href ="https://img.icons8.com/bubbles/3x/edit.png ">
10
+
11
+ <!-- Loading css -->
12
+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.css ">
13
+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/theme/material-darker.css "> </ link >
14
+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css ">
15
+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/show-hint.css ">
16
+ < link rel ="stylesheet " href ="css/main.css "> <!-- Main css -->
17
+
18
+ <!-- Loading js -->
19
+ < script src ="https://code.jquery.com/jquery-1.12.4.min.js "> </ script >
6
20
< script src ="https://code.jquery.com/ui/1.12.1/jquery-ui.js "> </ script >
7
- < link rel ="stylesheet "
8
- href ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.css ">
9
- < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/theme/material-darker.css ">
10
- </ link >
11
- < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css ">
21
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.js "> </ script >
22
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/xml/xml.js "> </ script >
23
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/javascript/javascript.js "> </ script >
24
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/css/css.js "> </ script >
25
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/htmlmixed/htmlmixed.js "> </ script >
26
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/edit/matchbrackets.js "> </ script >
27
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/show-hint.js "> </ script >
28
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/javascript-hint.js "> </ script >
29
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/html-hint.js "> </ script >
30
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/xml-hint.js "> </ script >
31
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/css-hint.js "> </ script >
32
+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/keymap/sublime.js "> </ script >
33
+ < script src ="js/main.js "> </ script > <!-- Main js -->
12
34
13
- < script type ="text/javascript "
14
- src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.js ">
15
- </ script >
16
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/xml/xml.js "> </ script >
17
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/javascript/javascript.js "> </ script >
18
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/css/css.js "> </ script >
19
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/mode/htmlmixed/htmlmixed.js "> </ script >
20
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/edit/matchbrackets.js "> </ script >
21
- < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/show-hint.css ">
22
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/show-hint.js "> </ script >
23
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/javascript-hint.js "> </ script >
24
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/html-hint.js "> </ script >
25
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/xml-hint.js "> </ script >
26
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/addon/hint/css-hint.js "> </ script >
27
- < script src ="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/keymap/sublime.js "> </ script >
28
- < script >
29
-
30
-
31
- $ ( '#main' ) . resizable ( {
32
- handles : 'e, w'
33
- } ) ;
34
-
35
- $ ( document ) . ready ( function ( ) {
36
-
37
- var validation = false ;
38
- var myTimeoutId = null ;
39
-
40
- var config = {
41
- mode : "text/html" ,
42
- extraKeys : { "Ctrl-Space" : "autocomplete" } ,
43
- lineNumbers : true ,
44
- keyMap :"sublime" ,
45
- tabSize :4 ,
46
- } ;
47
- // initialize editor
48
- var editor = CodeMirror . fromTextArea ( document . getElementById ( 'editor' ) , config ) ;
49
- editor . setOption ( "theme" , "material-darker" ) ;
50
-
51
- function loadHtml ( html ) {
52
- $ ( '#result' ) . contents ( ) . find ( 'html' ) . html ( html ) ;
53
- }
54
-
55
- loadHtml ( $ ( '#editor' ) . val ( ) ) ;
56
-
57
- editor . on ( 'change' , function ( cMirror ) {
58
-
59
- if ( myTimeoutId !== null ) {
60
- clearTimeout ( myTimeoutId ) ;
61
- }
62
- myTimeoutId = setTimeout ( function ( ) {
63
-
64
- try {
65
-
66
- loadHtml ( cMirror . getValue ( ) ) ;
67
-
68
- } catch ( err ) {
69
-
70
- console . log ( 'err:' + err ) ;
71
-
72
- }
73
-
74
-
75
- } , 2000 ) ;
76
-
77
- } ) ;
78
-
79
- } ) ;
80
-
81
- </ script >
82
- < style type ="text/css " media ="screen ">
83
- # main {
84
- width : 100% ;
85
- height : 100% ;
86
- }
87
- # output {
88
- overflow : auto;
89
- display : inline-block;
90
- position : absolute;
91
- top : 0 ;
92
- right : 0 ;
93
- bottom : 0 ;
94
- width : 50% ;
95
- }
96
- # result {
97
- position : absolute;
98
- width : 50vw ;
99
- height : 100vh ;
100
- }
101
- .CodeMirror {
102
- position : absolute;
103
- top : 0 ;
104
- left : 0 ;
105
- right : 0 ;
106
- bottom : 0 ;
107
- height : 100% ;
108
- width : 50% ;
109
- }
110
- # info {
111
- position : fixed;
112
- width : 60px ;
113
- height : 60px ;
114
- bottom : 40px ;
115
- right : 40px ;
116
- background-color : green;
117
- border-radius : 50% ;
118
- color : white;
119
- text-align : center;
120
- padding : auto;
121
- box-shadow : 2px 2px 3px # 999 ;
122
-
123
- }
124
- .top-float {
125
- font-size : 1.5em ;
126
- margin-top : 18px ;
127
- }
128
- </ style >
129
35
</ head >
130
36
< body >
131
- < span id ="info "> < i class ="fa fa-info top-float " aria-hidden ="true "> </ i > </ span >
132
- < div id ="main ">
133
- < textarea id ="editor "> <!DOCTYPE html>
37
+ <!-- FAB button -->
38
+ < span id ="info "> < i class ="fa fa-info top-float " aria-hidden ="true "> </ i > </ span >
39
+
40
+ <!-- Main area -->
41
+ < div id ="main ">
42
+
43
+ <!-- Editor -->
44
+ < textarea id ="editor "> <!DOCTYPE html>
134
45
<html>
135
46
<head>
136
- 	& lt;title></title>
47
+ <title>Editor </title>
137
48
</head>
138
49
<body>
139
50
<h1>Welcome to <span>HTML editor</span></h1><br>
140
51
<h2>Hello</h2>
141
52
</body>
142
53
</html></ textarea >
143
- < div id ="output "> < iframe id ="result "> </ iframe > </ div >
54
+
55
+ <!-- Iframe output -->
56
+ < div id ="output "> < iframe id ="result "> </ iframe > </ div >
144
57
</ div >
145
58
</ body >
146
59
</ html >
0 commit comments