From e94d7922a93917a0e008ac4c6db12feff1ace099 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Fri, 8 Jun 2012 03:50:14 +0200 Subject: [PATCH] simple style changer --- html/force.js | 29 +++++++++++++++++++++++++++++ html/nodes.html | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/html/force.js b/html/force.js index 7363214..d549b85 100644 --- a/html/force.js +++ b/html/force.js @@ -1,3 +1,17 @@ +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 @@ -14,6 +28,15 @@ var offset = getOffset(document.getElementById('chart')) var w = window.innerWidth - offset.left, h = window.innerHeight - offset.top - 1 +function next_style() { + var s = d3.select("head link[title]:not([disabled]) + link[title][disabled]") + + if (s[0][0] == null) + s = d3.select("head link[title][disabled]") + + switch_style(s[0][0].getAttribute("title")) +} + var cp = d3.select("header").append("div") .attr("id", "controlpanel") @@ -25,6 +48,12 @@ cp.append("button") .text("Aktualisieren") .on("click", reload) +var style_btn = cp.append("button") + .attr("class", "btn") + .attr("value", "reload") + .text("Farbwechsler") + .on("click", next_style) + var btns = cp.append("div") .attr("class", "btn-group") diff --git a/html/nodes.html b/html/nodes.html index 06b3873..cfd1051 100644 --- a/html/nodes.html +++ b/html/nodes.html @@ -5,7 +5,8 @@ Freifunk Lübeck - Knotengraph - + +