aboutsummaryrefslogtreecommitdiffstats
path: root/static/scripts.js
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2023-05-08 00:23:37 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2023-05-08 00:23:37 +0100
commit920fa08e0bd1a3eda1cc75c19b31cfaa495ea94f (patch)
tree22f0e8a7e9dd9820c49f1c1ee7c07deae7a50027 /static/scripts.js
parentcb07e37ed72182af33a992d7e0b44f7c7ee4af04 (diff)
downloadUKGenderPayGap-920fa08e0bd1a3eda1cc75c19b31cfaa495ea94f.tar.gz
UKGenderPayGap-920fa08e0bd1a3eda1cc75c19b31cfaa495ea94f.zip
Finished filtering time-series pay gap
Diffstat (limited to 'static/scripts.js')
-rw-r--r--static/scripts.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/static/scripts.js b/static/scripts.js
index 01196d3..261acfa 100644
--- a/static/scripts.js
+++ b/static/scripts.js
@@ -13,7 +13,11 @@ const PLOT_FUNC_MAPPINGS = {
}
$(document).ready(function() {
- document.getElementById("filterform").action = window.location.pathname + "/apply_click";
+ const filterform = document.getElementById("filterform");
+ if (filterform !== null) {
+ filterform.action = window.location.pathname + "/apply_click";
+ }
+
fetch("/api/charts.json").then((resp) => {
resp.json().then((body) => {
@@ -41,8 +45,10 @@ $(document).ready(function() {
var theIdSplit = u.pathname.split("/");
CHARTS["index"].forEach(element => {
- if (theId === "/chart" + element.url) {
+ if (location.href.substr(location.href.indexOf(location.host)+location.host.length).startsWith(element["url"])) {
+ console.log(location.href.substr(location.href.indexOf(location.host)+location.host.length), element["url"]);
filters = element["filters"];
+ // console.log(element);
}
});
@@ -53,17 +59,20 @@ $(document).ready(function() {
});
function form_api_url(containerName, filters) {
+ console.log(filters);
+ console.log(containerName);
var name = containerName.split("/")[containerName.split("/").length - 1];
var url = new URL(window.location.origin + "/api/" + name);
- for (const [filterName, value] of Object.entries(filters)) {
+ // for (const [filterName, value] of Object.entries(filters)) {
- if (typeof value === 'object' && value !== null) {
- if ("default" in value) {
- // console.log(filterName, value["default"]);
- url.searchParams.append(filterName, value["default"]);
- }
- }
- }
+ // if (typeof value === 'object' && value !== null) {
+ // if ("default" in value) {
+ // // console.log(filterName, value["default"]);
+ // url.searchParams.append(filterName, value["default"]);
+ // }
+ // }
+ // }
+ console.log("fetching ", url.toString());
return url.toString();
}