123

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <p style="text-align:center;font-family:Helvetica;">This is a WORK IN PROGRESS.<br />(That means it's not done)<br />IDK when / if I'll get around to finishing this. I'd like to sometime.</p>
<br />
<div class="difficulty-level">
  <span>Set Difficulty:</span>
  <select id="dl-select">
    <option value="veryeasy">Very Easy</option>
    <option value="easy">Easy</option>
    <option value="normal">Normal</option>
    <option value="hard">Hard</option>
    <option value="veryhard">Very Hard</option>
  </select>
</div>

<div id="minigame-container">
  <div class="terminal-display">
   <div class="static-text">
     ROBCO INDUSTRIES (TM) TERMLINK PROTOCOL
     <br />
     ENTER PASSWORD NOW
    </div>
    <div class="attempt-text">
      <span id="attempts-remaining">4</span>
      <span>ATTEMPT(S) LEFT:</span>
    </div>
    <ul id="hex-1" class="hexbox"></ul>
    <div id="pb-1" class="passbox"></div>
    <ul id="hex-2" class="hexbox"></ul>
    <div id="pb-2" class="passbox"></div>

  </div>
</div>
<div id="dev-commands">
<button class="dev-command" onclick="hex.generate();">Generate Hex Lists</button>
<button class="dev-command" onclick="key.generate();">Generate Key Lists</button>
  <button class="dev-command" onclick="asd();">Remove Password Test</button>
</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Inconsolata);
@import url(https://fonts.googleapis.com/css?family=Anonymous+Pro:700);
@import url(https://fonts.googleapis.com/css?family=VT323);

body{
  background-color:black;
  color:lime;
  font-family: 'VT323', 'Anonymous Pro', 'Inconsolata';
  width:100%;
  height:100%;
}

.difficulty-level{
  width:500px;
  margin:auto;
}

.difficulty-level span, .difficulty-level select{
  display:inline-block;
}

#dl-select{
  background:none;
  color:lime;
  border:none;
  font-family:Inconsolata;
  font-size:100%;
  border:solid 1px lime;
}

#minigame-container{
  position:relative;
  width:60%;
  margin:auto;
}

.terminal-display{
  position:relative;
  width:60%;
  height:60%;
  min-height:45%;
  background-color:#053105;
  display:block;
  margin:auto;
  border-radius:7px;
}

.static-text, .attempt-text{
  position:relative;
  margin:25px;
}

#hex-1{
  margin-left:25px;
}

.hexbox, .passbox{
  list-style-type:none;
  display:inline-block;
}

.hexbox{
  width:6ch;
  padding:0px;;
}

.passbox{
  word-wrap: break-word;
  width:12ch;
}

.choice{
  color:lime;
  background-color:transparent;
}

.choice:hover{
  color:#053105;
  background-color:lime;
}

#dev-commands{
  width:500px;
  display:block;
  margin:auto;
  padding:25px;
}

.dev-command{
  display:inline-block;
}
            
          
!
            
              

var password;
var attemptsLeft = 4;
var difficulty;

var terminal = {
  init: function(){
    hex.generate();
    key.generate();
  },
    
  check: function(){
    alert("test");
  },
  
  reset: function(){
  alert("test");
  }  
}

var hex = {
  trim: function(str){
    if(str.length > 6){
      var tmp = str.substring(0, 6);
      return tmp;
    }
    else{
      return str;
    }
  },
  
  add: function(hex, list){
    var el = document.createElement("li");
    var txt = document.createTextNode(hex);
    el.appendChild(txt);
    
    switch(list){
      case 1:
        document.getElementById("hex-1").appendChild(el);
      break;
        
      case 2:
        document.getElementById("hex-2").appendChild(el);
      break;
    }
  },
  
  generate: function(){
    //generate hex lists
    var hexList = [];
    for(var h = 100; hexList.length < 1000; h++){
      hexList.push("0xF" + h);
    }
    //console.log(hexList);
    var tempHex;
    
    for(var o = 0; o < 18; o++){
      //First Column
      tempHex = hex.trim(hexList[Math.floor(Math.random() * hexList.length)]);
      hex.add(tempHex, 1);
      //Second Column
      tempHex = hex.trim(hexList[Math.floor(Math.random() * hexList.length)]);
      hex.add(tempHex, 2);
    }
  }
}

var key = {
  generate: function(){
    difficulty = document.getElementById("dl-select").value;
    
    switch(difficulty){
        //There will be one more than the number submitted here once the passcode is added
      case "veryeasy":
        password = key.chooseRand(keywords.veryeasy, keywords.veryeasy.length);
        //alert(password);
        key.list(8, password, keywords.veryeasy);//9
      break;
        
      case "easy":
        //terminal.passGen(10, password);//11
      break;
        
      case "normal":
        //terminal.passGen(11, password);//12
      break;
        
      case "hard":
        //terminal.passGen(12, password);//13
      break;
        
      case "veryhard":
        //terminal.passGen(13);//14
      break;  
    }
  },
  
  add: function(newLine, col){
    var el = document.createElement("p");
    var txt = document.createTextNode(newLine);
    el.appendChild(txt);
    var br = document.createElement("br");
    
    switch(col){
      case 1:
        document.getElementById("pb-1").appendChild(txt);
        document.getElementById("pb-1").appendChild(br);
      break;
        
      case 2:
        document.getElementById("pb-2").appendChild(txt);
        document.getElementById("pb-2").appendChild(br);
      break;
    }
  },
  
  create: function(str){
    var el = '<span class="choice">' + str.toUpperCase() + '</span>';
    return el;
  },
  
  chooseRand: function(arr, num){
    var tmp = arr[Math.floor(Math.random() * num)];
    return tmp;
  },
  
  list: function(maxNum, pass, arr){
    var pList = new Array();
    var wordBank = arr.slice(0);//Duplicate wordbank
    var res;
    var woPass = keywords.rm(wordBank, pass);
    for(var j = 0; j < maxNum; j++){
      res = key.chooseRand(wordBank, wordBank.length);
      pList.push(res);
      wordBank = keywords.rm(wordBank, res);
    }
    pList.push(password);
    key.shuffle(pList);
    key.assemble(pList);
    //alert(pList);
    key.place(pList);
  },
    
  assemble: function(choices){
    var pbMaxLength = 216;
    var totalLength = 432;
    var str = new String();
    var strArr = new Array();
    var newLine;
    //18 lines per box
    //12 characters per line
    var unabridged = choices.slice(0);//total character length of passwords
    unabridged = unabridged.join("");//join into string
    var bridged = totalLength - unabridged.length;//space leftover after passwords are subtracted
    
    //turn passwords into choice <span>s
    var newChoices = new Array();// = choices.slice(0);
    var tmpChoice;
    for(var v = 0; v < choices.length; v++){
      tmpChoice = key.create(choices[v]);
      newChoices.push(tmpChoice);
    }
    
    //fill string with symbols, then splice in passwords
    var pbone = new String("");
    var pbtwo = new String("");
    //COUNTER THAT RESETS EVERY 12 CHARACTERS AND ADD A NEWLINE
    var bakersDozen = 0;
    for(var a = 1; a < (pbMaxLength + 1); a++){
      bakersDozen++;
      //console.log(a);
      if(bakersDozen == 12){
        bakersDozen = 0;
        document.getElementById("pb-1").innerHTML += "\n";
        document.getElementById("pb-2").innerHTML += "\n";
      }
      else{
        document.getElementById("pb-1").innerHTML += symbols[Math.floor(Math.random() * symbols.length)];
        document.getElementById("pb-2").innerHTML += symbols[Math.floor(Math.random() * symbols.length)];
      }
    }
  },
  
  place: function(pList){
    var passBoxOne = document.getElementById("pb-1").innerHTML;
    var passBoxTwo = document.getElementById("pb-2").innerHTML;
    var pListLength = pList.join();
    pListLength = pListLength.length;
    var pListCopy = pList.slice(0);
    //alert(pListLength);    
    var charNum = 0;
    var tmpNum;
    var placesOne = new Array();//used for multiple things
    var placesTwo = new Array();
    var tmpPlace = 0;
    
    var oneAmount = Math.floor(passBoxOne.length / pListLength);//Number of passwords for box one
    //console.log(oneAmount);
    
    for(var k = 0; k < oneAmount; k++){
      placesOne.push(pListCopy[0]);//add password to list for box one
      pListCopy.shift//remove from main list
    }
    var z = placesOne.join();
    z = z.length;
    console.log(z);
    
  },
  
  shuffle: function(array){
    for(var j, x, i = array.length; i; j = Math.floor(Math.random() * i), x = array[--i], array[i] = array[j], array[j] = x);
    return array;
  }  
}

var brackets = {
  
  confirm: function(){
    
  },
  
  queue: function(){
    
  },
  
  reward: function(){
    
  }
}

var symbols = [
  "!", "@", "#", "$", "%", "^", "*", "(", ")", "'", "<", ">", "?", ".", ",", "/", "+", "-", "=", "_", "[", "]", "{", "}", "|", "~", "`", ":", ";", "\""
];

var keywords = {
  veryeasy: [
    "shoe", "desk", "test", "flee", "door", "chair", "table", "sleep", "weep", "cheap", "open", "drink", "sword", "swim", "climb", "fight", "night", "sight", "shield", "wield", "child", "light"
  ],
  
  easy: [
    "test"
  ],
  
  normal: [
    "test"
  ],
  
  hard: [
    "test"
  ],
  
  veryhard: [
    "test"
  ],
  
  rm: function(array, word){
    var index = array.indexOf(word);
    
    if(index > -1){
      array.splice(index, 1);
    }
    return array;
  }
}

function roll(by){
  var temp = Math.floor(Math.random() * by);
  return temp;
}
//////////////////
terminal.init();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console