Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <article>
    <header>
      <h1>Janet Greene</h1>
      <p>Field User</p>
    </header>
    <button class="button icon-ptt-out"></button>
    <div class="message-container">
      <p class="msg-is-busy">Janet is busy...</p>
      <p class="msg-is-incoming">Janet is talking...</p>
      <p class="msg-is-error">Could not connect.<br>Try again.</p>
    </div>
    <div class="controls">
      <span>Simulation Buttons</span><br>
      <button class="test sim-incoming-btn">Incoming</button>
      <button class="test sim-busy-btn">Busy</button>
      <button class="test sim-error-btn">Error</button>
    </div>
  </article>
              
            
!

CSS

              
                :root {
  --white: #fff;
  --black: #333;
  --orange: #ff9900;
  --green: #8dc640;
  --red: #cc3333;
}
* {
  box-sizing: border-box;
  transition: all 500ms ease;
}
body {
  max-width: 750px;
  margin: 0 auto;
  color: var(--white);
  padding: 0;
  font-family: sans-serif;
}
/*-- APP --*/
article {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  background: var(--black);
  height: 1334px;
  margin: 0 auto;
  text-align: center;
  padding: 20px;
}
@media (min-width: 1281px) {
  article {
    width: 375px;
    height: 667px;
  }
}
header {
  margin-bottom: 60px;
}
h1 {
  font-size: 36px;
  font-weight: 400;
  line-height: 1;
  margin: 0;
}
h1 + p {
  font-size: 16px;
  margin: 0;
}

/*--PTT Button Styles--*/
.button {
  width: 270px;
  height: 270px;
  border: 4px solid var(--orange);
  box-shadow: inset 0 0 0 6px var(--black);
  background-color: var(--orange);
  background-size: 50%;
  border-radius: 50%;
  background-position: center;
  font-size: 30px;
  color: white;
  text-indent: -9999px;
}
/*--Animation--*/
.button.on {
  -webkit-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
  -moz-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
  -ms-animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
  animation: pulse 1.25s infinite cubic-bezier(0.66, 0, 0, 1);
  outline: none;
}
@-webkit-keyframes pulse {
  to {
    box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
  }
}
@-moz-keyframes pulse {
  to {
    box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
  }
}
@-ms-keyframes pulse {
  to {
    box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
  }
}
@keyframes pulse {
  to {
    box-shadow: 0 0 0 45px rgba(232, 76, 61, 0);
  }
}

/*--Body states
has-incoming
has-error
has-busy
has-sending
--*/
body.has-waiting button.button{
  border: 4px solid var(--red);
  box-shadow: inset 0 0 0 6px var(--black);
  background-color: var(--orange);
  background: repeating-linear-gradient(
  45deg,
    var(--black) 1.9px,
    var(--black) 12px,
    var(--orange) 12px,
    var(--orange) 22px
    
  );
  animation: barberpole 3s linear infinite;
}
@keyframes barberpole {
  from { background-position: 0 0; }
  to   { background-position: 0 -100px; }
}
body.has-sending button.button {
  box-shadow: 0 0 0 0 var(--green);
  background-color: var(--green);
  border-color: var(--black);
}
body.has-incoming button.button {
  border-color: var(--black);
  box-shadow: 0 0 0 0 var(--white);
  background-color: var(--white);
}
body.has-busy button.button {
  border: none;
  box-shadow: none;
  background-color: var(--red);
}

/*--Message paragraph states
msg-is-busy
msg-is-incoming
msg-is-error
--*/
.message-container {
  height: 60px;
  margin: 10px 0;
  padding: 20px;
  width: 100%;
}
body.has-busy p.msg-is-busy,
body.has-incoming p.msg-is-incoming,
body.has-error p.msg-is-error {
  display: block;
}
p.msg-is-busy,
p.msg-is-incoming,
p.msg-is-error {
  display: none;
  font-size: 24px;
}

/*--Simulation buttons-
sim-incoming-btn
sim-busy-btn
-*/
.controls {
  position: fixed;
  bottom: 0;
}
button.test {
  margin: 10px;
  padding: 10px 5px;
  font-size: 16px;
  line-height: 1.2;
}

/*--Icons--*/

.icon-ptt-out {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20standalone%3D%22no%22%3F%3E%0A%3Csvg%20width%3D%22220px%22%20height%3D%22220px%22%20viewBox%3D%220%200%20220%20220%22%20version%3D%221.1%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%3E%0A%20%20%20%20%3C%21--%20Generator%3A%20Sketch%2048.2%20%2847327%29%20-%20http%3A//www.bohemiancoding.com/sketch%20--%3E%0A%20%20%20%20%3Ctitle%3EPTT-Outline%3C/title%3E%0A%20%20%20%20%3Cdesc%3ECreated%20with%20Sketch.%3C/desc%3E%0A%20%20%20%20%3Cdefs%3E%3C/defs%3E%0A%20%20%20%20%3Cg%20id%3D%22Page-1%22%20stroke%3D%22none%22%20stroke-width%3D%221%22%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%0A%20%20%20%20%20%20%20%20%3Cg%20id%3D%22PTT-Outline%22%20fill%3D%22%234A4A4A%22%20fill-rule%3D%22nonzero%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cg%20id%3D%22Asset-2%22%20transform%3D%22translate%2816.041016%2C%2019.337822%29%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M0%2C59.3425164%20C0.824201617%2C55.4852529%201.39290073%2C51.5702952%202.41491074%2C47.8036938%20C9.78923833%2C20.4413725%2034.3080911%2C1.20747844%2062.6393229%2C0.5604571%20C92.1374988%2C-0.0906621779%20117.860831%2C19.5170943%20125.54239%2C46.4932132%20C126.325382%2C49.2295626%20126.465496%2C51.6197473%20123.37474%2C52.476917%20C120.440582%2C53.3011186%20119.41033%2C51.0098381%20118.610855%2C48.6114114%20C111.357881%2C26.7041324%2096.5304934%2C12.7833671%2073.8154968%2C8.72005311%20C42.2320909%2C3.06603002%2013.0718377%2C24.5035141%208.34916238%2C54.8753437%20C4.24463833%2C81.4311198%2015.6598307%2C102.93454%2039.3144171%2C115.553067%20C41.5150355%2C116.723433%2043.4848773%2C118.083366%2042.0919766%2C120.943345%20C40.6990759%2C123.803325%2038.2924071%2C123.110996%2036.1247569%2C122.006565%20C16.1048996%2C111.893612%204.45068873%2C95.6568397%200.824201617%2C73.5764784%20C0.593425164%2C72.1258835%200.28022855%2C70.6835307%200%2C69.2329359%20L0%2C59.3425164%20Z%22%20id%3D%22Shape%22%3E%3C/path%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M81.9338828%2C122.06426%20L61.5843448%2C89.0961948%20C58.6337031%2C84.2993414%2055.6253672%2C79.5519401%2052.7489035%2C74.7303606%20C48.2487627%2C67.1559478%2050.2762987%2C58.1226981%2057.5127889%2C53.4412329%20C60.9678642%2C51.2275973%2065.164281%2C50.4864559%2069.1685954%2C51.382667%20C73.1729098%2C52.2788781%2076.6530446%2C54.7381189%2078.8348847%2C58.2133602%20C83.3350255%2C65.0789597%2087.5054857%2C72.1506096%2092.0221106%2C79.4118258%20C97.5525034%2C74.2111136%20103.701047%2C72.7028247%20110.929296%2C75.5545623%20C115.717907%2C68.4829124%20122.204374%2C65.7135949%20130.710134%2C68.2603779%20C131.460158%2C68.4829124%20132.869543%2C67.5103545%20133.578356%2C66.735605%20C141.820372%2C57.603451%20154.372963%2C58.9468997%20160.290731%2C69.7027308%20C167.494253%2C82.7745684%20174.730743%2C95.8381641%20181.818877%2C108.975938%20C197.223205%2C137.509798%20181.085337%2C172.966951%20149.435995%2C179.972665%20C140.74891%2C181.901297%20132.28436%2C180.533122%20124.215426%2C176.758279%20C103.27521%2C166.95028%2082.3267522%2C157.145028%2061.3700524%2C147.342523%20C57.2490443%2C145.397407%2054.1830143%2C142.479734%2052.6170313%2C138.070255%20C49.8724399%2C130.339244%2052.3532867%2C124.883029%2059.9853937%2C122.410424%20C65.9912163%2C120.369141%2072.457759%2C120.100179%2078.6123503%2C121.635675%20C79.477762%2C121.825241%2080.3926258%2C121.858209%2081.9338828%2C122.06426%20Z%20M141.762678%2C174.087866%20L142.042907%2C173.3296%20C144.228004%2C173.235214%20146.405245%2C173.006755%20148.562342%2C172.645513%20C174.219738%2C166.834891%20188.074567%2C138.169159%20176.197822%2C114.671171%20C168.961332%2C100.379515%20160.917124%2C86.5411698%20153.210839%2C72.5297423%20C151.348143%2C69.1340317%20148.446953%2C67.7328889%20144.6309%2C68.30983%20C140.946719%2C68.8702871%20138.861488%2C71.2027777%20137.831236%2C74.6232144%20C136.257011%2C79.9475569%20134.666302%2C80.4503199%20130.28155%2C76.955705%20C125.064353%2C72.8346969%20118.586129%2C74.9528951%20116.822337%2C81.4476038%20C115.371742%2C86.7801883%20113.459595%2C87.4230655%20109.214956%2C84.0191129%20C104.574701%2C80.3102056%2099.1184865%2C81.6618962%2096.6211556%2C86.9120605%20C95.796954%2C88.5604638%2094.0496466%2C91.2473611%2093.0853307%2C91.0990048%20C91.3297812%2C90.8270182%2089.4011494%2C89.0797108%2088.3379293%2C87.4395496%20C83.2443633%2C79.5849082%2078.5299301%2C71.5654264%2073.5599943%2C63.686059%20C70.3868181%2C58.6419451%2066.0185495%2C57.3149805%2061.7656692%2C59.8617635%20C57.3067385%2C62.5321767%2056.4495688%2C67.279578%2059.5897769%2C72.340176%20C63.6283649%2C78.8596107%2067.7164049%2C85.3543195%2071.7962029%2C91.8490282%20C79.2964376%2C103.799952%2086.8790925%2C115.693181%2094.2144869%2C127.743009%20C95.0963826%2C129.177119%2094.6265877%2C131.42719%2094.783186%2C133.30637%20C92.8957643%2C133.413516%2090.8847123%2C133.982215%2089.1538889%2C133.51242%20C86.5498199%2C132.66024%2084.0350868%2C131.556076%2081.6454122%2C130.215614%20C75.8265488%2C127.322666%2069.801635%2C127.141341%2063.6366069%2C128.707325%20C59.0458039%2C129.877691%2057.6776292%2C133.30637%2060.5211248%2C137.155391%20C61.8156115%2C138.733152%2063.461121%2C139.986336%2065.3262202%2C140.814846%20C85.5768539%2C150.458005%20105.811004%2C160.158858%20126.218236%2C169.472337%20C131.048057%2C171.738891%20136.570208%2C172.596061%20141.762678%2C174.087866%20Z%22%20id%3D%22Shape%22%3E%3C/path%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M60.5128827%2C26.9513929%20C82.6674222%2C26.7535845%2097.857458%2C39.3144171%20101.722964%2C57.9248897%20C102.291663%2C60.661239%20101.516913%2C62.4497565%2099.1432125%2C63.0843918%20C96.5552195%2C63.7767211%2095.2200128%2C62.0953498%2094.6595557%2C59.5650509%20C92.0633207%2C47.8036938%2085.2059632%2C39.5616776%2073.7907708%2C35.6384779%20C58.4276527%2C30.3141355%2041.5067934%2C38.4737315%2035.4406695%2C53.8368496%20C29.5311439%2C68.7466569%2036.5698258%2C86.2197312%2051.2323725%2C92.9946685%20C51.7268935%2C93.2254449%2052.2461405%2C93.4067693%2052.7571455%2C93.6045777%20C55.0649101%2C94.5194415%2056.564957%2C95.9700363%2055.4358008%2C98.6157235%20C54.3066446%2C101.261411%2051.8505237%2C101.352073%2049.8971659%2C100.148739%20C45.2651528%2C97.3052429%2040.1138927%2C94.766702%2036.5203737%2C90.8682283%20C25.476072%2C78.8513687%2023.0034671%2C64.5844387%2029.4322398%2C49.6581474%20C35.8610124%2C34.7318562%2047.902598%2C27.503608%2060.5128827%2C26.9513929%20Z%22%20id%3D%22Shape%22%3E%3C/path%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C/g%3E%0A%20%20%20%20%20%20%20%20%3C/g%3E%0A%20%20%20%20%3C/g%3E%0A%3C/svg%3E");
  background-repeat: no-repeat;
}

              
            
