From 98e913c933c0e09e07f1ab79a045fe7e43b400f1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Jun 2012 15:22:29 +0200 Subject: [PATCH 1/6] Simplify style switcher --- html/force.js | 33 +++++++++------------------------ html/nodes.html | 2 +- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/html/force.js b/html/force.js index 7c29345..156ffd3 100644 --- a/html/force.js +++ b/html/force.js @@ -1,19 +1,3 @@ -var style; - -function switch_style(s) { - var el = document.getElementsByTagName("link") - for (var i = 0; i < el.length; i++ ) { - if (el[i].getAttribute("rel").indexOf("style") != -1 - && el[i].getAttribute("title")) { - if (el[i].getAttribute("title") == s) { - style_btn.text(s) - el[i].disabled = false - } else - el[i].disabled = true - } - } -} - function getOffset( el ) { var _x = 0, _y = 0 @@ -50,15 +34,16 @@ function resize() { } function next_style() { - var s; - if (style !== undefined) - s = d3.select("head link[title=" + style + "] + link") - - if (s == null || s[0][0] == null) - s = d3.select("head link[title]") + var n = document.styleSheetSets.length + var i; + for (i = 0; i < n; i++) { + if (document.styleSheetSets[i] == document.selectedStyleSheetSet) + break + } - style = s[0][0].getAttribute("title") - switch_style(style) + var s = document.styleSheetSets[(i+1) % n] + style_btn.text(s) + document.selectedStyleSheetSet = s } var cp = d3.select("header").append("div") diff --git a/html/nodes.html b/html/nodes.html index 728f6f8..13bbb7a 100644 --- a/html/nodes.html +++ b/html/nodes.html @@ -5,7 +5,7 @@ Freifunk Lübeck - Knotengraph - + From 74fc158ed71547fe7f247f64a6863a7207dc3225 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Jun 2012 15:31:02 +0200 Subject: [PATCH 2/6] Replace sidebar by div as the sidebar tag was dropped from the HTML5 standard --- html/force-big.css | 2 +- html/force-light.css | 2 +- html/force.css | 4 ++-- html/force.js | 2 +- html/nodes.html | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/html/force-big.css b/html/force-big.css index c4ea7f0..47bef13 100644 --- a/html/force-big.css +++ b/html/force-big.css @@ -49,6 +49,6 @@ fill: #C83771; } -sidebar { +#sidebar { color: #ddd; } diff --git a/html/force-light.css b/html/force-light.css index 7c8735e..d2e25f9 100644 --- a/html/force-light.css +++ b/html/force-light.css @@ -55,6 +55,6 @@ fill: #C83771; } -sidebar { +#sidebar { color: #777; } diff --git a/html/force.css b/html/force.css index 6c99999..b5f41e7 100644 --- a/html/force.css +++ b/html/force.css @@ -131,7 +131,7 @@ text-shadow: none; } -sidebar { +#sidebar { position: absolute; top: 1em; right: 1.5em; @@ -153,7 +153,7 @@ sidebar { vertical-align: center; } -sidebar h2 { +#sidebar h2 { margin-top: 0; font-size: 9pt; } diff --git a/html/force.js b/html/force.js index 156ffd3..131c6a7 100644 --- a/html/force.js +++ b/html/force.js @@ -94,7 +94,7 @@ btns.append("button") .text("VPN") .on("click", update_graph) -var meshinfo = d3.select("sidebar") +var meshinfo = d3.select("#sidebar") .insert("div", ":first-child") meshinfo.append("h2").text("Mesh") diff --git a/html/nodes.html b/html/nodes.html index 13bbb7a..e91eccf 100644 --- a/html/nodes.html +++ b/html/nodes.html @@ -22,7 +22,7 @@
- +
From fd41f11f6c2567cb4d5c61ce1a682208ff6b8c92 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Jun 2012 14:59:36 +0200 Subject: [PATCH 3/6] Fix geomap.html doctype --- html/geomap.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/html/geomap.html b/html/geomap.html index 229dcee..1d7ab71 100644 --- a/html/geomap.html +++ b/html/geomap.html @@ -1,6 +1,7 @@ + - + From e2347fa02013822c3e0f7dbcaf281330f53a946d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Jun 2012 15:49:35 +0200 Subject: [PATCH 4/6] Revert "Simplify style switcher" as it doesn't work with Chrome like this This reverts commit 98e913c933c0e09e07f1ab79a045fe7e43b400f1. --- html/force.js | 33 ++++++++++++++++++++++++--------- html/nodes.html | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/html/force.js b/html/force.js index 131c6a7..b29bf7c 100644 --- a/html/force.js +++ b/html/force.js @@ -1,3 +1,19 @@ +var style; + +function switch_style(s) { + var el = document.getElementsByTagName("link") + for (var i = 0; i < el.length; i++ ) { + if (el[i].getAttribute("rel").indexOf("style") != -1 + && el[i].getAttribute("title")) { + if (el[i].getAttribute("title") == s) { + style_btn.text(s) + el[i].disabled = false + } else + el[i].disabled = true + } + } +} + function getOffset( el ) { var _x = 0, _y = 0 @@ -34,16 +50,15 @@ function resize() { } function next_style() { - var n = document.styleSheetSets.length - var i; - for (i = 0; i < n; i++) { - if (document.styleSheetSets[i] == document.selectedStyleSheetSet) - break - } + var s; + if (style !== undefined) + s = d3.select("head link[title=" + style + "] + link") + + if (s == null || s[0][0] == null) + s = d3.select("head link[title]") - var s = document.styleSheetSets[(i+1) % n] - style_btn.text(s) - document.selectedStyleSheetSet = s + style = s[0][0].getAttribute("title") + switch_style(style) } var cp = d3.select("header").append("div") diff --git a/html/nodes.html b/html/nodes.html index e91eccf..ebf204e 100644 --- a/html/nodes.html +++ b/html/nodes.html @@ -5,7 +5,7 @@ Freifunk Lübeck - Knotengraph - + From a764f8e99916a4264d41de1956ca2ce2325b2238 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Jun 2012 16:03:19 +0200 Subject: [PATCH 5/6] Fix the style switcher in a way that is standard conformant *and* working --- html/force.js | 10 ++++++---- html/nodes.html | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/html/force.js b/html/force.js index b29bf7c..56a3f15 100644 --- a/html/force.js +++ b/html/force.js @@ -5,13 +5,15 @@ function switch_style(s) { for (var i = 0; i < el.length; i++ ) { if (el[i].getAttribute("rel").indexOf("style") != -1 && el[i].getAttribute("title")) { - if (el[i].getAttribute("title") == s) { - style_btn.text(s) + /* always set to true first to workaround Chrome bug */ + el[i].disabled = true + + if (el[i].getAttribute("title") == s) el[i].disabled = false - } else - el[i].disabled = true } } + + style_btn.text(s) } function getOffset( el ) { diff --git a/html/nodes.html b/html/nodes.html index ebf204e..e91eccf 100644 --- a/html/nodes.html +++ b/html/nodes.html @@ -5,7 +5,7 @@ Freifunk Lübeck - Knotengraph - + From 0d70e40fb3ad71cb9ca223a4757bdba226c5fac1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Jun 2012 16:35:38 +0200 Subject: [PATCH 6/6] Revert "Fix geomap.html doctype" ... it's valid, but doesn't work. This reverts commit fd41f11f6c2567cb4d5c61ce1a682208ff6b8c92. --- html/geomap.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/html/geomap.html b/html/geomap.html index 1d7ab71..229dcee 100644 --- a/html/geomap.html +++ b/html/geomap.html @@ -1,7 +1,6 @@ - - +