Skip to content

Instantly share code, notes, and snippets.

@jeshuaborges
Forked from TravisL12/TRLscript.js
Created September 22, 2012 00:16
Show Gist options
  • Save jeshuaborges/3764637 to your computer and use it in GitHub Desktop.
Save jeshuaborges/3764637 to your computer and use it in GitHub Desktop.
An attempt at JS
var blogs = [
{"Title" : "Rebuilding shit",
"Post" : "I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. ",
"Footer" : "September 3rd 2012"
},
{"Title" : "Second post containting stuff",
"Post" : "Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. " ,
"Footer" : "October 2nd 2012"
},
{"Title" : "The third thing I've typed out",
"Post" : "At this point I am trying to determine how a \'for\' loop effects what is drawn on a page\." ,
"Footer" : "December 4th 2012"
}
];
window.addEventListener("DOMContentLoaded", function() {
target = document.getElementById("post-index");
for(var i=0; i<blogs.length; i++) {
var element = document.createElement('li');
element.appendChild(document.createTextNode(blogs[i]['Title']));
target.appendChild(element);
}
})
window.addEventListener("click", function() {
target = document.getElementById("post-blog");
for(var i=0; i<blogs.length; i++) {
var element = document.createElement('ul');
element.appendChild(document.createTextNode(blogs[i]['Post']));
target.appendChild(element);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment