-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestions.js
57 lines (53 loc) · 1.69 KB
/
questions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var jsonObj=[{
"ID": 1,
"Question_Text": "Whaaaa?",
"Course": {
"ID": 1,
"Name": "COMP 426",
"Description": "Silly Class"
},
"User":{
"ID": 1,
"Display_Name": "Evan"
},
"Semester": "Fall 2013",
"Professor": "KMP"
},
{
"ID": 2,
"Question_Text": "How to things?",
"Course": {
"ID": 2,
"Name": "COMP 535",
"Description": "Security"
},
"User":{
"ID": 1,
"Display_Name": "Evan"
},
"Semester": "Fall 2013",
"Professor": "Mike Reiter"
}];
//var fakeJSON = $.parseJSON(jsonObj);
$(document).ready(function(){
console.log(jsonObj);
var i=0;
var html="";
for (i=0; i<jsonObj.length; i++) {
html+="<div class='question' id='question"+jsonObj[i].ID+"'><h3><a href='questionDetail.html?id="+jsonObj[i].ID+"'>"+jsonObj[i].Question_Text+"</a></h3>";
html+="<br/>Asked by "+jsonObj[i].User.Display_Name;
html+="<br/>In " ;
//CHange conditionals to existence of professor, course, and semester. Will be slightly more complicated.
if (true) {
html+= jsonObj[i].Professor + "'s ";
}
if(true){
html+= jsonObj[i].Course.Name + " course";
}
if (true) {
html+= " during " +jsonObj[i].Semester;
}
html+=".</div>";
}
$('#questions').html(html);
});