Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions docs/gallery/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@ <h5 id="sp-station-quake-map">&lt;sp-station-quake-map&gt;</h5>
map.removeColorClass("customcolor");
map.colorClass("quakecolor", "yellow");

//map.stationRemoveClass(allStations[0], "customcolor");
// map.stationRemoveClass(allStations[0], "customcolor");
});
});

const SELECTED_ROW = "selectedRow";
const infoList = document.querySelectorAll("sp-quake-table");
infoList.forEach((it) => {
it.quakeList = ds.catalog;
it.addStyle(`
table tbody tr.${SELECTED_ROW} td {
background-color: green;
color: white;
}
`);
// it.addStyle(`
// table tbody tr.${SELECTED_ROW} td {
// background-color: green;
// color: white;
// }
// `);
it.addEventListener("quakeclick", (ce) => {
mapList.forEach((map) => {
map.quakeList.forEach((q) => {
Expand All @@ -98,13 +98,41 @@ <h5 id="sp-station-quake-map">&lt;sp-station-quake-map&gt;</h5>
let allRows = quakeRow.parentNode.querySelectorAll(`tbody tr`);
console.log(`num rows: ${Array.from(allRows).length}`);
allRows.forEach((r) => {
console.log(`${r.classList.contains(SELECTED_ROW)}`);
r.classList.remove(SELECTED_ROW);
if (r.classList.contains(SELECTED_ROW)) {
console.log(`${r.classList.contains(SELECTED_ROW)}`);
r.removeAttribute("style");
r.classList.remove(SELECTED_ROW);
}
});
quakeRow.classList.add(SELECTED_ROW);
quakeRow.setAttribute("style", "background-color: green");
//ce.detail.mouseevent.currentTarget.setAttribute("style", "background-color: green");
});
});
// Click on a quake map circle
mapList.forEach((map) => {
map.addEventListener("quakeclick", (me) => {
map.quakeList.forEach((q) => {
map.removeColorClass(sp.leafletutil.cssClassForQuake(q));
map.colorClass(
sp.leafletutil.cssClassForQuake(me.detail.quake),
"green",
);
});
// console.log(`mEvent: ${me.detail.quake}`);
const SELECTED_ROW = "SelectedRow";
let quakeRow = it.findRowForQuake(me.detail.quake);
let allRows = quakeRow.parentNode.querySelectorAll(`tbody tr`);
allRows.forEach((r) => {
if (r.classList.contains(SELECTED_ROW)) {
r.removeAttribute("style");
r.classList.remove(SELECTED_ROW);
}
});
quakeRow.classList.add(SELECTED_ROW);
quakeRow.setAttribute("style", "background-color: green");
});
});
});
console.log(
`${ds.catalog.length} ${Array.from(sp.stationxml.allStations(ds.inventory)).length}`,
Expand Down