Untitled

mail@pastecode.io avatar
unknown
javascript
3 years ago
2.2 kB
1
Indexable
Never
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
    <meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
    <title>Video&Audio Downloader</title>
  </head>
  <body>
      <div class="container">
          <div class="title-container">
              <h3>Video&Audio Downloader</h3>
          </div>
          <div class="form-container">
            <form name="dataForm">
                <label for="url">VIDEO URL</label>
                <input type="url" name="URL" id="video-url-input">
                <p>Select format:</p>  
                <input type="radio" name="format" value="MP3">MP3 
                <input type="radio" name="format" value="MP4">MP4
                <input id="sub-but" type="submit" onclick="receiveData()" value="Start">  
            </form>
          </div>
          <div class="status-container">
              <h5>Stato: <span>In attesa</span></h5>
          </div>
      </div>
      <script>
        const {ipcRenderer, remote} = require('electron')
        const receiveData = () => {
            let video_url = document.getElementById("video-url-input").value;
            let format = document.dataForm.elements["format"].value;
            const pathArray = remote.dialog.showOpenDialog({properties: ['openDirectory']})
            console.log(pathArray)


            let form_data = {
              video_url: video_url,
              download_path: pathArray,
              format: format
            }
            // send username to main.js 
            ipcRenderer.send('asynchronous-message', form_data)

            // receive message from main.js
            ipcRenderer.on('asynchronous-reply', (event, arg) => {
              console.log(arg) 
            })
        }
      </script>
      <script src="renderer.js"></script>
  </body>
</html>