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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <nav id="navbar">
  <header>
    <h1>
      Mobile Assesment Documentation
    </h1> 
    <div id="hide-menu" class="hide-menu menu-button -right">
      <a href="#" class="btn">close [x]</a>
    </div>
  </header>
  <ul>
    <li><a class="nav-link" href="#introduction">Introduction</a></li>
    <li><a class="nav-link" href="#what_you_should_already_know">What you should already know</a></li>
    <li><a class="nav-link" href="#how_we_calculate">How we calculate</a></li>
    <li><a class="nav-link" href="#data_structure">Data Structure</a></li>
    <li><a class="nav-link" href="#models">Models</a></li>
    <li><a class="nav-link" href="#model_relation">Model Relation</a></li>
    <li><a class="nav-link" href="#next">Next</a></li>
  </ul>
  <div class="border-right"></div>
</nav>

<main id="main-doc">
  <div id="show-menu" class="show-menu menu-button">
    <a href="#" class="btn">&laquo; menu</a>
  </div>
  <section class="main-section" id="introduction">
    <header>
      <h2>Introduction</h2>        
    </header>
    <article>
      <p>This documentation wiil explain about Assesment App that being used as one of the service or app in SOYUT.</p>        
    </article>
  </section>
  
  <section class="main-section" id="what_you_should_already_know">
    <header>
      <h2>What You Should Already Know</h2>
    </header>
    <article>
      <p></p>
    </article>
  </section>
  
  <section class="main-section" id="how_we_calculate">
    <header>
      <h2>How We Calculate</h2>
    </header>
    <article></article>
  </section>
  
  <section class="main-section" id="data_structure">
    <header>
      <h2>Data Structure</h2>
    </header>
    <article>
      <h3>Databases</h3>
      <p>This app using 2 database with 5 tables involved, these data structured like this:</p>
      <p></p>
    </article>
  </section>
  
  <section class="main-section" id="models">
    <header>
      <h2>Models</h2>
    </header>
    <article>
      <p>The application contains of 5 Javascript Classes</p>

      <h3>Base Models</h3>
      <ul>
        <li>
          <a href="#subyek_subyek_penilaian">SubyekSubyekPenilaian</a>
          <ul>
            <li>
              <a href="#subyek_penilaian">SubyekPenilaian</a>
              <ul>
                <li>
                  <a href="#nilai">Nilai</a>
                  <ul>
                    <li>
                      <a href="#aspect">Aspect</a>
                      <ul>
                        <li><a href="#checklist">Checklist</a></li>
                        <li>NilaiData</li>
                        <li>Poin</li>
                      </ul>
                    </li>           
                  </ul>
                </li>
              </ul>
            </li>
          </ul>
        </li>


      </ul>
      
      <h3>Extended Models</h3>
      <ul>
        <li>KogasKogas extend SubyekSubyekPenilaian</li>
        <li>ParaPelaku extend SubyekPenilaian</li>
        <li>Kogas extend SubyekPenilaian</li>
        <li>Pelaku extend SubyekPenilaian</li>
      </ul>
      
      <section id="subyek_subyek_penilaian">
        <h4>SubyekSubyekPenilaian</h4></a>
      <code>
        <pre>
class SubyekSubyekPenilaian {
    constructor() {
        this.subyek = {};
        this.countSubyek = 0;
        this.winningSubyek = {};
        this.highestGrade = 0;
    }
    addSubyek(subyek) {
        this.subyek[subyek.id] = subyek;
    }    
    copy() {    
        this.calculateEachSubyek();        
        this.getCountSubyek();
        this.getHighestGrade();
    }
    getCountSubyek() {
        let count = 0;
        for (let item in this.subyek) {
            count++;
        }
        this.countSubyek = count;
    }
    calculateEachSubyek() {
        for (let id in this.subyek) {
            this.subyek[id].getNilaiSubyek()
        }
    }
    getHighestGrade() {                
        for (let id in this.subyek) {
            if (this.highestGrade < this.subyek[id].result) {
                this.highestGrade = this.subyek[id].result;
                this.winningSubyek = this.subyek[id];
            }
        }
        
    }
}

module.exports = SubyekSubyekPenilaian;
        </pre>
      </code>  
      </section>
      
      <section id="subyek_penilaian">
        <h3>Subyek Penilaian</h3>
        <code>
          <pre>
const Nilai = require('./Nilai');

