json pcfgadm-数据01.json

pcfgadm-data-03.json
{
    "auth": {
        "users": {
            "root": {
                "shadow": "$5$O2EFsgjs$IF1U3Y2m4ETHzt82cwlIaNgpQR8Gpj32f8wDIAe.XuC"
            }
        }
    },
    "storage": {
        "zfs": {
            "zpools": [
                "datap01",
                "datap02",
                "datap03"
            ],
            "zfstune": {
                "arc_shrink_shift": null,
                "l2arc_noprefetch": "0x0",
                "l2arc_write_boost": null,
                "zfs_arc_meta_limit": "0x4000000",
                "zfs_nocacheflush": "0x1",
                "zfs_no_write_throttle": "0x1",
                "zfs_txg_timeout": null,
                "zfs_txg_synctime_ms": null,
                "zfs_prefetch_disable": "0x0",
                "zfs_vdev_max_pending": "0xa",
                "zfs_vdev_min_pending": null
            }
        }
    },
    "network": {
        "identify": {
            "hostname": "rts-bsros-sandb-01",
            "ntp": [
                "server 0.us.pool.ntp.org",
                "server 1.us.pool.ntp.org",
                "server 2.us.pool.ntp.org",
                "server 3.us.pool.ntp.org"
            ],
            "timezone": "US/Eastern"
        },
        "ipmp": {
            "groups": [
                "ip0",
                "ip1",
                "ip2"
            ],
            "ip0": {
                "create": true,
                "interfaces": [
                    "e1000g1",
                    "e1000g2"
                ],
                "address": "10.255.1.112",
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "tag": null,
                "aliases": [
                    {
                        "id": 1,
                        "create": true,
                        "address": "10.255.1.112",
                        "netmask": null,
                        "broadcast": null,
                        "group": "ip0",
                        "tag": null
                    },
                    {
                        "id": 2,
                        "create": true,
                        "address": "10.255.1.212",
                        "netmask": null,
                        "broadcast": null,
                        "group": "ip0",
                        "tag": null
                    }
                ]
            }
        },
        "aggregates": {
            "aggr1": {
                "create": false,
                "interfaces": [
                    "e1000g1",
                    "e1000g2"
                ],
                "policy": "L4",
                "lacp-mode": "off",
                "name": "aggr_NFS_01"
            },
            "aggr2": {
                "create": false
            }
        },
        "interfaces": {
            "physical": [
                "e1000g0",
                "e1000g1",
                "e1000g2",
                "e1000g3"
            ],
            "e1000g0": {
                "create": true,
                "address": "dhcp",
                "netmask": null,
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "tag": ["admin"]
            },
            "e1000g1": {
                "create": true,
                "address": null,
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "group": "ip0",
                "failover": false
            },
            "e1000g2": {
                "create": true,
                "address": null,
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "group": "ip0",
                "failover": false
            },
            "e1000g3": {
                "address": "10.255.11.100",
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "tag": ["test", "service"],
                "aliases": [
                    {
                        "id": 1,
                        "create": true,
                        "address": "10.255.1.3",
                        "netmask": "255.255.255.0",
                        "broadcast": null
                    },
                    {
                        "id": 2,
                        "create": true,
                        "address": "10.255.1.4",
                        "netmask": "255.255.255.0",
                        "broadcast": null
                    }
                ]
            }
        }
    }
}
pcfgadm-data-02.json
{
    "auth": {
        "users": {
            "root": {
                "shadow": "$5$O2EFsgjs$IF1U3Y2m4ETHzt82cwlIaNgpQR8Gpj32f8wDIAe.XuC"
            }
        }
    },
    "storage": {
        "zfs": {
            "zpools": [
                "datap01",
                "datap02",
                "datap03"
            ],
            "zfstune": {
                "arc_shrink_shift": null,
                "l2arc_noprefetch": "0x0",
                "l2arc_write_boost": null,
                "zfs_arc_meta_limit": "0x4000000",
                "zfs_nocacheflush": "0x1",
                "zfs_no_write_throttle": "0x1",
                "zfs_txg_timeout": null,
                "zfs_txg_synctime_ms": null,
                "zfs_prefetch_disable": "0x0",
                "zfs_vdev_max_pending": "0xa",
                "zfs_vdev_min_pending": null
            }
        }
    },
    "network": {
        "identify": {
            "hostname": "rts-bsros-sandb-04",
            "ntp": [
                "server 0.us.pool.ntp.org",
                "server 1.us.pool.ntp.org",
                "server 2.us.pool.ntp.org",
                "server 3.us.pool.ntp.org"
            ],
            "timezone": "US/Eastern"
        },
        "ipmp": {
            "groups": [
                "ip0",
                "ip1",
                "ip2"
            ],
            "ip0": {
                "create": true,
                "interfaces": [
                    "e1000g1",
                    "e1000g2"
                ],
                "address": "10.255.1.100",
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "tag": null,
                "aliases": [
                    {
                        "id": 1,
                        "create": true,
                        "address": "10.255.1.101",
                        "netmask": null,
                        "broadcast": null,
                        "group": "ip0",
                        "tag": null
                    },
                    {
                        "id": 2,
                        "create": true,
                        "address": "10.255.1.102",
                        "netmask": null,
                        "broadcast": null,
                        "group": "ip0",
                        "tag": null
                    }
                ]
            }
        },
        "aggregates": {
            "aggr1": {
                "create": false,
                "interfaces": [
                    "e1000g1",
                    "e1000g2"
                ],
                "policy": "L4",
                "lacp-mode": "off",
                "name": "aggr_NFS_01"
            },
            "aggr2": {
                "create": false
            }
        },
        "interfaces": {
            "physical": [
                "e1000g0",
                "e1000g1",
                "e1000g2",
                "e1000g3"
            ],
            "e1000g0": {
                "create": true,
                "address": "dhcp",
                "netmask": null,
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "tag": ["admin"]
            },
            "e1000g1": {
                "create": true,
                "address": null,
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "group": "ip0",
                "failover": false
            },
            "e1000g2": {
                "create": true,
                "address": null,
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "group": "ip0",
                "failover": false
            },
            "e1000g3": {
                "address": "10.255.11.100",
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "tag": ["data", "test"],
                "aliases": [
                    {
                        "id": 1,
                        "create": true,
                        "address": null,
                        "netmask": null,
                        "broadcast": null,
                    },
                    {
                        "id": 2,
                        "create": true,
                        "address": null,
                        "netmask": null,
                        "broadcast": null
                    }
                ]
            }
        }
    }
}
pcfgadm-data-01.json
{
    "auth": {
        "users": {
            "root": {
                "shadow": "$5$O2EFsgjs$IF1U3Y2m4ETHzt82cwlIaNgpQR8Gpj32f8wDIAe.XuC"
            }
        }
    },
    "storage": {
        "zfs": {
            "zpools": [
                "datap01",
                "datap02",
                "datap03"
            ],
            "zfstune": {
                "arc_shrink_shift": null,
                "l2arc_noprefetch": "0x0",
                "l2arc_write_boost": null,
                "zfs_arc_meta_limit": "0x4000000",
                "zfs_nocacheflush": "0x1",
                "zfs_no_write_throttle": "0x1",
                "zfs_txg_timeout": null,
                "zfs_txg_synctime_ms": null,
                "zfs_prefetch_disable": "0x0",
                "zfs_vdev_max_pending": "0xa",
                "zfs_vdev_min_pending": null
            }
        }
    },
    "network": {
        "identify": {
            "hostname": "rts-bsros-sandb-02",
            "ntp": [
                "server 0.us.pool.ntp.org",
                "server 1.us.pool.ntp.org",
                "server 2.us.pool.ntp.org",
                "server 3.us.pool.ntp.org"
            ],
            "timezone": "US/Eastern"
        },
        "ipmp": {
            "groups": [
                "ip0",
                "ip1",
                "ip2"
            ],
            "ip0": {
                "create": true,
                "interfaces": [
                    "e1000g1",
                    "e1000g2"
                ],
                "address": "10.255.1.100",
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "tag": null,
                "aliases": [
                    {
                        "id": 1,
                        "create": true,
                        "address": "10.255.1.101",
                        "netmask": null,
                        "broadcast": null,
                        "group": "ip0",
                        "tag": null
                    },
                    {
                        "id": 2,
                        "create": true,
                        "address": "10.255.1.102",
                        "netmask": null,
                        "broadcast": null,
                        "group": "ip0",
                        "tag": null
                    }
                ]
            }
        },
        "aggregates": {
            "aggr1": {
                "create": false,
                "interfaces": [
                    "e1000g1",
                    "e1000g2"
                ],
                "policy": "L4",
                "lacp-mode": "off",
                "name": "aggr_NFS_01"
            },
            "aggr2": {
                "create": false
            }
        },
        "interfaces": {
            "physical": [
                "e1000g0",
                "e1000g1",
                "e1000g2",
                "e1000g3"
            ],
            "e1000g0": {
                "create": true,
                "address": "dhcp",
                "netmask": null,
                "broadcast": null,
                "gateway": null,
                "mtu": 1500
            },
            "e1000g1": {
                "create": true,
                "address": null,
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "group": "ip0",
                "failover": false
            },
            "e1000g2": {
                "create": true,
                "address": null,
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "group": "ip0",
                "failover": false
            },
            "e1000g3": {
                "address": "10.255.11.100",
                "netmask": "255.255.255.0",
                "broadcast": null,
                "gateway": null,
                "mtu": 1500,
                "tag": ["admin", "test"],
                "aliases": [
                    {
                        "id": 1,
                        "create": true,
                        "address": "10.255.1.3",
                        "netmask": "255.255.255.0",
                        "broadcast": null
                    },
                    {
                        "id": 2,
                        "create": true,
                        "address": "10.255.1.4",
                        "netmask": "255.255.255.0",
                        "broadcast": null
                    }
                ]
            }
        }
    }
}

