Skip to content

Commit

Permalink
jslint console.data.js and console.ui.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjlee committed Dec 2, 2010
1 parent cbf01f0 commit f67c950
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 129 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
- Console
- Update charts & summary on real data
- Update test spec on real data
- Adding a master node should add its slaves
- Really "add" a node (ping and connect to it)
Expand Down
31 changes: 17 additions & 14 deletions console/js/console.data.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
/*jslint forin:true */
/*globals window document $ */

var nodes = {};
var selectedNode = null;

function refreshReportsData(node) {
if (!node) { return; }
$.getJSON('http://' + node.name + '/reports', function(data, status) {
if (data) { node.reports = data; }
});
}
function initData() {
refreshReports = function() {
var refreshReports = function() {
for (var i in nodes) { refreshReportsData(nodes[i]); }
setTimeout(function() { refreshReports() }, 2000);
setTimeout(function() { refreshReports(); }, 2000);
};
refreshReports();
}
function getIdFromString(str) {
return str.replace(/[^a-zA-Z0-9-]/g,'-');
return str.replace(/[^a-zA-Z0-9\-]/g,'-');
}
function getNodeId(name) {
var parts = name.split(':');
if (parts.length == 1)
if (parts.length === 1) {
return getIdFromString(name) + "-8000";
}
return getIdFromString(name);
}
function getNodeObject(name) {
var nodeId = getNodeId(name);

if (nodes[nodeId]) return nodes[nodeId];
if (nodes[nodeId]) { return nodes[nodeId]; }
var node = nodes[nodeId] = {
id: nodeId,
name: name,
Expand All @@ -30,21 +40,14 @@ function getNodeObject(name) {
return node;
}
function deleteNodeObject(node) {
if (!node) return;
if (!node) { return; }
nodes[node.id] = null;
}

// Stubs
function getTests(nodeId) {
return ['Read', 'Read+Write']
return ['Read', 'Read+Write'];
}
function refreshReportsData(node) {
if (!node) return;
$.getJSON('http://' + node.name + '/reports', function(data, status) {
if (data) node.reports = data;
});
}

function randomize(list) {
return list.map(function(x) {
var rnd = [x[0]];
Expand Down
Loading

0 comments on commit f67c950

Please sign in to comment.