class SubyekPenilaian {
    constructor(subyek) {
        this.id = subyek.id;
        this.type = subyek.type;
        this.refId = subyek.refId;
        this.subyekId = subyek.subyekId || '';
        this.subyekData = subyek.subyekData || '';
        this.result = 0;

        this.nilai = new Nilai();
    }
    addAspects(checklists) {
        this.nilai.addAspects(checklists);
    }
    addNilaiData(nilaiData) {
        this.nilai.addNilaiData(nilaiData);
    }
    getNilaiSubyek() {
        this.nilai.getResult();        
        this.result = this.nilai.result;
    } 
}

module.exports = SubyekPenilaian;
          </pre>
        </code>
      </section>
      
      <section id="nilai">
        <h3>Nilai</h3>
        <code><pre>
const Aspect = require('./Aspect');

class Nilai {
    constructor() {
        this.aspect = {};
        this.countAspect = 0;
    }
    addAspect(checklist) {        
        this.aspect[checklist.penilaianData.id] = new Aspect(checklist);
        this.countAspect++;
        this.result = 0;
    }
    addAspects(checklists) {
        for (let i = 0, y = checklists.length; i < y; i++) {
            this.addAspect(checklists[i]);
        }
    }
    addNilaiData(nilaiData) {
        if (this.aspect[nilaiData.lembarNilaiId]) {
            this.aspect[nilaiData.lembarNilaiId].addNilaiData(nilaiData);
        } else {
            console.log('no aspect id for', nilaiData.lembarNilaiId);
        }
    }    
    getResult() {
        let totalNilai = 0;
        for (let key in this.aspect) {
            totalNilai += this.aspect[key].nilai;
        }
        this.result =  totalNilai / this.countAspect;
    }
    

}

module.exports = Nilai;
</pre></code>
      </section>
        
      <section id="aspect">
        <h3>Aspect</h3>
        <code>
          <pre>
const Checklist = require('./Checklist');
class Aspect {
    constructor(checklist) {
        this.checklist = new Checklist(checklist);
        this.nilaiData = {};
        this.poin;
        this.weight = 0;
        if (checklist.penilaianData) {
            this.poin = this.initPoin(checklist);
            this.weight = this.getTotalWeight();
        }
        this.nilai = 0;
    }
    addNilaiData(nilaiData) {
        this.nilaiData = nilaiData;
        this.addGradeToPoin(nilaiData);
        this.nilai = this.calculatePoin();
    }
    initPoin(checklist) {
        return checklist.penilaianData.aspects.map(aspect => {
            return {
                id: aspect.id,
                title: aspect.aspect,
                description: aspect.description,
                max: aspect.max,
                weight: aspect.weight,
                grade: aspect.grade
            }
        });
    }
    addGradeToPoin(nilaiData) {
        for (let i = 0, y = nilaiData.aspeks.length; i < y; i++) {
            if (nilaiData.aspeks[i].nilai !== 0) {
                for (let z = 0, j = this.poin.length; z < j; z++) {
                    if (nilaiData.aspeks[i].aspekId === this.poin[z].id) {
                        this.poin[z].grade = nilaiData.aspeks[i].nilai;
                        this.poin[z].description = nilaiData.aspeks[i].keterangan;                        
                    }
                }
            }
        }
    }
    calculatePoin() {
        let totalVal = 0;
        for (var i = 0, y = this.poin.length; i < y; i++) {
            if (this.poin[i].grade !== 0) {
                this.poin[i].value = (this.poin[i].grade / this.poin[i].max) * this.poin[i].weight;
                totalVal += this.poin[i].value;
            }            
        }
        return totalVal;
    }
    getTotalWeight() {
        let res = 0;
        for (let i = 0, y = this.poin.length; i < y; i++) {
            res += this.poin[i].weight;
        }
        return res;
    }
    get totalWeight() {
        return this.getTotalWeight();
    }
}

module.exports = Aspect;
          </pre>
        </code>
      </section>
        
      <section id="checklist">
        <h3>Checklist</h3>
        <code>
          <pre>
  class Checklist {
    constructor(checklist) {
        this.aspect = checklist.aspect;
        this.description = checklist.description;
        this.id = checklist.id;
        this.main = checklist.main;
        this.penilaian = checklist.penilaian;
        this.no = checklist.no;
        this.sort = checklist.sort;
        this.penilaianData = checklist.penilaianData;
        this.nilaiData = {};        
    }
}