json socket.io + express + sessions

socket.io + express + sessions

realtime-server.js
var sio = require('socket.io'),
        express = require('express'),
        http = require('http'),
        connect = require('connect'),
        app = express(),
        server = http.createServer(app);
var util = require('util');
 
var cookieParser = express.cookieParser('secret'),
        sessionStore = new connect.middleware.session.MemoryStore();
 
app.configure(function() {
        app.use(cookieParser);
        app.use(express.bodyParser());
        app.use(express.session({
                store: sessionStore
        }));
});
 
function checkAuth(req, res, next) {
        if (!req.session.user_id) {
                res.send('You are not authorized to connect to this server');
        } else {
                next();
        }
};
 
app.post('/login', function(req, res) {
        var post = req.body;
        if (post.un == 'redism' && post.pw == '1234') {
                req.session.user_id = 'redism';
                res.send('Done');
        } else {
                res.send('Bad user/pw', 403);
        }
});
 
server.listen(1337);
//var io = sio.listen(server, {resource: '/realtime'});
var io = sio.listen(server);
 
var SessionSockets = require('session.socket.io'),
        sessionSockets = new SessionSockets(io, sessionStore, cookieParser);
 
function parseSessionCookie(cookie, sid, secret) {
        var cookies = require('express/node_modules/cookie').parse(cookie),
                parsed = require('express/node_modules/connect/lib/utils').parseSignedCookies(
                        cookies, secret);
        return parsed[sid] || null;
}
 
io.configure(function() {
 
        // Setup socket.io authorization using express cookie.
        // To succeed authorization, client must first perform login
        // using POST to /login uri.
        io.set('authorization ', function(data, callback) {
                if (data.headers.cookie) {
                        var sid = parseSessionCookie(data.headers.cookie,
                                'connect.sid', 'secret');
                        console.log(sid);
                        callback(null, true);
                } else {
                        callback('Authorization required', false);
                }
        });
});
 
sessionSockets.on('connection', function(err, socket, session) {
        console.log('connection established.');
        io.sockets.emit('announcement', 'connected ');
 
        socket.on('user message', function(msg) {
                io.sockets.emit('user message', msg);
        });
 
        setInterval(function() {
                socket.emit('announcement', 'hello');
        }, 1000);
});
realtime-client.js
var util = require('util');
var sio = require('socket.io-client');
var request = require('request');
 
// The code below is borrowed from the gist below.
// https://gist.github.com/jfromaniello/4087861
//
// Make socket.io client work with login cookie so that authentication
// can work with socket.io client and request.
var j = request.jar();
 
var originalRequest = require('xmlhttprequest').XMLHttpRequest;
 
require('socket.io-client/node_modules/xmlhttprequest').XMLHttpRequest = function() {
        originalRequest.apply(this, arguments);
        this.setDisableHeaderCheck(true);
        var stdOpen = this.open;
 
        // I will patch now open in order to set my cookie from the jar request.
        this.open = function() {
                stdOpen.apply(this, arguments);
                var header = j.get({
                        url: 'http://localhost:9000'
                }).map(function(c) {
                        return c.name + "=" + c.value;
                }).join("; ");
                this.setRequestHeader('cookie', header);
        };
};
 
request.post({
        uri: 'http://localhost:1337/login',
        jar: j,
        form: {
                un: 'redism',
                pw: '1234'
        }
}, function(err, res, body) {
        if (res.statusCode == 403) {
                console.log('Login : Authentication failed!');
        } else if (res.statusCode == 200) {
                console.log('Connecting to RT server');
                connectToRTServer();
        }
});
 
function connectToRTServer() {
        var socket = sio.connect('http://localhost:1337');
 
        socket.on('connect', function() {
                console.log('connected!');
        });
 
        socket.on('connect_failed', function(reason) {
                console.log('connection failed : ' + reason);
        });
 
        socket.on('disconnect', function(obj) {
                util.inspect(obj);
                console.log('disconnected!');
        });
 
        socket.on('error', function(err, reason) {
                if (err === 'handshake error') {
                        console.log('Error : Authorization failed');
                } else {
                        console.log('Error : ' + err);
                }
        });
 
        socket.on('news', function(data) {
                console.log(data);
        });
 
    socket.on('announcement', function(data) {
				console.log('Announcement from the server : ' + data);
		});
};
package.json
{
        "name": "soup_realtime",
        "version": "0.1.0",
        "description": "realtime server",
        "main": "realtime-server.js",
        "scripts": {
                "test": "echo \"Error: no test specified! Configure in package.json\" && exit 1"
        },
        "repository": "",
        "dependencies": {
                "socket.io-client": "*",
                "socket.io": "*",
                "express": "*",
                "request": "*",
                "xmlhttprequest": "*",
    		"connect": "*",
				"session.socket.io": "*"
        },
        "keywords": [],
        "author": "redism",
        "license": "MIT",
        "readmeFilename": "README.md"
}

json 我的Sublime Text 2获取包列表。

我的Sublime Text 2获取包列表。

