View difference between Paste ID: dinuR9kR and T2GLRHph
SHOW: | | - or go back to the newest paste.
1
<script>
2
$(document).ready(function(){
3
4
var new_block = function(articleHID, articleHeader, section){
5
    var stuff = $("#article").clone();
6
7
    $(stuff).attr('id', "notheader");
8
    $(stuff).find('#articleHeader').attr('id',articleHID);
9
    $(stuff).find('#articleHeader').html(articleHeader);
10
    $(stuff).find('#sectionList').html(section);
11
    $(stuff).attr('style', 'visibility: visible;');
12
13
    return stuff;
14
15
}
16
var loadConstitution = function(d){
17
	$.each(d[0].articles, function(i, article){
18
      var articleID = "article" + i;
19
      var articleHeaderID = "articleHeader" + i;
20
      var articleHeader = "<p class='lead' id='articleHeader'><strong>Article " + i + "</strong></p>";
21
      
22
      var mySections = article.sections;
23
24
      var thisSection = "<dl id='sectionList'>";
25
      
26
      $.each(mySections, function(j, section){
27
				thisSection +=
28
      	"<dt>Section " + j + "</dt>" +
29
      	"<dd>" + mySections[j] + "</dd>";
30
      })
31
      document.write(thisSection);
32
      thisSection += "</dl>";
33
34
      $("#constitutionHolder").append(new_block(articleHeaderID, articleHeader, thisSection));
35
	})
36
}
37
		//loads the JSON file to the above function
38
		$.getJSON('data/constitution.json', loadConstitution);
39
})
40
</script>