forked from Rizsyad/texteditorwebased
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
153 lines (135 loc) · 4.79 KB
/
index.html
File metadata and controls
153 lines (135 loc) · 4.79 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Coding Online">
<meta name="keywords" content="coding,online,coding online">
<meta name="author" content="Rizsyad AR">
<title>Coding Online</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
</head>
<body>
<div style="background: #000;">
<div class="row">
<div class="col-md-4 col-sm-12">
<div class="card">
<div class="card-header bg-dark text-white text-center">HTML</div>
<div class="table-responsive">
<div id="html" class="border" style="height: 300px;"></div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-12">
<div class="card">
<div class="card-header bg-dark text-white text-center">CSS</div>
<div class="table-responsive">
<div id="css" class="border" style="height: 300px;"></div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-12">
<div class="card">
<div class="card-header bg-dark text-white text-center">Javascript</div>
<div class="table-responsive">
<div id="javascript" class="border" style="height: 300px;"></div>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-12 col-sm-12">
<button type="button" class="btn btn-info btn-block" data-toggle="modal" data-target="#getcode" id="getcodes">GET CODE</button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12">
<div class="card">
<div class="card-header bg-dark text-white text-center">VIEW</div>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" id="previewtarget" sandbox="allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts" allowpaymentrequest="true" allowtransparency="true">
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
</body>
</html>
</iframe>
</div>
</div>
</div>
</div>
<div class="modal fade" id="getcode">
<div class="modal-dialog modal-md">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Code</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="form-group">
<label for="resultgetcodemini">minify</label>
<textarea id="resultgetcodemini" cols="30" rows="10" class="form-control"></textarea>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-success ml-auto" onclick="myFunction()">Copy to clipboard</button>
<button type="button" class="btn btn-danger mr-auto" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
setEditor();
update();
function setEditor() {
window.htmleditor = ace.edit("html");
htmleditor.setTheme("ace/theme/monokai");
htmleditor.session.setMode("ace/mode/html");
htmleditor.getSession().on("change", function() {
update();
});
window.csseditor = ace.edit("css");
csseditor.setTheme("ace/theme/monokai");
csseditor.session.setMode("ace/mode/css");
csseditor.getSession().on("change", function() {
update();
});
window.javascripteditor = ace.edit("javascript");
javascripteditor.setTheme("ace/theme/monokai");
javascripteditor.session.setMode("ace/mode/javascript");
javascripteditor.getSession().on("change", function() {
update();
});
update();
}
function update() {
var result = $("#previewtarget")[0].contentWindow.document;
var resultforcopy1 = $("#resultgetcodemini");
result.open();
result.close();
$("body", result).append(htmleditor.getValue());
$("head", result).append("<meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><style>" + csseditor.getValue() + "</style>");
$("body", result).append("<script>" + javascripteditor.getValue() + "<\/script>" );
resultforcopy1.val("<!DOCTYPE html><html lang=\"en\">" + result.documentElement.innerHTML + "</html>");
}
});
function myFunction() {
var copyText = document.getElementById("resultgetcodemini");
copyText.select();
document.execCommand("copy");
}
</script>
</body>
</html>