fetch.json
{
	"files":
	{
		"[Bloqhead] CSS Banner": "https://gist.github.com/bloqhead/6a8c13c82bedc702e01b/raw/275d3f27e79d0d57fe30e1290bccbff6c114a7cb/CSSBanner.scss",
		"[Bloqhead] Tile Tamer": "https://gist.github.com/bloqhead/03710045d8e79bd7b725/raw/2648ea6fac13a0388b074e400bfbccf3554e6675/tile.tamer.js",
		"[Bones] Footer": "https://raw.github.com/eddiemachado/bones/master/footer.php",
		"[Bones] Grid Mixins": "https://gist.github.com/bloqhead/a774ed3c5e603b73888e/raw/BonesGrid.scss",
		"[Bones] Header": "https://raw.github.com/eddiemachado/bones/master/header.php",
		"[CSS] Eric Meyer's Reset": "http://meyerweb.com/eric/tools/css/reset/reset.css",
		"[CSS] FlexSlider CSS": "https://raw.github.com/woothemes/FlexSlider/master/flexslider.css",
		"[CSS] Normalize CSS": "https://raw.github.com/necolas/normalize.css/master/normalize.css",
		"[Grunt] Gruntfile": "https://gist.github.com/bloqhead/aece7166e24e6b20db71/raw/Gruntfile.js",
		"[Grunt] Package": "https://gist.github.com/bloqhead/c7b619082e7ec22aed4a/raw/package.json",
		"[HTML] FlexSlider Example": "https://gist.github.com/bloqhead/e0d53075878455ec79d1/raw/497d1da8089261e72ee72f8f6308fc2fe1f1ebb1/FlexSliderSample.html",
		"[JS] Bones Scripts": "https://raw.github.com/eddiemachado/bones/master/library/js/scripts.js",
		"[Misc] Google Analytics": "https://gist.github.com/bloqhead/2ed65899ebe22463279c/raw/717672c852b0f130751f3e8279c83e98363d02bc/GATracking.html",
		"[Misc] Rick Astley Embed": "https://gist.github.com/bloqhead/1b68b996abbb5fb97e6b/raw/1544638992bf8899eb53851a2d3dc4c34ba7bb23/rickrolled.html",
		"[Misc] State Select Menu": "https://gist.github.com/bloqhead/430230ce84860b9b5293/raw/1791224911b4e76793841767be6c3085d87651cb/state-select.html",
		"[SASS] Simple Bourbon Grid": "https://gist.github.com/bloqhead/d0f7471efcfad92b138d/raw/BourbonNeatGrid.scss",
		"[WP] Custom Options Page": "https://gist.github.com/bloqhead/39b882c645c6825b07f8/raw/0cbe1352337017623cf16a9d737662446fa3f723/custom-options.php",
		"[WP] Featured Image URL": "https://gist.github.com/bloqhead/05ca7c237bf4a49955c2/raw/eb2f6f92a68e67783f0c05461f3be417b73b438f/WPFeaturedImage.php",
		"[WP] Query": "https://gist.github.com/bloqhead/bc3404cecbde7b886551/raw/wp_query.php",
		"[WP] Salt": "https://api.wordpress.org/secret-key/1.1/salt/",
		"[WP] Static Shortcode": "https://gist.github.com/bloqhead/baceb2ef72eb0a02470e/raw/d679e5629fce6c4fd1084ede3607bb50d4601478/shortcode.php",
		"[WP] Title": "https://gist.github.com/bloqhead/f68b83b3b3c1c1eb3a6f/raw/d1b05f7362a2bc6a8dd8d8bd527dccaa589e3d7c/WPTitle.php",
		"[jQuery] Basic Opening": "https://gist.github.com/bloqhead/f52bb07982f29e3ca45e/raw/a00b9a3c86864efabd1bdf9a355fe5c897d35355/jquery.function.js",
		"[jQuery] Cycle": "http://malsup.github.io/jquery.cycle.all.js",
		"[jQuery] FitVids": "https://raw.github.com/davatron5000/FitVids.js/master/jquery.fitvids.js",
		"[jQuery] FlexSlider JS": "https://raw.github.com/woothemes/FlexSlider/master/jquery.flexslider-min.js",
		"[jQuery] Latest Core": "http://code.jquery.com/jquery.min.js",
		"[jQuery] No Conflict": "https://gist.github.com/bloqhead/360dd75eb581975cedd2/raw/812badb21638fdc227369eeb8f2137602db8eeea/jQuery.noConflict.js"
	},
	"packages":
	{
		"[BSD] Bones SCSS Starter": "https://dl.dropboxusercontent.com/u/46127334/startercss.zip",
		"[Fonts] Font Awesome": "http://fortawesome.github.io/Font-Awesome/assets/font-awesome.zip",
		"[HTML5] HTML5 Boilerplate": "https://github.com/h5bp/html5-boilerplate/zipball/master",
		"[SASS] Bourbon Neat": "https://github.com/thoughtbot/neat/archive/master.zip",
		"[WP] Bones": "https://github.com/eddiemachado/bones/zipball/master"
	}
}

json 我的Sublime Text 2设置(截至2013-09-19)。

我的Sublime Text 2设置(截至2013-09-19)。

user.json
{
	"bold_folder_labels": true,
	"caret_style": "phase",
	"color_scheme": "Packages/Base16/base16-tomorrow.light.tmTheme",
	"draw_minimap_border": true,
	"ensure_newline_at_eof_on_save": false,
	"fade_fold_buttons": false,
	"file_exclude_patterns":
	[
		"*.pyc",
		"*.pyo",
		"*.exe",
		"*.dll",
		"*.obj",
		"*.o",
		"*.a",
		"*.lib",
		"*.so",
		"*.dylib",
		"*.ncb",
		"*.sdf",
		"*.suo",
		"*.pdb",
		"*.idb",
		".DS_Store",
		"*.class",
		"*.psd",
		"*.pxm",
		"*.ai",
		"*.eps",
		"*.db",
		"*.tmproj",
		"*.sublime-project",
		"*.sublime-workspace"
	],
	"folder_exclude_patterns":
	[
		".svn",
		".git",
		".hg",
		"CVS",
		".sass-cache"
	],
	"font_face": "inconsolata-g",
	"font_size": 12,
	"gutter": true,
	"highlight_line": false,
	"highlight_modified_tabs": true,
	"ignored_packages":
	[
		"Vintage"
	],
	"line_padding_bottom": 1,
	"line_padding_top": 1,
	"margin": 4,
	"remember_open_files": false,
	"show_minimap": true,
	"tab_size": 4,
	"theme": "Phoenix Light.sublime-theme",
	"translate_tabs_to_spaces": false,
	"trim_trailing_white_space_on_save": true,
	"word_wrap": true
}

json Grunt开发服务器

Grunt开发服务器

Gruntfile.js
module.exports = function (grunt) {

  grunt.loadNpmTasks('grunt-contrib-connect');

  grunt.initConfig({
    connect: {
      server: {
        options: {
          port: 8000,
          base: '.',
          keepalive: true
        }
      }
    }
  });

  grunt.registerTask("serve", "connect:server");
};
README.md
Simple setup to have a dev server in the desired directory. Simply download the two files to your directory and execute

```
$ npm install
$ grunt server
```
package.json
{
  "name": "Test",
  "description": "Grunt development server",
  "version": "0.0.0",
  "devDependencies": {
    "grunt": "0.4.0",
    "http-server": "0.5.1",
    "grunt-contrib-connect": "0.1.2"
  }
}

json http://blog.storyful.com/2013/09/04/how-we-save-hours-of-work-every-week-with-a-few-clever-lines-of-code的代码片段

http://blog.storyful.com/2013/09/04/how-we-save-hours-of-work-every-week-with-a-few-clever-lines-of-code的代码片段

multisearch004.json
{
  ...
  "content_security_policy": "script-src 'self' https://cdn.mxpnl.com 
                              https://ssl.google-analytics.com; 
                              object-src 'self'",
  "permissions": [
    "tabs", 
    "http://*/*/",
    "https://*/*/"
  ]
  ...
}

json gistfile1.json

gistfile1.json
{
    "ID": "3c6207e5-5373-4524-870d-7e7c80b6e84f",
    "beschreibung": "Snowden-Vertrauter Greenwald im Interview Der ehemalige Guardian-Journalist Glenn Greenwald spricht über seine enge Zusammenarbeit mit dem Whistleblower Edward Snowden.   Themen des Interviews sind die von ihm angekündigten neuesten Enthüllungen über die US-Spähprogramme, den schwierigen Umgang mit Geheimdokumenten und die Festnahme seines Lebenspartners David Miranda am Londoner Flughafen Heathrow.    Militärschlag gegen Syrien Politiker von Regierung und Opposition lehnen eine militärische Intervention ab.   MoMa Reporter: Steinbrück im Wahlkampf Wie macht Peer Steinbrück Wahlkampf, wenn alle Vorhersagen eine Niederlage im Kampf um das Kanzleramt prophezeien?   Service: Krankenkassen im Test Experte: Holger Rohde, Stiftung Warentest.",
    "endTime": "2013-08-27T09:00:00+02:00",
    "images": {
        "image": [
            {
                "cuttingDimension": {
                    "contentId": "142",
                    "externalId": "6c37c877-3450-3f0d-98b0-ded5be898ecd",
                    "height": "378",
                    "name": "MMBuehne_Bild_Video_5-5_672x378",
                    "width": "672"
                },
                "uri": "http://www.zdf.de/ZDF/zdfportal/blob/21699076/1/data.jpg"
            },
            {
                "cuttingDimension": {
                    "contentId": "3410",
                    "externalId": "21416a69-a2ae-3011-8c00-79a2711f5ba0",
                    "height": "51",
                    "name": "EPG-small_Zeitstrahl_90x51",
                    "width": "90"
                },
                "uri": "http://www.zdf.de/ZDF/zdfportal/blob/22482828/1/data.jpg"
            }
        ]
    },
    "link": "http://www.zdf.de/ZDF/zdfportal/xml/epg/20197101,3c6207e5-5373-4524-870d-7e7c80b6e84f",
    "livestream": "true",
    "station": {
        "contentId": "14",
        "externalId": "",
        "name": "ZDF",
        "serviceId": "1",
        "epgLogo": {
            "contentId": "716",
            "externalId": "",
            "altText": [],
            "height": "0",
            "uri": "http://www.zdf.de/ZDF/zdfportal/blob/716/11/data.png",
            "width": "0"
        },
        "detailLevel": "4"
    },
    "time": "2013-08-27T05:30:00+02:00",
    "tvTipp": "false",
    "titel": "ARD-Morgenmagazin",
    "url": "http://www.zdf.de/ZDF/zdfportal/programdata/3c6207e5-5373-4524-870d-7e7c80b6e84f/20197101",
    "programdata": {
        "actorDetails": [],
        "airtimeBegin": "2013-08-27T05:30:00+02:00",
        "airtimeDate": "2013-08-27T00:00:00+02:00",
        "audioComments": "false",
        "blackwhite": "false",
        "broadcastStation": {
            "contentId": "14",
            "externalId": "",
            "name": "ZDF",
            "serviceId": "1",
            "epgLogo": {
                "contentId": "716",
                "externalId": "",
                "altText": [],
                "height": "0",
                "uri": "http://www.zdf.de/ZDF/zdfportal/blob/716/11/data.png",
                "width": "0"
            },
            "detailLevel": "4"
        },
        "caption": "true",
        "crewFunctionDetails": {
            "crewFunction": {
                "name": "moderation",
                "crewNames": {
                    "crewName": "Anne Gesthuysen und Sven Lorig"
                }
            }
        },
        "dolbyDigital51": "false",
        "dolbySurround": "false",
        "dualchannel": "false",
        "duration": "210",
        "foreignLangWithCaption": "false",
        "guests": [],
        "hd": "false",
        "livestream": "true",
        "vpsBegin": "2013-08-27T05:30:00+02:00",
        "widescreen169": "false",
        "url": "http://www.zdf.de/ZDF/zdfportal/xml/epg/20197101,3c6207e5-5373-4524-870d-7e7c80b6e84f"
    }
}

