PageSourceSearch

https://www.bergason.co.uk/js/brightlogic-maps.js

js bergason.co.uk collected 2026-10-08 13:11:10 UTC 11,983 bytes, 315 lines download raw bytes

1HTMLElement.prototype._getBoundingClientRect = HTMLElement.prototype.getBoundingClientRect;
2HTMLElement.prototype.getBoundingClientRect = function () {
3    try {
4        return this._getBoundingClientRect();
5    } catch (e) {
6        return { top: this.offsetTop, left: this.offsetLeft };
7    }
8};
9
10var schoolmap;
11var schoolMapBounds;
12var schoolmarkers = [];
13var stationmap;
14var stationMapBounds;
15var stations = [];
16var stationMarkers = [];
17
18var railwayStationIconLocation = "https://www.acquaintcrm.co.uk/images/mapfiles/uk-rail.png";
19var subwayStationIconLocation = "https://www.acquaintcrm.co.uk/images/mapfiles/uk-london-metro.png";
20
21function CreateMap(varMapDivID, varLat, varLng, varZoom, varTitle) {
22    var locationmap = L.map(varMapDivID).setView([varLat, varLng], varZoom);
23
24    L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
25        maxZoom: 18,
26        attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
27            '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
28            'Imagery © <a href="https://a.tile.openstreetmap.org/">OpenStreetMap Tiles</a>'
29    }).addTo(locationmap);
30
31    L.marker([varLat, varLng]).addTo(locationmap);
32}
33
34//******************** Start Stations map code ********************
35
36function ClearStationTableRowSelections() {
37    var stationsTable = document.getElementById('stations-table');
38
39    if (stationsTable !== null) {
40        for (var i = 0; i < stationsTable.rows.length; i++) {
41            stationsTable.rows[i].className = 'selectable-row';
42        }
43    }
44}
45
46function CenterStationOnMap(row) {
47    var latitude = row.cells[3].innerText;
48    var longitude = row.cells[4].innerText;
49    stationmap.panTo([latitude, longitude]);
50    ClearStationTableRowSelections();
51    row.className = 'selected-row';
52}
53
54function CreateStationMap(varStationMapDivID, varCenterLat, varCenterLong, varZoom, varTableExistsNow) {
55    if (varTableExistsNow) {
56        ClearStationTableRowSelections();
57    }
58
59    stationMarkers = [];
60
61    stationMapBounds = L.latLngBounds();
62
63    stationmap = L.map(varStationMapDivID, {
64        center: [varCenterLat, varCenterLong],
65        zoom: varZoom
66    });
67
68    L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
69        maxZoom: 18,
70        attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
71            '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
72            'Imagery © <a href="https://a.tile.openstreetmap.org/">OpenStreetMap Tiles</a>'
73    }).addTo(stationmap);
74
75    var marker = L.marker([varCenterLat, varCenterLong]).addTo(stationmap);
76
77    stationMapBounds.extend(marker.getLatLng());
78}
79
80//this function doesn't really create markers anymore but keeping name for consistency
81function CreateAllStationMarkers() {
82    var stationsTable = document.getElementById("stations-table");
83
84    if (stationsTable !== null) {
85        for (var i = stationsTable.rows.length - 1; i > 0; i--) {
86            //get type id
87            var stationType = stationsTable.rows[i].cells[5].innerText.replace(/\s/g, '');
88            //get table's first empty column to insert station icons into
89            var cell0 = stationsTable.rows[i].cells[0];
90            //allow station icon images to appear adjacent to each other in cell
91            cell0.style.display = "flex";
92
93            //if the station is either type railway or subway but not both
94            if (stationType !== '-1') {
95                var stationIconImage = document.createElement('img');
96                stationIconImage.width = 15;
97                stationIconImage.height = 15;
98                if (stationType === '0' || stationType === '2') {
99                    //change source to railway station icon
100                    stationIconImage.src = railwayStationIconLocation;
101                } else if (stationType === '1') {
102                    //change source to subway station icon
103                    stationIconImage.src = subwayStationIconLocation;
104                }
105                stationIconImage.style.marginBottom = "0px";
106                stationIconImage.style.marginTop = "5px";
107                stationIconImage.style.marginRight = "5px";
108                //insert station icon image
109                cell0.appendChild(stationIconImage);
110            } else {
111                //if station is type -1 it's both an underground and railway station
112                var railwayStationIconImage = document.createElement('img');
113                var subwayStationIconImage = document.createElement('img');
114
115                railwayStationIconImage.width = 15;
116                railwayStationIconImage.height = 15;
117                railwayStationIconImage.src = railwayStationIconLocation;
118                railwayStationIconImage.style.marginBottom = "0px";
119                railwayStationIconImage.style.marginTop = "5px";
120                railwayStationIconImage.style.marginRight = "5px";
121                cell0.appendChild(railwayStationIconImage);
122
123                subwayStationIconImage.width = 15;
124                subwayStationIconImage.height = 15;
125                subwayStationIconImage.src = subwayStationIconLocation;
126                subwayStationIconImage.style.marginBottom = "0px";
127                subwayStationIconImage.style.marginTop = "5px";
128                subwayStationIconImage.style.marginRight = "5px";
129                cell0.appendChild(subwayStationIconImage);
130            }
131        }
132    }
133}
134
135//******************** End Stations map code ********************
136
137//******************** Start Schools map code ********************
138
139function ClearSchoolTableRowSelections() {
140    var schoolsTable = document.getElementById("schools-table");
141
142    for (var i = 0; i < schoolsTable.rows.length; i++) {
143        schoolsTable.rows[i].className = 'selectable-row';
144    }
145}
146
147function SelectFirstSchoolRow() {
148    var schoolsTable = document.getElementById("schools-table");
149    if (schoolsTable !== null) {
150        CenterOnSchoolMap(schoolsTable.rows[1]);
151    }
152}
153
154function FitSchoolsMapToBounds() {
155    setTimeout(function () { if (schoolmap !== undefined) { schoolmap.fitBounds(schoolMapBounds); }});
156}
157
158function CreateSchoolMap(varSchoolMapDivID, varCenterLat, varCenterLong, varZoom, varTableExistsNow) {
159    if (varTableExistsNow) {
160        ClearSchoolTableRowSelections();
161    }
162
163    markers = [];
164
165    schoolMapBounds = L.latLngBounds();
166
167    schoolmap = L.map(varSchoolMapDivID, {
168        center: [varCenterLat, varCenterLong],
169        zoom: varZoom
170    });
171
172    L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
173        maxZoom: 18,
174        attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
175            '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
176            'Imagery © <a href="https://a.tile.openstreetmap.org/">OpenStreetMap Tiles</a>'
177    }).addTo(schoolmap);
178
179    var marker = L.marker([varCenterLat, varCenterLong]).addTo(schoolmap);
180
181    schoolMapBounds.extend(marker.getLatLng());
182}
183
184function CreateAllSchoolMarkers() {
185    var schoolsTable = document.getElementById("schools-table");
186
187    if (schoolsTable !== null) {
188        for (var i = schoolsTable.rows.length - 1; i > 0; i--) {
189            var latitude = schoolsTable.rows[i].cells[8].innerText;
190            var longitude = schoolsTable.rows[i].cells[9].innerText;
191            CreateSchoolMarker(latitude, longitude, "https://www.acquaintcrm.co.uk/images/mapfiles/marker-" + i + ".png");
192        }
193    }
194
195}
196
197function CreateSchoolMarker(varLat, varLng, varIconURL) {
198    var marker = L.marker([varLat, varLng], {
199        icon: L.icon({
200            iconUrl: varIconURL,
201            iconAnchor: [16, 34]
202        })
203    }).addTo(schoolmap);
204
205    if (varIconURL !== "") {
206        marker.on('click', function () {
207            var markerIconURI = marker._icon.src;
208            var markerId = parseInt(markerIconURI.substring(markerIconURI.lastIndexOf("-") + 1, markerIconURI.lastIndexOf("."), 10));
209            document.getElementById("marker-icon").src = markerIconURI;
210            CenterOnSchoolMap(document.getElementById("schools-table").rows[markerId]);
211        });
212    }
213
214    markers.unshift(marker);
215    schoolMapBounds.extend(marker.getLatLng());
216}
217
218function CenterOnSchoolMap(row) {
219    ClearSchoolTableRowSelections();
220
221    row.className = 'selected-row';
222
223    document.getElementById("marker-icon").src = "https://www.acquaintcrm.co.uk/images/mapfiles/marker-" + (row.rowIndex) + ".png";
224
225    var establishmentNameLabel = document.getElementById("establishment-name");
226    establishmentNameLabel.innerText = row.cells[1].innerHTML.trim();
227
228    var schoolWebsiteURL = row.cells[11].innerHTML.trim();
229    if (schoolWebsiteURL !== "null" && schoolWebsiteURL !== "") {
230        establishmentNameLabel.setAttribute("href", schoolWebsiteURL);
231        establishmentNameLabel.setAttribute("target", "_blank");
232        establishmentNameLabel.setAttribute("style", "margin: 0em 0em !important;");
233    } else {
234        establishmentNameLabel.setAttribute("style", "margin: 0em 0em!important; text-decoration:none;");
235        establishmentNameLabel.removeAttribute("href");
236    }
237
238    var strSchoolInfoList = "";
239
240    var infoList = [{ name: "Gender", value: row.cells[2].innerHTML }, { name: "Ages", value: row.cells[3].innerHTML }, { name: "Phase Of Education", value: row.cells[6].innerHTML }, { name: "Ofsted", value: row.cells[4].innerHTML }, { name: "Religion", value: row.cells[7].innerHTML }, { name: "Oversubscribed", value: row.cells[10].innerHTML }];
241
242    for (var i = 0; i < infoList.length; i++) {
243        var info = infoList[i];
244
245        info.name = info.name.trim();
246        info.value = info.value.trim();
247
248        if (info.name === "Gender") {
249            if (info.value === "") {
250                continue;
251            }
252        }
253
254        if (info.name === "Ages") {
255            if (info.value === "") {
256                continue;
257            }
258        }
259
260        if (info.name === "Phase Of Education") {
261            if (info.value === "Not applicable") {
262                continue;
263            }
264        }
265
266        if (info.name === "Ofsted") {
267            if (info.value === "" || info.value === "Not available") {
268                continue;
269            }
270        }
271
272        if (info.name === "Religion") {
273            if (info.value === "" || info.value === "Does not apply" || info.value === "None") {
274                continue;
275            }
276        }
277
278        if (info.name === "Oversubscribed") {
279            if (info.value === "") {
280                continue;
281            }
282        }
283
284        if (info.name === "Ofsted" || info.name === "Ages") {
285            strSchoolInfoList += info.name + ": ";
286        }
287
288        strSchoolInfoList += info.value;
289
290        if (i + 1 < infoList.length) {
291            strSchoolInfoList += ", ";
292        }
293
294    }
295
296    strSchoolInfoList = strSchoolInfoList.replace(/,\s*$/, "");
297    strSchoolInfoList = strSchoolInfoList.replace(/\r?\n|\r/g, '');
298
299    document.getElementById("school-info-list").innerText = "Info: " + strSchoolInfoList;
300
301    schoolmap.panTo(markers[row.rowIndex - 1].getLatLng());
302}
303
304//******************** End Schools map code ********************
305
306//******************** Start misc code ********************
307
308function RefreshMap(varMapDivID, varLats, varLngs, varZoom, varTitle) {
309    //var center = varMapDivID.getCenter();
310    google.maps.event.trigger(varMapDivID, 'resize');
311
312    //varMapDivID.setCenter(center);
313}
314
315//******************** End misc code ********************

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.