File size: 4,536 Bytes
0cb0169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Real-Time HTML, CSS, JavaScript Online Code Editor</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            height: 100vh;
        }
        .header {
            background-color: #f8f9fa;
            padding: 10px;
            text-align: center;
            position: relative;
        }
        .header button {
            position: absolute;
            top: 10px;
            right: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            padding: 5px 10px;
            cursor: pointer;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .header button:hover {
            background-color: #0056b3;
        }
        .editor-container {
            width: 50%;
            height: calc(100vh - 40px);
            display: flex;
            flex-direction: column;
        }
        textarea {
            flex: 1;
            border: none;
            resize: none;
            outline: none;
            padding: 10px;
            font-size: 14px;
            tab-size: 4;
        }
        #output {
            width: 50%;
            height: calc(100vh - 40px);
            border-left: 1px solid #ccc;
            overflow: auto;
        }
        iframe {
            width: 100%;
            height: 100%;
            border: none;
        }
        #fullScreenPreview {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: white;
            z-index: 1000;
            display: none;
            flex-direction: column;
        }
        #fullScreenPreview iframe {
            width: 100%;
            height: 100%;
            border: none;
        }
        #closeFullScreen {
            position: absolute;
            top: 10px;
            right: 10px;
            background-color: red;
            color: white;
            border: none;
            padding: 5px 10px;
            cursor: pointer;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        #closeFullScreen:hover {
            background-color: darkred;
        }
    </style>
</head>
<body>
    <div class="header">
        <button id="fullScreenButton">Full Screen</button>
    </div>
    <div class="editor-container">
        <textarea id="html" placeholder="HTML"></textarea>
        <textarea id="css" placeholder="CSS"></textarea>
        <textarea id="javascript" placeholder="JavaScript"></textarea>
    </div>
    <div id="output">
        <iframe id="preview"></iframe>
    </div>
    <div id="fullScreenPreview">
        <button id="closeFullScreen">Close</button>
        <iframe id="fullScreenIframe"></iframe>
    </div>
    <script>
        const html = document.getElementById('html');
        const css = document.getElementById('css');
        const javascript = document.getElementById('javascript');
        const preview = document.getElementById('preview').contentDocument;
        const fullScreenButton = document.getElementById('fullScreenButton');
        const fullScreenPreview = document.getElementById('fullScreenPreview');
        const fullScreenIframe = document.getElementById('fullScreenIframe');
        const closeFullScreen = document.getElementById('closeFullScreen');

        function updatePreview() {
            const htmlContent = html.value;
            const cssContent = `<style>${css.value}</style>`;
            const jsContent = `<script>${javascript.value}<\/script>`;
            preview.open();
            preview.write(htmlContent + cssContent + jsContent);
            preview.close();

            fullScreenIframe.srcdoc = htmlContent + cssContent + jsContent;
        }

        html.addEventListener('input', updatePreview);
        css.addEventListener('input', updatePreview);
        javascript.addEventListener('input', updatePreview);

        fullScreenButton.addEventListener('click', () => {
            fullScreenPreview.style.display = 'flex';
        });

        closeFullScreen.addEventListener('click', () => {
            fullScreenPreview.style.display = 'none';
        });

        // Initial update
        updatePreview();
    </script>
</body>
</html>