Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="container">
  <div class="IO-field">
    <h2 class="type-title">Snazzy JSON Code</h2>
    <textarea placeholder="Paste Snazzy Style Here" id="plain-text" class="text"></textarea>
    <button class="convert-button" id="text-submit" type="submit">Encode to DIVI</button>
  </div>
  <div class="IO-field">
    <h2 class="type-title">DIVI Code</h2>
    <textarea placeholder="your DIVI code will oputput here (it can alsogo the other way if nessasary)" id="base-64" class="text"></textarea>
    <button class="convert-button" id="base64-submit" type="submit">Decode from DIVI</button>
  </div>
</div>
              
            
!

CSS

              
                * {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

body,
html {
  height: 100%;
  width: 100%;
}

body {
  background-color: #bada55;
  margin: 0;
}

textarea {
  font-family: 'Arvo', serif;
  border: 3px solid #CA1FC4;
  color: black;
  width: 100%;
  height: 70%;
  margin-bottom: 5%;
  padding: 15px 15px;
  outline: none;
  resize: none;
}

.IO-field {
  height: 100%;
  width: 50%;
  float: left;
  padding: 40px;
  text-align: center;
}

#container {
  height: 100%;
  width: 100%;
  margin: 0 auto;
  padding: 30px;
}

.type-title {
  color: #222;
  font-family: 'Arvo', serif;
  margin-top: 0;
  margin-bottom: 5%;
  font-size: 2em;
}

.convert-button {
  background-color: #CA1FC4;
  font-family: 'Arvo', serif;
  color: white;
  padding: 10px 15px;
  font-size: 1.1em;
  cursor: pointer;
}
              
            
!

JS

              
                var plainTextIOField = document.querySelector("#plain-text"),
  base64IOField = document.querySelector("#base-64"),
  base64Submit = document.querySelector("#base64-submit"),
  textSubmit = document.querySelector("#text-submit"),
  
  //use the index of each character in the array as the key that links value and corresponding char in base64 table  
  base64Table = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
    "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
    "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"
  ];


//function that converts a standard ASCII character decimal value into its binary correspondant and turns it into a string
function dec2bin(dec) {
  var bin = (dec >>> 0).toString(2);
  if (bin.length < 8) {
    var itrs = 8 - bin.length;
    for (var i = 0; i < itrs; i++) {
      bin = "0" + bin;
    }
  }
  return bin;
}

base64Submit.addEventListener("click", function(e) {

  //block browser form reloading the page
  e.preventDefault();

  
  //declare variables needed during the conversion
  var string = base64IOField.value,
    stringToArray = string.split(''),
    s = "",
    textArray = [];

  
  //find index of each characer in the variable string and convert it into a string representing the 6 bit value corresponding to the character's index in base64 table and, since dec2bin returns an 8 bit binary number, cut the last two 0s of the string
  for (var i = 0; i < stringToArray.length; i++) {

    if (stringToArray[i] == "="){
      break;
    }
    stringToArray[i] = base64Table.indexOf(stringToArray[i]);
    s += dec2bin(stringToArray[i]).slice(2);

  }

  //create an array by splitting the s string
  s = s.split('');

  //add a separator between each series of 8 bit contained in the textArray array
  for (var i = 0; i < s.length; i++) {

    if (i > 0 && i % 8 === 0){
      textArray.push(" ");
    }
    textArray.push(s[i]);

  }
  
  //join the array textArray using as a separator the space just added in the previous for-loop
  textArray = textArray.join('').split(' ');

  
  //substitute each binary value in string form with its corresponding ASCII character
  for (var i = 0; i < textArray.length; i++) {

    charater = String.fromCharCode(parseInt(textArray[i], 2));
    textArray[i] = charater;

  }
  
  //join all the letters in the text array and we are done :D
  plainTextIOField.value = textArray.join('');

})

textSubmit.addEventListener("click", function(e) {

  //block browser form reloading the page
  e.preventDefault();

  //declare variables needed during the conversion
  var string = plainTextIOField.value,
    stringToArray = string.split(''),
    s = "",
    array64 = [];

  //for each letter in the stringToArray array get its charCode, convert it to binary form, make it a string and concatenate it with the s string
  for (var i = 0; i < stringToArray.length; i++) {

    var charCode = stringToArray[i].charCodeAt(0);
    s += dec2bin(charCode);

  }

  //make s an array made of each bit represented in the s string
  s = s.split('');

  
  //put all the strings of the s array inside array64 and separate each series of 6 consecutive elements with a single whitespace
  for (var i = 0; i < s.length; i++) {

    if (i > 0 && i % 6 === 0)
      array64.push(" ");
    array64.push(s[i]);

  }

  //concatenate all of array64's elements into a single string and then break the string using the whitespaces just added as divider
  array64 = array64.join('').split(' ');

  
  //make sure each string representing a binary value in array64 is 6 chars long
  if (array64[array64.length - 1].length < 6) {

    var array64Last = array64.pop(),
      nOf0s = 6 - array64Last.length;

    for (var i = 0; i < nOf0s; i++) {

      array64Last += "0";

    }

    array64.push(array64Last);

  }

  
  //make sure the array64's length is a multiple of 4, and if not add correct padding as base64 encoding requires
  if (array64.length % 4 !== 0) {

    var padding = 4 - (array64.length % 4);

    for (var i = 0; i < padding; i++) {

      array64.push("=");

    }

  }

  
  //substitute each string in array64 with its corresponding binary value and then with the value get the right character from the base 64 table
  for (var i = 0; i < array64.length; i++) {
    if (array64[i] == "=") {
      continue;
    }
    array64[i] = base64Table[parseInt(array64[i], 2)];
  }
  
  //concatenate all the characters inside of array64 and done :D
  base64IOField.value = array64.join('');

})
              
            
!
999px

Console