Advanced Mobile VR Station Download Generator

In development download link generator

HTML

<div id="box">

  <h2>
    Advanced Download Generator for Mobile VR Station 2.1
  </h2>

  <p>
    <label for="url">Content Url (UTF-8 Encoded):</label> (Required)
    <br/>
    <input type="input" name="url" id="url" value="http://urltomedia" />
  </p>

  <ul>
    <li>Make sure the content url points to a video or zip file</li>
    <li>It must point to an actual zip file, not a redirecting website</li>
  </ul>

  <p>
    <label for="url">Title:</label> (Required)
    <br/>
    <input type="input" name="title" id="title">
  </p>

  <ul>
    <li>The title will be displayed while content is downloading</li>
  </ul>

  <p>
    <label for="url">Filename:</label> (Required)
    <br/>
    <input type="input" name="filename" id="filename">
  </p>

  <ul>
    <li>You must include the final file name of the link</li>
    <li>Include the extension, for example amovie<span style="font-weight:bold;">.mp4</span> or archive<span style="font-weight:bold;">.zip</span></li>
    <li>This is useful, incase you want to rename the file to include playback tags</li>
    <ul>
      <li>_LR : 3D Left-Right</li>
      <li>_RL : 3D Right-Left</li>
      <li>_TB : 3D Top-Bottom</li>

      <li>_360 : 2D 360</li>
      <li>_360_TB : 3D 360 Top-Bottom</li>
      <li>_360_LR : 3D 360 Left-Right</li>

      <li>_180 : 2D 180</li>
      <li>_180_LR : 3D 180 Left-Right</li>

      <li>_FFD : 2D Front Full Dome</li>
      <li>_FFD_LR : 3D Front Full Dome Left-Right</li>

    </ul>
  </ul>

  <p>
    <label for="url">Type:</label> (Required)
    <br/>
    <select name="contentType" id="contentType">
      <option value="dl">Download Only</option>
      <option value="dle">Download &amp; Extract</option>
    </select>
  </p>

  <button id="gen">Generate</button>

  <p>
    <label for="result">Result:</label>
    <br/>
    <input type="input" name="result" id="result" readonly>
  </p>

</div>

CSS

#box {
  background: white;
  margin: 1em;
  padding: 1em;
}

.presetRequired {
  margin: 1em;
}

select,
input {
  width: 80%;
}

JavaScript

$(function() {

  function replaceAll(str, find, replace) {
    return str.replace(new RegExp(find, 'g'), replace);
  }

  window.MVRS = {};

  $('#gen').click(function() {
    $('#result').val('');
    var media = $('#url').val(),
      title = $('#title').val(),
      filename = $('#filename').val(),
      type, i, link, js;
    if (!media) {
      alert('Please enter a content url');
      return;
    } else if (!title) {
      alert('Please enter a title');
      return;
    } else if (!filename) {
      alert('Please enter a filename');
      return;
    }
    type = $('#contentType').val() || '';

    js = {
      v: 1,
      url: media,
      title: title,
      filename: filename,
      type: type
    }

    var json =

      link = 'https://webvr.mobilevrstation.com/dl/' + replaceAll(window.btoa(JSON.stringify(js)), '=', '');

    $('#result').val(link).focus().select();
  });
  $("#result").focus(function() {
    $(this).select();
  });
});