main.html
3.93 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<link href="/pages/forecast/sample/css/main.css" rel="stylesheet" type="text/css" />
<div id="lineConfigPanel">
<div class="line_config_tree" >
<h1 >线路</h1>
<ul></ul>
</div>
<div class="line_config_content">
<div class="body ">
<div class="left_station_route">
<div class="tabbable-line" style="height: 100%;">
<ul class="nav nav-tabs ">
<li class="active"><a href="#tab_up" data-toggle="tab"
aria-expanded="true"> 上 行 </a></li>
<li class=""><a href="#tab_down" data-toggle="tab"
aria-expanded="false"> 下 行 </a></li>
</ul>
<div class="tab-content" >
<div class="tab-pane active" id="tab_up">
<ul class="list">
</ul>
</div>
<div class="tab-pane" id="tab_down">
<ul class="list">
</ul>
</div>
</div>
</div>
</div>
<div id="trafficChart" >
<div class="sample_tags"></div>
</div>
</div>
</div>
</div>
<script id="forecast_sample_tree_item_temp" type="text/html">
{{each array as line }}
<li data-code={{line.lineCode}}>
<button>{{line.name}}</button>
</li>
{{/each}}
</script>
<script id="forecast_sample_route_temp" type="text/html">
{{each list as route i}}
<li>
<div> <a class="sample_route_item" data-id="{{route.stationCode}}">{{route.stationName}}</a><div>
</li>
{{/each}}
</script>
<script src="/pages/forecast/sample/js/svg.js"></script>
<script>
!function(){
//站点路由信息
var routes = {};
var $panel = $('#lineConfigPanel')
,$body = $('.line_config_content .body');
var h = $('.page-container>.page-sidebar-wrapper>.page-sidebar').height();
$panel.css('height', h - 18);
//线路滚动条
$('.line_config_tree ul').slimscroll({
height : 'calc(100% - 68px)',
alwaysVisible : true,
opacity : .8
});
//路由
$('.left_station_route .tab-content').slimscroll({
height : 'calc(100% - 46px)',
opacity : .8
});
//上下行切换事件
$('.left_station_route .tabbable-line ul li').on('click', function(){setTimeout(drawSvg, 300);});
$get('/line/all', {destroy_eq:0}, function(rs){
var itemsHtml = template('forecast_sample_tree_item_temp', {array: rs});
$('.line_config_tree ul').html(itemsHtml)
.find('li:eq(0)').click();
});
$panel.on('click', '.line_config_tree li', function(){
$('.line_config_tree li.selected').removeClass('selected');
$(this).addClass('selected');
//显示路由信息
showRouteInfo();
});
function showRouteInfo(){
$.get('/stationroute/all', {'line.lineCode_eq': getLineCode(), 'destroy_eq': 0}
,function(rs){
rs.sort(function(a, b){
return a.stationRouteCode - b.stationRouteCode;
});
var temp = 'forecast_sample_route_temp';
//上下行分组
var ups = [],downs = [];
$.each(rs, function(){
if(this.directions == 0)
ups.push(this);
else
downs.push(this);
});
$('#tab_up ul').html(template(temp, {list: ups}));
$('#tab_down ul').html(template(temp, {list: downs}));
routes.ups = ups;
routes.downs = downs;
drawSvg();
});
}
function showLoad(text){
return layer.msg(text, {icon: 16, time: 0, shade: 0.3});
}
function getUpdown(){
var activePanel = $('.left_station_route .tab-content .tab-pane.active')
,updown = -1
,id = activePanel.attr('id');
if(id == 'tab_up')
updown = 0;
else if(id == 'tab_down')
updown = 1;
return updown;
}
function getLineCode(){
return $('.line_config_tree li.selected').data('code');
}
function drawSvg(){
//绘制svg
var rts = [], updown = getUpdown();
if(updown === 0)
rts = routes.ups;
else if(updown === 1)
rts = routes.downs;
sampleSvg.draw({lineCode: getLineCode(), rts: rts, updown: getUpdown()});
}
$('#lineConfigPanel').on('click', '.sample_route_item', function(){
sampleSvg.popAddModal($(this).data('id'));
})
}();
</script>