From e2347fa02013822c3e0f7dbcaf281330f53a946d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 16 Jun 2012 15:49:35 +0200 Subject: [PATCH] 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 - +