Langsung ke konten utama

HTML Editor Sederhana (New Window Preview)

Ini merupakan fitur dasar untuk membuat html editor

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>HTML Edit</title>
  <style>
    /* Styles for editor area */
    #editor {
      width: 100%;
      height: 500px;
      font-size: 16px;
      border: 1px solid #ccc;
    }

    /* Styles for preview area */
    #preview {
      width: 100%;
      height: 500px;
      font-size: 16px;
      border: 1px solid #ccc;
      padding: 10px;
      box-sizing: border-box;
      overflow: auto;
    }
  </style>
</head>

<body>
  <h1>HTML Edit</h1>
  <p>Edit your HTML code below:</p>
  <textarea id="editor"></textarea>
  <button onclick="preview()">Preview</button>

  <script>
    function preview() {
      var editor = document.getElementById("editor");
      var previewHTML = editor.value;

      // Open a new window and write the preview HTML to it
      var previewWindow = window.open("", "previewWindow", "width=800,height=600");
      previewWindow.document.write(previewHTML);
      previewWindow.document.close();
    }
  </script>
</body>
</html> 

Tambah Fitur Dark Mode:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>HTML Edit</title>
  <!-- <link rel="stylesheet" type="text/css" href="style.css"> -->
  <style type="text/css">
    body {
      background-color: #eee;
      color: #222;
    }

    /* Dark mode styles */
    body.dark {
      background-color: #222;
      color: #eee;
    }

    #editor {
      width: 100%;
      height: 500px;
      font-size: 16px;
      border: 1px solid #ccc;
      background-color: #fff;
      color: #222;
    }

    /* Dark mode styles */
    body.dark #editor {
      background-color: #222;
      color: #eee;
    }

    #preview {
      width: 100%;
      height: 500px;
      font-size: 16px;
      border: 1px solid #ccc;
      padding: 10px;
      box-sizing: border-box;
      overflow: auto;
      background-color: #fff;
      color: #222;
    }

    /* Dark mode styles */
    body.dark #preview {
      background-color: #222;
      color: #eee;
    }
  </style>
</head>

<body>
  <h1>HTML Edit</h1>
  <p>Edit your HTML code below:</p>
  <textarea id="editor"></textarea>
  <button onclick="preview()">Preview</button>
  <button onclick="toggleDarkMode()">Toggle Dark Mode</button>

  <script>
    function preview() {
      var editor = document.getElementById("editor");
      var previewHTML = editor.value;

      // Open a new window and write the preview HTML to it
      var previewWindow = window.open("", "previewWindow", "width=800,height=600");
      previewWindow.document.write(previewHTML);
      previewWindow.document.close();
    }

    function toggleDarkMode() {
      var body = document.querySelector("body");
      body.classList.toggle("dark");
    }
  </script>
</body>
</html>

Postingan populer dari blog ini

3 Cara Otomatis Replace index.php di Linux Ubuntu: Systemd, Cron, dan Shell Loop

Ada beberapa cara untuk membuat Linux Ubuntu otomatis mengganti atau memperbarui file: /var/www/html/index.php secara berkala dari script lokal. Tiga metode yang paling umum adalah: Systemd Service + Timer Cron Shell Loop + nohup Di bawah ini adalah contoh implementasinya. 1. Menggunakan Systemd Service + Timer Metode ini paling cocok untuk VPS atau server Ubuntu normal yang menggunakan systemd . Buat script update sudo nano /usr/local/bin/update-index.sh Isi: #!/bin/sh cat > /var/www/html/index.php <<'EOF' <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Website</title> </head> <body> <h1>INDEX OTOMATIS</h1> </body> </html> EOF Beri permission execute: sudo chmod +x /usr/local/bin/update-index.sh Buat service sudo nano /etc/systemd/system/update-index.service Isi: [Unit] Description=Update index.php [Service] Type=oneshot ExecStart=/usr/local...

Tutorial Dasar GSocket dan gs-netcat di Windows dan Ubuntu

GSocket atau Global Socket Toolkit adalah kumpulan tool yang memungkinkan dua komputer membuat koneksi TCP melalui Global Socket Relay Network (GSRN) . Salah satu tool di dalamnya adalah gs-netcat . Berbeda dengan koneksi TCP tradisional yang biasanya membutuhkan alamat IP dan port tujuan, GSocket memungkinkan dua endpoint saling menemukan berdasarkan sebuah shared secret . Koneksi antarendpoint kemudian dapat dilindungi dengan enkripsi end-to-end. Gambaran Cara Kerja Secara sederhana: Windows | | outbound connection v Global Socket Relay Network ^ | outbound connection | Ubuntu Artinya Ubuntu tidak harus membuka sebuah port publik khusus agar endpoint GSocket dapat berkomunikasi. Ini berbeda dengan SSH langsung: Windows | | SSH v IP Ubuntu:22 Pada SSH biasa, Windows harus mengetahui IP atau domain server serta port SSH yang dapat dijangkau. Apakah gs-netcat Tersedia di Windows? Ya. GSocket menyediakan gs-netcat yang dapat digunaka...