json 针对q-learn应用程序中某些事件/场景应发出多少硬币的建议规则集

针对q-learn应用程序中某些事件/场景应发出多少硬币的建议规则集

q-learn-coin-rules.json
{
  "login": {
    "firstForDay": {
      "coins": 1000,
      "message": "First login for the day!"
    },
    "firstEver": {
      "coins": 10000,
      "message": "First login"
    }
  },

  "topic": {
    "onComplete": {
      "coins": 1000,
      "message": "Topic Complete!"
    },

    "onMaster": {
      "coins": 2000,
      "message": "Topic Mastered!"
    },

    "quiz": {
      "firstAttempt": {
        "correct": {
          "coins": 100,
          "message": [
            "Excellent!", 
            "Nice!", 
            "Sweet!", 
            "Amazing!", 
            "Great!", 
            "Smooth!"
          ]
        },
        "incorrect": 0,
        "combos": {
          "2": {
            "coins": 200,
            "message": [
              "Two in a row!", 
              "Two for Two!", 
              "Super Smooth!"
            ]
          },
          "3": {
            "coins": 200,
            "message": [
              "Three in a row!", 
              "Triple Threat!", 
              "On Fire!",
              "Three Peat!",
              "Epic!"
            ]
          },
          "4": {
            "coins": 200,
            "message": "4xCombo!"
          },
          "5": {
            "coins": 200,
            "message": "5xCombo!"
          },
          "6": {
            "coins": 200,
            "message": "6xCombo!"
          },
          "7": {
            "coins": 200,
            "message": "7xCombo!"
          },
          "8": {
            "coins": 200,
            "message": "8xCombo!"
          },
          "9": {
            "coins": 200,
            "message": "9xCombo!"
          },
          "10": {
            "coins": 200,
            "message": "10xCombo!"
          }
        }
      },

      "revisionAttempt": {
        "correct": {
          "coins": 50,
          "message": [
            "Excellent!", 
            "Nice!", 
            "Sweet!", 
            "Amazing!", 
            "Great!", 
            "Smooth!"
          ]
        },
        "incorrect": 0,
        "combos": {
          "2": {
            "coins": 100,
            "message": [
              "Two in a row!", 
              "Two for Two!", 
              "Super Smooth!"
            ]
          },
          "3": {
            "coins": 150,
            "message": [
              "Three in a row!", 
              "Triple Threat!", 
              "On Fire!",
              "Three Peat!",
              "Epic!"
            ]
          },
          "4": {
            "coins": 150,
            "message": "4xCombo!"
          },
          "5": {
            "coins": 150,
            "message": "5xCombo!"
          },
          "6": {
            "coins": 150,
            "message": "6xCombo!"
          },
          "7": {
            "coins": 150,
            "message": "7xCombo!"
          },
          "8": {
            "coins": 200,
            "message": "8xCombo!"
          },
          "9": {
            "coins": 200,
            "message": "9xCombo!"
          },
          "10": {
            "coins": 200,
            "message": "10xCombo!"
          }
        }
      }
    }
  }
}

json flare.json

