source: trunk/npemap.org.uk/static/reportedAsProblem.html @ 440

Last change on this file since 440 was 324, checked in by Nick Burch, 13 years ago

Do escaping and de-escaping of ' properly

File size: 2.9 KB
Line 
1<!--#set var="title" value="Postcodes Reported as Problematic" -->
2<!--#set var="link" value="/reportedAsProblem.html" -->
3<!--#set var="shownav" value="yes" -->
4<!--#include virtual="inc/header.shtml" -->
5
6<style type="text/css">
7        th { text-align: left; }
8</style>
9
10
11<div id="actions">
12</div>
13
14<br />
15
16<table id="tbl" width="100%" height="100%">
17<tbody id="reports">
18<tr>
19        <th>Postcode</th>
20        <th>ID</th>
21        <th>Report Reason</th>
22        <th>Report Date</th>
23</tr>
24</tbody>
25</table>
26
27<script type="text/javascript">
28var actions = document.getElementById("actions");
29var reports = document.getElementById("reports");
30
31var last_postcode = "";
32function addReport(id,postcode,easting,northing,other,reporting) {
33        var source_id = other[0];
34        var disp_source = "NPE Submission";
35        if(source_id == 1) {
36                disp_source = "FreeThePostcode";
37        }
38
39        var row = document.createElement("tr");
40        var pcc = document.createElement("td");
41        var idc = document.createElement("td");
42        var textc = document.createElement("td");
43        var datec = document.createElement("td");
44
45        if(last_postcode == postcode) {
46                pcc.appendChild(document.createTextNode(" "));
47        } else {
48                var pclink = document.createElement("a");
49                pclink.href = "/tiles/map.html#" + Math.round(easting/1000) + "," + Math.round(northing/1000) + ",1";
50                pclink.appendChild(document.createTextNode(postcode));
51                pcc.appendChild(pclink);
52        }
53        last_postcode = postcode;
54
55        idc.appendChild(document.createTextNode(id));
56
57        // De-escape
58        reporting[0] = reporting[0].replace(/&quot;/g,"'");
59        reporting[2] = reporting[2].replace(/&quot;/g,"'");
60        // Display
61        textc.appendChild(document.createTextNode(reporting[0]));
62        datec.appendChild(document.createTextNode(reporting[2]));
63
64        row.appendChild(pcc);
65        row.appendChild(idc);
66        row.appendChild(textc);
67        row.appendChild(datec);
68        reports.appendChild(row);
69}
70
71// How should we call the script?
72var cgi = "/cgi/get-reports.fcgi";
73var sLinkA = document.createElement("a");
74var sLinkB = document.createElement("a");
75if(location.href.indexOf("?number") > 0) {
76        cgi = cgi + "?sort=number";
77        sLinkA.href = "?postcode";
78        sLinkA.appendChild(document.createTextNode("Sort by postcode"));
79        sLinkB.href = "?date";
80        sLinkB.appendChild(document.createTextNode("Sort by date"));
81} else if(location.href.indexOf("?date") > 0) {
82        cgi = cgi + "?sort=date";
83        sLinkA.href = "?postcode";
84        sLinkA.appendChild(document.createTextNode("Sort by postcode"));
85        sLinkB.href = "?number";
86        sLinkB.appendChild(document.createTextNode("Sort by number of reports"));
87} else {
88        cgi = cgi + "?sort=postcode";
89        sLinkA.href = "?date";
90        sLinkA.appendChild(document.createTextNode("Sort by date"));
91        sLinkB.href = "?number";
92        sLinkB.appendChild(document.createTextNode("Sort by number of reports"));
93}
94actions.appendChild(sLinkA);
95actions.appendChild(document.createTextNode(" : "));
96actions.appendChild(sLinkB);
97
98// Include the script
99var sc = document.createElement("script");
100sc.type = "text/javascript";
101sc.src = cgi;
102actions.appendChild(sc);
103</script>
104<!--#include virtual="inc/footer.shtml" -->
105
Note: See TracBrowser for help on using the repository browser.