Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathprogram_visualization.html
More file actions
Latest commit
91 lines (76 loc) · 3.59 KB
/
Copy pathprogram_visualization.html
File metadata and controls
91 lines (76 loc) · 3.59 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<head>
<metahttp-equiv=Content-Typecontent="text/html; charset=utf-8">
<title>Program visualization</title>
</head>
<body>
<divid="hackfmi-root"></div>
<scriptsrc="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<scriptsrc="http://underscorejs.org/underscore.js" type="text/javascript"></script>
<scripttype="text/javascript">
$(document).ready(function(){
functiontoId(selector){
return"#"+selector;
}
functiondays(){
return["monday","tuesday","wednesday","thursday","friday","saturday"];
}
functionlabelOrDefault(item,defaultValue){
if(!_.isUndefined(item.label)){
returnitem.label;
}
returndefaultValue;
}
varrenderProgramItem=(function(){
varitemTemplate="<strong><%= label %></strong> От: <%= startTime %> До: <%= endTime %>";
returnfunction(programItem){
return_.template(itemTemplate,{
label : labelOrDefault(programItem,"Предмет без label"),
startTime : programItem.start,
endTime : programItem.end
});
};
})();
$.getJSON('program_cs.json',{},function(json,textStatus){
console.log(json);
varroot="#hackfmi-root";
$("<h1></h1>").html(labelOrDefault(json,"Няма label за тази програма")).appendTo(root);
_.each(["year1","year2","year3","year4"],function(year){
$("<h2></h2>")
.attr("id",year)
.html(labelOrDefault(json[year],year))
.appendTo(root);
varflows=json[year].flows;
for(vari=0,len=flows.length;i<len;i++){
var$p=$("<p></p>")
.html("Поток "+(i+1).toString());
console.log($p);
$(toId(year))
.after($p);
var$containerDiv=$("<div></div>");
$p.after($containerDiv);
_.each(days(),function(day){
$containerDiv.append(
$("<strong></strong>")
.html(labelOrDefault(flows[i][day],day))
);
$containerDiv.append($("<br />"));
for(varj=0,flowsLen=flows[i][day].groups.length;j<flowsLen;j++){
console.log("Looping");
$containerDiv.append(
$("<p></p>")
.html("Група "+(j+1).toString()));
var$programList=$containerDiv.append("<ul></ul>");
_.each(flows[i][day].groups[j],function(currentGroupProgramItem){
$programList.append($("<li></li>").html(renderProgramItem(currentGroupProgramItem)));
});
}
});
}
});
});
});
</script>
</body>
</html>