flare.json
{
 "name": "flare",
 "children": [
  {
   "name": "analytics",
   "children": [
    {
     "name": "cluster",
     "children": [
      {"name": "AgglomerativeCluster", "size": 3938},
      {"name": "CommunityStructure", "size": 3812},
      {"name": "HierarchicalCluster", "size": 6714},
      {"name": "MergeEdge", "size": 743}
     ]
    },
    {
     "name": "graph",
     "children": [
      {"name": "BetweennessCentrality", "size": 3534},
      {"name": "LinkDistance", "size": 5731},
      {"name": "MaxFlowMinCut", "size": 7840},
      {"name": "ShortestPaths", "size": 5914},
      {"name": "SpanningTree", "size": 3416}
     ]
    },
    {
     "name": "optimization",
     "children": [
      {"name": "AspectRatioBanker", "size": 7074}
     ]
    }
   ]
  },
  {
   "name": "animate",
   "children": [
    {"name": "Easing", "size": 17010},
    {"name": "FunctionSequence", "size": 5842},
    {
     "name": "interpolate",
     "children": [
      {"name": "ArrayInterpolator", "size": 1983},
      {"name": "ColorInterpolator", "size": 2047},
      {"name": "DateInterpolator", "size": 1375},
      {"name": "Interpolator", "size": 8746},
      {"name": "MatrixInterpolator", "size": 2202},
      {"name": "NumberInterpolator", "size": 1382},
      {"name": "ObjectInterpolator", "size": 1629},
      {"name": "PointInterpolator", "size": 1675},
      {"name": "RectangleInterpolator", "size": 2042}
     ]
    },
    {"name": "ISchedulable", "size": 1041},
    {"name": "Parallel", "size": 5176},
    {"name": "Pause", "size": 449},
    {"name": "Scheduler", "size": 5593},
    {"name": "Sequence", "size": 5534},
    {"name": "Transition", "size": 9201},
    {"name": "Transitioner", "size": 19975},
    {"name": "TransitionEvent", "size": 1116},
    {"name": "Tween", "size": 6006}
   ]
  },
  {
   "name": "data",
   "children": [
    {
     "name": "converters",
     "children": [
      {"name": "Converters", "size": 721},
      {"name": "DelimitedTextConverter", "size": 4294},
      {"name": "GraphMLConverter", "size": 9800},
      {"name": "IDataConverter", "size": 1314},
      {"name": "JSONConverter", "size": 2220}
     ]
    },
    {"name": "DataField", "size": 1759},
    {"name": "DataSchema", "size": 2165},
    {"name": "DataSet", "size": 586},
    {"name": "DataSource", "size": 3331},
    {"name": "DataTable", "size": 772},
    {"name": "DataUtil", "size": 3322}
   ]
  },
  {
   "name": "display",
   "children": [
    {"name": "DirtySprite", "size": 8833},
    {"name": "LineSprite", "size": 1732},
    {"name": "RectSprite", "size": 3623},
    {"name": "TextSprite", "size": 10066}
   ]
  },
  {
   "name": "flex",
   "children": [
    {"name": "FlareVis", "size": 4116}
   ]
  },
  {
   "name": "physics",
   "children": [
    {"name": "DragForce", "size": 1082},
    {"name": "GravityForce", "size": 1336},
    {"name": "IForce", "size": 319},
    {"name": "NBodyForce", "size": 10498},
    {"name": "Particle", "size": 2822},
    {"name": "Simulation", "size": 9983},
    {"name": "Spring", "size": 2213},
    {"name": "SpringForce", "size": 1681}
   ]
  },
  {
   "name": "query",
   "children": [
    {"name": "AggregateExpression", "size": 1616},
    {"name": "And", "size": 1027},
    {"name": "Arithmetic", "size": 3891},
    {"name": "Average", "size": 891},
    {"name": "BinaryExpression", "size": 2893},
    {"name": "Comparison", "size": 5103},
    {"name": "CompositeExpression", "size": 3677},
    {"name": "Count", "size": 781},
    {"name": "DateUtil", "size": 4141},
    {"name": "Distinct", "size": 933},
    {"name": "Expression", "size": 5130},
    {"name": "ExpressionIterator", "size": 3617},
    {"name": "Fn", "size": 3240},
    {"name": "If", "size": 2732},
    {"name": "IsA", "size": 2039},
    {"name": "Literal", "size": 1214},
    {"name": "Match", "size": 3748},
    {"name": "Maximum", "size": 843},
    {
     "name": "methods",
     "children": [
      {"name": "add", "size": 593},
      {"name": "and", "size": 330},
      {"name": "average", "size": 287},
      {"name": "count", "size": 277},
      {"name": "distinct", "size": 292},
      {"name": "div", "size": 595},
      {"name": "eq", "size": 594},
      {"name": "fn", "size": 460},
      {"name": "gt", "size": 603},
      {"name": "gte", "size": 625},
      {"name": "iff", "size": 748},
      {"name": "isa", "size": 461},
      {"name": "lt", "size": 597},
      {"name": "lte", "size": 619},
      {"name": "max", "size": 283},
      {"name": "min", "size": 283},
      {"name": "mod", "size": 591},
      {"name": "mul", "size": 603},
      {"name": "neq", "size": 599},
      {"name": "not", "size": 386},
      {"name": "or", "size": 323},
      {"name": "orderby", "size": 307},
      {"name": "range", "size": 772},
      {"name": "select", "size": 296},
      {"name": "stddev", "size": 363},
      {"name": "sub", "size": 600},
      {"name": "sum", "size": 280},
      {"name": "update", "size": 307},
      {"name": "variance", "size": 335},
      {"name": "where", "size": 299},
      {"name": "xor", "size": 354},
      {"name": "_", "size": 264}
     ]
    },
    {"name": "Minimum", "size": 843},
    {"name": "Not", "size": 1554},
    {"name": "Or", "size": 970},
    {"name": "Query", "size": 13896},
    {"name": "Range", "size": 1594},
    {"name": "StringUtil", "size": 4130},
    {"name": "Sum", "size": 791},
    {"name": "Variable", "size": 1124},
    {"name": "Variance", "size": 1876},
    {"name": "Xor", "size": 1101}
   ]
  },
  {
   "name": "scale",
   "children": [
    {"name": "IScaleMap", "size": 2105},
    {"name": "LinearScale", "size": 1316},
    {"name": "LogScale", "size": 3151},
    {"name": "OrdinalScale", "size": 3770},
    {"name": "QuantileScale", "size": 2435},
    {"name": "QuantitativeScale", "size": 4839},
    {"name": "RootScale", "size": 1756},
    {"name": "Scale", "size": 4268},
    {"name": "ScaleType", "size": 1821},
    {"name": "TimeScale", "size": 5833}
   ]
  },
  {
   "name": "util",
   "children": [
    {"name": "Arrays", "size": 8258},
    {"name": "Colors", "size": 10001},
    {"name": "Dates", "size": 8217},
    {"name": "Displays", "size": 12555},
    {"name": "Filter", "size": 2324},
    {"name": "Geometry", "size": 10993},
    {
     "name": "heap",
     "children": [
      {"name": "FibonacciHeap", "size": 9354},
      {"name": "HeapNode", "size": 1233}
     ]
    },
    {"name": "IEvaluable", "size": 335},
    {"name": "IPredicate", "size": 383},
    {"name": "IValueProxy", "size": 874},
    {
     "name": "math",
     "children": [
      {"name": "DenseMatrix", "size": 3165},
      {"name": "IMatrix", "size": 2815},
      {"name": "SparseMatrix", "size": 3366}
     ]
    },
    {"name": "Maths", "size": 17705},
    {"name": "Orientation", "size": 1486},
    {
     "name": "palette",
     "children": [
      {"name": "ColorPalette", "size": 6367},
      {"name": "Palette", "size": 1229},
      {"name": "ShapePalette", "size": 2059},
      {"name": "SizePalette", "size": 2291}
     ]
    },
    {"name": "Property", "size": 5559},
    {"name": "Shapes", "size": 19118},
    {"name": "Sort", "size": 6887},
    {"name": "Stats", "size": 6557},
    {"name": "Strings", "size": 22026}
   ]
  },
  {
   "name": "vis",
   "children": [
    {
     "name": "axis",
     "children": [
      {"name": "Axes", "size": 1302},
      {"name": "Axis", "size": 24593},
      {"name": "AxisGridLine", "size": 652},
      {"name": "AxisLabel", "size": 636},
      {"name": "CartesianAxes", "size": 6703}
     ]
    },
    {
     "name": "controls",
     "children": [
      {"name": "AnchorControl", "size": 2138},
      {"name": "ClickControl", "size": 3824},
      {"name": "Control", "size": 1353},
      {"name": "ControlList", "size": 4665},
      {"name": "DragControl", "size": 2649},
      {"name": "ExpandControl", "size": 2832},
      {"name": "HoverControl", "size": 4896},
      {"name": "IControl", "size": 763},
      {"name": "PanZoomControl", "size": 5222},
      {"name": "SelectionControl", "size": 7862},
      {"name": "TooltipControl", "size": 8435}
     ]
    },
    {
     "name": "data",
     "children": [
      {"name": "Data", "size": 20544},
      {"name": "DataList", "size": 19788},
      {"name": "DataSprite", "size": 10349},
      {"name": "EdgeSprite", "size": 3301},
      {"name": "NodeSprite", "size": 19382},
      {
       "name": "render",
       "children": [
        {"name": "ArrowType", "size": 698},
        {"name": "EdgeRenderer", "size": 5569},
        {"name": "IRenderer", "size": 353},
        {"name": "ShapeRenderer", "size": 2247}
       ]
      },
      {"name": "ScaleBinding", "size": 11275},
      {"name": "Tree", "size": 7147},
      {"name": "TreeBuilder", "size": 9930}
     ]
    },
    {
     "name": "events",
     "children": [
      {"name": "DataEvent", "size": 2313},
      {"name": "SelectionEvent", "size": 1880},
      {"name": "TooltipEvent", "size": 1701},
      {"name": "VisualizationEvent", "size": 1117}
     ]
    },
    {
     "name": "legend",
     "children": [
      {"name": "Legend", "size": 20859},
      {"name": "LegendItem", "size": 4614},
      {"name": "LegendRange", "size": 10530}
     ]
    },
    {
     "name": "operator",
     "children": [
      {
       "name": "distortion",
       "children": [
        {"name": "BifocalDistortion", "size": 4461},
        {"name": "Distortion", "size": 6314},
        {"name": "FisheyeDistortion", "size": 3444}
       ]
      },
      {
       "name": "encoder",
       "children": [
        {"name": "ColorEncoder", "size": 3179},
        {"name": "Encoder", "size": 4060},
        {"name": "PropertyEncoder", "size": 4138},
        {"name": "ShapeEncoder", "size": 1690},
        {"name": "SizeEncoder", "size": 1830}
       ]
      },
      {
       "name": "filter",
       "children": [
        {"name": "FisheyeTreeFilter", "size": 5219},
        {"name": "GraphDistanceFilter", "size": 3165},
        {"name": "VisibilityFilter", "size": 3509}
       ]
      },
      {"name": "IOperator", "size": 1286},
      {
       "name": "label",
       "children": [
        {"name": "Labeler", "size": 9956},
        {"name": "RadialLabeler", "size": 3899},
        {"name": "StackedAreaLabeler", "size": 3202}
       ]
      },
      {
       "name": "layout",
       "children": [
        {"name": "AxisLayout", "size": 6725},
        {"name": "BundledEdgeRouter", "size": 3727},
        {"name": "CircleLayout", "size": 9317},
        {"name": "CirclePackingLayout", "size": 12003},
        {"name": "DendrogramLayout", "size": 4853},
        {"name": "ForceDirectedLayout", "size": 8411},
        {"name": "IcicleTreeLayout", "size": 4864},
        {"name": "IndentedTreeLayout", "size": 3174},
        {"name": "Layout", "size": 7881},
        {"name": "NodeLinkTreeLayout", "size": 12870},
        {"name": "PieLayout", "size": 2728},
        {"name": "RadialTreeLayout", "size": 12348},
        {"name": "RandomLayout", "size": 870},
        {"name": "StackedAreaLayout", "size": 9121},
        {"name": "TreeMapLayout", "size": 9191}
       ]
      },
      {"name": "Operator", "size": 2490},
      {"name": "OperatorList", "size": 5248},
      {"name": "OperatorSequence", "size": 4190},
      {"name": "OperatorSwitch", "size": 2581},
      {"name": "SortOperator", "size": 2023}
     ]
    },
    {"name": "Visualization", "size": 16540}
   ]
  }
 ]
}