module.exports = Checklist;
          </pre>
        </code>
        </section>
      
    </article>
  </section>
 

  <section class="main-section" id="model_relation">
    <header>
      <h2>Model Relation</h2>
    </header>
    <article>
      <h3>Kogas Relation</h3>
      <p></p>
      
      <h3>Pelaku Relation</h3>
      <p></p>
      
      <h3>Nilai Relation</h3>
      <p></p>
    </article>
  </section>
  
  <section class="main-section" id="next">
    <header>
      <h2>Next</h2>
    </header>
    <article>
      <h3>What to do next ?</h3>
      <p></p>
      
      <h3>How you can improve this app</h3>
      <p></p>
    </article>
  </section>
</main>

              
            
!

CSS

              
                html, body {
  font-family: 'Rubik', sans-serif;
  font-size: 1em;
  line-height: 1.618em;
  background: whitesmoke;
}
* {
  box-sizing: border-box;
}

#navbar {
  position: fixed;
  min-width: 300px;
  width: 300px;
  height: 100%;
  top: 0px;
  left: 0px;
  background-color: lightskyblue;

  z-index: 100;
}
.border-right {
  position: absolute;
  display: block;
  width: 1em;
  height: 100%;
  background-color: rgba(128,187,248, .38);
  z-index: 1000;
  top: 0px;
  right: 0px;
}
#main-doc {
  position: absolute;
  max-width: 100%;
  margin-left: 300px;
  margin-bottom: 110px;
  padding-left: 1.618em;
  padding-top: 1.618em;
  border-left: 3px solid white;
  z-index: 50;
}
code {
  display: block;
  text-align: left;
  position: relative;
  word-break: normal;
  line-height: 2;
  background-color: #ddeeff;
  padding: 1.618em;
  margin: 1.618em;
  font-size: .83em;
  border-radius: 1em;
}

/* sidebar styling */
#navbar header h1 {
  display: block;
  padding: 1em;
  text-align: left;
}
#navbar ul {
  height: 88%;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}
#navbar ul li {
  padding: 1em;
  list-style-type: none;
  border: 1px solid rgba(255, 255, 255, .6);
  border-bottom: none;
  border-right: none;
  width: 100%;
  background: hsl(202,88,75);  
}
#navbar ul li:hover {
  cursor: pointer;
  background: rgb(140,215,255);
}
#navbar ul li a {
  display: block;
  color: black;
  background: black
  width: 100%;
}
#navbar ul li a:hover {
  text-decoration: none;
}


/* menu & responsives */
.menu-button {
  display: none;
  position: fixed;
  top: 1.618em;
  margin-bottom: 1em;  
  z-index: 150;
}
.menu-button .btn {
  padding: 10px 16px;
  line-height: 1em;
  background: #dedede;
  border-radius: 1em;
  color: #555;
  border: 1px solid #dedede;
}
.menu-button.-left {
  left: 1em;
}
.menu-button.-right {
  right: 1em;  
}
.menu-button .btn:hover {
  text-decoration: none;
  background-color: #ededed;
  border-color: #dedede;
  color: #333;
}

@media (max-width: 480px) {
  .menu-button {
    display: block;    
  }
  #navbar {
    width: 100%;
/*     padding-top: 1em; */
    transform: translateX(-98%);
    border: none;
  }
  #main-doc {
    padding-top: 5em;
    margin: 0;
  }
  #navbar.-hide {
    animation-name: slideLeft;
    animation-duration: .3s;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
  }
  #navbar.-show {
    animation-name: slideRight;
    animation-duration: .3s;
    animation-timing-function: ease-out;
    animation-fill-mode: forwards;
  }
}
@keyframes slideRight {
  100% {
    transform: translateX(0%);
  }
}
@keyframes slideLeft {
  0% {
    transform: translate(0%);
  }
  100% {
    transform: translateX(-98%);
  }
}
              
            
!

JS

              
                const showMenuBtn = document.getElementById('show-menu');
const hideMenuBtn = document.getElementById('hide-menu');
const navbar = document.getElementById('navbar')

function handleShowMenu(e) {
  e.preventDefault();
  navbar.classList.remove('-hide');
  navbar.classList.add('-show');
  console.log('show', e.target)
}

function handleHideMenu(e) {
  e.preventDefault();
  navbar.classList.remove('-show');
  navbar.classList.add('-hide');
  console.log('hide', e.target)
}

showMenuBtn.addEventListener('click', handleShowMenu);
hideMenuBtn.addEventListener('click', handleHideMenu);
              
            
!
999px

Console