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

              
                <h2 class="bar bar-header bar-light">My Tasks (<span id="tasksLength"></span>)</h2>
<hr class="has-header" />
<div id="taskContainer" class="has-header">
</div>
<hr />
<button id="refresh-tasks">Refresh Tasks</button>
<div class="add-task-section">
  <form name="addTask">
    <input type="search" required placeholder="I want to..." id="add-task" />
    <input type="submit" value="Add Task" />
  </form>
</div>

<div class="delete-item-section">
   <button onclick="deleteTask();" id="deleteSelected">Delete Selected</button>
</div>

<hr />
<h3>Tasks Completed</h3>
<hr />
<div id="completedTasksContainer">
</div>




<div class="overlay" id="overlay">
  <div class="roadmap">
  <ol>
    <li class="achieved">Add roadmap section</li>
    <li class="achieved">Add Delete Task Functionality</li>
    <li class="achieved">Move Delete Tasks to Archived Section</li>
    <li>Add Task Clear Functionality</li>
  </ol>  
  </div>
  <button id="hideRoadmap">Hide</a>
</div>
<button class="roadmap-btn" id="showRoadmap">Roadmap</button>




              
            
!

CSS

              
                .has-header{
  margin-top: 24px;
}
#taskContainer ul{list-style-type:none}
li{
  transition: all 0.7s ease-in;
}

li.selected{
  background:#ccc;
}

#completedTasksContainer li.selected{
  background: #fff;
  text-decoration:line-through;
}

/* -- Road map styles **/
.achieved{text-decoration: line-through}
.overlay{
  width: 100%;
  height: 100%;
  display:none;
  position:absolute;
  top:0;
  left:0;
  background: rgba(0,0,0,0.8);
}

.show{ display: block;}
.overlay ol{
  color:#fff;
}
.roadmap-btn{
  position:fixed;
  right: 0;
  bottom: 0;
  z-index:-1;
}
              
            
!

JS

              
                
var tasksContainer = document.getElementById("taskContainer");
 var selectedTasksContainer = document.createElement('ul');
var superItem;

var myTasks = ["Retrieve Driving Licence", "Write 300 words", "Check Emails"];

function selectTasks(){
  document.getElementById('refresh-tasks').addEventListener('click', refreshTasks);

var inputs = document.querySelectorAll('[type=checkbox]');

for(var i=0; i<inputs.length; i++){
    inputs[i].addEventListener('change',function(){
    highlight(this);
  });
}
}



function refreshTasks() {
  tasksContainer.innerHTML = '';
  
  if(myTasks.length <= 0){
    tasksContainer.innerHTML = "There no tasks, kindly add one"
  } else {
  
  var list = document.createElement('ul');
  for (var i = 0; i < myTasks.length; i++) {
    var item = document.createElement('li');
    var cb = document.createElement('input');
    var itemText = document.createTextNode(myTasks[i]);
    
    cb.setAttribute('type', 'checkbox');
    cb.setAttribute('data-item',myTasks[i]);
    cb.setAttribute('data-item','cb');
    cb.setAttribute('id','cb'+i);
    

    item.appendChild(cb);
    item.appendChild(itemText);

    list.appendChild(item);
  }
    tasksContainer.appendChild(list);
  selectTasks();
  }
  document.getElementById('tasksLength').innerHTML = myTasks.length;

}

function addTask(){
  myTasks.splice(myTasks.length,0,document.getElementById('add-task').value);
 
  refreshTasks();
  document.getElementById('add-task').value="";
}

document.forms.addTask.addEventListener('submit',function(evt){
  evt.preventDefault();
  addTask();
});

function deleteTask(){  
  //debug
  
 //selectedTasksContainer.innerHTML = '';
var inputs = document.querySelectorAll('[type=checkbox]');
  
for(var i=0; i<inputs.length; i++){
    if(inputs[i].checked){
      var currentCB = inputs[i];
      var currentLi = inputs[i].parentNode;
      currentLi.removeChild(currentCB);
      selectedTasksContainer.appendChild(currentLi);
      
      myTasks.splice(currentLi.childNodes[0].nodeValue,1);
    }
  
  
}
  console.log(selectedTasksContainer);
  refreshTasks();
  document.getElementById('completedTasksContainer').appendChild(selectedTasksContainer);
 
}



function highlight(item){
  var selectedItems = document.querySelectorAll('[data-item]');
  //console.log(selectedItems);
  //console.log(item.parentNode);
  item.parentNode.classList.toggle('selected');
}

refreshTasks();

// Overlay Section

document.getElementById("showRoadmap").addEventListener('click',function(){
  document.getElementById("overlay").classList.add('show');
});

document.getElementById("hideRoadmap").addEventListener('click',function(){
  document.getElementById("overlay").classList.remove('show');
})




              
            
!
999px

Console