json 的index.html

index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Hive Plots</title>
<style>

@import url(../style.css?20120427);

.axis {
  stroke: #000;
  stroke-width: 1.5px;
}

.node circle {
  stroke: #000;
}

.link {
  fill: none;
  stroke: #999;
  stroke-width: 1.5px;
  stroke-opacity: .3;
}

.link.active {
  stroke: red;
  stroke-width: 2px;
  stroke-opacity: 1;
}

.link.ortholog {
  stroke: green;
  stroke-width: 2px;
  stroke-opacity: 1;
}


.node circle.active {
  stroke: red;
  stroke-width: 3px;
}

</style>


<h1>TreeFam Homology Hive Plots</h1>

<p>Mouseover to show the homology relationships for the corresponding gene.
  <p id="info">Loading…

<p id="chart">


<p style="margin-top:4em;">Special thanks to <a href="http://www.cfcl.com/rdm/">Rich Morin</a> for assisting in the implementation of hive plots in D3!

<footer>
  <aside>March 18, 2012</aside>
  <a href="../" rel="author">Mike Bostock</a>
</footer>

<script src="http://d3js.org/d3.v2.js?2.8.1"></script>
<script>

var width = 960,
    height = 850,
    innerRadius = 40,
    outerRadius = 640,
    majorAngle = 2 * Math.PI / 3,
    minorAngle = 1 * Math.PI / 12;

var angle = d3.scale.ordinal()
    //.domain(["source", "source-target", "target-source", "target"])
    .domain(["source", "source-target", "target-source", "target"])
//		.range([0, majorAngle - minorAngle, majorAngle + minorAngle, 2 * majorAngle])
		.range([0, majorAngle - minorAngle, majorAngle + minorAngle, 2 * majorAngle]);

var radius = d3.scale.linear()
    .range([innerRadius, outerRadius]);

var color = d3.scale.category10();

var svg = d3.select("#chart").append("svg")
    .attr("width", width)
    .attr("height", height)
  .append("g")
    //.attr("transform", "translate(" + outerRadius * .20 + "," + outerRadius * .57 + ")")
	.attr("transform", "translate(140,40)")
	;

