Permalink
Browse files

Rename measuring library to “Measviz” and unify CSS prefixes.

  • Loading branch information...
1 parent 4e967cb commit 6b7921881bc6521eb52a10aac61fbe6c5e67bf32 @kpreid committed Sep 10, 2012
View
@@ -8,7 +8,7 @@
<title>Cubes</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
- <link rel="stylesheet" href="deps/measuring/src/measuring.css" type="text/css">
+ <link rel="stylesheet" href="deps/measviz/src/measviz.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<!-- Third-party GL libraries -->
@@ -22,10 +22,10 @@
<!-- Framework -->
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript" src="storage.js"></script>
- <script type="text/javascript" src="deps/measuring/src/measuring.js"></script>
+ <script type="text/javascript" src="deps/measviz/src/measviz.js"></script>
<!-- Game components -->
- <script type="text/javascript" src="measuring-instance.js"></script>
+ <script type="text/javascript" src="measviz-instance.js"></script>
<script type="text/javascript" src="circuit.js"></script>
<script type="text/javascript" src="blockset.js"></script>
<script type="text/javascript" src="world.js"></script>
@@ -8,24 +8,23 @@
<title>Cubes Measuring Testbed</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
- <link rel="stylesheet" href="../src/measuring.css" type="text/css">
+ <link rel="stylesheet" href="../src/measviz.css" type="text/css">
<script type="text/javascript" src="../../../deps/gl-matrix/gl-matrix.js"></script>
<script type="text/javascript" src="../../../deps/game-shim/game-shim.js"></script>
<script type="text/javascript" src="../../../module-initial.js"></script>
<script type="text/javascript" src="../../../util.js"></script>
<script type="text/javascript" src="../../../storage.js"></script>
- <script type="text/javascript" src="../src/measuring.js"></script>
+ <script type="text/javascript" src="../src/measviz.js"></script>
</head>
<body>
<script type="text/javascript">
- var Measuring = cubes.Measuring;
- var TopGroup = Measuring.TopGroup;
- var ViewGroup = Measuring.ViewGroup;
- var TaskGroup = Measuring.TaskGroup;
- var Counter = Measuring.Counter;
+ var TopGroup = measviz.TopGroup;
+ var ViewGroup = measviz.ViewGroup;
+ var TaskGroup = measviz.TaskGroup;
+ var Counter = measviz.Counter;
// TODO: Make up a demo-relevant example
var measuring = {};
@@ -118,6 +117,6 @@
setZeroTimeout(loop);
</script>
-<p>This file is designed to test the performance of the measuring module, to ensure it does not place excessive load on that which it measures.</p>
+<p>This file is designed to test the performance of Measviz, to ensure it does not place excessive load on that which it measures.</p>
</body></html>
@@ -1,4 +1,4 @@
-.measuring-item {
+.measviz-item {
display: table;
font-family: "Geneva", "Verdana", sans-serif;
font-size: 9px;
@@ -12,38 +12,38 @@
background: rgba(80,80,80,0.5);
padding: 3px;
}
-.measuring-item .measuring-item {
+.measviz-item .measviz-item {
/* non-roots */
padding: 0;
background: none;
}
-.measuring-label, .measuring-group-header {
+.measviz-label, .measviz-group-header {
display: inline-block;
min-width: 16ex;
text-align: left;
}
-.measuring-value {
+.measviz-value {
display: inline-block;
min-width: 13ex;
text-align: right;
}
-.measuring-group-header {
+.measviz-group-header {
background: none;
color: #CCC;
font-weight: bold;
}
-ul.measuring-group-contents, ol.measuring-group-contents {
+ul.measviz-group-contents, ol.measviz-group-contents {
margin: 0 0 0 0;
padding: 0 0 0 1em;
list-style-type: none;
}
-.measuring-sparkline {
+.measviz-sparkline {
vertical-align: baseline;
}
-.measuring-hide-sparklines .measuring-sparkline {
+.measviz-hide-sparklines .measviz-sparkline {
display: none;
}
-.measuring-toggle {
+.measviz-toggle {
/* reset <button> style */
margin: 0;
border: none;
@@ -1,15 +1,16 @@
// Copyright 2011-2012 Kevin Reid under the terms of the MIT License as detailed
// in the accompanying file README.md or <http://opensource.org/licenses/MIT>.
+var measviz;
(function () {
"use strict";
- var measuring = cubes.measuring = {};
-
var max = Math.max;
var min = Math.min;
var mkelement = cubes.util.mkelement;
var PersistentCell = cubes.storage.PersistentCell;
+ var classPrefix = "measviz-";
+
function numberWithCommas(x) {
// source: http://stackoverflow.com/a/2901298/99692
return (+x).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
@@ -23,7 +24,7 @@
function createToggle(storageName, callback) {
var toggleState = new PersistentCell(localStorage, storageName, "boolean", true);
- var toggler = mkelement("button", "measuring-toggle");
+ var toggler = mkelement("button", classPrefix + "toggle");
toggleState.nowAndWhenChanged(function (v) {
if (v) {
toggler.textContent = "[−]" /* minus sign */;
@@ -46,11 +47,11 @@
}
ViewGroup.prototype.createDisplay = function (document, stateContext) {
var subContext = stateContext + "." + this.label;
- var container = mkelement("div", "measuring-item measuring-group");
- var list = mkelement("ul", "measuring-group-contents");
+ var container = mkelement("div", classPrefix + "item " + classPrefix + "group");
+ var list = mkelement("ul", classPrefix + "group-contents");
var header = null;
if (this.label) {
- header = mkelement("div", "measuring-group-header",
+ header = mkelement("div", classPrefix + "group-header",
createToggle(subContext + ".visible", function (visible) {
if (visible) {
list.style.removeProperty("display");
@@ -66,7 +67,7 @@
var updaters = [];
this.elements.forEach(function (thing) {
var subdisplay = thing.createDisplay(document, subContext);
- list.appendChild(mkelement("li", "measuring-group-element", subdisplay.element));
+ list.appendChild(mkelement("li", classPrefix + "group-element", subdisplay.element));
updaters.push(subdisplay.update.bind(subdisplay));
});
@@ -105,9 +106,9 @@
TopGroup.prototype.createDisplay = function (document, stateContext) {
var d = ViewGroup.prototype.createDisplay.call(this, document, stateContext);
var toggle = createToggle(stateContext + ".graphsVisible", function (visible) {
- d.element.classList[visible ? "remove" : "add"]("measuring-hide-sparklines");
+ d.element.classList[visible ? "remove" : "add"](classPrefix + "hide-sparklines");
});
- var bogusval = mkelement("span", "measuring-value"); // strictly for layout :(
+ var bogusval = mkelement("span", classPrefix + "value"); // strictly for layout :(
d.header.parentNode.insertBefore(toggle, d.header.nextSibling);
d.header.parentNode.insertBefore(bogusval, d.header.nextSibling);
return d;
@@ -121,11 +122,11 @@
}
Quantity.prototype.createDisplay = function (document, stateContext) {
var labelElem, valueText, sparkCanvas;
- var container = mkelement("div", "measuring-item measuring-quantity",
- labelElem = mkelement("span", "measuring-label", this.label + ": "),
- mkelement("span", "measuring-value",
+ var container = mkelement("div", classPrefix + "item " + classPrefix + "quantity",
+ labelElem = mkelement("span", classPrefix + "label", this.label + ": "),
+ mkelement("span", classPrefix + "value",
valueText = document.createTextNode("")),
- sparkCanvas = mkelement("canvas", "measuring-sparkline")
+ sparkCanvas = mkelement("canvas", classPrefix + "sparkline")
);
// sparkline
@@ -250,7 +251,7 @@
}
TaskGroup.prototype = Object.create(ViewGroup.prototype);
- cubes.Measuring = Object.freeze({
+ measviz = Object.freeze({
Counter: Counter,
TaskGroup: TaskGroup,
TopGroup: TopGroup,
@@ -4,11 +4,10 @@
(function () {
"use strict";
- var Measuring = cubes.Measuring;
- var TopGroup = Measuring.TopGroup;
- var ViewGroup = Measuring.ViewGroup;
- var TaskGroup = Measuring.TaskGroup;
- var Counter = Measuring.Counter;
+ var TopGroup = measviz.TopGroup;
+ var ViewGroup = measviz.ViewGroup;
+ var TaskGroup = measviz.TaskGroup;
+ var Counter = measviz.Counter;
var measuring = cubes.measuring = {};
measuring.all = new TopGroup("Performance", [
View
@@ -29,8 +29,8 @@
<script type="text/javascript" src="../module-initial.js"></script>
<script type="text/javascript" src="../util.js"></script>
<script type="text/javascript" src="../storage.js"></script>
- <script type="text/javascript" src="../deps/measuring/src/measuring.js"></script>
- <script type="text/javascript" src="../measuring-instance.js"></script>
+ <script type="text/javascript" src="../deps/measviz/src/measviz.js"></script>
+ <script type="text/javascript" src="../measviz-instance.js"></script>
<script type="text/javascript" src="../circuit.js"></script>
<script type="text/javascript" src="../blockset.js"></script>
<script type="text/javascript" src="../world.js"></script>
View
@@ -26,6 +26,9 @@ describe("Source code", function () {
mat3: false,
mat4: false,
+ // provided by measviz
+ measviz: false,
+
// our own globals
cubes: true,
},

0 comments on commit 6b79218

Please sign in to comment.