質問するログイン新規登録

回答編集履歴

1

抜本的ン変えました。

2025/02/14 03:47

投稿

senbokukoumi
senbokukoumi

スコア1

answer CHANGED
@@ -1,1 +1,214 @@
1
- この件については、一度取り下げてまた再度別のサイトで出させていただきます。
1
+ function getStationTimetable(currentStaNum)
2
+ {
3
+ //alert(currentStaNum);
4
+
5
+ stationTimetableArrayKey = new Array();
6
+
7
+ stationTimetableArrayKey[currentStaNum] = new Array();
8
+ stationTimetableArrayKey[currentStaNum]["下り"] = new Array();
9
+ stationTimetableArrayKey[currentStaNum]["上り"] = new Array();
10
+
11
+ var i=0;
12
+ var trainCount = new Array;
13
+ trainCount["下り"] = 0;
14
+ trainCount["上り"] = 0;
15
+ for(i=0 ; i<trainBasicData.length ; i++)
16
+ {
17
+ arrayKey = timeTableArrayKey[i];
18
+
19
+ //運転日が一致する場合のみ続ける
20
+ //if(timeTable[arrayKey]["運転日"] != "平日" && timeTable[arrayKey]["運転日"] != "全日")
21
+ if(!judgeTrainRunningDay(timeTable[arrayKey]["運転日"]))
22
+ continue;
23
+
24
+ //駅の時刻がちゃんと入力されていて
25
+ //、かつ終着駅=大阪駅でない場合 && timeTable[arrayKey]["行先"] != stationList[currentStaNum]
26
+ if(timeTable[arrayKey]["駅時刻"][currentStaNum]["着"] >= 0 )
27
+ {
28
+ var direction = timeTable[arrayKey]["方向"];
29
+ //列車番号+運転日を記録
30
+ stationTimetableArrayKey[currentStaNum][direction][trainCount[direction]] = arrayKey;
31
+
32
+ //カウント
33
+ trainCount[direction]++;
34
+
35
+ //alert(arrayKey + " は " + stationList[currentStaNum] + "駅で " + timeTable[arrayKey]["駅時刻"][stationList[currentStaNum]]["着"] + "〜" + timeTable[arrayKey]["駅時刻"][stationList[currentStaNum]]["発"]);
36
+ //stationTimetableArrayKey[19][trainCount]
37
+ //trainCount++;
38
+ }
39
+ }
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ //alert(stationList[currentStaNum])
48
+ //alert(stationTimetableArrayKey[currentStaNum]["下り"].length +"本を入れ替えよう");
49
+
50
+ ////////発車時刻の順にクイックソートで並び替える
51
+ var i, j, k;
52
+ for(i = 0 ; i<directionNameAry.length ; i++)
53
+ {
54
+ var currentDirection = directionNameAry[i];
55
+
56
+ var buff = ""; //データを一時的に避難させておくところ
57
+
58
+ for(j=stationTimetableArrayKey[currentStaNum][currentDirection].length-1 ; j>=0 ; j--)
59
+ {
60
+ for(k=0 ; k<j ; k++)
61
+ {
62
+ //時刻の大小関係が逆だったら、入れ替える
63
+ //クイックソート
64
+ //入れ替える対象は
65
+ var arrayKeyA = stationTimetableArrayKey[currentStaNum][currentDirection][k];
66
+ var arrayKeyB = stationTimetableArrayKey[currentStaNum][currentDirection][k+1];
67
+
68
+ //alert(arrayKeyA);
69
+ //alert(arrayKeyB);
70
+
71
+ if(timeTable[arrayKeyA]["駅時刻"][currentStaNum]["発"] > timeTable[arrayKeyB]["駅時刻"][currentStaNum]["発"])
72
+ {
73
+ //入れ替える
74
+ stationTimetableArrayKey[currentStaNum][currentDirection][k] = arrayKeyB;
75
+ stationTimetableArrayKey[currentStaNum][currentDirection][k+1] = arrayKeyA;
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ //alert(stationTimetableArrayKey[currentStaNum]["下り"]);
82
+
83
+
84
+ //alert(stationTimetableArrayKey[currentStaNum]["下り"].length +"本あるよ");
85
+
86
+
87
+
88
+
89
+ //////結果をDIVに出力
90
+ for(i = 0 ; i<directionNameAry.length ; i++)
91
+ {
92
+ var currentDirection = directionNameAry[i];
93
+ var output = "";
94
+ output += "";
95
+ output += "";
96
+ //output += "<table border='0'>";
97
+ output += "<div>";
98
+ output += "";
99
+ output += "";
100
+ output += "";
101
+
102
+ nextTrainHeight = ""; //次発の列車の縦位置を記録する変数
103
+ divTop = 0; //1行ごとに20ずつ増やしていく
104
+
105
+ for(j=0 ; j < stationTimetableArrayKey[currentStaNum][currentDirection].length ; j++)
106
+ {
107
+ var currentArrayKey = stationTimetableArrayKey[currentStaNum][currentDirection][j];
108
+ //alert(currentArrayKey);
109
+ //document.getElementById("staTimetableTimeDiv").innerHTML += i+"本目 "+currentArrayKey+"<br />";
110
+ //output += "<tr style='white-space:nowrap; height:25px; '>";
111
+
112
+ var bgColor = getTypeColor(timeTable[currentArrayKey]["種別"], 0);
113
+ var color = getTypeColor(timeTable[currentArrayKey]["種別"], 1);
114
+
115
+ output += "<div style='position:absolute; top:"+divTop+"px; left:0px; width:60px; text-align:center;'><span style='color:"+color+"; background-color:"+bgColor+"'>" + timeTable[currentArrayKey]["列車番号"] + "</span></div>";
116
+ output += "<div style='position:absolute; top:"+divTop+"px; left:40px; width:120px; text-align:center;'><span style='color:"+color+"; background-color:"+bgColor+"'>" + timeTable[currentArrayKey]["種別"] + "</span></div>";
117
+
118
+ //着時刻と発時刻が異なる場合、つまりその駅に停車する場合
119
+ if(timeTable[currentArrayKey]["駅時刻"][currentStaNum]["着"] != timeTable[currentArrayKey]["駅時刻"][currentStaNum]["発"])
120
+ {
121
+
122
+ //着時刻
123
+ var timeOutput = "";
124
+ var secondSum = timeTable[currentArrayKey]["駅時刻"][currentStaNum]["着"];
125
+ timeOutput += digitAdjuster(secondToHour(secondSum), "&nbsp;");
126
+ timeOutput += ":";
127
+ timeOutput += digitAdjuster(secondToMinute(secondSum), "0");
128
+ //timeOutput += "<span style='font-size:70%;'> ";
129
+ //timeOutput += digitAdjuster(secondToSecond(secondSum), "0");
130
+ //timeOutput += "</span>";
131
+ timeOutput += "";
132
+
133
+ output += "<div style='position:absolute; top:"+divTop+"px; left:150px; width:70px; text-align:right;'>" + timeOutput + " <span style='font-size:80%; '>着</span></div>";
134
+
135
+ //発時刻
136
+ var timeOutput = "";
137
+ var secondSum = timeTable[currentArrayKey]["駅時刻"][currentStaNum]["発"];
138
+ timeOutput += digitAdjuster(secondToHour(secondSum), "&nbsp;");
139
+ timeOutput += ":";
140
+ timeOutput += digitAdjuster(secondToMinute(secondSum), "0");
141
+ //timeOutput += "<span style='font-size:70%;'> ";
142
+ //timeOutput += digitAdjuster(secondToSecond(secondSum), "0");
143
+ //timeOutput += "</span>";
144
+ timeOutput += "";
145
+
146
+ output += "<div style='position:absolute; top:"+divTop+"px; left:230px; width:70px; text-align:right;'>" + timeOutput + " <span style='font-size:80%; '>発 </span></div>";
147
+ }
148
+ else
149
+ {
150
+ //その駅を通過する列車の場合
151
+ var timeOutput = "";
152
+ var secondSum = timeTable[currentArrayKey]["駅時刻"][currentStaNum]["発"];
153
+ timeOutput += digitAdjuster(secondToHour(secondSum), "&nbsp;");
154
+ timeOutput += ":";
155
+ timeOutput += digitAdjuster(secondToMinute(secondSum), "0");
156
+ //timeOutput += "<span style='font-size:70%;'> ";
157
+ //timeOutput += digitAdjuster(secondToSecond(secondSum), "0");
158
+ //timeOutput += "</span>";
159
+ timeOutput += "";
160
+
161
+ //output += "<td colspan='2' style='text-align:center;'>" + timeOutput + " 通過</td>";
162
+ output += "<div style='position:absolute; top:"+divTop+"px; left:230px; width:70px; text-align:center; color:#aaa; '>" + timeOutput + " <span style='font-size:80%; '>通過</span></div>";
163
+ }
164
+
165
+ //次発の列車の縦位置を特定する
166
+ var secondSum = timeTable[currentArrayKey]["駅時刻"][currentStaNum]["発"];
167
+ if(setSecondSum < secondSum && nextTrainHeight == "")
168
+ nextTrainHeight = divTop - 20;
169
+
170
+
171
+
172
+ if(timeTable[currentArrayKey]["行先"] != stationList[currentStaNum])
173
+ {
174
+ output += "<div style='position:absolute; top:"+divTop+"px; left:310px; width:150px; '>" + timeTable[currentArrayKey]["行先"] + "<span style='font-size:80%;'> 行</span></div>";
175
+ }
176
+ else
177
+ {
178
+ output += "<div style='position:absolute; top:"+divTop+"px; left:310px; width:80px; '>当駅止まり</div>";
179
+ }
180
+
181
+ if(timeTable[currentArrayKey]["駅時刻"][currentStaNum]["のりば"] >= 0)
182
+ output += "<div style='position:absolute; top:"+divTop+"px; left:390px; width:80px; text-align:right;'>" + timeTable[currentArrayKey]["駅時刻"][currentStaNum]["のりば"] + "<span style='font-size:80%;'> 番線</span></div>";
183
+ else
184
+ output += "<td></td>";
185
+ output += "</tr>\n";
186
+
187
+ divTop+= 20;
188
+
189
+
190
+ }
191
+ //output += "</table>";
192
+ output += "</div>";
193
+
194
+ var idName = "staTimetableTime"+i+"Div";
195
+ if(document.getElementById(idName) != null)
196
+ document.getElementById(idName).innerHTML = output;
197
+
198
+ //現在時刻へスクロールする
199
+ if(document.getElementById(idName) != null)
200
+ document.getElementById(idName).scrollTop = nextTrainHeight;
201
+
202
+
203
+ var idName = "staTimetableTimeTitle"+i+"Div";
204
+ if(document.getElementById(idName) != null)
205
+ document.getElementById(idName).innerHTML = stationList[currentStaNum]+"駅 "+currentDirection+" 時刻表";
206
+
207
+
208
+ output += "";
209
+ output += "";
210
+ output += "";
211
+
212
+
213
+ }
214
+ }→始発駅と終着駅の表示時間に揺らぎを持たせないことで解決しました。