// Load the data and display the plot!
d3.json("treefam.json", function(nodes) {
  var nodesByName = {},
  	  genesByName = {},
      links = [],
	  geneNodes = [],
	  homologyNodes = [],
	  ignoreSpecies = {},
	  ignoreRank = {},
      formatNumber = d3.format(",d"),
      defaultInfo;
	  image_path = "../../lib/images/";
	  var rank_x = 200;
	  var species_x = 400;
	  var homologs_x = 600;
	  var gene_distance = 12;
	  var rank_distance = 12;
	  var species_distance = 12;
	  var homologs_distance = 12;
	  var rankNodes = [];
	  var speciesNodes = [];
	  

	  // iterating over all input genes
	  // Construct an index by node name.
	  nodes.forEach(function(d) {
	    d.connectors = [];
	    d.packageName = d.name.split(".")[0];
	    genesByName[d.name] = d;
	  });
	  //console.log(genesByName);
	  
	  
	  // Convert the import lists into links with sources and targets.
	  nodes.forEach(function(source) {
		//	console.log(source);
		//console.log(source.imports);
	    
		source.imports.forEach(function(targetName) {
		 // console.log(targetName);
	      var target = genesByName[targetName];
		  //console.log("adding to links: "+links.length);
		  //if(!target){console.log("could not find target for "+targetName.target);}
	      //if (!source.source) {
			//  console.log("source: add to connectors");
			//  source.connectors.push(source.source = {node: source, degree: 0});
		  //}
	      //if (!target.target){ 
			//console.log("target: add to connectors");
			 // target.connectors.push(target.target = {node: target, degree: 0});
		  //}
		  //rank2species.push(d.rank);
	      links.push({source: source, target: targetName});
		  if( ignoreRank[targetName.rank] === undefined ) {
		  	rankNodes.push(targetName);
			ignoreRank[targetName.rank] = 1;
		  }
		  if( ignoreSpecies[targetName.taxon] === undefined ) {
		  	speciesNodes.push(targetName);
			ignoreSpecies[targetName.taxon] = 1;
		  }	
		 // if( ignoreS[targetName.taxon] === undefined ) {
		  	homologyNodes.push(targetName);
			//ignoreHomology[targetName.taxon] = 1;
		  //}	
		  
		  	  
		  
	    });
		geneNodes.push(source);
	  });
	  console.log("species");
	  console.log(speciesNodes);
	  //console.log(nodes);
	  
	  //test
	 // console.log("geneNodes");
	 // console.log(geneNodes);
	 // console.log("homologyNodes");
	 // console.log(homologyNodes);
	  
	  
//	  test
	  nodes.forEach(function(node) {
	    if (node.source && node.target) {
	      node.type = node.source.type = "target-source";
	      node.target.type = "source-target";
	    } else if (node.source) {
	      node.type = node.source.type = "source";
	    } else if (node.target) {
	      node.type = node.target.type = "target";
	    } else {
	      node.homologs = [{node: node}];
	      node.type = "source";
	    }
	  });
	  //console.log(nodes);
	  //var 
	  
	  // Nest nodes by type, for computing the rank.
	  var nodesByType = d3.nest()
	      .key(function(d) { return d.type; })
	      .sortKeys(d3.ascending)
	      .entries(nodes);

	  // Duplicate the target-source axis as source-target.
	 // nodesByType.push({key: "source-target", values: nodesByType[2].values});

	  // Compute the rank for each type, with padding between packages.
	  nodesByType.forEach(function(type) {
	    var lastName = type.values[0].packageName, count = 0;
	    type.values.forEach(function(d, i) {
	      if (d.packageName != lastName) lastName = d.packageName, count += 2;
	      d.index = count++;
	    });
	    type.count = count - 1;
	  });
	  var specieslookup = {};
	  var species_counter = 0;
	  	  homologyNodes.forEach(function(d) {
			  //console.log(d.name);
			  if( specieslookup[d.name] === undefined ) {
				//  console.log("not found yet");
				  specieslookup[d.name] = species_counter++;
			  		d.index = specieslookup[d.name];
					console.log(d.index);
			  }else{
				//  console.log("found!");
		  		d.index = specieslookup[d.name];
			  }
			//console.log(d.index);
		  });
		  
		  console.log(specieslookup);
		  
		 // dsfsdf
	 /* svg.selectAll(".axis")
	      .data(nodesByType)
	    .enter().append("line")
	      .attr("class", "axis")
	      .attr("transform", function(d) { return "rotate(" + degrees(angle(d.key)) + ")"; })
	      .attr("x1", radius(-2))
	      .attr("x2", function(d) { return radius(d.count + 2); });
	  */
	 
	 var lineFunction = d3.svg.line()
	                           .x(function(d) { return d.x; })
	                           .y(function(d) { return d.y; })
	                          .interpolate("basis");
							  console.log(links.length+" links found");
							  console.log(links);
			//				  dffdf
// Draw the links.
	  svg.append("g")
	      .attr("class", "links")
	    .selectAll(".link")
	      .data(links)
	    .enter().append("path")
	      .attr("class", "link")
		  .attr("d", function(d){
			  //console.log(d.source);
			  //console.log(d.target);
			  var source_name = d.source.name;
			  var target_name = d.target.name;
			  var source_index = d.source.index;
			  var target_index = specieslookup[d.target.name];
			  console.log("source: "+source_name+" "+source_index+" and target: "+target_name+" "+target_index);
			  var source_x = 0 ;
			  var source_y = 50+ (source_index*7);
			  var target_x = 700 ;
			  var target_y = 50 + (target_index*20);
			  console.log(""+d.source.name+" has "+source_x+"y"+source_y+"x"+target_x+"y"+target_y);
			  var lineData = [ { "x": source_x,   "y": source_y},  { "x": target_x,  "y": target_y}];
			  return lineFunction(lineData);
	    	  //return "M10,25L10,75L60,75L10,25";
			}
	  		)
	      .on("mouseover", linkMouseover)
	      .on("mouseout", mouseout);
	  
		  //looool
		  var silent_counter=0;

// Draw gene nodes	  

	  var all_gene_nodes = svg.append("g")
	      .attr("class", "nodes")
	    .selectAll(".node")
	      .data(geneNodes)
	    .enter().append("g")
	      .attr("class", "node")
	      .style("fill", function(d) { 
			  console.log("color: for "+d.name+" and package: "+d.packageName+" is "+color(d.packageName));
			  return color(d.packageName); 
		  })
	      .on("mouseover", nodeMouseover)
	      .on("mouseout", mouseout);  
		  
	  /*  var all_gene_circles = all_gene_nodes.selectAll("circle")
	      .data(function(d) { return d.homologs; })
	      .enter().append("circle")
		  .attr("cy", function(d,i) { 
				console.log("node index : "+i+" "+(40 + (silent_counter++ * 10)));
				return 40 + (silent_counter++ * 10); 
		  })
		  .attr("cx", function(d){
			  if(d.type = "source"){return 0;}
			  else{ return 30;}
		  })
	      .attr("r", 4);
		*/  
		 var all_gene_circles = all_gene_nodes.append("svg:image")
		              //.attr("y", -10)
					  .attr("y", function(d,i) { 
							console.log("node index : "+i+" "+(40 + (silent_counter++ * 10)));
							return 30 + (silent_counter++ * gene_distance); 
					  })
					  .attr("x", function(d){
						  if(d.type = "source"){return 0;}
						  else{ return 30;}
					  })
		              .attr("text-anchor", function(d){ return  "end";})
		              .attr("width", 12).attr("height", 12)
		              //.attr("xlink:href", function(d) { return d.children == null? image_path+"/thumb_"+d.taxon+".png" : "";  });
		          .attr("xlink:href", function(d) { return "../data/MB_dna.gif";  });
		  
		  
		  
		  all_gene_nodes.insert("svg:text")
		              .attr("x", -8)
		              .attr("y", function(d,i){ return 55 + (i * gene_distance*2);})
		              //.attr("class","innerNode_label")
					  .attr("font-size", "15")
		              .attr("text-anchor", function(d){ return "end";})
					  .text(function(d) { return d.name;});
		  
	silent_counter = 0;
	
	
// draw rank nodes	
	var all_rank_nodes = svg.append("g")
      .attr("class", "nodes")
    .selectAll(".node")
      .data(rankNodes)
    .enter().append("g")
      .attr("class", "node")
      .style("fill", function(d) { 
		  console.log("color: for "+d.name+" and package: "+d.rank+" is "+color(d.rank));
		  return color(d.rank); 
	  })
      .on("mouseover", nodeMouseover)
      .on("mouseout", mouseout);  
	  
    var all_rank_circles = all_rank_nodes
	  .append("circle")
	  .attr("cy", function(d,i) { 
			console.log("node index : "+i+" "+(40 + (silent_counter++ * rank_distance)));
			return 40 + (silent_counter++ * 10); 
	  })
	  .attr("cx", function(d){
		  return rank_x;
	  })
      .attr("r", 4);
	  
	  all_rank_nodes.insert("svg:text")
	              .attr("x", rank_x + 10)
	              .attr("y", function(d,i){ return 55 + (i * rank_distance * 2);})
	              //.attr("class","innerNode_label")
				  .attr("font-size", "15")
	              .attr("text-anchor", function(d){ return  "start";})
				  .text(function(d) { return d.rank;});
	
   silent_counter = 0;
	
  var all_species_nodes = svg.append("g")
      .attr("class", "nodes")
    .selectAll(".node")
      .data(speciesNodes)
    .enter().append("g")
      .attr("class", "node")
      .style("fill", function(d) { 
		  console.log("color: for "+d.name+" and package: "+d.rank+" is "+color(d.rank));
		  return color(d.rank); 
	  })
      .on("mouseover", nodeMouseover)
      .on("mouseout", mouseout);  
	  
	 var all_species_circles = all_species_nodes.append("svg:image")
	              //.attr("y", -10)
				  .attr("y", function(d,i) { 
						console.log("node index : "+i+" "+(40 + (silent_counter++ * species_distance)));
						return 30 + (silent_counter++ * 10); 
				  })
				  .attr("x", function(d){
					  if(d.type = "source"){return species_x;}
					  else{ return 30;}
				  })
	              
	              .attr("text-anchor", function(d){ return  "end";})
	              .attr("width", 15).attr("height", 15)
	              //.attr("xlink:href", function(d) { return d.children == null? image_path+"/thumb_"+d.taxon+".png" : "";  });
	          .attr("xlink:href", function(d) { return image_path+"/thumb_"+d.taxon+".png";  });

	  
	  all_species_nodes.insert("svg:text")
	              .attr("x", species_x + 10)
	              .attr("y", function(d,i){ return 55 + (i * species_distance * 2);})
	              //.attr("class","innerNode_label")
				  .attr("font-size", "15")
	              .attr("text-anchor", function(d){ return  "start";})
				  .text(function(d) { return d.taxon;});
	
	/*var all_homology_nodes = svg.append("g")
				      .attr("class", "nodes")
				    .selectAll(".node")
				      .data(homologyNodes)
				    .enter().append("g")
				      .attr("class", "node")
				      .style("fill", function(d) { 
						  console.log("color: for "+d.name+" and package: "+d.rank+" is "+color(d.rank));
						  return color(d.rank); 
					  })
				      .on("mouseover", nodeMouseover)
				      .on("mouseout", mouseout);  
	  
		var all_homology_circles = all_homology_nodes.append("svg:image")
 		              //.attr("y", -10)
 					  .attr("y", function(d,i) { 
 							console.log("node index : "+i+" "+(40 + (silent_counter++ * homologs_distance)));
 							return 30 + (silent_counter++ * homologs_distance); 
 					  })
 					  .attr("x", function(d){
 						  if(d.type = "source"){return homologs_x;}
 						  else{ return 30;}
 					  })
 		              .attr("text-anchor", function(d){ return  "end";})
 		              .attr("width", 15).attr("height", 15)
 		              //.attr("xlink:href", function(d) { return d.children == null? image_path+"/thumb_"+d.taxon+".png" : "";  });
 		          .attr("xlink:href", function(d) { return "../data/MB_dna.gif";  });
		  
					  
	  
					  all_species_nodes.insert("svg:text")
					              .attr("x", homologs_x + 10)
					              .attr("y", function(d,i){ return 55 + (i * homologs_distance * 2);})
					              //.attr("class","innerNode_label")
								  .attr("font-size", "15")
					              .attr("text-anchor", function(d){ return  "start";})
								  .text(function(d) { return d.name;});
	*/
	
	
	
		  // Initialize the info display.
		  var info = d3.select("#info")
		      .text(defaultInfo = "Showing " + formatNumber(links.length) + " homologies for " + formatNumber(nodes.length) + " genes.");
	
	  
		  /*
		 // test
  // Construct an index by node name.
  nodes.forEach(function(d) {
    d.connectors = [];
    d.packageName = d.name.split(".")[1];
    nodesByName[d.name] = d;
  });

  // Convert the import lists into links with sources and targets.
  nodes.forEach(function(source) {
    source.imports.forEach(function(targetName) {
      var target = nodesByName[targetName];
      if (!source.source) source.connectors.push(source.source = {node: source, degree: 0});
      if (!target.target) target.connectors.push(target.target = {node: target, degree: 0});
      links.push({source: source.source, target: target.target});
    });
  });

  // Determine the type of each node, based on incoming and outgoing links.
  nodes.forEach(function(node) {
    if (node.source && node.target) {
     // node.type = node.source.type = "target-source";
      node.target.type = "source-target";
    } else if (node.source) {
      node.type = node.source.type = "source";
    } else if (node.target) {
      node.type = node.target.type = "target";
    } else {
      node.connectors = [{node: node}];
      node.type = "source";
    }
  });


  // Normally, Hive Plots sort nodes by degree along each axis. However, since
  // this example visualizes a package hierarchy, we get more interesting
  // results if we group nodes by package. We don't need to sort explicitly
  // because the data file is already sorted by class name.

  // Nest nodes by type, for computing the rank.
  var nodesByType = d3.nest()
      .key(function(d) { return d.type; })
      .sortKeys(d3.ascending)
      .entries(nodes);

  // Duplicate the target-source axis as source-target.
  nodesByType.push({key: "source-target", values: nodesByType[2].values});

  // Compute the rank for each type, with padding between packages.
  nodesByType.forEach(function(type) {
    var lastName = type.values[0].packageName, count = 0;
    type.values.forEach(function(d, i) {
      if (d.packageName != lastName) lastName = d.packageName, count += 2;
      d.index = count++;
    });
    type.count = count - 1;
  });

  // Set the radius domain.
  radius.domain(d3.extent(nodes, function(d) { return d.index; }));

  // Draw the axes.
  svg.selectAll(".axis")
      .data(nodesByType)
    .enter().append("line")
      .attr("class", "axis")
      .attr("transform", function(d) { return "rotate(" + degrees(angle(d.key)) + ")"; })
      .attr("x1", radius(-2))
      .attr("x2", function(d) { return radius(d.count + 2); });

  // Draw the links.
  svg.append("g")
      .attr("class", "links")
    .selectAll(".link")
      .data(links)
    .enter().append("path")
      .attr("class", "link")
      .attr("d", link()
      .angle(function(d) { return angle(d.type); })
      .radius(function(d) { return radius(d.node.index); }))
      .on("mouseover", linkMouseover)
      .on("mouseout", mouseout);

  // Draw the nodes. Note that each node can have up to two connectors,
  // representing the source (outgoing) and target (incoming) links.
  svg.append("g")
      .attr("class", "nodes")
    .selectAll(".node")
      .data(nodes)
    .enter().append("g")
      .attr("class", "node")
      .style("fill", function(d) { return color(d.packageName); })
    .selectAll("circle")
      .data(function(d) { return d.connectors; })
    .enter().append("circle")
      .attr("transform", function(d) { 
	console.log("rotate "+d.type+"(" + degrees(angle(d.type)) + ")");
	
	return "rotate(" + degrees(angle(d.type)) + ")"; })
      
	.attr("cx", function(d) { 
	console.log("node index : "+d.node.index+" "+radius(d.node.index));
	return radius(d.node.index); 
	
	return radius(d.node.index); })
      .attr("r", 4)
      .on("mouseover", nodeMouseover)
      .on("mouseout", mouseout);
*/
  // Highlight the link and connected nodes on mouseover.
  function linkMouseover(d) {
	//console.log(d);
	console.log(d.source.name);
    svg.selectAll(".link").classed("active", function(p) { 
		//console.log(d.name+" == "+p.name);
		//console.log(p);
		//console.log(p.source.name);
		//console.log("");
		
		return p.source.name === d.source.name; 
	});
    svg.selectAll(".node circle").classed("active", function(p) { return p === d.source || p === d.target; });
	console.log(d.source.name + " → " + d.target.name);
    info.text(d.source.name + " → " + d.target.name);
  }

  // Highlight the node and connected links on mouseover.
  function nodeMouseover(d) {
    var all_nodes = svg.selectAll(".link").classed("active", function(p) { return p.source.name === d.name || p.target.name === d.name; });
     d3.select(this).classed("active", true);
    info.text(d.name);
  }

  // Clear any highlighted nodes or links.
  function mouseout() {
    svg.selectAll(".active").classed("active", false);
    info.text(defaultInfo);
  } 
});