!

JS

              
                //Begin ugly JQuery!!!
$(document).ready(function() {
  var talkStart = "https://res.cloudinary.com/fergd/video/upload/v1519582545/sounds/PTT-Start-2.wav";
  var talkStop = "https://res.cloudinary.com/fergd/video/upload/v1519582545/sounds/PTT-End-2.wav";
  var talkError = "https://res.cloudinary.com/fergd/video/upload/v1519582545/sounds/PTT-Error-2.wav";
  var pttButton = $(".button");
  var simIncoming = $(".sim-incoming-btn");
  var simBusy = $(".sim-busy-btn");
  var simError = $(".sim-error-btn");
  var getBody = $(document).find("body");

  $(pttButton).removeClass("on");
  $(getBody).removeAttr('class');

  // Sending Message Sequence
  $(function() {
    $(pttButton).on("vmousedown", function() {
      if (!$("body").hasClass("active")) {
        $(getBody).removeClass("has-error");
        
        $(getBody).addClass("has-waiting");
        setTimeout(endHandshake, 300);

        function endHandshake() {  
          $(getBody).removeClass('has-waiting');
          $('button').addClass("on");
          $("body").addClass("has-sending");
          $.playSound(talkStart);
        }  
      }
    });
    $(pttButton).on("vmouseup", function() {
      if (!$("body").hasClass("active")) {
        $(getBody).removeClass('has-waiting');
        $('button').removeClass("on");
        $.playSound(talkStop);
        $("body").removeAttr("class");
      }
    });
    $('audio').remove();
  });

  /*===================
  Simulations  
  ====================*/

  // Incoming Message Sequence
  $(simIncoming).click(function() {
    if (!$("body").hasClass("has-busy")) {
      $(getBody).removeAttr("class");
      $("body").addClass("has-incoming active");
      $("button").addClass("on");
      setTimeout(stopIncoming, 3000);

      function stopIncoming() {
        $.playSound(talkStop);
        $("body").removeAttr("class");
        $("button").removeClass("on");
      }
    }
    $('audio').remove();
  });

  // Receiver is busy

  $(simBusy).click(function() {
    if (!$("body").hasClass("has-incoming")) {
      if ($(getBody).hasClass("has-busy")) {
        $(getBody).removeAttr("class");
      } else {
        $(getBody).addClass("has-busy active");
      }
    }
    $('audio').remove();
  });

  // Handshake Error
  $(simError).click(function() {
    $.playSound(talkError);
    $(getBody).removeAttr("class");
    $(getBody).addClass("has-error");
  });
  $('audio').remove();
});
              
            
!
999px

Console