aboutsummaryrefslogtreecommitdiff
path: root/templates/index.html
blob: 5cfefb26f808f8f2de7d12c6f058f55b92b59c61 (plain)
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html version="-//W3C//DTD XHTML 1.0 Transitional//EN" >
<head>
    <title>AGInteractive Directory and Map</title>
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Philosopher">
{% if mode == 'map' %}
    <link rel="stylesheet" href="/static/css/style_result.css" type="text/css" />
{% else %}
    <link rel="stylesheet" href="/static/css/style_search.css" type="text/css" />
{% end %}

{% if mode == 'map' and len(plots) > 0 %}
    <script src="/static/js/openlayers2.10/OpenLayers.js"></script>
    <script src="/static/js/openlayers2.10/lib/OpenLayers/Tile/InlineXhtml.js"></script>
    <script src="/static/js/openlayers2.10/lib/OpenLayers/Layer/WMS/InlineXhtml.js"></script>
    <script src="/static/js/openlayers2.10/lib/OpenLayers/Layer/InlineXhtml.js"></script>
    <script src="/static/js/openlayers2.10/lib/OpenLayers/Layer/ScalableInlineXhtml.js"></script>

    <script type="text/javascript">

   var map; //OpenLayers.Map
   var map_width = {{plots[0].map.width}};
   var map_height = {{plots[0].map.height}};
   //These are the coordinates from bottom left
   var center_point_x = {{center_plot.x}};
   var center_point_y = {{center_plot.y}};

   //Initialise the 'map' object
   function init()
   {
     var ext = new OpenLayers.Bounds(0, 0, map_width, map_height);
     //var size = new OpenLayers.Size(map_width, map_height);
     var size = new OpenLayers.Size(map_width/4, map_height/4);

     options = {numZoomLevels: 6,
                units: 'pixels',
                maxExtent: ext,
                controls:[
                    new OpenLayers.Control.Navigation(),
                    new OpenLayers.Control.PanZoomBar(),
                    new OpenLayers.Control.LayerSwitcher(),
                    new OpenLayers.Control.Attribution()]};

     map = new OpenLayers.Map ("map", options);

   var outline = new OpenLayers.Layer.ScalableInlineXhtml(
     "Outline",
     "/static/svgs/d2_structure.svg",
     ext,
     size,
     {isBaseLayer: true, visibility: true, singleTile: true }      );

   var ntwk_id = new OpenLayers.Layer.ScalableInlineXhtml(
     "Network Id",
     "/static/svgs/d2_ntwk_id.svg",
     ext,
     size,
     {isBaseLayer: false}      );

   var name_label = new OpenLayers.Layer.ScalableInlineXhtml(
        "Name Labels",
        "/svg_text/{{plots[0].map.id}}",
        ext,
        size,
        {isBaseLayer: false}
    );

   name_label.events.register("loadend", name_label, function() {
       emphasize();
   });

   map.addLayers([outline, ntwk_id, name_label]);
   map.zoomToExtent(ext);
  }

  function emphasize()
  {
     {% if details %}
     var e = document.getElementById("{{details.occupant_id}}_{{details.plot_id}}");
         if (e)
         {
            e.setAttributeNS(null, "fill", "red");
            e.style.fontFamily = "Arial";
            e.style.fontSize = 20;
            setCenter();
         }
     {% end %}
  }

  //Note: origin is set at the bottom left corner for OpenLayers !!!
  function setCenter()
  {
      /*
     map.setCenter(new OpenLayers.LonLat(center_point_x,
                                         center_point_y),
                   0, true, true);
                   */

     //map.setCenter(new OpenLayers.LonLat(280, 683), 0, true, true) ;
     map.setCenter(new OpenLayers.LonLat(center_point_x,
                                         center_point_y),
                   2, true, true);
  }
  </script>
{% end %}
</head>

{% if mode == 'map' and len(plots) > 0 %}
    <body onload="init();">
{% else %}
    <body>
{% end %}
<div id="header">
    <span id="logo">
        <img title="AGInteractive" alt="AGInteractive" src="/static/images/ag_logo_t2.gif">
    </span>
    <span id="title">AGInteractive Directory Search</span>
    <form action="/" method="post">
    <input id="search-entry" type="text" maxlength="2048" name="name">
    <input class="button" type="submit" value="   " alt="search">
    </form>
</div>

{% if mode == 'post' %}
    {% if details %}
        <div id="result">
        Found:
        {% for detail in details %}
            <ul id="result-list">
                {% if detail.occupant_id %}
                    {% if detail.plot_id %}
                        <li><a href="/occupant/{{detail.occupant_id}}/plot/{{detail.plot_id}}">{{detail.label}}</a>{{detail.description}}</li>
                    {% else %}
                        <li><a href="/occupant/{{detail.occupant_id}}">{{detail.label}}</a>{{detail.description}}</li>
                    {% end %}
                {% else %}
                    {% if detail.plot_id %}
                        <li><a href="/plot/{{detail.plot_id}}">{{detail.label}}</a>{{detail.description}}</li>
                    {% else %}
                        <li>{{detail.label}} {{detail.description}}</li>
                    {% end %}
                {% end %}
            </ul>
        {% end %}
        </div>
    {% else %}
    <div id="result">
    Sorry, no match found. Please try to broaden your search by entering more in the search field above.
    </div>
    {% end %}
{% else %}
    {% if mode == 'map' %}
        {% if len(plots) > 0 %}
        <div id="content">
            <div id="mapdiv">
                <div id="map"></div>
            </div>
            <div id="infodiv">
                <h2>{{details[0]}}</h2>
                <ul id="details">
                    <li>Location: {{plots[0].map.location.name}} </li>
                    {% for i in xrange(3, len(details._fields)) %}
                        {% if isinstance(getattr(details, details._fields[i]).data, list) %}
                         <li>{{getattr(details, details._fields[i]).name}}: {{u', '.join(getattr(details, details._fields[i]).data)}}</li>
                        {% else %}
                         <li>{{getattr(details, details._fields[i]).name}}: {{getattr(details, details._fields[i]).data}}</li>
                    {% end %}
                    {% end %}
                </ul>
            </div>
        </div>
        {% else %}
        <div id="content">
            Sorry, unable to locate in the map
            <div id="infodiv">
                <h2>{{details[0]}}</h2>
                <ul id="details">
                    {% for i in xrange(3, len(details._fields)) %}
                        <li>{{getattr(details, details._fields[i]).name}}: {{getattr(details, details._fields[i]).data}}</li>
                    {% end %}
                </ul>
            </div>
        </div>
        {% end %}
    {% end %}
{% end %}
<div id="footer">
    <span id="footer-text">Brought you by team:</span>
    <span id="team-logo">
        <img title="d2" alt="d2" src="/static/images/logo_thumb.png" width="50" height="41">
    </span>
</div>
</body>
</html>