// A shape generator for Hive links, based on a source and a target.
// The source and target are defined in polar coordinates (angle and radius).
// Ratio links can also be drawn by using a startRadius and endRadius.
// This class is modeled after d3.svg.chord.
function link() {
  var source = function(d) { return d.source; },
      target = function(d) { return d.target; },
      angle = function(d) { return d.angle; },
      startRadius = function(d) { return d.radius; },
      endRadius = startRadius,
      arcOffset = -Math.PI / 2;

	  console.log("now we are in link with "+source+" and "+target+"");

  function link(d, i) {
    var s = node(source, this, d, i),
        t = node(target, this, d, i),
        x;
    if (t.a < s.a) x = t, t = s, s = x;
    if (t.a - s.a > Math.PI) s.a += 2 * Math.PI;
    var a1 = s.a + (t.a - s.a) / 3,
        a2 = t.a - (t.a - s.a) / 3;
    return s.r0 - s.r1 || t.r0 - t.r1
        ? "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
        + "L" + Math.cos(s.a) * s.r1 + "," + Math.sin(s.a) * s.r1
        + "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
        + " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
        + " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1
        + "L" + Math.cos(t.a) * t.r0 + "," + Math.sin(t.a) * t.r0
        + "C" + Math.cos(a2) * t.r0 + "," + Math.sin(a2) * t.r0
        + " " + Math.cos(a1) * s.r0 + "," + Math.sin(a1) * s.r0
        + " " + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
        : "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
        + "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
        + " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
        + " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1;
  }

  function node(method, thiz, d, i) {
    var node = method.call(thiz, d, i),
        a = +(typeof angle === "function" ? angle.call(thiz, node, i) : angle) + arcOffset,
        r0 = +(typeof startRadius === "function" ? startRadius.call(thiz, node, i) : startRadius),
        r1 = (startRadius === endRadius ? r0 : +(typeof endRadius === "function" ? endRadius.call(thiz, node, i) : endRadius));
    return {r0: r0, r1: r1, a: a};
  }

  link.source = function(_) {
    if (!arguments.length) return source;
    source = _;
    return link;
  };

  link.target = function(_) {
    if (!arguments.length) return target;
    target = _;
    return link;
  };

  link.angle = function(_) {
    if (!arguments.length) return angle;
    angle = _;
    return link;
  };

  link.radius = function(_) {
    if (!arguments.length) return startRadius;
    startRadius = endRadius = _;
    return link;
  };

  link.startRadius = function(_) {
    if (!arguments.length) return startRadius;
    startRadius = _;
    return link;
  };

  link.endRadius = function(_) {
    if (!arguments.length) return endRadius;
    endRadius = _;
    return link;
  };

  return link;
}

function degrees(radians) {
  return radians / Math.PI * 180 - 90;
}

</script>

treefam.json
[
{"name":"BRCA2_HUMAN", "taxon":"Homo_sapiens", "rank":"primates","size":3938,"imports":[
  				{"type":"inparalog","name": "BRCA1_HUMAN","target":"primates.Human","taxon" : "Homo_sapiens", "rank":"primates"},
					{"type":"ortholog","name": "BRCA2_MOUSE","target":"glires.Mouse","taxon" : "Mus_musculus", "rank":"glires"}
					]},
{"name":"BRCA2_RAT", "taxon":"Rattus_norvegicus", "rank":"glires","size":19975,"imports":[
					{"type":"ortholog","name": "BRCA2_HUMAN","target":"primates.Human", "taxon" : "Homo_sapiens", "rank":"primates"}, 
					{"type":"ortholog","name": "BRCA2_HUMAN","target":"glires.Mouse", "taxon" : "Mus_musculus", "rank":"glires"}
					]},
{"name":"BRCA2_MOUSE", "taxon":"Mus_musculus", "rank":"glires","size":20544,"imports":[
					{"type":"ortholog","name": "BRCA2_HUMAN","target":"primates.Human", "taxon" : "Homo_sapiens", "rank":"primates"}, 
					{"type":"inparalog","name": "BRCA1_MOUSE","target":"glires.Mouse", "taxon" : "Mus_musculus", "rank":"glires"}, 
					{"type":"ortholog","name": "BRCA2_RAT","target":"glires.Rat", "taxon" : "Rattus_norvegicus", "rank":"glires"},
					{"type":"ortholog","name": "BRCA2_YEAST","target":"outgroup.Yeast", "taxon" : "Saccharomyces_cerevisiae", "rank":"outgroup"}
					]}
]