Mercurial > hgrepos > hgweb.cgi > skipweb
changeset 123:c80468550499
bus_cgi update
author | MIYAHARA Emiri <c110188@f.koeki-u.ac.jp> |
---|---|
date | Fri, 01 Feb 2013 14:37:44 +0900 |
parents | f4823654c462 |
children | a1ed0503eb8f |
files | bus_cgi/bus1.rb bus_cgi/ruru.css bus_cgi/top.html |
diffstat | 3 files changed, 77 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/bus_cgi/bus1.rb Tue Jan 15 15:30:41 2013 +0900 +++ b/bus_cgi/bus1.rb Fri Feb 01 14:37:44 2013 +0900 @@ -16,21 +16,21 @@ which = cgi["which"] if direc == "e" - open("/home/irhome/c110/c110188/Ruby/zikoku1.txt","r:euc-jp") do |zikoku| + open("zikoku1.txt","r:euc-jp") do |zikoku| while line = zikoku.gets if /(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*)/ =~ line - bus[$10.to_s] = [$1.to_i,$2.to_i,$3.to_i,$4.to_i,$5.to_i, - $6.to_i,$7.to_i,$8.to_i,$9.to_i] + bus[$10.to_s] = [$1.to_s,$2.to_s,$3.to_s,$4.to_s,$5.to_s, + $6.to_s,$7.to_s,$8.to_s,$9.to_s] end end end elsif direc == "k" - open("/home/irhome/c110/c110188/Ruby/zikoku2.txt","r:euc-jp") do |zikoku| + open("zikoku2.txt","r:euc-jp") do |zikoku| while line = zikoku.gets if /(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*),(\S*)/ =~ line - bus[$10.to_s] = [$1.to_i,$2.to_i,$3.to_i,$4.to_i,$5.to_i, - $6.to_i,$7.to_i,$8.to_i,$9.to_i] + bus[$10.to_s] = [$1.to_s,$2.to_s,$3.to_s,$4.to_s,$5.to_s, + $6.to_s,$7.to_s,$8.to_s,$9.to_s] end end end @@ -46,35 +46,72 @@ print("</head>\n") print("<body>\n") print("<link rel=\"stylesheet\" href=\"ruru.css\" type=\"text/css\">\n") -print("<h1>検索結果</h1>\n") - +print("<h1>検索結果</h1><br>\n") +print("<img src=\"bus.png\" align=\"right\">") a = 0 if which == "t" - while true - if time.to_i < bus[arr][0] - print("<h2>乗車</h2>") - printf("<p> %s %d\n</p>\n",dep,bus[dep][8]) - printf("<p>下車 %s %d\n</p>\n",arr,bus[arr][8]) - break - elsif a >= 8 || time.to_i > bus[arr][a] && time.to_i < bus[arr][a+1] - print("<h2>乗車</h2>") - printf("<p>%s %d\n</p>\n",dep,bus[dep][a]) - print("<h2>下車</h2>") - printf("<p>%s %d\n</p>\n",arr,bus[arr][a]) - break - else - a += 1 + while true + if time.to_i < bus[arr][0].to_i + if /(\S\S)(\S\S)/ =~ bus[dep][8] + dhour = $1 + dmin = $2 + end + if /(\S\S)(\S\S)/ =~ bus[arr][8] + ahour = $1 + amin = $2 end + print("<h2>乗車</h2>") + printf("<p> %s %s:%s\n</p>\n",dep ,dhour, dmin) + print("<h2>降車</h2>") + printf("<p> %s %s:%s\n</p>\n",arr ,ahour, amin) + break + elsif a >= 8 || time.to_i > bus[arr][a].to_i && time.to_i < bus[arr][a+1].to_i + if /(\S\S)(\S\S)/ =~ bus[dep][a] + dhour = $1 + dmin = $2 + end + if /(\S\S)(\S\S)/ =~ bus[arr][a] + ahour = $1 + amin = $2 + end + print("<h2>乗車</h2>") + printf("<p> %s %s:%s\n</p>\n",dep ,dhour, dmin) + print("<h2>降車</h2>") + printf("<p> %s %s:%s\n</p>\n",arr ,ahour, amin) + break + else + a += 1 end + end elsif which == "s" while true - if time.to_i < bus[dep][0] || time.to_i > bus[dep][8] - printf("<p>乗車 %s %d\n</p>\n",dep,bus[dep][0]) - printf("<p>下車 %s %d\n</p>\n",arr,bus[arr][0]) + if time.to_i < bus[dep][0].to_i || time.to_i > bus[dep][8].to_i + if /(\S\S)(\S\S)/ =~ bus[dep][0] + dhour = $1 + dmin = $2 + end + if /(\S\S)(\S\S)/ =~ bus[arr][0] + ahour = $1 + amin = $2 + end + print("<h2>乗車</h2>") + printf("<p> %s %s:%s\n</p>\n",dep ,dhour, dmin) + print("<h2>降車</h2>") + printf("<p> %s %s:%s\n</p>\n",arr ,ahour, amin) break - elsif time.to_i > bus[dep][a] && time.to_i < bus[dep][a+1] - printf("<p>乗車 %s %d\n</p>\n",dep,bus[dep][a+1]) - printf("<p>下車 %s %d\n</p>\n",arr,bus[arr][a+1]) + elsif time.to_i > bus[dep][a].to_i && time.to_i < bus[dep][a+1].to_i + if /(\S\S)(\S\S)/ =~ bus[dep][a+1] + dhour = $1 + dmin = $2 + end + if /(\S\S)(\S\S)/ =~ bus[arr][a+1] + ahour = $1 + amin = $2 + end + print("<h2>乗車</h2>") + printf("<p> %s %s:%s\n</p>\n",dep ,dhour, dmin) + print("<h2>降車</h2>") + printf("<p> %s %s:%s\n</p>\n",arr ,ahour, amin) break else a += 1
--- a/bus_cgi/ruru.css Tue Jan 15 15:30:41 2013 +0900 +++ b/bus_cgi/ruru.css Fri Feb 01 14:37:44 2013 +0900 @@ -1,7 +1,7 @@ -body {color: maroon; - margin: 15%;} +body {color: dodgerblue; + margin: 10%;} -p { color: dodgerblue; +p { color: maroon; text-align: left;} h1 { color: saddlebrown;
--- a/bus_cgi/top.html Tue Jan 15 15:30:41 2013 +0900 +++ b/bus_cgi/top.html Fri Feb 01 14:37:44 2013 +0900 @@ -1,4 +1,3 @@ - <html> <html lang="ja"> <head> @@ -11,12 +10,12 @@ <body> <form method="POST" action="./bus1.rb"> -<h1>酒田市福祉乗合バスを活用しよう</h1> +<h1>酒田駅大学線バス時刻検索</h1> <br> -<h2>るんるんバス時刻検索</h2> <img src="bus.png" align="right"> -<input type="radio" name="direc" value="e" checked>駅方面 -<input type="radio" name="direc" value="k">かんぽの郷方面 +<h2>時刻検索</h2> +<p><input type="radio" name="direc" value="e" checked>駅方面 +<input type="radio" name="direc" value="k">かんぽの郷方面</p> <p>出発* <select name="dep"> <option> かんぽの郷 @@ -28,7 +27,7 @@ <option> 山居町東 <option> 二番町 <option> 中町西 - <option> 文化センター + <option> 文化センター前 <option> 八雲神社前 <option> 酒田駅正面口 </select></p> @@ -44,7 +43,7 @@ <option> 山居町東 <option> 二番町 <option> 中町西 - <option> 文化センター + <option> 文化センター前 <option> 八雲神社前 <option> 酒田駅正面口 </select> </p> @@ -92,6 +91,8 @@ <input type="reset" value="リセット"> </p> </form> - +<br> +<h2>プログラムに関して</h2> +<p>このプログラムは、酒田市福祉乗合バス時刻表を基に、東北公益文科大学SKIPが作成したものです。<br>このページにおいて提供されているコンテンツに関して、編集著作権を含む一切の権利は管理者SKIPが保有致します。<br>また、このプログラムはデモ版であり、このページから得られた情報に関しての責任は一切負いません。</p> </body> </html>