$(document).ready(function() { var taxonomy = $.fn.Taxonomy(Home.Context); var classifyContext = taxonomy.classify(); var lSelecter = "#lines ul li.selected a:first"; var sSelecter = "#stations ul li.selected a:first"; var hSelecter = "#homes ul li.selected a:first"; var lines = $("#lines ul"); var stations = $("#stations ul"); var homes = $("#homes ul"); /** * 路線クリック時のイベントハンドラ */ var clickLine = function() { //選択された路線をハイライトする $(lines).children("li").removeClass("selected"); $(this.parentNode).addClass("selected"); //駅とホームを初期化する stations.html(""); homes.html(""); //駅名リストを取得する var selectIndex = $(lSelecter).attr("href").replace("#", ""); var stationList = taxonomy.getLine(selectIndex).stations; for (var stationID in stationList) { var station = stationList[stationID]; var li = $("
  • "); var a = $("") .text(station.name) .attr("href", "#" + stationID); //駅名をクリニックされた時のイベントハンドラを設定する a.click(clickStation); a.addClass("fs12"); li.append(a); stations.append(li); } } /** * 駅名クリック時のイベントハンドラ */ var clickStation = function() { //選択された駅名をハイライトする $(stations).children("li").removeClass("selected"); $(this.parentNode).addClass("selected"); homes.html(""); var line = $(lSelecter).attr("href").replace("#", ""); var station = $(sSelecter).attr("href").replace("#", ""); var shopList = taxonomy.getStation( parseInt(line), parseInt(station) ).shops; if (shopList != undefined) { for (var shopID in shopList) { var shop = shopList[shopID]; var li = $("
  • ") $(li).html("" + shop.homeName + "

    " + shop.description+ "

    "); //ホームをクリニックされた時のイベントハンドラを設定する //$(li).children("a:first").click(clickHome); homes.append(li); } } } /** * ホームクリック時のイベントハンドラ */ var clickHome = function() { $(homes).children("li").removeClass("selected"); $(this.parentNode).addClass("selected"); $("#information").html(""); var line = $(lSelecter).attr("href").replace("#", ""); var station = $(sSelecter).attr("href").replace("#", ""); var home = $(hSelecter).attr("href").replace("#", ""); var homeProperty = taxonomy.getHome( parseInt(line), parseInt(station), parseInt(home) ); if (homeProperty != undefined) { $("#information").html( "
    " + "
    ホーム名
    " + "
    " + homeProperty.homeName + "
    " + "
    沿線
    " + "
    " + homeProperty.lineName + homeProperty.stationName + "
    " + "
    詳細
    " + "
    " + homeProperty.description + "
    " + "
    URL
    " + "
    " + homeProperty.link + "
    " + "
    " ); } } for (var lineID in classifyContext) { var line = classifyContext[lineID]; var li = $("
  • "); var a = $("") .text(line.name) .attr("href", "#" + lineID); a.click(clickLine); a.addClass("fs12"); li.append(a); lines.append(li); } });